Index: topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java diff -u topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java:1.3 topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java:1.4 --- topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java:1.3 Wed Jan 11 17:57:53 2006 +++ topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java Fri Jan 13 18:37:50 2006 @@ -25,9 +25,9 @@ * * @author Arnaud Thimel * - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * - * Mise a jour: $Date: 2006/01/11 17:57:53 $ par : $Author: thimel $ + * Mise a jour: $Date: 2006/01/13 18:37:50 $ par : $Author: thimel $ */ package org.codelutin.topia.generator; @@ -44,6 +44,7 @@ import org.codelutin.generator.models.object.ObjectModelElement; import org.codelutin.generator.models.object.ObjectModelInterface; import org.codelutin.generator.Util; +import org.codelutin.topia.persistence.TopiaEntity; /** * Classe regroupant divers méthodes utiles pour la génération des entités */ @@ -266,4 +267,28 @@ return attr.getName(); } + public static String getDOType(ObjectModelElement elem, ObjectModel model) { + String type = elem.getName(); + if (elem instanceof ObjectModelAttribute) { + type = ((ObjectModelAttribute)elem).getType(); + } if (elem instanceof ObjectModelClass) { + type = ((ObjectModelClass)elem).getQualifiedName(); + } + return getDOType(type, model); + } + + public static String getDOType(String type, ObjectModel model) { +// try { +// Class typeClass = Class.forName(type); +// if (TopiaEntity.class.isAssignableFrom(typeClass)) { +// type += "Impl"; +// } +// } catch (ClassNotFoundException cnfe) { +// } + if (model.hasClass(type)) { + type += "Impl"; + } + return type; + } + } // GeneratorUtil Index: topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java diff -u topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.9 topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.10 --- topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.9 Fri Jan 13 15:25:06 2006 +++ topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java Fri Jan 13 18:37:50 2006 @@ -24,10 +24,10 @@ * Created: 12 déc. 2005 * * @author Arnaud Thimel -* @version $Revision: 1.9 $ +* @version $Revision: 1.10 $ * -* Mise a jour: $Date: 2006/01/13 15:25:06 $ -* par : $Author: bpoussin $ +* Mise a jour: $Date: 2006/01/13 18:37:50 $ +* par : $Author: thimel $ */ package org.codelutin.topia.generator; @@ -67,7 +67,7 @@ @Override public String getFilenameForClass(ObjectModelClass clazz) { - return clazz.getQualifiedName().replace('.', File.separatorChar) + ".hbm.xml"; + return GeneratorUtil.getDOType(clazz, model).replace('.', File.separatorChar) + ".hbm.xml"; } @Override @@ -86,10 +86,10 @@ ObjectModelClass superClass = (ObjectModelClass)clazz.getSuperclasses().iterator().next(); String superClassname = superClass.getQualifiedName(); log.debug("superClass for " + clazz.getQualifiedName() + " is " + superClassname); -/*{ +/*{ }*/ } else { -/*{ +/*{ @@ -143,7 +143,7 @@ }*/ } if (attr.getReverseAttribute() == null) { - String type = ((ObjectModelClassifier)attr.getDeclaringElement()).getQualifiedName(); + String type = GeneratorUtil.getDOType(((ObjectModelClassifier)attr.getDeclaringElement()).getQualifiedName(), model); String name = Util.toLowerCaseFirstLetter(attr.getDeclaringElement().getName()); if (!Util.isNMultiplicity(attr)) { /*{ @@ -158,8 +158,6 @@ } -/*{ -}*/ if (haveSuper) { /*{ }*/ @@ -188,7 +186,11 @@ } private String getType(ObjectModelAttribute attr, boolean isAssoc) { - return ((attr.hasAssociationClass() && !isAssoc) ? attr.getAssociationClass().getQualifiedName() : attr.getType()); + String type = attr.getType(); + if (attr.hasAssociationClass() && !isAssoc) { + type = attr.getAssociationClass().getQualifiedName(); + } + return GeneratorUtil.getDOType(type, model); } private void generateHibernateProperty(Writer output, ObjectModelAttribute attr) throws IOException {