/** * Updates a <code>Collection</code> of {@link DomainMetaClass}es.<br> * Each {@link DomainMetaClass} whose superclass changed will be deleted, so * that it can be reprocessed later as a new meta class. * * @param existingMetaClassesToUpdate * the <code>Collection</code> of {@link DomainMetaClass}es to be * updated */ private void updateExistingMetaClassHierarchy(Collection<DomainMetaClass> existingMetaClassesToUpdate) { for (DomainMetaClass metaClass : existingMetaClassesToUpdate) { if (metaClass.getDomainMetaSuperclass() == null) { if (hasSuperclassInDML(metaClass)) { logger.info("DomainMetaClass " + metaClass.getDomainClass().getSimpleName() + " (and subclasses) hierarchy has changed"); metaClass.delete(); } } else { DomainMetaClass currentMetaSuperclass = null; if (hasSuperclassInDML(metaClass)) { currentMetaSuperclass = getDomainMetaSuperclassFromDML(metaClass); } if (currentMetaSuperclass != metaClass.getDomainMetaSuperclass()) { logger.info("DomainMetaClass " + metaClass.getDomainClass().getSimpleName() + " (and subclasses) hierarchy has changed"); metaClass.delete(); } } } }
/** * Creates a {@link DomainMetaClass} for each new class. For each new {@link DomainMetaClass}, initializes its * meta-superclass and creates a {@link DomainMetaObject} for each existing object of the new {@link DomainMetaClass}. * * @param newClassesToAddTopDown * the <code>Collection</code> of Classes for which to create {@link DomainMetaClass}es, in top-down * order */ private void createNewMetaClasses(Collection<Class<? extends DomainObject>> newClassesToAddTopDown) { for (Class<? extends DomainObject> domainClass : newClassesToAddTopDown) { DomainMetaClass newDomainMetaClass = new DomainMetaClass(domainClass); if (hasSuperclassInDML(newDomainMetaClass)) { newDomainMetaClass.initDomainMetaSuperclass(getDomainMetaSuperclassFromDML(newDomainMetaClass)); } newDomainMetaClass.initExistingDomainObjects(); newDomainMetaClass.executeInheritedPredicates(); // Because the initExistingDomainObjects method is split among several transactions, // the creation of the DomainMetaClass and its full initialization may not run atomically. // In case of a system failure during the execution of the initExistingDomainObjects() method, // the DomainMetaClass was already created, but not yet fully initialized. // The init is only considered completed when finalized is set to true. newDomainMetaClass.setInitialized(true); checkpointTransaction(); } }