public Role getOtherRole() { return (isFirstRole() ? relation.getSecondRole() : relation.getFirstRole()); }
public List<Role> getRoles() { int numRoles = countRoles(); List<Role> result = new ArrayList<Role>(numRoles); copyRolesInto(this, result); return result; }
public void addRelation(DomainRelation domRelation) { checkNotFinalized(); checkNameUnique(domRelation.getFullName()); relations.put(domRelation.getFullName(), domRelation); }
private static void copyRolesInto(DomainRelation rel, List<Role> result) { DomainRelation superRel = rel.getSuperrelation(); if (superRel != null) { copyRolesInto(superRel, result); } result.addAll(rel.roles); } }
public int countRoles() { DomainRelation superRel = getSuperrelation(); return roles.size() + ((superRel == null) ? 0 : superRel.countRoles()); }
protected String getRelationMethodNameFor(Role role, boolean direct) { // when the two roles of a relation are played by the same class, // we need to give different names to the relation slots because both // will be in the same class return "getRelation" + role.getRelation().getName() + "()" + (direct ? "" : ".getInverseRelation()"); }
public boolean isFirstRole() { return relation.getFirstRole() == this; }
DomainRelation domRelation = new DomainRelation(sourceFile, name, null, null);
private static void generateManyToManyCollectionDescriptor(CollectionDescriptor collectionDescriptor, Role role) { String indirectionTableName = DbUtil.convertToDBStyle(role.getRelation().getName()); String fkToItemClass = DbUtil.getFkName(role.getType().getName()); String fkToThisClass = DbUtil.getFkName(role.getOtherRole().getType().getName()); if (fkToItemClass.equals(fkToThisClass)) { fkToItemClass = fkToItemClass + "_" + DbUtil.convertToDBStyle(role.getName()); fkToThisClass = fkToThisClass + "_" + DbUtil.convertToDBStyle(role.getOtherRole().getName()); } collectionDescriptor.setIndirectionTable(indirectionTableName); collectionDescriptor.addFkToItemClass(fkToItemClass); collectionDescriptor.addFkToThisClass(fkToThisClass); collectionDescriptor.setCascadingDelete(ObjectReferenceDescriptor.CASCADE_NONE); }
private static boolean is1toNRelation(DomainRelation domRelation) { int multiplicity1 = domRelation.getFirstRole().getMultiplicityUpper(); int multiplicity2 = domRelation.getSecondRole().getMultiplicityUpper(); return ((multiplicity1 == 1) && (multiplicity2 != 1)) || ((multiplicity1 != 1) && (multiplicity2 == 1)); }
String relationSlotName = role.getRelation().getName(); String directRelationType = getDirectRelationType(); String methodName = "getRelation" + role.getRelation().getName(); print(out, getRoleHandlerName(role, false)); print(out, ", \""); print(out, role.getRelation().getName()); print(out, "\""); generateDefaultRelationListeners(role, out);
if (is1toNRelation(relation)) { ClassDescriptor clazz = getOtherRoleClassDescriptor(relation.getFirstRole()); SQLTableChangeSet change = changes.get(clazz.getFullTableName()); change.addIndex(relation.getFirstRole()); ClassDescriptor clazz = getOtherRoleClassDescriptor(relation.getSecondRole()); SQLTableChangeSet change = changes.get(clazz.getFullTableName()); change.addIndex(relation.getSecondRole());