Relation Mapper
If you have already checked the PMD manual, you know that a PMD file can define relations between models. When these relations are parsed, they are stored in a Julia dictionary, the Relation Mapper.
Relation Mapper JSON file
However, it is also possible to fill the Relation Mapper with a JSON file, that follows the same structure as OpenStudy's dictionary for relations.
In the example below, we have a Relation Mapper file with the following information:
- The model
CustomModelhas two relations defined, one withSecondCollectionand another withThirdCollection.- The relation with
SecondCollectionis a1_to_1relation, and the parameter is calledsystem. - The relation with
ThirdCollectionis a1_to_Nrelation, and the parameter is calledstation.
- The relation with
- The model
SecondCollectionhas two relations withFourthCollection.- The first relation with
FourthCollectionis aFROMrelation, and the parameter is calledno1. - The second relation with
FourthCollectionis aTOrelation, and the parameter is calledno2.
- The first relation with
The relation parameter stores the reference_id from the element of the Target Collection. See PMD manual
{
"CustomCollection": {
"SecondCollection": {
"system": {
"is_vector": false,
"type": "1_TO_1"
}
},
"ThirdCollection": {
"station": {
"is_vector": true,
"type": "1_TO_N"
}
}
},
"SecondCollection": {
"FourthCollection": {
"no1": {
"is_vector": false,
"type": "FROM"
},
"no2": {
"is_vector": false,
"type": "TO"
}
}
}
}