public boolean visitCollectionArc(CollectionProperty property) { if (prefetchTree != null) { PrefetchTreeNode child = prefetchTree.getNode(property.getName()); if (child != null) { Collection collection = (Collection) property .readProperty(source); Collection targetCollection = new ArrayList(collection.size()); Iterator it = collection.iterator(); while (it.hasNext()) { Object destinationSource = it.next(); Object destinationTarget = destinationSource != null ? detach(destinationSource, property .getTargetDescriptor(), child) : null; targetCollection.add(destinationTarget); } CollectionProperty targetProperty = (CollectionProperty) targetDescriptor .getProperty(property.getName()); targetProperty.writeProperty(target, null, targetCollection); } } return true; }
/** * Removes or makes phantom a node defined by this path. If the node for this path * doesn't have any children, it is removed, otherwise it is made phantom. */ public void removePath(String path) { PrefetchTreeNode node = getNode(path); while (node != null) { if (node.children != null) { node.setPhantom(true); break; } String segment = node.getName(); node = node.getParent(); if (node != null) { node.removeChild(segment); } } }
/** * Removes or makes phantom a node defined by this path. If the node for * this path doesn't have any children, it is removed, otherwise it is made * phantom. */ public void removePath(String path) { PrefetchTreeNode node = getNode(path); while (node != null) { if (node.children != null) { node.setPhantom(true); break; } String segment = node.getName(); node = node.getParent(); if (node != null) { node.removeChild(segment); } } }
public boolean visitToMany(ToManyProperty property) { if (prefetchTree != null) { PrefetchTreeNode child = prefetchTree.getNode(property.getName());
public boolean visitSingleObjectArc(SingleObjectArcProperty property) { if (prefetchTree != null) { PrefetchTreeNode child = prefetchTree.getNode(property.getName()); if (child != null) { Object destinationSource = property.readProperty(source); Object destinationTarget = destinationSource != null ? detach( destinationSource, property.getTargetDescriptor(), child) : null; SingleObjectArcProperty targetProperty = (SingleObjectArcProperty) targetDescriptor .getProperty(property.getName()); Object oldTarget = targetProperty.isFault(target) ? null : targetProperty.readProperty(target); targetProperty .writeProperty(target, oldTarget, destinationTarget); } } return true; }
public boolean visitToOne(ToOneProperty property) { if (prefetchTree != null) { PrefetchTreeNode child = prefetchTree.getNode(property.getName()); if (child != null) { Object destinationSource = property.readProperty(source); Object destinationTarget = destinationSource != null ? detach( destinationSource, property.getTargetDescriptor(), child) : null; if (destinationTarget != null) { fillReverseRelationship(destinationTarget, property); } ToOneProperty targetProperty = (ToOneProperty) targetDescriptor .getProperty(property.getName()); Object oldTarget = targetProperty.isFault(target) ? null : targetProperty.readProperty(target); targetProperty .writeProperty(target, oldTarget, destinationTarget); } } return true; }