Index: topia-service/src/java/org/codelutin/topia/migration/kernel/DependenciesHelper.java diff -u topia-service/src/java/org/codelutin/topia/migration/kernel/DependenciesHelper.java:1.2 topia-service/src/java/org/codelutin/topia/migration/kernel/DependenciesHelper.java:1.3 --- topia-service/src/java/org/codelutin/topia/migration/kernel/DependenciesHelper.java:1.2 Wed Oct 17 13:14:42 2007 +++ topia-service/src/java/org/codelutin/topia/migration/kernel/DependenciesHelper.java Fri Nov 2 15:23:00 2007 @@ -26,6 +26,8 @@ import java.util.Map; import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.codelutin.topia.migration.common.ProxyClass; import org.codelutin.topia.migration.common.SimpleProxyClass; import org.hibernate.SessionFactory; @@ -33,6 +35,7 @@ import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; +import org.hibernate.mapping.Subclass; import org.hibernate.type.CollectionType; import org.hibernate.type.Type; @@ -45,9 +48,9 @@ * @author Chevallereau Benjamin * @author Eon Sébastien * @author Trève Vincent - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * - * Last update : $Date: 2007-10-17 13:14:42 $ + * Last update : $Date: 2007-11-02 15:23:00 $ */ public class DependenciesHelper { @@ -64,7 +67,7 @@ /** * Logger (common-logging) */ - //private Log logger = LogFactory.getLog(DependenciesHelper.class); + private Log logger = LogFactory.getLog(DependenciesHelper.class); /** * Liste des classes dépendantes pour chaque classe @@ -86,12 +89,17 @@ this.sessionFactory = sessionFactory; calculateDependencies(); + + if(logger.isDebugEnabled()) { + for(ProxyClass clazz : mDependencies.keySet()) { + logger.debug("Dep. for class : " + clazz + "=" + mDependencies.get(clazz)); + } + } } /** * Calcules les dependances */ - @SuppressWarnings("unchecked") private void calculateDependencies() { mDependencies = new Hashtable>(); @@ -123,31 +131,60 @@ } PersistentClass clazz = configuration.getClassMapping(currentClass); + + // gestion de l'heritage + if(clazz instanceof Subclass) { + Subclass usb = (Subclass)clazz; + String superClassName = usb.getSuperclass().getEntityName(); + ProxyClass pcDependentClass = new SimpleProxyClass(superClassName); + lDependecies.add(pcDependentClass); + + //classe dont depend la classe courante -> classe courante + List lOldDependents = mInvertDependencies.get(pcDependentClass); + if(lOldDependents == null) { + lOldDependents = new LinkedList(); + mInvertDependencies.put(pcDependentClass, lOldDependents); + } + lOldDependents.add(new SimpleProxyClass(currentClass)); + } + Iterator i = clazz.getPropertyIterator(); //on parcourt les proprietes de la classe courante while (i.hasNext()) { Property p = (Property)i.next(); - Type t = p.getType(); + Type propertyType = p.getType(); + // si c'est une association - if(t.isAssociationType()){ + if(propertyType.isAssociationType()) { + String dependentClassName; // on recupere le nom de la classe dont depend la classe courante - if(t.isCollectionType()){ - // - // - // - // - // - dependentClassName = ((CollectionType)t).getAssociatedEntityName(sfi); + if(propertyType.isCollectionType()){ + // + // + // + // + // + + CollectionType collectionType = (CollectionType)propertyType; + + dependentClassName = collectionType.getAssociatedEntityName(sfi); + + logger.debug(clazz.getEntityName() +":"+ dependentClassName + " : aj :" + collectionType.getAssociatedJoinable(sfi).getName()); + logger.debug(clazz.getEntityName() +":"+ dependentClassName + " : ajic :" + collectionType.getAssociatedJoinable(sfi).isCollection()); + logger.debug(clazz.getEntityName() +":"+ dependentClassName + " : et :" + collectionType.getElementType(sfi).getName()); + logger.debug(clazz.getEntityName() +":"+ dependentClassName + " : et :" + collectionType.getForeignKeyDirection()); + logger.debug(""); } else { // - dependentClassName = t.getName(); + dependentClassName = propertyType.getName(); } //on l'ajoute dans les listes correspondantes ProxyClass pcDependentClass = new SimpleProxyClass(dependentClassName); //classe courante -> classe dont elle depend lDependecies.add(pcDependentClass); + //classe dont depend la classe courante -> classe courante List lOldDependents = mInvertDependencies.get(pcDependentClass); if(lOldDependents == null) {