? .classpath ? .project ? patch.txt ? modules/borland/resources ? modules/hp/resources ? modules/libelis/resources ? modules/macromedia/resources ? modules/mockobjects/resources ? modules/mx4j/resources ? modules/objectweb/resources ? modules/openejb/resources ? modules/oracle/resources ? modules/orion/resources ? modules/portlet/resources ? modules/pramati/resources ? modules/spring/resources ? modules/sun/resources ? modules/tjdo/resources ? modules/web/resources ? modules/webwork/resources ? modules/wsee/resources Index: modules/hibernate/src/xdoclet/modules/hibernate/HibernateTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/HibernateTagsHandler.java,v retrieving revision 1.42 diff -u -r1.42 HibernateTagsHandler.java --- modules/hibernate/src/xdoclet/modules/hibernate/HibernateTagsHandler.java 1 Jun 2005 16:08:10 -0000 1.42 +++ modules/hibernate/src/xdoclet/modules/hibernate/HibernateTagsHandler.java 1 Jul 2005 21:01:42 -0000 @@ -4,11 +4,15 @@ */ package xdoclet.modules.hibernate; +import java.util.ArrayList; + import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Properties; +import java.util.Set; import org.apache.commons.logging.Log; import org.apache.tools.ant.types.Parameter; @@ -17,6 +21,7 @@ import xjavadoc.XDoc; import xjavadoc.XMethod; import xjavadoc.XProgramElement; +import xjavadoc.XTag; import xdoclet.DocletContext; import xdoclet.DocletSupport; import xdoclet.DocletTask; @@ -30,7 +35,7 @@ /** * Specific tags handler to make the template easy. * - * @author Sébastien Guimont (sebastieng@sympatico.ca) + * @author S?bastien Guimont (sebastieng@sympatico.ca) * @created August 9th, 2002 * @version $Revision: 1.42 $ * @xdoclet.taghandler namespace="Hibernate" @@ -52,6 +57,18 @@ private Parameter currentOtherMapping; + private static boolean isHibernated(XClass xClass) + { + if (xClass == null) { + return false; + } + + return ( + xClass.getDoc().getTag("hibernate.class") != null || + xClass.getDoc().getTag("hibernate.subclass") != null + ); + } + /** * Returns full path of hibernate file for the current class. * @@ -598,8 +615,12 @@ log.debug("typeName=" + typeName); Collection classes = getXJavaDoc().getSourceClasses(); + +// List reorderedClasses = flattenHierarchy(getCurrentClass(), classes); + XClass clazz; +// for (Iterator i = reorderedClasses.iterator(); i.hasNext(); ) { for (Iterator i = classes.iterator(); i.hasNext(); ) { clazz = (XClass) i.next(); @@ -608,8 +629,13 @@ if (DocletSupport.isDocletGenerated(clazz)) { log.debug("isDocletGenerated"); } - else if (clazz.getSuperclass() != null && clazz.getSuperclass().getQualifiedName().equals(typeName)) { - log.debug("is a subclass"); + else if (isValidSubclass(clazz, getCurrentClass())) { + if (getCurrentClass().isInterface()) { + log.debug("is an implementing class"); + } + else { + log.debug("is a subclass"); + } XClass current = getCurrentClass(); @@ -622,7 +648,7 @@ //TODO: why do we need this?! } else { - log.debug("is not a subclass"); + log.debug(" is not a subclass"); } } } @@ -771,10 +797,128 @@ //TODO: Why do we need this!!?? } + private boolean isValidSubclass(XClass clazz, XClass currentClass) + { + // first check the extends attribute of the subclass tag. + // if it exists, we blindly follow that. Note that this + // requires the fully qualified name of the class in the + // extends attribute. + XTag tag = clazz.getDoc().getTag("hibernate.subclass"); + + if (tag != null) { + String ext = tag.getAttributeValue("extends"); + + if (ext != null) { + return currentClass.getQualifiedName().equals(ext); + } + } + + String typeName = currentClass.getQualifiedName(); + + // easy case, clazz is implementing interface of hibernated class + // NB: not easy anymore, if we've got a hibernated interface hierarchy + // only return true for "deepest" implemented interface in this hierarchy + if (currentClass.isInterface() && clazz.isImplementingInterface(typeName)) { + List extending = currentClass.getExtendingInterfaces(); + + if (extending.isEmpty()) { + return true; + } + + for (int i = 0; i < extending.size(); i++) { + XClass xClass = (XClass) extending.get(i); + + if (isHibernated(xClass) && clazz.isImplementingInterface(xClass.getQualifiedName())) { + // we found an interface deeper in the hierarchy + return false; + } + } + return true; + } + + if (clazz.getSuperclass() != null) { + // easy case, this class is direct subclass of the hibernated type + if (clazz.getSuperclass().equals(typeName)) { + return true; + } + else { + // go up class hierarchy to find first hibernate tag + XClass xc = clazz; + + do { + xc = xc.getSuperclass(); + + } while (xc != null && !isHibernated(xc)); + + // did we find a valid superclass, is it the current ? + if (xc != null) { + return xc.equals(currentClass); + } + } + } + return false; + } + private HibernateSubTask getHibernateSubTask() { return ((HibernateSubTask) (DocletContext.getInstance() .getSubTaskBy(DocletTask.getSubTaskName(HibernateSubTask.class)))); } + + private void printCollection(Collection c) + { + int i = 0; + + for (Iterator it = c.iterator(); it.hasNext(); i++) + System.out.println(" [i]: " + it.next()); + } + + /** + * Flattens the collection of classes by eliminating descendants (for hibernated non interface classes). + * + * @param currentClass + * @param classes + * @return + */ + private List flattenHierarchy(XClass currentClass, Collection classes) + { + Log log = LogUtil.getLog(HibernateTagsHandler.class, "flattenHierarchy"); + + log.debug("for class " + currentClass); + + if (!currentClass.isInterface()) { + List l = new ArrayList(classes); + + l.retainAll(currentClass.getAllSubclasses()); + return l; + } + + Set s = new HashSet(classes); + + log.debug("initial set size: " + s.size()); + + for (Iterator iterator = classes.iterator(); iterator.hasNext(); ) { + XClass xClass = (XClass) iterator.next(); + + if (xClass.isInterface() || !isHibernated(xClass)) { + continue; + } + + List subClasses = xClass.getAllSubclasses(); + + for (int i = 0; i < subClasses.size(); i++) { + XClass aClass = (XClass) subClasses.get(i); + + if (s.contains(aClass)) { + log.debug("removing " + aClass + " from set"); + s.remove(aClass); + } + } + } + + log.debug("new set size: " + s.size()); + + return new ArrayList(s); + } } Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-any.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-any.xdt,v retrieving revision 1.2 diff -u -r1.2 hibernate-any.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-any.xdt 20 May 2005 15:00:19 -0000 1.2 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-any.xdt 1 Jul 2005 21:01:43 -0000 @@ -1,4 +1,4 @@ - + " Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-array.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-array.xdt,v retrieving revision 1.1 diff -u -r1.1 hibernate-array.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-array.xdt 8 Jun 2005 15:11:25 -0000 1.1 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-array.xdt 1 Jul 2005 21:01:43 -0000 @@ -1,4 +1,4 @@ - + ="" Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-bag.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-bag.xdt,v retrieving revision 1.1 diff -u -r1.1 hibernate-bag.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-bag.xdt 7 Jun 2005 13:54:48 -0000 1.1 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-bag.xdt 1 Jul 2005 21:01:43 -0000 @@ -1,4 +1,4 @@ - + ="" Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-component.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-component.xdt,v retrieving revision 1.1 diff -u -r1.1 hibernate-component.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-component.xdt 31 May 2005 15:50:02 -0000 1.1 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-component.xdt 1 Jul 2005 21:01:43 -0000 @@ -1,4 +1,4 @@ - + Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-list.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-list.xdt,v retrieving revision 1.1 diff -u -r1.1 hibernate-list.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-list.xdt 7 Jun 2005 13:54:48 -0000 1.1 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-list.xdt 1 Jul 2005 21:01:43 -0000 @@ -1,4 +1,4 @@ - + ="" Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-many-to-one.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-many-to-one.xdt,v retrieving revision 1.2 diff -u -r1.2 hibernate-many-to-one.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-many-to-one.xdt 1 Jun 2005 16:58:38 -0000 1.2 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-many-to-one.xdt 1 Jul 2005 21:01:43 -0000 @@ -1,4 +1,4 @@ - + Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-map.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-map.xdt,v retrieving revision 1.1 diff -u -r1.1 hibernate-map.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-map.xdt 8 Jun 2005 15:11:25 -0000 1.1 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-map.xdt 1 Jul 2005 21:01:43 -0000 @@ -1,4 +1,4 @@ - + ="" Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-one-to-one.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-one-to-one.xdt,v retrieving revision 1.1 diff -u -r1.1 hibernate-one-to-one.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-one-to-one.xdt 2 Jun 2005 14:15:38 -0000 1.1 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-one-to-one.xdt 1 Jul 2005 21:01:43 -0000 @@ -1,4 +1,4 @@ - + Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-primitive-array.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-primitive-array.xdt,v retrieving revision 1.1 diff -u -r1.1 hibernate-primitive-array.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-primitive-array.xdt 8 Jun 2005 15:11:26 -0000 1.1 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-primitive-array.xdt 1 Jul 2005 21:01:44 -0000 @@ -1,4 +1,4 @@ - + ="" Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-property.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-property.xdt,v retrieving revision 1.3 diff -u -r1.3 hibernate-property.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-property.xdt 1 Jun 2005 16:58:38 -0000 1.3 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-property.xdt 1 Jul 2005 21:01:44 -0000 @@ -1,4 +1,4 @@ - + Index: modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-set.xdt =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-set.xdt,v retrieving revision 1.2 diff -u -r1.2 hibernate-set.xdt --- modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-set.xdt 6 Jun 2005 19:02:42 -0000 1.2 +++ modules/hibernate/src/xdoclet/modules/hibernate/resources/hibernate-set.xdt 1 Jul 2005 21:01:44 -0000 @@ -1,4 +1,4 @@ - + =""