Index: topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java diff -u topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java:1.12 topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java:1.13 --- topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java:1.12 Fri May 5 08:05:38 2006 +++ topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java Wed May 24 13:22:04 2006 @@ -25,9 +25,9 @@ * * @author Arnaud Thimel * - * @version $Revision: 1.12 $ + * @version $Revision: 1.13 $ * - * Mise a jour: $Date: 2006/05/05 08:05:38 $ par : $Author: thimel $ + * Mise a jour: $Date: 2006/05/24 13:22:04 $ par : $Author: thimel $ */ package org.codelutin.topia.generator; @@ -47,6 +47,9 @@ import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelElement; import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; + +import sun.util.logging.resources.logging; /** * Classe regroupant divers méthodes utiles pour la génération des entités @@ -289,8 +292,12 @@ } public static String getDOType(String type, ObjectModel model) { - if (model.hasClass(type) && model.getClass(type).hasStereotype(STEREOTYPE_ENTITY)) { - if (model.getClass(type).isAbstract()) { + if (!model.hasClass(type)) { + return type; + } + ObjectModelClass clazz = model.getClass(type); + if (clazz.hasStereotype(STEREOTYPE_ENTITY)) { + if (shouldBeAbstract(clazz)) { type += "Abstract"; } else { type += "Impl"; @@ -300,6 +307,34 @@ } /** + * Indique si la classe specifiee n'a aucune ou que des methodes abstraites + * @param clazz l'instance de ObjectModelClass + * @return true si la classe n'a que des operations abstraite ou aucune + * operation + */ + public static boolean hasNothingOrAbstractMethods(ObjectModelClass clazz) { + boolean result = true; + Iterator operations = clazz.getOperations().iterator(); + while (result && operations.hasNext()) { + ObjectModelOperation op = (ObjectModelOperation)operations.next(); + result &= op.isAbstract(); + } + return result; + } + + /** + * Indique si la classe specifiee devrait etre abstraite + * @param clazz l'instance de ObjectModelClass + * @return true dans ce cas, false sinon + */ + public static boolean shouldBeAbstract(ObjectModelClass clazz) { + if (clazz == null) { + return false; + } + return (clazz.isAbstract() && hasNothingOrAbstractMethods(clazz)); + } + + /** *

* Cette méthode permet de détecter si * - l'attribut représente une relation 1-n Index: topia2/src/java/org/codelutin/topia/generator/EntityAbstractGenerator.java diff -u topia2/src/java/org/codelutin/topia/generator/EntityAbstractGenerator.java:1.18 topia2/src/java/org/codelutin/topia/generator/EntityAbstractGenerator.java:1.19 --- topia2/src/java/org/codelutin/topia/generator/EntityAbstractGenerator.java:1.18 Tue May 23 09:17:32 2006 +++ topia2/src/java/org/codelutin/topia/generator/EntityAbstractGenerator.java Wed May 24 13:22:04 2006 @@ -24,9 +24,9 @@ * Created: 12 déc. 2005 * * @author Arnaud Thimel -* @version $Revision: 1.18 $ +* @version $Revision: 1.19 $ * -* Mise a jour: $Date: 2006/05/23 09:17:32 $ +* Mise a jour: $Date: 2006/05/24 13:22:04 $ * par : $Author: thimel $ */ @@ -34,6 +34,7 @@ import static org.codelutin.topia.generator.GeneratorUtil.TAG_ANNOTATION; import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType; +import static org.codelutin.topia.generator.GeneratorUtil.shouldBeAbstract; import java.io.File; import java.io.IOException; @@ -49,7 +50,6 @@ import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelClassifier; -import org.codelutin.generator.models.object.ObjectModelOperation; /** * Generateur d'entites abstraites. Il s'agit de l'implatation par defaut d'une @@ -96,18 +96,7 @@ // impl ne sera pas créé boolean abstractParent = false; if (parent instanceof ObjectModelClass) { - abstractParent = ((ObjectModelClass)parent).isAbstract(); - } - Iterator superOps = parent.getOperations().iterator(); - boolean parentHasAbstractMethod = false; - while (superOps.hasNext()) { - ObjectModelOperation superOp = (ObjectModelOperation)superOps.next(); - parentHasAbstractMethod |= superOp.isAbstract(); - } - //Si les methodes presentes sur le parent abstrait sont - //non-abstraites, on doit alors considerer qu'il y aura un Impl - if (parent.getOperations().size()>0 && abstractParent && !parentHasAbstractMethod) { - abstractParent = false; + abstractParent = shouldBeAbstract((ObjectModelClass)parent); } if (parent.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) { if (abstractParent) {