public boolean shouldCascadeNoParts() { return (getCascadeDepth() == NoCascading); }
/** * This is the root method called to start the iteration. */ public void startIterationOn(Object sourceObject) { if (getVisitedObjects().containsKey(sourceObject)) { return; } getVisitedObjects().put(sourceObject, sourceObject); setCurrentMapping(null); setCurrentDescriptor(getSession().getDescriptor(sourceObject)); iterate(sourceObject); // start the recursion if ((getCurrentDescriptor() != null) && (!shouldCascadeNoParts()) && !this.shouldBreak()) { iterateReferenceObjects(sourceObject); } } }
/** * INTERNAL: * Iterate on the appropriate attribute. */ public void iterate(DescriptorIterator iterator) { // PERF: Only iterate when required. if (iterator.shouldIterateOnPrimitives()) { iterator.iteratePrimitiveForMapping(getAttributeValueFromObject(iterator.getVisitedParent()), this); } }
/** * Iterate on the primitive value for its mapping. */ public void iteratePrimitiveForMapping(Object primitiveValue, DatabaseMapping mapping) { if (primitiveValue == null) { return; } setCurrentMapping(mapping); setCurrentDescriptor(null); if (shouldIterateOnPrimitives()) {// false by default internalIteratePrimitive(primitiveValue); } }
/** * Iterate on the mapping's reference object and * recursively iterate on the reference object's * reference objects. * This is used for aggregate and aggregate collection mappings, which are not iterated on by default. */ public void iterateForAggregateMapping(Object aggregateObject, DatabaseMapping mapping, ClassDescriptor descriptor) { if (aggregateObject == null) { return; } setCurrentMapping(mapping); // aggregate descriptors are passed in because they could be part of an inheritance tree setCurrentDescriptor(descriptor); if (shouldIterateOnAggregates()) {// false by default internalIterateAggregateObject(aggregateObject); if (shouldBreak()) { setShouldBreak(false); return; } } iterateReferenceObjects(aggregateObject); }
if (!(shouldCascadeAllParts() || (shouldCascadePrivateParts() && mapping.isPrivateOwned()))) { return; if ((!shouldIterateOverWrappedObjects()) && (rd != null) && (rd.hasWrapperPolicy())) { return; if (getVisitedObjects().containsKey(referenceObject)) { return; getVisitedObjects().put(referenceObject, referenceObject); setCurrentMapping(mapping); setCurrentDescriptor(getDescriptorFor(referenceObject)); internalIterateReferenceObject(referenceObject); if (shouldBreak()) { setShouldBreak(false); return; iterateReferenceObjects(referenceObject);
/** * Iterate on the indirection object for its mapping. */ public void iterateIndirectContainerForMapping(IndirectContainer container, DatabaseMapping mapping) { setCurrentMapping(mapping); setCurrentDescriptor(null); if (shouldIterateOnIndirectionObjects()) {// false by default internalIterateIndirectContainer(container); } if (shouldIterateOverUninstantiatedIndirectionObjects() || (shouldIterateOverIndirectionObjects() && container.isInstantiated())) { // force instantiation only if specified mapping.iterateOnRealAttributeValue(this, container); } }
/** * Iterate on the specified attribute value. */ protected void iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue) { iterator.iterateForAggregateMapping(attributeValue, this, getReferenceDescriptor(attributeValue, iterator.getSession())); }
/** * Iterate over the sourceObject's reference objects, * updating the visited stack appropriately. */ protected void iterateReferenceObjects(Object sourceObject) { getVisitedStack().push(sourceObject); getCurrentDescriptor().getObjectBuilder().iterate(this); getVisitedStack().pop(); }
/** * INTERNAL: * Iterate on the attribute value. * The value holder has already been processed. */ public void iterateOnRealAttributeValue(DescriptorIterator iterator, Object realAttributeValue) { // This may be wrapped as the caller in iterate on foreign reference does not unwrap as the type is generic. Object unwrappedAttributeValue = getReferenceDescriptor().getObjectBuilder().unwrapObject(realAttributeValue, iterator.getSession()); iterator.iterateReferenceObjectForMapping(unwrappedAttributeValue, this); }
/** * Return the last object visited. */ public Object getVisitedParent() { return getVisitedStack().peek(); }
/** * INTERNAL: * Iterate on the appropriate attribute value. */ public void iterate(DescriptorIterator iterator) { iterateOnAttributeValue(iterator, getAttributeValueFromObject(iterator.getVisitedParent())); }
/** * Fetch and return the descriptor for the specified object. */ protected ClassDescriptor getDescriptorFor(Object object) { ClassDescriptor result = getSession().getDescriptor(object); if (result == null) { throw DescriptorException.missingDescriptor(object.getClass().getName()); } return result; }
/** * INTERNAL: * Iterate on the specified element. */ public void iterateOnElement(DescriptorIterator iterator, Object element) { // CR#... Aggregate collections must iterate as aggregates, not regular mappings. // For some reason the element can be null, this makes absolutly no sense, but we have a test case for it... if (element != null) { iterator.iterateForAggregateMapping(element, this, iterator.getSession().getDescriptor(element)); } }
/** * Return the second-to-last object visited. */ public Object getVisitedGrandparent() { Object parent = getVisitedStack().pop(); Object result = getVisitedStack().peek(); getVisitedStack().push(parent); return result; }
/** * INTERNAL: * Iterate on the iterator's current object's attribute defined by this mapping. * The iterator's settings for cascading and value holders determine how the * iteration continues from here. */ public void iterate(DescriptorIterator iterator) { Object attributeValue = this.getAttributeValueFromObject(iterator.getVisitedParent()); this.getIndirectionPolicy().iterateOnAttributeValue(iterator, attributeValue); }
/** * INTERNAL: * Iterate on the attribute value. * The value holder has already been processed. */ public void iterateOnRealAttributeValue(DescriptorIterator iterator, Object realAttributeValue) { if (realAttributeValue == null) { return; } ContainerPolicy cp = getContainerPolicy(); for (Object iter = cp.iteratorFor(realAttributeValue); cp.hasNext(iter);) { iterateOnElement(iterator, cp.next(iter, iterator.getSession())); } }
public boolean shouldCascadeAllParts() { return getCascadeDepth() == CascadeAllParts; }
public boolean shouldCascadePrivateParts() { return (getCascadeDepth() == CascadeAllParts) || (getCascadeDepth() == CascadePrivateParts); }