@Override public String getFullName(String packagePrefix) { return super.getFullName(null); } }
@Override public Slot findSlot(String slotName) { if (slotName == null) { return null; } for (Slot s : slots) { if (s.getName().equals(slotName)) { return s; } } return (superclass != null) ? superclass.findSlot(slotName) : null; }
public String getSuperclassName() { return ((superclass == null) ? null : superclass.getName()); }
@Override protected void generateStaticRoleSlotsMultOneSetterBody(Role role, Role otherRole, PrintWriter out) { printWords(out, "((" + otherRole.getType().getBaseName() + ")o1)." + role.getName() + ".put(o2);"); }
protected void checkForRepeatedSlots() { for (DomainClass domClass : classes.values()) { DomainEntity superDomClass = domClass.getSuperclass(); if (superDomClass != null) { for (Slot slot : domClass.getSlotsList()) { if (superDomClass.findSlot(slot.getName()) != null) { System.err.printf("WARNING: Slot named '%s' in class '%s' already exists in a superclass\n", slot.getName(), domClass.getName()); } if (superDomClass.findRoleSlot(slot.getName()) != null) { System.err.printf("WARNING: Slot named '%s' in class '%s' already exists in a superclass as role slot\n", slot.getName(), domClass.getName()); } } for (Role role : domClass.getRoleSlotsList()) { if (superDomClass.findSlot(role.getName()) != null) { System.err.printf( "WARNING: Role slot named '%s' in class '%s' already exists in a superclass as a slot\n", role.getName(), domClass.getName()); } if (superDomClass.findRoleSlot(role.getName()) != null) { System.err.printf( "WARNING: Role slot named '%s' in class '%s' already exists in a superclass as role slot\n", role.getName(), domClass.getName()); } } } } }
protected void generateStaticRoleSlotsMultOneGetterBody(Role role, Role otherRole, PrintWriter out) { printWords(out, "return", "((" + otherRole.getType().getBaseName() + ")o1)." + role.getName() + ";"); }
public String getFullName() { return getFullName(null); }
protected void generateStaticRoleSlotsMultOneSetterBody(Role role, Role otherRole, PrintWriter out) { printWords(out, "((" + otherRole.getType().getBaseName() + ")o1)." + role.getName() + " = o2;"); }
private Slot getIndexedSlot(Role role) { Slot indexedSlot = role.getType().findSlot(role.getIndexProperty()); if (indexedSlot == null) { // indexed field doesn't exist throw new Error("Unknown indexed field: " + role.getIndexProperty()); } return indexedSlot; }
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); }
protected String getEntityFullName(DomainEntity domEntity) { if (domEntity == null) { return null; } else { return domEntity.getFullName(getPackageName()); } }
@Override protected void generateStaticRoleSlotsMultOneGetterBody(Role role, Role otherRole, PrintWriter out) { printWords(out, "return", "((" + otherRole.getType().getBaseName() + ")o1)." + role.getName() + ".get();"); }
private static ClassDescriptor getOtherRoleClassDescriptor(Role role) { String classname = role.getOtherRole().getType().getFullName(); return getDescriptorTable().get(classname); }
@Override protected void generateStaticRoleSlotsMultOne(Role role, Role otherRole, PrintWriter out) { String rType = getTypeFullName(role.getType()); String oType = getTypeFullName(otherRole.getType()); printWords(out, "@Override"); newline(out); printMethod(out, "public", rType, "getValue", makeArg(oType, "o1")); startMethodBody(out); print(out, "return "); print(out, getReadExpression(otherRole.getType().getBaseName(), "o1", role.getName())); print(out, ";"); endMethodBody(out); printWords(out, "@Override"); newline(out); printMethod(out, "public", "void", "setValue", makeArg(oType, "o1"), makeArg(rType, "o2")); startMethodBody(out); print(out, getLValueExpression(otherRole.getType().getBaseName(), "o1", role.getName())); print(out, " = o2;"); endMethodBody(out); }
@Override public int compare(Role one, Role other) { if (one.getName() == null) { return -1; } if (other.getName() == null) { return 1; } if (!one.getName().equals(other.getName())) { return one.getName().compareTo(other.getName()); } else { return one.getType().getFullName().compareTo(other.getType().getFullName()); } } };
@Override protected void generateStaticRoleSlotsMultStar(Role role, Role otherRole, PrintWriter out) { String rType = getTypeFullName(role.getType()); String oType = getTypeFullName(otherRole.getType()); printMethod(out, "public", makeGenericType("pt.ist.fenixframework.dml.runtime.RelationBaseSet", rType), "getSet", makeArg(oType, "o1")); startMethodBody(out); print(out, "return (("); print(out, otherRole.getType().getBaseName()); print(out, ")o1)."); print(out, makeRelationListGetterName(role.getName()) + "()"); print(out, ";"); endMethodBody(out); }
protected String getDefaultCollectionFor(Role role) { return makeGenericType(getCollectionToUse(), role.getType().getFullName()); }
protected void generateStaticRoleSlotsMultStar(Role role, Role otherRole, PrintWriter out) { print(out, "public "); print(out, makeGenericType("pt.ist.fenixframework.dml.runtime.RelationBaseSet", getTypeFullName(role.getType()))); print(out, " "); print(out, "getSet("); print(out, getTypeFullName(otherRole.getType())); print(out, " o1)"); startMethodBody(out); print(out, "return (" + getConcreteSetTypeDeclarationFor(role) + ") (("); print(out, otherRole.getType().getBaseName()); print(out, ") o1)."); print(out, role.getName()); print(out, ";"); endMethodBody(out); }
@Override protected void generateRelationAddMethodCall(Role role, String otherArg, String indexParam, PrintWriter out) { generateSetterDAPStatement(dC, role.getName(), role.getType().getFullName(), out); super.generateRelationAddMethodCall(role, otherArg, indexParam, out); }
@Override protected void generateRelationRemoveMethodCall(Role role, String otherArg, PrintWriter out) { generateSetterDAPStatement(dC, role.getName(), role.getType().getFullName(), out); super.generateRelationRemoveMethodCall(role, otherArg, out); }