This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository topia. See http://git.nuiton.org/topia.git commit 43beb6c78bd3c0d8702b1e222208638203e44df5 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Oct 3 18:13:40 2014 +0200 Removes usages of 'dao' stereotype (refs #2081) --- .../topiatest/AbstractExtraDAOEntityTopiaDao.java | 39 ---- ...Contact2TopiaDao.java => Contact2TopiaDao.java} | 6 +- topia-it/src/main/xmi/topia-it-legacy.zargo | Bin 25927 -> 24499 bytes .../topia/templates/EntityDaoTransformer.java | 228 ++------------------- .../nuiton/topia/templates/EntityTransformer.java | 7 +- .../nuiton/topia/templates/TopiaGeneratorUtil.java | 20 -- .../nuiton/topia/templates/TopiaStereoTypes.java | 35 ---- .../topia/templates/TopiaTemplateHelper.java | 24 +-- 8 files changed, 25 insertions(+), 334 deletions(-) diff --git a/topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/AbstractExtraDAOEntityTopiaDao.java b/topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/AbstractExtraDAOEntityTopiaDao.java deleted file mode 100644 index b8c7b1c..0000000 --- a/topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/AbstractExtraDAOEntityTopiaDao.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.nuiton.topia.it.legacy.topiatest; - -/* - * #%L - * ToPIA :: IT - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.nuiton.topia.persistence.TopiaException; - -/** - * Created: 26 mai 2010 - * - * @author fdesbois <fdesbois@codelutin.com> - */ -public class AbstractExtraDAOEntityTopiaDao<E extends ExtraDAOEntity> extends GeneratedExtraDAOEntityTopiaDao<E> { - - @Override - public void extra() throws TopiaException { - } -} diff --git a/topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/deletetest/AbstractContact2TopiaDao.java b/topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/deletetest/Contact2TopiaDao.java similarity index 83% rename from topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/deletetest/AbstractContact2TopiaDao.java rename to topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/deletetest/Contact2TopiaDao.java index 12ccb53..ad4deb7 100644 --- a/topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/deletetest/AbstractContact2TopiaDao.java +++ b/topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/deletetest/Contact2TopiaDao.java @@ -24,7 +24,6 @@ package org.nuiton.topia.it.legacy.topiatest.deletetest; * #L% */ -import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.it.legacy.topiatest.Company; import org.nuiton.topia.it.legacy.topiatest.Employe; @@ -35,10 +34,9 @@ import java.util.TreeSet; * * @author desbois */ -public class AbstractContact2TopiaDao<E extends Contact2> extends GeneratedContact2TopiaDao<E> { +public class Contact2TopiaDao extends GeneratedContact2TopiaDao<Contact2> { - @Override - public Set<Contact2> findAllByCompany(Company company) throws TopiaException { + public Set<Contact2> findAllByCompany(Company company) { Set<Contact2> contacts = new TreeSet<Contact2>(); for (Employe e : company.getEmploye()) { contacts.addAll(e.getContacts()); diff --git a/topia-it/src/main/xmi/topia-it-legacy.zargo b/topia-it/src/main/xmi/topia-it-legacy.zargo index 30a7642..84b054b 100644 Binary files a/topia-it/src/main/xmi/topia-it-legacy.zargo and b/topia-it/src/main/xmi/topia-it-legacy.zargo differ diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDaoTransformer.java b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDaoTransformer.java index b522097..054cc10 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDaoTransformer.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDaoTransformer.java @@ -31,7 +31,6 @@ import com.google.common.base.Joiner; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -42,9 +41,6 @@ import org.nuiton.eugene.models.object.ObjectModel; import org.nuiton.eugene.models.object.ObjectModelAssociationClass; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelDependency; -import org.nuiton.eugene.models.object.ObjectModelInterface; import org.nuiton.eugene.models.object.ObjectModelJavaModifier; import org.nuiton.eugene.models.object.ObjectModelOperation; import org.nuiton.topia.persistence.TopiaDao; @@ -98,14 +94,7 @@ public class EntityDaoTransformer extends ObjectModelTransformerToJava { protected TopiaTemplateHelper templateHelper; - protected TopiaTagValues topiaTagValues; - - /** - * Map of extra operations for DAO. The key of the map is the qualified - * name of the entity relative to the DAO. - */ - protected Map<String, Collection<ObjectModelOperation>> extraOperations = - new HashMap<String, Collection<ObjectModelOperation>>(); + protected TopiaTagValues topiaTagValues; @Override public void transformFromModel(ObjectModel model) { @@ -136,78 +125,7 @@ public class EntityDaoTransformer extends ObjectModelTransformerToJava { for (ObjectModelClass entity : allEntities) { String fqn = entity.getQualifiedName(); allEntitiesFqn.add(fqn); - Collection<ObjectModelOperation> daoOperations = - new HashSet<ObjectModelOperation>(); - for (ObjectModelOperation op : entity.getOperations()) { - if (TopiaStereoTypes.hasDaoStereotype(op)) { - daoOperations.add(op); - } - } - - if (daoOperations.isEmpty()) { - - // found some dao operations - extraOperations.put(fqn, daoOperations); - } - } - } - - @Override - public void transformFromInterface(ObjectModelInterface interfacez) { - if (!TopiaStereoTypes.hasDaoStereotype(interfacez)) { - return; - } - - /** - * EVO #636 : Manage extra operations for DAO from "dao" dependency - * between an interface with stereotype <<dao>> (dependency client) and - * a class with stereotype <<entity>> (dependency supplier). - */ - - ObjectModelDependency dependency = - interfacez.getDependency(TopiaTemplateHelper.DEPENDENCIES_DAO); - - if (dependency == null) { - if (log.isWarnEnabled()) { - log.warn("Could not find dependency " + - TopiaTemplateHelper.DEPENDENCIES_DAO + - " but DAO stereotype was placed on the interface " + - interfacez.getName()); - } - return; - } - - ObjectModelClassifier classifier = dependency.getSupplier(); - - if (!templateHelper.isEntity(classifier)) { - - // dependency supplier is not an entity... - if (log.isWarnEnabled()) { - log.warn("Dependency supplier " + - classifier.getQualifiedName() + - " is not an entity."); - } - return; - } - - // keep only direct operations - Collection<ObjectModelOperation> operations = - interfacez.getOperations(); - - if (CollectionUtils.isEmpty(operations)) { - - // no operations on interface, this is not normal - if (log.isWarnEnabled()) { - log.warn("No operation found on interface with DAO " + - "stereotype "+classifier.getQualifiedName()); - } - return; } - if (log.isDebugEnabled()) { - log.debug("add "+operations.size()+" extra operation(s) for DAO"); - } - - extraOperations.put(classifier.getQualifiedName(), operations); } @Override @@ -266,23 +184,9 @@ public class EntityDaoTransformer extends ObjectModelTransformerToJava { String fqn = templateHelper.getAbstractDaoFqn(input); - if (isInClassPath(fqn)) { - - // already in class-path - return false; - } + boolean isGenerateAbstractDao = ! isInClassPath(fqn); - Collection<ObjectModelOperation> moreOperations = - extraOperations.get(input.getQualifiedName()); - - if (CollectionUtils.isNotEmpty(moreOperations)) { - - // no user operations, can not generate it - return false; - } - - // can safely generate the dao impl - return true; + return isGenerateAbstractDao; } @@ -309,33 +213,25 @@ public class EntityDaoTransformer extends ObjectModelTransformerToJava { String clazzName, String clazzFQN) { - Collection<ObjectModelOperation> moreOperations = - extraOperations.get(clazz.getQualifiedName()); - - if (CollectionUtils.isEmpty(moreOperations)) { - - // no business Dao found, can safely generate the abstract Dao class + String abstractDaoName = templateHelper.getAbstractDaoName(clazz); + String daoGenerics = "<E extends " + clazzName + ">"; + ObjectModelClass abstractDaoClass = createClass(abstractDaoName + daoGenerics, clazz.getPackageName()); + String documentation = String.format("/**%n" + + " * Implantation du Dao pour l'entité '%s'.%n" + + " * L'utilisateur peut remplacer cette classe par la sienne en la mettant%n" + + " * simplement dans ses sources. Cette classe générée sera alors simplement%n" + + " * ignorée à la génération suivante.%n" + + " */", clazzName); + setDocumentation(abstractDaoClass, documentation); + String superclassQualifiedName = templateHelper.getGeneratedDaoFqn(clazz) + "<E>"; + setSuperClass(abstractDaoClass, superclassQualifiedName); - String abstractDaoName = templateHelper.getAbstractDaoName(clazz); - String daoGenerics = "<E extends " + clazzName + ">"; - ObjectModelClass abstractDaoClass = createClass(abstractDaoName + daoGenerics, clazz.getPackageName()); - String documentation = String.format("/**%n" + - " * Implantation du Dao pour l'entité '%s'.%n" + - " * L'utilisateur peut remplacer cette classe par la sienne en la mettant%n" + - " * simplement dans ses sources. Cette classe générée sera alors simplement%n" + - " * ignorée à la génération suivante.%n" + - " */", clazzName); - setDocumentation(abstractDaoClass, documentation); - String superclassQualifiedName = templateHelper.getGeneratedDaoFqn(clazz) + "<E>"; - setSuperClass(abstractDaoClass, superclassQualifiedName); - - // TODO AThimel 25/10/13 Remove the next lines in ToPIA 3.1 - // Look for legacy Dao class, then warn user if found in classpath - String legacyDaoImplName = templateHelper.getLegacyDaoName(clazz) + "Impl"; - warnOnLegacyClassDetected(clazz.getPackageName(), legacyDaoImplName, abstractDaoName, daoGenerics, - superclassQualifiedName); + // TODO AThimel 25/10/13 Remove the next lines in ToPIA 3.1 + // Look for legacy Dao class, then warn user if found in classpath + String legacyDaoImplName = templateHelper.getLegacyDaoName(clazz) + "Impl"; + warnOnLegacyClassDetected(clazz.getPackageName(), legacyDaoImplName, abstractDaoName, daoGenerics, + superclassQualifiedName); - } } // TODO AThimel 25/10/13 Remove this method in ToPIA 3.1 @@ -416,14 +312,6 @@ public class EntityDaoTransformer extends ObjectModelTransformerToJava { // imports - Collection<ObjectModelOperation> daoOperations = getDaoOperations(clazz); - - if (templateHelper.isCollectionNeeded(daoOperations)) { - addImport(daoAbstractClass, Collection.class); - } - if (templateHelper.isSetNeeded(daoOperations)) { - addImport(daoAbstractClass, Set.class); - } addImport(daoAbstractClass, List.class); addImport(daoAbstractClass, TopiaQueryBuilderAddCriteriaOrRunQueryStep.class); @@ -455,8 +343,6 @@ public class EntityDaoTransformer extends ObjectModelTransformerToJava { }*/ ); - generateDAOOperations(daoAbstractClass, daoOperations); - generateDelete(clazz, daoAbstractClass); generateNaturalId(daoAbstractClass, clazz); @@ -851,39 +737,6 @@ public class EntityDaoTransformer extends ObjectModelTransformerToJava { setOperationBody(operation, buffer.toString()); } - /** - * Generation of DAO operations signatures from class. These operations are - * abstract and identified by <<dao>> stereotype in the model. The - * developper must defined these methods in the DAOImpl associated to this - * DAOAbstract. - * - * @param result clazz where to add operations - * @param operations operations to generate - * @deprecated will be removed ASAP in topia 3.0 - */ - @Deprecated - protected void generateDAOOperations(ObjectModelClass result, - Collection<ObjectModelOperation> - operations) { - if (CollectionUtils.isEmpty(operations)) { - - // no extra operations to generate - return; - } - - for (ObjectModelOperation op : operations) { - - Set<String> exceptions = op.getExceptions(); - cloneOperation(op, - result, - true, - ObjectModelJavaModifier.ABSTRACT, - ObjectModelJavaModifier.fromVisibility(op.getVisibility()) - ); - } - } - - protected void generateNoNMultiplicity(String clazzName, ObjectModelClass result, ObjectModelAttribute attr, @@ -1050,47 +903,6 @@ public class EntityDaoTransformer extends ObjectModelTransformerToJava { } - - /** - * Obtain business operations of the DAO. - * - * This operations can not be generated, but must be written by developper. - * - * @param clazz the clazz to test. - * @return collections of extra operations, or empty collection if none found. - * @deprecated Dao operation will not be generated anymore in a very close future - */ - @Deprecated - public Collection<ObjectModelOperation> getDaoOperations( - ObjectModelClass clazz) { - -// // Note : this collection will contains extra operations for DAO. -// // Overriding existing generated methods is not managed yet -// Collection<ObjectModelOperation> results = -// new ArrayList<ObjectModelOperation>(); - -// // This code will be deprecated -// for (ObjectModelOperation op : clazz.getOperations()) { -// if (templateHelper.hasDaoStereotype(op)) { -// results.add(op); -// } -// } - - Collection<ObjectModelOperation> extra = - extraOperations.get(clazz.getQualifiedName()); - if (extra != null && !extra.isEmpty() && log.isWarnEnabled()) { - log.warn("Dao contract in model will not be supported in topia 3.0"); - } - return extra; -// if (extra != null) { -// for (ObjectModelOperation op : extra) { -// results.add(op); -// } -// } - -// return results; - } - private void generateNaturalId(ObjectModelClass result, ObjectModelClass clazz) { Set<ObjectModelAttribute> props = diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java index ce6e1b9..4e3c172 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java @@ -564,14 +564,9 @@ public class EntityTransformer extends ObjectModelTransformerToJava { " - visibility : " + visibility); } - // Deprecated from 2.3.4 - // Pas de génération des signatures de méthodes pour celles à intégrer au DAO de l'entité - if (TopiaStereoTypes.hasDaoStereotype(operation)) { - return; - // Generate entity methods which have not a public visibility. // Only in abstract entity class as abstract operation. - } else if (!visibility.equals(ObjectModelJavaModifier.PUBLIC)) { + if (!visibility.equals(ObjectModelJavaModifier.PUBLIC)) { addOperation(outputAbstract, opName, opType, visibility, ObjectModelJavaModifier.ABSTRACT); diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaGeneratorUtil.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaGeneratorUtil.java index 4c38e5d..f335bff 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaGeneratorUtil.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaGeneratorUtil.java @@ -240,26 +240,6 @@ public class TopiaGeneratorUtil extends JavaGeneratorUtil { } /** - * Renvoie l'interface DAO associée à la classe passée en paramètre - * - * @param clazz la classe à tester - * @param model le modele utilisé - * @return l'interface trouvée ou null sinon - */ - public static ObjectModelInterface getDAOInterface(ObjectModelClass clazz, - ObjectModel model) { - for (Object o : model.getInterfaces()) { - ObjectModelInterface daoInterface = (ObjectModelInterface) o; - if (daoInterface.getName().equals(clazz.getName() + "DAO")) { - if (TopiaStereoTypes.hasDaoStereotype(daoInterface)) { - return daoInterface; - } - } - } - return null; - } - - /** * Renvoie le type de persistence pour le classifier donné. Si aucun n'est * trouvé, le type par défaut est utilisé * diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java index 4c8d377..c13dca6 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java @@ -26,7 +26,6 @@ package org.nuiton.topia.templates; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelOperation; import org.nuiton.eugene.models.object.ObjectModelPackage; import org.nuiton.eugene.models.stereotype.StereotypeDefinition; import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider; @@ -60,16 +59,6 @@ public class TopiaStereoTypes extends StereotypeDefinitionProvider { public static final String STEREOTYPE_DTO = "dto"; /** - * Stéréotype pour les interfaces devant être générées sous forme de DAO. - * - * @see #hasDaoStereotype(ObjectModelClassifier) - * @see #hasDaoStereotype(ObjectModelOperation) - */ - @StereotypeDefinition(target = {ObjectModelClassifier.class, ObjectModelOperation.class}, - documentation = "To Specify that a classifier or an operation should be generated as (or in) a DAO") - public static final String STEREOTYPE_DAO = "dao"; - - /** * Stéréotype pour les attributs étant des clés primaires. * * @see #hasPrimaryKeyStereotype(ObjectModelAttribute) @@ -109,30 +98,6 @@ public class TopiaStereoTypes extends StereotypeDefinitionProvider { } /** - * Check if the given classifier has the {@link TopiaStereoTypes#STEREOTYPE_DAO} stereotype. - * - * @param classifier classifier to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaStereoTypes#STEREOTYPE_DAO - * @since 2.5 - */ - public static boolean hasDaoStereotype(ObjectModelClassifier classifier) { - return classifier.hasStereotype(TopiaStereoTypes.STEREOTYPE_DAO); - } - - /** - * Check if the given operation has the {@link TopiaStereoTypes#STEREOTYPE_DAO} stereotype. - * - * @param operation operation to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaStereoTypes#STEREOTYPE_DAO - * @since 2.5 - */ - public static boolean hasDaoStereotype(ObjectModelOperation operation) { - return operation.hasStereotype(TopiaStereoTypes.STEREOTYPE_DAO); - } - - /** * Check if the given attribute has the {@link TopiaStereoTypes#STEREOTYPE_PRIMARY_KEY} stereotype. * * @param attribute attribute to test diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java index 94a9642..1d0020d 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTemplateHelper.java @@ -241,25 +241,6 @@ public class TopiaTemplateHelper { return result; } - /** - * Renvoie l'interface DAO associée à la classe passée en paramètre - * - * @param clazz la classe à tester - * @param model le modele utilisé - * @return l'interface trouvée ou null sinon - */ - public ObjectModelInterface getDAOInterface(ObjectModelClass clazz, - ObjectModel model) { - for (Object o : model.getInterfaces()) { - ObjectModelInterface daoInterface = (ObjectModelInterface) o; - if (daoInterface.getName().equals(clazz.getName() + "DAO")) { - if (TopiaStereoTypes.hasDaoStereotype(daoInterface)) { - return daoInterface; - } - } - } - return null; - } /** * Obtain the reverse db name of an attribute. @@ -920,10 +901,9 @@ public class TopiaTemplateHelper { * dependency to add extra operations for entity dao. * * @since 2.3.4 + * @deprecated only used for warn to help migration to 3.0, should be deleted */ - @Deprecated - public static final String DEPENDENCIES_DAO = "dao"; - + // TODO brendan 03/10/14 delete in 3.1 @Deprecated public static String getLegacyDaoName(ObjectModelClass input) { return input.getName() + "DAO"; -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.