[topia] branch develop updated (86ec18f -> f287155)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository topia. See http://git.nuiton.org/topia.git from 86ec18f Remove remaining TODO tags in HqlAndParametersBuilder: won't fixes (fixes #2894) new 43beb6c Removes usages of 'dao' stereotype (refs #2081) new 0b30751 Removes usages of 'dto' stereotype (refs #2081) new f287155 Removes usages of 'dto' and 'dao' stereotypes (fixes #2081) The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit f28715506ee321d805fe557badd2b073ab304487 Merge: 86ec18f 0b30751 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Oct 3 18:27:49 2014 +0200 Removes usages of 'dto' and 'dao' stereotypes (fixes #2081) commit 0b30751c77bac201170ece2eadc55585b5a38863 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Oct 3 18:27:08 2014 +0200 Removes usages of 'dto' stereotype (refs #2081) 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) Summary of changes: .../topiatest/AbstractExtraDAOEntityTopiaDao.java | 39 -- ...Contact2TopiaDao.java => Contact2TopiaDao.java} | 6 +- topia-it/src/main/xmi/topia-it-legacy.zargo | Bin 25927 -> 24499 bytes .../org/nuiton/topia/templates/DTOTransformer.java | 480 --------------------- .../topia/templates/EntityDaoTransformer.java | 228 +--------- .../nuiton/topia/templates/EntityTransformer.java | 7 +- .../nuiton/topia/templates/TopiaGeneratorUtil.java | 20 - .../nuiton/topia/templates/TopiaStereoTypes.java | 56 --- .../topia/templates/TopiaTemplateHelper.java | 24 +- 9 files changed, 25 insertions(+), 835 deletions(-) delete mode 100644 topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/AbstractExtraDAOEntityTopiaDao.java rename topia-it/src/main/java/org/nuiton/topia/it/legacy/topiatest/deletetest/{AbstractContact2TopiaDao.java => Contact2TopiaDao.java} (83%) delete mode 100644 topia-templates/src/main/java/org/nuiton/topia/templates/DTOTransformer.java -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
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>.
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 0b30751c77bac201170ece2eadc55585b5a38863 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Oct 3 18:27:08 2014 +0200 Removes usages of 'dto' stereotype (refs #2081) --- .../org/nuiton/topia/templates/DTOTransformer.java | 480 --------------------- .../nuiton/topia/templates/TopiaStereoTypes.java | 21 - 2 files changed, 501 deletions(-) diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/DTOTransformer.java b/topia-templates/src/main/java/org/nuiton/topia/templates/DTOTransformer.java deleted file mode 100644 index 3a2f376..0000000 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/DTOTransformer.java +++ /dev/null @@ -1,480 +0,0 @@ -package org.nuiton.topia.templates; - -/* - * #%L - * ToPIA :: Templates - * $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.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.GeneratorUtil; -import org.nuiton.eugene.java.JavaGeneratorUtil; -import org.nuiton.eugene.java.ObjectModelTransformerToJava; -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.ObjectModelInterface; -import org.nuiton.eugene.models.object.ObjectModelJavaModifier; -import org.nuiton.eugene.models.object.ObjectModelOperation; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -import java.util.Collection; -import java.util.List; - - -/*{generator option: parentheses = false}*/ - -/*{generator option: writeString = +}*/ - -/** - * Created: 20 déc. 2009 - * - * @author Tony Chemit - chemit@codelutin.com - * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.topia.templates.DTOTransformer" - * @since 2.3.0 - */ -public class DTOTransformer extends ObjectModelTransformerToJava { - - /** - * Logger - */ - private static final Log log = LogFactory.getLog(DTOTransformer.class); - - protected TopiaTemplateHelper templateHelper; - - protected TopiaTagValues topiaTagValues; - - @Override - public void transformFromClass(ObjectModelClass clazz) { - - if (!TopiaStereoTypes.hasDtoStereotype(clazz)) { - return; - } - - if (templateHelper == null) { - templateHelper = new TopiaTemplateHelper(model); - } - - if (topiaTagValues == null) { - topiaTagValues = templateHelper.getTopiaTagValues(); - } - String clazzName = clazz.getName(); - ObjectModelClass result; - result = createClass(clazzName + "DTO", clazz.getPackageName()); - addImport(result, ToStringBuilder.class); - addImport(result, PropertyChangeListener.class); - - setDocumentation(result, "Implantation DTO pour l'entité " + StringUtils.capitalize(clazzName) + "."); - String extendClass = ""; - for (ObjectModelClass parent : clazz.getSuperclasses()) { - extendClass = parent.getQualifiedName() + "DTO"; - // no multi-inheritance in java - break; - } - if (extendClass.length() > 0) { - setSuperClass(result, extendClass); - } - - addInterface(result, Serializable.class); - for (ObjectModelInterface parentInterface : clazz.getInterfaces()) { - if (TopiaStereoTypes.hasDtoStereotype(parentInterface)) { - addInterface(result, parentInterface.getName() + "DTO"); - } else { - addInterface(result, parentInterface.getName()); - } - } - - addAttributes(result, clazz); - - addOperations(result, clazz); - } - - protected void addAttributes(ObjectModelClass result, ObjectModelClass clazz) { - - String svUID = topiaTagValues.findTagValue("dto-serialVersionUID", clazz, model); - if (StringUtils.isNotEmpty(svUID)) { - addAttribute(result, "serialVersionUID", long.class, svUID, ObjectModelJavaModifier.FINAL, ObjectModelJavaModifier.PUBLIC, ObjectModelJavaModifier.STATIC); - } - - addAttribute(result, "p", PropertyChangeSupport.class, null, ObjectModelJavaModifier.PROTECTED); - -/* -* Définition des attributs -*/ - ObjectModelAttribute attr2; - for (ObjectModelAttribute attr : clazz.getAttributes()) { - ObjectModelAttribute reverse = attr.getReverseAttribute(); - - String attributeName; - String attributeType; - if (!(attr.isNavigable() - || attr.hasAssociationClass())) { - continue; - } - - String attrName = attr.getName(); - String attrVisibility = attr.getVisibility(); - String attrType = attr.getType(); - if (!GeneratorUtil.isNMultiplicity(attr)) { - if (!attr.hasAssociationClass()) { - if (isDTO(attrType)) { - attrType += "DTO"; - } - attributeType = attrType; - attributeName = attrName; - } else { - String assocAttrName = GeneratorUtil.getAssocAttrName(attr); - attributeType = attr.getAssociationClass().getQualifiedName(); - attributeName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName); - } - } else { - if (!attr.hasAssociationClass()) { - String nMultType; - if (JavaGeneratorUtil.isOrdered(attr)) { - nMultType = List.class.getName() + "<"; - } else { - nMultType = Collection.class.getName() + "<"; - } - nMultType += attrType; - if (isDTO(attrType)) { - nMultType += "DTO"; - } - nMultType += ">"; - - attributeType = nMultType; - attributeName = attrName; - } else { - String assocAttrName = GeneratorUtil.getAssocAttrName(attr); - String assocClassFQN = attr.getAssociationClass().getQualifiedName(); - String nMultType; - if (JavaGeneratorUtil.isOrdered(attr)) { - nMultType = List.class.getName() + "<"; - } else { - nMultType = Collection.class.getName() + "<"; - } - nMultType += assocClassFQN; - if (isDTO(attrType)) { - nMultType += "DTO"; - } - nMultType += ">"; - attributeType = nMultType; - attributeName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName); - } - } - - attr2 = addAttribute(result, attributeName, attributeType, null, ObjectModelJavaModifier.PROTECTED); - - if (attr2 != null) { - if (GeneratorUtil.hasDocumentation(attr)) { - setDocumentation(attr2, attr.getDocumentation()); - } - String annotation = topiaTagValues.getAnnotationTagValue(attr); - if (StringUtils.isNotEmpty(annotation)) { - addAnnotation(result, attr2, annotation); - } - } - } /* end for*/ - - //Déclaration des attributs d'une classe d'associations - if (clazz instanceof ObjectModelAssociationClass) { - ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz; - for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) { - if (attr != null) { - String attrName = attr.getName(); - String attrVisibility = attr.getVisibility(); - String attrType = attr.getType(); - if (isDTO(attrType)) { - attrType += "DTO"; - } - addAttribute(result, GeneratorUtil.toLowerCaseFirstLetter(attrName), attrType); - } - } - } - - } - - protected void addOperations(ObjectModelClass result, ObjectModelClass clazz) { - ObjectModelOperation op; - op = addOperation(result, "addPostWriteListener", "void", ObjectModelJavaModifier.PUBLIC); - addParameter(op, PropertyChangeListener.class, "listener"); - setOperationBody(op, "" -/*{ - p.addPostWriteListener(listener); - }*/ - ); - - op = addOperation(result, "addPostWriteListener", "void", ObjectModelJavaModifier.PUBLIC); - addParameter(op, String.class, "propertyName"); - addParameter(op, PropertyChangeListener.class, "listener"); - setOperationBody(op, "" -/*{ - p.addPostWriteListener(propertyName, listener); - }*/ - ); - - op = addOperation(result, "removePostWriteListener", "void", ObjectModelJavaModifier.PUBLIC); - addParameter(op, PropertyChangeListener.class, "listener"); - setOperationBody(op, "" -/*{ - p.removePostWriteListener(listener); - }*/ - ); - - op = addOperation(result, "removePostWriteListener", "void", ObjectModelJavaModifier.PUBLIC); - addParameter(op, String.class, "propertyName"); - addParameter(op, PropertyChangeListener.class, "listener"); - setOperationBody(op, "" -/*{ - p.removePostWriteListener(propertyName, listener); - }*/ - ); - /* - * Définition des getteurs et setteurs - */ - for (ObjectModelAttribute attr : clazz.getAttributes()) { - - ObjectModelAttribute reverse = attr.getReverseAttribute(); - -// if (!(attr.isNavigable() || hasUnidirectionalRelationOnAbstractType(reverse, model))) { - if (!attr.isNavigable()) { - continue; - } - - String attrName = attr.getName(); - String attrType = attr.getType(); - String attrTypeDTO = attr.getType(); - if (isDTO(attrType)) { - attrTypeDTO += "DTO"; - } - - if (!GeneratorUtil.isNMultiplicity(attr)) { - if (!attr.hasAssociationClass()) { - op = addOperation(result, "set" + StringUtils.capitalize(attrName), "void", ObjectModelJavaModifier.PUBLIC); - addParameter(op, attrTypeDTO, "value"); - setOperationBody(op, "" -/*{ - <%=attrTypeDTO%> oldValue = this.<%=attrName%>; - this.<%=attrName%> = value; - p.firePropertyChange("<%=attrName%>", oldValue, value); - }*/ - ); - - op = addOperation(result, "get" + StringUtils.capitalize(attrName), attrTypeDTO, ObjectModelJavaModifier.PUBLIC); - setOperationBody(op, "" -/*{ - return <%=attrName%>; - }*/ - ); - - } else { - String assocAttrName = GeneratorUtil.getAssocAttrName(attr); - String assocClassFQN = attr.getAssociationClass().getQualifiedName(); - if (log.isTraceEnabled()) { - log.trace("assocAttrName: " + assocAttrName); - } - op = addOperation(result, "set" + StringUtils.capitalize(assocAttrName), "void", ObjectModelJavaModifier.PUBLIC); - addParameter(op, assocClassFQN + "DTO", "association"); - setOperationBody(op, "" -/*{ - <%=assocClassFQN%>DTO oldAssocation = this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>; - this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = association; - p.firePropertyChange("<%=attrName%>", oldAssocation, assocation); - }*/ - ); - - op = addOperation(result, "get" + StringUtils.capitalize(assocAttrName), assocClassFQN + "DTO", ObjectModelJavaModifier.PUBLIC); - setOperationBody(op, "" -/*{ - return <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>; - }*/ - ); - } - } else { //NMultiplicity - if (!attr.hasAssociationClass()) { //Méthodes remplacées par des accesseurs sur les classes d'assoc - - String nMultType; - if (JavaGeneratorUtil.isOrdered(attr)) { - nMultType = List.class.getName() + "<" + attrTypeDTO + ">"; - } else { - nMultType = Collection.class.getName() + "<" + attrTypeDTO + ">"; - } - op = addOperation(result, "set" + StringUtils.capitalize(attrName), "void", ObjectModelJavaModifier.PUBLIC); - addParameter(op, nMultType, "values"); - setOperationBody(op, "" -/*{ - <%=nMultType%> oldValues = this.<%=attrName%>; - this.<%=attrName%> = values; - p.firePropertyChange("<%=attrName%>", oldValues, values); - }*/ - ); - - op = addOperation(result, "addChild" + StringUtils.capitalize(attrName), attrTypeDTO, ObjectModelJavaModifier.PUBLIC); - addParameter(op, attrTypeDTO, attrName); - StringBuilder buffercode = new StringBuilder(); - - buffercode.append("" -/*{ - this.<%=attrName%>.add(<%=attrName%>); - }*/ - ); - - if (reverse != null && reverse.isNavigable()) { - String reverseAttrName = reverse.getName(); - buffercode.append("" -/*{ <%=attrName%>.set<%=StringUtils.capitalize(reverseAttrName)%>(this); - }*/ - ); - } - buffercode.append("" -/*{ return <%=attrName%>; - }*/ - ); - setOperationBody(op, buffercode.toString()); - - op = addOperation(result, "removeChild", "void"); - addParameter(op, attrTypeDTO, attrName); - - buffercode = new StringBuilder(); - buffercode.append("" -/*{ - this.<%=attrName%>.remove(<%=attrName%>); - }*/ - ); - - if (reverse != null && reverse.isNavigable()) { - String reverseAttrName = reverse.getName(); - buffercode.append("" -/*{ <%=attrName%>.set<%=StringUtils.capitalize(reverseAttrName)%>(null); - }*/ - ); - } - setOperationBody(op, buffercode.toString()); - - } else { - String assocAttrName = GeneratorUtil.getAssocAttrName(attr); - String assocClassFQN = attr.getAssociationClass().getQualifiedName(); - String nMultType; - if (JavaGeneratorUtil.isOrdered(attr)) { - nMultType = List.class.getName() + "<" + assocClassFQN + "DTO>"; - } else { - nMultType = Collection.class.getName() + "<" + assocClassFQN + "DTO>"; - } - if (log.isTraceEnabled()) { - log.trace("assocAttrName: " + assocAttrName); - } - op = addOperation(result, "set" + StringUtils.capitalize(assocAttrName), "void"); - addParameter(op, nMultType, "values"); - setOperationBody(op, "" -/*{ - <%=nMultType%> oldValues = this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>; - this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = values; - p.firePropertyChange("<%=attrName%>", oldValues, values); - }*/ - ); - } - if (!attr.hasAssociationClass()) { - String nMultType; - if (JavaGeneratorUtil.isOrdered(attr)) { - nMultType = List.class.getName() + "<" + attrTypeDTO + ">"; - } else { - nMultType = Collection.class.getName() + "<" + attrTypeDTO + ">"; - } - op = addOperation(result, "get" + StringUtils.capitalize(attrName), nMultType); - setOperationBody(op, "" -/*{ - return this.<%=attrName%>; - }*/ - ); - } else { - String assocAttrName = GeneratorUtil.getAssocAttrName(attr); - String assocClassFQN = attr.getAssociationClass().getQualifiedName(); - String nMultType; - if (JavaGeneratorUtil.isOrdered(attr)) { - nMultType = List.class.getName() + "<" + assocClassFQN + "DTO>"; - } else { - nMultType = Collection.class.getName() + "<" + assocClassFQN + "DTO>"; - } - if (log.isTraceEnabled()) { - log.trace("assocAttrName: " + assocAttrName); - } - op = addOperation(result, "get" + StringUtils.capitalize(assocAttrName), nMultType); - setOperationBody(op, "" -/*{ - return this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>; - }*/ - ); - } - } - } - - op = addOperation(result, "toString", String.class, ObjectModelJavaModifier.PUBLIC); - StringBuilder buffer = new StringBuilder(); - - buffer.append("" -/*{ - String result = new ToStringBuilder(this). -}*/ - ); - - for (Object o : clazz.getAttributes()) { - ObjectModelAttribute attr = (ObjectModelAttribute) o; - if (!(attr.isNavigable() - || attr.hasAssociationClass())) { - continue; - } - //FIXME possibilité de boucles (non directes) - ObjectModelClass attrEntity = null; - if (model.hasClass(attr.getType())) { - attrEntity = model.getClass(attr.getType()); - } - boolean isDTO = attrEntity != null && - templateHelper.isEntity(attrEntity); //THIMEL : STEREOTYPE ENTITY ??? - ObjectModelAttribute reverse = attr.getReverseAttribute(); - if (isDTO && (reverse == null || !reverse.isNavigable()) && !attr.hasAssociationClass() || !isDTO) { - String attrName = attr.getName(); - buffer.append("" -/*{ append("<%=attrName%>", this.<%=attrName%>). -}*/ - ); - } - } - buffer.append("" -/*{ toString(); - return result; - }*/ - ); - setOperationBody(op, buffer.toString()); - } - - public boolean isDTO(String type) { - ObjectModelClassifier clazz = model.getClassifier(type); - return clazz != null && TopiaStereoTypes.hasDtoStereotype(clazz); - } - - -} - 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 c13dca6..5744dca 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 @@ -50,15 +50,6 @@ public class TopiaStereoTypes extends StereotypeDefinitionProvider { public static final String STEREOTYPE_ENTITY = "entity"; /** - * Stéréotype pour les objets devant être générées sous forme de DTO. - * - * @see #hasDtoStereotype(ObjectModelClassifier) - */ - @StereotypeDefinition(target = ObjectModelClassifier.class, - documentation = "to specify that a class is a DTO") - public static final String STEREOTYPE_DTO = "dto"; - - /** * Stéréotype pour les attributs étant des clés primaires. * * @see #hasPrimaryKeyStereotype(ObjectModelAttribute) @@ -86,18 +77,6 @@ public class TopiaStereoTypes extends StereotypeDefinitionProvider { } /** - * Check if the given classifier has the {@link TopiaStereoTypes#STEREOTYPE_DTO} stereotype. - * - * @param classifier classifier to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaStereoTypes#STEREOTYPE_DTO - * @since 2.5 - */ - public static boolean hasDtoStereotype(ObjectModelClassifier classifier) { - return classifier.hasStereotype(TopiaStereoTypes.STEREOTYPE_DTO); - } - - /** * Check if the given attribute has the {@link TopiaStereoTypes#STEREOTYPE_PRIMARY_KEY} stereotype. * * @param attribute attribute to test -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
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 f28715506ee321d805fe557badd2b073ab304487 Merge: 86ec18f 0b30751 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Oct 3 18:27:49 2014 +0200 Removes usages of 'dto' and 'dao' stereotypes (fixes #2081) .../topiatest/AbstractExtraDAOEntityTopiaDao.java | 39 -- ...Contact2TopiaDao.java => Contact2TopiaDao.java} | 6 +- topia-it/src/main/xmi/topia-it-legacy.zargo | Bin 25927 -> 24499 bytes .../org/nuiton/topia/templates/DTOTransformer.java | 480 --------------------- .../topia/templates/EntityDaoTransformer.java | 228 +--------- .../nuiton/topia/templates/EntityTransformer.java | 7 +- .../nuiton/topia/templates/TopiaGeneratorUtil.java | 20 - .../nuiton/topia/templates/TopiaStereoTypes.java | 56 --- .../topia/templates/TopiaTemplateHelper.java | 24 +- 9 files changed, 25 insertions(+), 835 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm