/** * INTERNAL: * The first table in the tables is always treated as default. */ protected DatabaseTable extractDefaultTable() { if (getTables().isEmpty()) { if (isChildDescriptor()) { return getInheritancePolicy().getParentDescriptor().extractDefaultTable(); } else { return null; } } return getTables().get(0); }
/** * INTERNAL: * The first table in the tables is always treated as default. */ protected DatabaseTable extractDefaultTable() { if (getTables().isEmpty()) { if (isChildDescriptor()) { return getInheritancePolicy().getParentDescriptor().extractDefaultTable(); } else { return null; } } return getTables().get(0); }
/** * INTERNAL: * The first table in the tables is always treated as default. */ protected DatabaseTable extractDefaultTable() { if (getTables().isEmpty()) { if (isChildDescriptor()) { return getInheritancePolicy().getParentDescriptor().extractDefaultTable(); } else { return null; } } return getTables().get(0); }
/** * Reset the identity map for only the instances of the class. * For inheritance the user must make sure that they only use the root class. */ public void initializeIdentityMap(Class theClass) throws EclipseLinkException { ClassDescriptor descriptor = this.session.getDescriptor(theClass); if (descriptor == null) { throw ValidationException.missingDescriptor(String.valueOf(theClass)); } if (descriptor.isChildDescriptor()) { throw ValidationException.childDescriptorsDoNotHaveIdentityMap(); } // Bug 3736313 - look up identity map by descriptor's java class Class javaClass = descriptor.getJavaClass(); IdentityMap identityMap = buildNewIdentityMap(descriptor); getIdentityMaps().put(javaClass, identityMap); clearLastAccessedIdentityMap(); }
/** * Reset the identity map for only the instances of the class. * For inheritance the user must make sure that they only use the root class. */ public void initializeIdentityMap(Class theClass) throws EclipseLinkException { ClassDescriptor descriptor = this.session.getDescriptor(theClass); if (descriptor == null) { throw ValidationException.missingDescriptor(String.valueOf(theClass)); } if (descriptor.isChildDescriptor()) { throw ValidationException.childDescriptorsDoNotHaveIdentityMap(); } // Bug 3736313 - look up identity map by descriptor's java class Class javaClass = descriptor.getJavaClass(); IdentityMap identityMap = buildNewIdentityMap(descriptor); getIdentityMaps().put(javaClass, identityMap); clearLastAccessedIdentityMap(); invalidateQueryCache(theClass); }
/** * Reset the identity map for only the instances of the class. * For inheritance the user must make sure that they only use the root class. */ public void initializeIdentityMap(Class theClass) throws EclipseLinkException { ClassDescriptor descriptor = this.session.getDescriptor(theClass); if (descriptor == null) { throw ValidationException.missingDescriptor(String.valueOf(theClass)); } if (descriptor.isChildDescriptor()) { throw ValidationException.childDescriptorsDoNotHaveIdentityMap(); } // Bug 3736313 - look up identity map by descriptor's java class Class javaClass = descriptor.getJavaClass(); IdentityMap identityMap = buildNewIdentityMap(descriptor); getIdentityMaps().put(javaClass, identityMap); clearLastAccessedIdentityMap(); invalidateQueryCache(theClass); }
/** * INTERNAL: * Notify the event listeners. */ public void notifyListeners(DescriptorEvent event) { if (hasAnyListeners()) { for (int index = 0; index < getEventListeners().size(); index++) { DescriptorEventListener listener = (DescriptorEventListener)getEventListeners().get(index); notifyListener(listener, event); } } // Also must notify any inherited listeners. if (getDescriptor().isChildDescriptor()) { getDescriptor().getInheritancePolicy().getParentDescriptor().getEventManager().notifyListeners(event); } }
/** * INTERNAL: * Notify the event listeners. */ public void notifyListeners(DescriptorEvent event) { if (hasAnyListeners()) { for (int index = 0; index < getEventListeners().size(); index++) { DescriptorEventListener listener = (DescriptorEventListener)getEventListeners().get(index); notifyListener(listener, event); } } // Also must notify any inherited listeners. if (getDescriptor().isChildDescriptor()) { getDescriptor().getInheritancePolicy().getParentDescriptor().getEventManager().notifyListeners(event); } }
/** * INTERNAL: * Notify the event listeners. */ public void notifyListeners(DescriptorEvent event) { if (hasAnyListeners()) { for (int index = 0; index < getEventListeners().size(); index++) { DescriptorEventListener listener = (DescriptorEventListener)getEventListeners().get(index); notifyListener(listener, event); } } // Also must notify any inherited listeners. if (getDescriptor().isChildDescriptor()) { getDescriptor().getInheritancePolicy().getParentDescriptor().getEventManager().notifyListeners(event); } }
@Override public void initializeField(AbstractSession session) { if (this.field == null) { session.getIntegrityChecker().handleError(DescriptorException.serializedObjectPolicyFieldNotSet(this.descriptor)); return; } if (this.descriptor.isChildDescriptor()) { SerializedObjectPolicy parentPolicy = this.descriptor.getInheritancePolicy().getParentDescriptor().getSerializedObjectPolicy(); if (parentPolicy != null && parentPolicy.getField() == this.field) { return; } } this.field = this.descriptor.buildField(this.field); this.descriptor.getFields().add(this.field); }
@Override public void initializeField(AbstractSession session) { if (this.field == null) { session.getIntegrityChecker().handleError(DescriptorException.serializedObjectPolicyFieldNotSet(this.descriptor)); return; } if (this.descriptor.isChildDescriptor()) { SerializedObjectPolicy parentPolicy = this.descriptor.getInheritancePolicy().getParentDescriptor().getSerializedObjectPolicy(); if (parentPolicy != null && parentPolicy.getField() == this.field) { return; } } this.field = this.descriptor.buildField(this.field); this.descriptor.getFields().add(this.field); }
/** * INTERNAL: * Verify that an aggregate descriptor's inheritance tree * is full of aggregate descriptors. */ public void checkInheritanceTreeAggregateSettings(AbstractSession session, AggregateMapping mapping) throws DescriptorException { if (!this.hasInheritance()) { return; } if (this.isChildDescriptor()) { Class parentClass = this.getInheritancePolicy().getParentClass(); if (parentClass == this.getJavaClass()) { throw DescriptorException.parentClassIsSelf(this); } // recurse up the inheritance tree to the root descriptor session.getDescriptor(parentClass).checkInheritanceTreeAggregateSettings(session, mapping); } else { // we have a root descriptor, now verify it and all its children, grandchildren, etc. this.checkInheritanceTreeAggregateSettingsForChildren(session, mapping); } }
public void removeLifecycle(EntityManagerFactory entityManagerFactory, JpaGpsDevice device) throws JpaGpsDeviceException { CompassGpsInterfaceDevice gps = (CompassGpsInterfaceDevice) device.getGps(); JpaEntityManager entityManager = (JpaEntityManager) entityManagerFactory.createEntityManager(); Session session = entityManager.getServerSession(); entityManager.close(); Map descriptors = session.getDescriptors(); for (Object o : descriptors.values()) { ClassDescriptor classDescriptor = (ClassDescriptor) o; Class mappedClass = classDescriptor.getJavaClass(); // if we have a parent class that is mapped in JPA and in Compass, then don't add an event listner // since we will add it to the parent descriptor and it will notify this class as well if (classDescriptor.isChildDescriptor()) { Class parentClass = classDescriptor.getInheritancePolicy().getParentDescriptor().getJavaClass(); if (gps.hasMappingForEntityForMirror(parentClass, Cascade.ALL)) { classDescriptor.getDescriptorEventManager().removeListener(dummyEventListener); continue; } } if (gps.hasMappingForEntityForMirror(mappedClass, Cascade.ALL)) { classDescriptor.getDescriptorEventManager().removeListener(eventListener); } } } }
/** * INTERNAL: * Verify that an aggregate descriptor's inheritance tree * is full of aggregate descriptors. */ public void checkInheritanceTreeAggregateSettings(AbstractSession session, AggregateMapping mapping) throws DescriptorException { if (!this.hasInheritance()) { return; } if (this.isChildDescriptor()) { Class parentClass = this.getInheritancePolicy().getParentClass(); if (parentClass == this.getJavaClass()) { throw DescriptorException.parentClassIsSelf(this); } // recurse up the inheritance tree to the root descriptor session.getDescriptor(parentClass).checkInheritanceTreeAggregateSettings(session, mapping); } else { // we have a root descriptor, now verify it and all its children, grandchildren, etc. this.checkInheritanceTreeAggregateSettingsForChildren(session, mapping); } }
/** * INTERNAL: * Verify that an aggregate descriptor's inheritance tree * is full of aggregate descriptors. */ public void checkInheritanceTreeAggregateSettings(AbstractSession session, AggregateMapping mapping) throws DescriptorException { if (!this.hasInheritance()) { return; } if (this.isChildDescriptor()) { Class parentClass = this.getInheritancePolicy().getParentClass(); if (parentClass == this.getJavaClass()) { throw DescriptorException.parentClassIsSelf(this); } // recurse up the inheritance tree to the root descriptor session.getDescriptor(parentClass).checkInheritanceTreeAggregateSettings(session, mapping); } else { // we have a root descriptor, now verify it and all its children, grandchildren, etc. this.checkInheritanceTreeAggregateSettingsForChildren(session, mapping); } }
/** * Hook together the inheritance policy tree. */ protected void preInitializeInheritancePolicy(AbstractSession session) throws DescriptorException { if (isChildDescriptor() && (requiresInitialization(session))) { if (getInheritancePolicy().getParentClass().equals(getJavaClass())) { setInterfaceInitializationStage(ERROR); throw DescriptorException.parentClassIsSelf(this); } ClassDescriptor parentDescriptor = session.getDescriptor(getInheritancePolicy().getParentClass()); parentDescriptor.getInheritancePolicy().addChildDescriptor(this); getInheritancePolicy().setParentDescriptor(parentDescriptor); parentDescriptor.preInitialize(session); } }
/** * Hook together the inheritance policy tree. */ protected void preInitializeInheritancePolicy(AbstractSession session) throws DescriptorException { if (isChildDescriptor() && (requiresInitialization())) { if (getInheritancePolicy().getParentClass().equals(getJavaClass())) { setInterfaceInitializationStage(ERROR); throw DescriptorException.parentClassIsSelf(this); } ClassDescriptor parentDescriptor = session.getDescriptor(getInheritancePolicy().getParentClass()); parentDescriptor.getInheritancePolicy().addChildDescriptor(this); getInheritancePolicy().setParentDescriptor(parentDescriptor); parentDescriptor.preInitialize(session); } }
/** * Hook together the inheritance policy tree. */ protected void preInitializeInheritancePolicy(AbstractSession session) throws DescriptorException { if (isChildDescriptor() && (requiresInitialization(session))) { if (getInheritancePolicy().getParentClass().equals(getJavaClass())) { setInterfaceInitializationStage(ERROR); throw DescriptorException.parentClassIsSelf(this); } ClassDescriptor parentDescriptor = session.getDescriptor(getInheritancePolicy().getParentClass()); parentDescriptor.getInheritancePolicy().addChildDescriptor(this); getInheritancePolicy().setParentDescriptor(parentDescriptor); parentDescriptor.preInitialize(session); } }
/** * INTERNAL: * Validate that the descriptor's non-mapping attribute are defined correctly. */ protected void selfValidationBeforeInitialization(AbstractSession session) throws DescriptorException { if (isChildDescriptor()) { ClassDescriptor parentDescriptor = session.getDescriptor(getInheritancePolicy().getParentClass()); if (parentDescriptor == null) { session.getIntegrityChecker().handleError(DescriptorException.parentDescriptorNotSpecified(getInheritancePolicy().getParentClass().getName(), this)); } } else { if (getTables().isEmpty() && (!isAggregateDescriptor())) { session.getIntegrityChecker().handleError(DescriptorException.tableNotSpecified(this)); } } if (!isChildDescriptor() && !isDescriptorTypeAggregate()) { if (getPrimaryKeyFieldNames().isEmpty()) { session.getIntegrityChecker().handleError(DescriptorException.primaryKeyFieldsNotSepcified(this)); } } if ((getIdentityMapClass() == ClassConstants.NoIdentityMap_Class) && (getQueryManager().getDoesExistQuery().shouldCheckCacheForDoesExist())) { session.getIntegrityChecker().handleError(DescriptorException.identityMapNotSpecified(this)); } if (((getSequenceNumberName() != null) && (getSequenceNumberField() == null)) || ((getSequenceNumberName() == null) && (getSequenceNumberField() != null))) { session.getIntegrityChecker().handleError(DescriptorException.sequenceNumberPropertyNotSpecified(this)); } }
/** * INTERNAL: * Helper to build a HashMap to help in the construction of a CompositeData * * @param String mappedClassName: fullyQualified class name of the class * @return HashMap */ private ClassSummaryDetail buildLowlevelDetailsForNew(String mappedClassName) { Class mappedClass = (Class)getSession().getDatasourcePlatform().getConversionManager().convertObject(mappedClassName, ClassConstants.CLASS); IdentityMap identityMap = getSession().getIdentityMapAccessorInstance().getIdentityMap(mappedClass); ClassDescriptor descriptor = getSession().getProject().getDescriptor(mappedClass); String cacheType = getCacheTypeFor(identityMap.getClass()); String configuredSize = "" + identityMap.getMaxSize(); String currentSize = ""; //show the current size, including subclasses currentSize = "" + identityMap.getSize(mappedClass, true); String parentClassName = ""; boolean isChildDescriptor = descriptor.isChildDescriptor(); ClassSummaryDetail details = new ClassSummaryDetail( mappedClassName, (isChildDescriptor ? "" : cacheType), (isChildDescriptor ? "" : configuredSize), currentSize, parentClassName); return details; }