/** * INTERNAL: * Add child descriptor to the parent descriptor. */ public void addChildDescriptor(ClassDescriptor childDescriptor) { getChildDescriptors().add(childDescriptor); }
/** * INTERNAL: * Check if descriptor has children */ public boolean hasChildren() { return !getChildDescriptors().isEmpty(); }
/** * INTERNAL: * Check if descriptor has children */ public boolean hasChildren() { return !getChildDescriptors().isEmpty(); }
/** * INTERNAL: * Add child descriptor to the parent descriptor. */ public void addChildDescriptor(ClassDescriptor childDescriptor) { getChildDescriptors().addElement(childDescriptor); }
/** * INTERNAL: * Check if descriptor has children */ public boolean hasChildren() { return !getChildDescriptors().isEmpty(); }
/** * INTERNAL: * Add child descriptor to the parent descriptor. */ public void addChildDescriptor(ClassDescriptor childDescriptor) { getChildDescriptors().add(childDescriptor); }
/** * INTERNAL: * Recursive subroutine of getAllChildDescriptors. */ protected Vector getAllChildDescriptors(Vector allChildDescriptors) { for (Enumeration enumtr = getChildDescriptors().elements(); enumtr.hasMoreElements();) { ClassDescriptor childDescriptor = (ClassDescriptor)enumtr.nextElement(); allChildDescriptors.addElement(childDescriptor); childDescriptor.getInheritancePolicyOrNull().getAllChildDescriptors(allChildDescriptors); } return allChildDescriptors; }
/** * INTERNAL: * Recursive subroutine of getAllChildDescriptors. */ protected List<ClassDescriptor> getAllChildDescriptors(List<ClassDescriptor> allChildDescriptors) { for (ClassDescriptor childDescriptor : getChildDescriptors()) { allChildDescriptors.add(childDescriptor); childDescriptor.getInheritancePolicyOrNull().getAllChildDescriptors(allChildDescriptors); } return allChildDescriptors; }
/** * INTERNAL: * Recursive subroutine of getAllChildDescriptors. */ protected List<ClassDescriptor> getAllChildDescriptors(List<ClassDescriptor> allChildDescriptors) { for (ClassDescriptor childDescriptor : getChildDescriptors()) { allChildDescriptors.add(childDescriptor); childDescriptor.getInheritancePolicyOrNull().getAllChildDescriptors(allChildDescriptors); } return allChildDescriptors; }
/** * Remove all of the subclasses (and so on) from the set of classes. */ protected void removeChildren(ClassDescriptor descriptor, Set<Class> classes, Set<Class> subclasses) { for (ClassDescriptor childDescriptor : descriptor.getInheritancePolicy().getChildDescriptors()) { classes.remove(childDescriptor.getJavaClass()); subclasses.add(childDescriptor.getJavaClass()); removeChildren(childDescriptor, classes, subclasses); } }
/** * Remove all of the subclasses (and so on) from the set of classes. */ protected void removeChildren(ClassDescriptor descriptor, Set<Class> classes, Set<Class> subclasses) { for (ClassDescriptor childDescriptor : descriptor.getInheritancePolicy().getChildDescriptors()) { classes.remove(childDescriptor.getJavaClass()); subclasses.add(childDescriptor.getJavaClass()); removeChildren(childDescriptor, classes, subclasses); } }
/** * Add all of the objects of the class and all of its subclasses. * The session is needed because there is no other way to find all subclasses. */ public void addAllObjectsForAbstractClass(Class objectsClass, AbstractSession session, Vector allObjects) { ClassDescriptor descriptor = session.getDescriptor(objectsClass); addAllObjectsForClass(objectsClass, allObjects); for (Enumeration enumeration = descriptor.getInheritancePolicy().getChildDescriptors().elements(); enumeration.hasMoreElements();) { addAllObjectsForAbstractClass(((ClassDescriptor)enumeration.nextElement()).getJavaClass(), session, allObjects); } }
/** * Return all of the objects of the class and all of its subclasses. * The session is needed because there is no other way to find all subclasses. */ public Vector getAllObjectsForAbstractClass(Class objectsClass, AbstractSession session) { ClassDescriptor descriptor = session.getDescriptor(objectsClass); Vector allObjects = new Vector(); addAllObjectsForClass(objectsClass, allObjects); if (descriptor.hasInheritance()) { for (Enumeration enumeration = descriptor.getInheritancePolicy().getChildDescriptors().elements(); enumeration.hasMoreElements();) { addAllObjectsForClass(((ClassDescriptor)enumeration.nextElement()).getJavaClass(), allObjects); } } return allObjects; }
/** * Return all of the objects of the class and all of its subclasses. * The session is needed because there is no other way to find all subclasses. */ public Vector getAllObjectsForAbstractClass(Class objectsClass, AbstractSession session) { ClassDescriptor descriptor = session.getDescriptor(objectsClass); Vector allObjects = new Vector(); addAllObjectsForClass(objectsClass, allObjects); if (descriptor.hasInheritance()) { for (ClassDescriptor child : descriptor.getInheritancePolicy().getChildDescriptors()) { addAllObjectsForClass(child.getJavaClass(), allObjects); } } return allObjects; }
/** * Add all of the objects of the class and all of its subclasses. * The session is needed because there is no other way to find all subclasses. */ public void addAllObjectsForAbstractClass(Class objectsClass, AbstractSession session, Vector allObjects) { ClassDescriptor descriptor = session.getDescriptor(objectsClass); addAllObjectsForClass(objectsClass, allObjects); for (ClassDescriptor child : descriptor.getInheritancePolicy().getChildDescriptors()) { addAllObjectsForAbstractClass(child.getJavaClass(), session, allObjects); } }
/** * Verify that an aggregate descriptor's inheritance tree * is full of aggregate descriptors, cont. */ private void checkInheritanceTreeAggregateSettingsForChildren(AbstractSession session, AggregateMapping mapping) throws DescriptorException { if (!this.isAggregateDescriptor()) { session.getIntegrityChecker().handleError(DescriptorException.referenceDescriptorIsNotAggregate(this.getJavaClass().getName(), mapping)); } for (ClassDescriptor childDescriptor : this.getInheritancePolicy().getChildDescriptors()) { // recurse down the inheritance tree to its leaves childDescriptor.checkInheritanceTreeAggregateSettingsForChildren(session, mapping); } }
/** * Add all of the objects of the class and all of its subclasses. * The session is needed because there is no other way to find all subclasses. */ public void addAllObjectsForAbstractClass(Class objectsClass, AbstractSession session, Vector allObjects) { ClassDescriptor descriptor = session.getDescriptor(objectsClass); addAllObjectsForClass(objectsClass, allObjects); for (ClassDescriptor child : descriptor.getInheritancePolicy().getChildDescriptors()) { addAllObjectsForAbstractClass(child.getJavaClass(), session, allObjects); } }
/** * Verify that an aggregate descriptor's inheritance tree * is full of aggregate descriptors, cont. */ private void checkInheritanceTreeAggregateSettingsForChildren(AbstractSession session, AggregateMapping mapping) throws DescriptorException { if (!this.isAggregateDescriptor()) { session.getIntegrityChecker().handleError(DescriptorException.referenceDescriptorIsNotAggregate(this.getJavaClass().getName(), mapping)); } for (ClassDescriptor childDescriptor : this.getInheritancePolicy().getChildDescriptors()) { // recurse down the inheritance tree to its leaves childDescriptor.checkInheritanceTreeAggregateSettingsForChildren(session, mapping); } }
/** * PUBLIC: * Adds the given Java class to the receiver's set of read-only classes. * Cannot be called after objects have been registered in the unit of work. */ public void addReadOnlyClass(Class theClass) throws ValidationException { if (!canChangeReadOnlySet()) { throw ValidationException.cannotModifyReadOnlyClassesSetAfterUsingUnitOfWork(); } getReadOnlyClasses().add(theClass); ClassDescriptor descriptor = getDescriptor(theClass); // Also mark all subclasses as read-only. if (descriptor.hasInheritance()) { for (ClassDescriptor childDescriptor : descriptor.getInheritancePolicy().getChildDescriptors()) { addReadOnlyClass(childDescriptor.getJavaClass()); } } }
/** * INTERNAL: * A user should not be setting which attributes to join or not to join * after descriptor initialization; provided only for backwards compatibility. */ public void reInitializeJoinedAttributes() { if (!isInitialized(POST_INITIALIZED)) { // wait until the descriptor gets initialized first return; } getObjectBuilder().initializeJoinedAttributes(); if (hasInheritance()) { for (ClassDescriptor child : getInheritancePolicy().getChildDescriptors()) { child.reInitializeJoinedAttributes(); } } }