private void mergeDataObjects(DataObjectInfo keep, DataObjectInfo merge) { for (AttributeInfo attr : merge.getAttributeDefs()) { if (keep.getAttributeDef(attr.getAttrName()) == null) { attr.setParentDataObject(keep); keep.addAttribute(attr); } } if (keep.getFindAllMethod() == null) { keep.setFindAllMethod(merge.getFindAllMethod()); } if (keep.getFindMethod() == null) { keep.setFindMethod(merge.getFindMethod()); } if (keep.getGetCanonicalMethod() == null) { keep.setGetCanonicalMethod(merge.getGetCanonicalMethod()); } if (keep.getCreateMethod() == null) { keep.setCreateMethod(merge.getCreateMethod()); } if (keep.getUpdateMethod() == null) { keep.setUpdateMethod(merge.getUpdateMethod()); } if (keep.getMergeMethod() == null) { keep.setMergeMethod(merge.getMergeMethod()); } if (keep.getDeleteMethod() == null) { keep.setDeleteMethod(merge.getDeleteMethod()); } // move child accessors to "keep" data object" for (AccessorInfo accessor : merge.getAllChildren()) { if (keep.findChildAccessor(accessor.getChildAccessorName()) == null) { accessor.setParentDataObject(keep); keep.addChild(accessor); } } // loop over all other data objects, and check if they have a child accessor with the "merge" // data object as child. If so, move the pointer from "merge" to "keep" data object // NOTE: we should not loop over getSelectedDataObjectInfo, would cause infinite loop // as this method is called from getSelectedDataObjectInfos for (DataObjectInfo doi : this.getDataObjectInfos()) { for (AccessorInfo accessor : doi.getAllChildren()) { if (accessor.getChildDataObject() == merge) { accessor.setChildDataObject(keep); // if there is a child accessor method, we also need to add that "find-in=parent method to // "keep" doi! if (accessor.getChildAccessorMethod() != null) { keep.addFindAllInParentMethod(accessor.getChildAccessorMethod()); } } } // also check the parameterValueProvider objects for methods for (DCMethod method : doi.getAllMethods()) { if (merge == method.getParameterValueProviderDataObject()) { method.setParameterValueProviderDataObject(keep); } } } }