for (int i = 0; i < relationships.length; i++) {
DbRelationship relationship = (DbRelationship) relationships[i];
if (relationship.getReverseRelationship() == null) {
DbRelationship reverse = relationship.createReverseRelationship();
Entity targetEntity = reverse.getSourceEntity();
reverse.setName(makeUniqueRelationshipName(targetEntity));
reverse.setRuntime(true);
targetEntity.addRelationship(reverse);
logger.info("added runtime complimentary DbRelationship from "
+ targetEntity.getName()
+ " to "
+ reverse.getTargetEntityName());
}
}
}
}
// connect object layer
maps = domain.getDataMaps().iterator();
while (maps.hasNext()) {
DataMap map = (DataMap) maps.next();
Iterator entities = map.getObjEntities().iterator();
while (entities.hasNext()) {
ObjEntity entity = (ObjEntity) entities.next();
// iterate by copy to avoid concurrency modification errors on reflexive
// relationships
Object[] relationships = entity.getRelationships().toArray();
for (int i = 0; i < relationships.length; i++) {
ObjRelationship relationship = (ObjRelationship) relationships[i];
if (relationship.getReverseRelationship() == null) {
ObjRelationship reverse = relationship
.createReverseRelationship();
Entity targetEntity = reverse.getSourceEntity();
reverse.setName(makeUniqueRelationshipName(targetEntity));
reverse.setRuntime(true);
targetEntity.addRelationship(reverse);
logger.info("added runtime complimentary ObjRelationship from "
+ targetEntity.getName()
+ " to "
+ reverse.getTargetEntityName());
}
}
}