l.addAll(getAttributeDescriptors()); l.addAll(getReferenceDescriptors()); l.addAll(getCollectionDescriptors()); boolean firstClass = true; for (FieldDescriptor fd : l) {
l.addAll(getAttributeDescriptors()); l.addAll(getReferenceDescriptors()); l.addAll(getCollectionDescriptors()); boolean firstClass = true; for (FieldDescriptor fd : l) {
sb.append(generate(cld)); for (CollectionDescriptor collection : cld.getCollectionDescriptors()) { if (FieldDescriptor.M_N_RELATION == collection.relationType()) { if (!indirections.contains(collection.getReverseReferenceDescriptor())) {
sb.append(generate(cld)); for (CollectionDescriptor collection : cld.getCollectionDescriptors()) { if (FieldDescriptor.M_N_RELATION == collection.relationType()) { if (!indirections.contains(collection.getReverseReferenceDescriptor())) {
for (CollectionDescriptor col : cld.getCollectionDescriptors()) { if (FieldDescriptor.M_N_RELATION == col.relationType()) { String tableName = DatabaseUtil.getIndirectionTableName(col).toLowerCase();
public void testCloneCollectionDescriptors() throws Exception { ClassDescriptor cld = testModel .getClassDescriptorByName("org.intermine.model.testmodel.Company"); Set colls = cld.getCollectionDescriptors(); Set copy = ModelMerger.cloneCollectionDescriptors(colls); assertEquals(colls, copy); }
for (CollectionDescriptor col : cld.getCollectionDescriptors()) { if (FieldDescriptor.M_N_RELATION == col.relationType()) { String tableName = DatabaseUtil.getIndirectionTableName(col).toLowerCase();
/** * Construct a ClassDescriptor that takes on all the properties of <code>cld</code> * without attaching to a particular Model. * * @param cld the ClassDescriptor to clone * @return cloned ClassDescriptor */ protected static ClassDescriptor cloneClassDescriptor(ClassDescriptor cld) { // supers can't be an empty string String supers = StringUtil.join(cld.getSuperclassNames(), " "); if (supers != null && "".equals(supers)) { supers = null; } return new ClassDescriptor(cld.getName(), supers, cld.isInterface(), cloneAttributeDescriptors(cld.getAttributeDescriptors()), cloneReferenceDescriptors(cld.getReferenceDescriptors()), cloneCollectionDescriptors(cld.getCollectionDescriptors())); }
/** * Construct a ClassDescriptor that takes on all the properties of <code>cld</code> * without attaching to a particular Model. * * @param cld the ClassDescriptor to clone * @return cloned ClassDescriptor */ protected static ClassDescriptor cloneClassDescriptor(ClassDescriptor cld) { // supers can't be an empty string String supers = StringUtil.join(cld.getSuperclassNames(), " "); if (supers != null && "".equals(supers)) { supers = null; } return new ClassDescriptor(cld.getName(), supers, cld.isInterface(), cloneAttributeDescriptors(cld.getAttributeDescriptors()), cloneReferenceDescriptors(cld.getReferenceDescriptors()), cloneCollectionDescriptors(cld.getCollectionDescriptors())); }
ClassDescriptor merge) throws ModelMergerException { Set<CollectionDescriptor> newSet = new HashSet<CollectionDescriptor>(); newSet.addAll(cloneCollectionDescriptors(original.getCollectionDescriptors())); for (CollectionDescriptor merg : merge.getCollectionDescriptors()) {
ClassDescriptor merge) throws ModelMergerException { Set<CollectionDescriptor> newSet = new HashSet<CollectionDescriptor>(); newSet.addAll(cloneCollectionDescriptors(original.getCollectionDescriptors())); for (CollectionDescriptor merg : merge.getCollectionDescriptors()) {
cd.getCollectionDescriptors()); Set<AttributeDescriptor> adescs = cloneAttributeDescriptors( cd.getAttributeDescriptors());
cd.getCollectionDescriptors()); Set<AttributeDescriptor> adescs = cloneAttributeDescriptors( cd.getAttributeDescriptors());
System.out.println(expected.toString()); assertEquals(expected.getCollectionDescriptors(), result);
public void testMergeCollectionSettingReverseRef() throws Exception { String modelStr = "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" + "<collection name=\"company\" referenced-type=\"org.intermine.model.testmodel.Company\"/>" + "</class>"; // add Department.company String addition = "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" + "<collection name=\"company\" referenced-type=\"org.intermine.model.testmodel.Company\" reverse-reference=\"dept\"/>" + "</class>"; String expXml = "<class name=\"org.intermine.model.testmodel.Department\" is-interface=\"false\">" + "<collection name=\"company\" referenced-type=\"org.intermine.model.testmodel.Company\" reverse-reference=\"dept\"/>" + "</class>"; ClassDescriptor cld1 = parseClass(modelStr, "org.intermine.model.testmodel"); ClassDescriptor cld2 = parseClass(addition, "org.intermine.model.testmodel"); ClassDescriptor expected = parseClass(expXml, "org.intermine.model.testmodel"); Set result = ModelMerger.mergeCollections(cld1, cld2); assertEquals(expected.getCollectionDescriptors(), result); }