branch develop updated (7df046b -> 915c6a7)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository topia. See https://gitlab.nuiton.org/nuiton/topia.git from 7df046b Use latest apis from eugene + clean code (See #4043) new 5a41446 Fix one tag value loading + remove dependencies on deprecated code new a877e40 Use now only tag values (See #4043) new 915c6a7 Remove old tag values and stereoptyes api 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 915c6a76565e783561344e6083f77340743d645f Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Oct 8 15:06:49 2016 +0200 Remove old tag values and stereoptyes api commit a877e40db37e7c1a70d3301ce9924416e6751cb9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Oct 8 14:42:12 2016 +0200 Use now only tag values (See #4043) commit 5a41446ec4c851ceb03d47130fafc439c119e7c3 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Oct 8 14:40:01 2016 +0200 Fix one tag value loading + remove dependencies on deprecated code Summary of changes: .../templates/EntityHibernateMappingGenerator.java | 4 +- .../nuiton/topia/templates/EntityTransformer.java | 3 +- .../topia/templates/TopiaCoreStereoTypes.java | 138 --- .../nuiton/topia/templates/TopiaCoreTagValues.java | 47 + .../nuiton/topia/templates/TopiaGeneratorUtil.java | 16 +- .../topia/templates/TopiaHibernateTagValues.java | 13 +- .../nuiton/topia/templates/TopiaStereoTypes.java | 94 -- .../org/nuiton/topia/templates/TopiaTagValues.java | 998 --------------------- .../topia/templates/TopiaTemplateHelper.java | 18 +- ...stereotype.provider.StereotypeMetadatasProvider | 1 - ....models.stereotype.StereotypeDefinitionProvider | 1 - ...gene.models.tagvalue.TagValueDefinitionProvider | 1 - .../topia/templates/TopiaCoreStereoTypesTest.java | 69 -- .../topia/templates/TopiaCoreTagValuesTest.java | 12 +- .../topia/templates/TopiaStereoTypesTest.java | 57 -- .../nuiton/topia/templates/TopiaTagValuesTest.java | 68 -- 16 files changed, 85 insertions(+), 1455 deletions(-) delete mode 100644 topia-templates/src/main/java/org/nuiton/topia/templates/TopiaCoreStereoTypes.java delete mode 100644 topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java delete mode 100644 topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java delete mode 100644 topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.extension.stereotype.provider.StereotypeMetadatasProvider delete mode 100644 topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider delete mode 100644 topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider delete mode 100644 topia-templates/src/test/java/org/nuiton/topia/templates/TopiaCoreStereoTypesTest.java delete mode 100644 topia-templates/src/test/java/org/nuiton/topia/templates/TopiaStereoTypesTest.java delete mode 100644 topia-templates/src/test/java/org/nuiton/topia/templates/TopiaTagValuesTest.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 https://gitlab.nuiton.org/nuiton/topia.git commit 5a41446ec4c851ceb03d47130fafc439c119e7c3 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Oct 8 14:40:01 2016 +0200 Fix one tag value loading + remove dependencies on deprecated code --- .../java/org/nuiton/topia/templates/TopiaHibernateTagValues.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaHibernateTagValues.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaHibernateTagValues.java index 2f064ac..0735509 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaHibernateTagValues.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaHibernateTagValues.java @@ -46,8 +46,6 @@ import java.util.Set; import static org.nuiton.eugene.models.tagvalue.TagValues.findTagValue; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; -import static org.nuiton.topia.templates.TopiaTagValues.TAG_ATTRIBUTE_TYPE; -import static org.nuiton.topia.templates.TopiaTagValues.TAG_HIBERNATE_ATTRIBUTE_TYPE; /** * All extra tag values usable in topia generators. @@ -58,6 +56,9 @@ import static org.nuiton.topia.templates.TopiaTagValues.TAG_HIBERNATE_ATTRIBUTE_ */ public class TopiaHibernateTagValues extends DefaultTagValueMetadatasProvider { + private static final String TAG_ATTRIBUTE_TYPE = "attributeType"; + private static final String TAG_HIBERNATE_ATTRIBUTE_TYPE = "hibernateAttributeType"; + @Override public String getDescription() { return t("topia.hibernate.tagvalues"); @@ -435,7 +436,7 @@ public class TopiaHibernateTagValues extends DefaultTagValueMetadatasProvider { * @since 2.9.2 */ public String getManytoManyTableNameTagValue(ObjectModelAttribute attribute) { - return TagValueUtil.findDirectTagValue(Store.manyToManyTableName); + return TagValueUtil.findDirectTagValue(Store.manyToManyTableName, attribute); } /** -- 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 https://gitlab.nuiton.org/nuiton/topia.git commit a877e40db37e7c1a70d3301ce9924416e6751cb9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Oct 8 14:42:12 2016 +0200 Use now only tag values (See #4043) --- .../templates/EntityHibernateMappingGenerator.java | 4 +- .../nuiton/topia/templates/EntityTransformer.java | 3 +- .../topia/templates/TopiaCoreStereoTypes.java | 138 --------------------- .../nuiton/topia/templates/TopiaCoreTagValues.java | 47 +++++++ .../nuiton/topia/templates/TopiaGeneratorUtil.java | 16 +-- .../nuiton/topia/templates/TopiaStereoTypes.java | 14 +-- .../topia/templates/TopiaTemplateHelper.java | 18 +-- ...stereotype.provider.StereotypeMetadatasProvider | 1 - .../topia/templates/TopiaCoreStereoTypesTest.java | 69 ----------- .../topia/templates/TopiaCoreTagValuesTest.java | 12 +- 10 files changed, 86 insertions(+), 236 deletions(-) diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java index 6598415..65f66c2 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java @@ -28,7 +28,7 @@ import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.EugeneCoreStereotypes; +import org.nuiton.eugene.EugeneCoreTagValues; import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.models.object.ObjectModel; @@ -585,7 +585,7 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { generateFromTagValue(optionalAttributesMap, HIBERNATE_ATTRIBUTE_INDEX, indexName); } - if (EugeneCoreStereotypes.hasUniqueStereotype(attr)) { + if (EugeneCoreTagValues.isUnique(attr)) { generateFromTagValue(optionalAttributesMap, HIBERNATE_ATTRIBUTE_UNIQUE, "true"); } 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 8992fc7..c86a4f2 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 @@ -28,7 +28,6 @@ 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.EugeneCoreStereotypes; import org.nuiton.eugene.EugeneCoreTagValues; import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.java.JavaGeneratorUtil; @@ -756,7 +755,7 @@ public class EntityTransformer extends ObjectModelTransformerToJava { GeneratorUtil.getSimpleName(collectionImpl); boolean ordered = JavaGeneratorUtil.isOrdered(attribute); - boolean unique = EugeneCoreStereotypes.hasUniqueStereotype(attribute); + boolean unique = EugeneCoreTagValues.isUnique(attribute); boolean entity = templateHelper.isEntity(attribute, model); // addXXX diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaCoreStereoTypes.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaCoreStereoTypes.java deleted file mode 100644 index 8195382..0000000 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaCoreStereoTypes.java +++ /dev/null @@ -1,138 +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 com.google.common.collect.ImmutableSet; -import org.nuiton.eugene.models.extension.stereotype.StereotypeMetadata; -import org.nuiton.eugene.models.extension.stereotype.StereotypeUtil; -import org.nuiton.eugene.models.extension.stereotype.provider.DefaultStereotypeMetadatasProvider; -import org.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelPackage; - -import java.util.Set; - -import static org.nuiton.i18n.I18n.n; -import static org.nuiton.i18n.I18n.t; - -/** - * All extra stereotypes usable in topia generators. - * - * @author Tony Chemit - chemit@codelutin.com - * @plexus.component role="org.nuiton.eugene.models.extension.stereotype.provider.StereotypeMetadatasProvider" role-hint="topia-core" - * @since 2.5 - */ -public class TopiaCoreStereoTypes extends DefaultStereotypeMetadatasProvider { - - @Override - public String getDescription() { - return t("topia.stereotypes"); - } - - public enum Store implements StereotypeMetadata { - - /** - * Stéréotype pour les objets devant être générées sous forme d'entités - * - * @see TopiaTemplateHelper#isEntity(ObjectModelClassifier) - * @see #hasEntityStereotype(ObjectModelClassifier , ObjectModelPackage) - */ - entity(n("topia.stereotypes.entity"), false, ObjectModelPackage.class, ObjectModelClassifier.class), - /** - * Stéréotype pour les attributs étant des clés primaires. - * - * @see #hasPrimaryKeyStereotype(ObjectModelAttribute) - * @deprecated since 3.0, use nowhere in ToPIA - */ - primaryKey(n("topia.stereotypes.primaryKey"), true, ObjectModelAttribute.class); - - private final Set<Class<?>> targets; - private final String i18nDescriptionKey; - private final boolean deprecated; - - Store(String i18nDescriptionKey, boolean deprecated, Class<?>... targets) { - this.deprecated=deprecated; - this.targets = ImmutableSet.copyOf(targets); - this.i18nDescriptionKey = i18nDescriptionKey; - } - - @Override - public String getName() { - return name(); - } - - @Override - public Set<Class<?>> getTargets() { - return targets; - } - - @Override - public String getDescription() { - return t(i18nDescriptionKey); - } - - @Override - public boolean isDeprecated() { - return deprecated; - } - - } - - public TopiaCoreStereoTypes() { - super((StereotypeMetadata[]) Store.values()); - } - - /** - * Check if the given classifier has the {@link Store#entity} stereotype. - * - * @param aPackage FIXME - * @param classifier classifier to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see Store#entity - * - * @since 2.5 - */ - public static boolean hasEntityStereotype(ObjectModelClassifier classifier, ObjectModelPackage aPackage) { - boolean hasStereotype = StereotypeUtil.findDirectStereotype(Store.entity, classifier); - if (!hasStereotype && aPackage!=null) { - hasStereotype = StereotypeUtil.findDirectStereotype(Store.entity, aPackage); - } - return hasStereotype; - } - - /** - * Check if the given attribute has the {@link Store#primaryKey} stereotype. - * - * @param attribute attribute to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see Store#primaryKey - * @since 2.5 - * @deprecated since 3.0, not used in ToPIA - */ - @Deprecated - public static boolean hasPrimaryKeyStereotype(ObjectModelAttribute attribute) { - return StereotypeUtil.findDirectStereotype(Store.primaryKey, attribute); - } -} diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaCoreTagValues.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaCoreTagValues.java index 56bb155..44a940f 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaCoreTagValues.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaCoreTagValues.java @@ -60,6 +60,21 @@ public class TopiaCoreTagValues extends DefaultTagValueMetadatasProvider { public enum Store implements TagValueMetadata { /** + * Stéréotype pour les objets devant être générées sous forme d'entités + * + * @see TopiaTemplateHelper#isEntity(ObjectModelClassifier) + * @see #isEntity(ObjectModelClassifier , ObjectModelPackage) + */ + entity(n("topia.stereotypes.entity"), boolean.class, null, ObjectModelPackage.class, ObjectModelClassifier.class), + /** + * Stéréotype pour les attributs étant des clés primaires. + * + * @see #isPrimaryKey(ObjectModelAttribute) + * @deprecated since 3.0, use nowhere in ToPIA + */ + primaryKey(n("topia.stereotypes.primaryKey"), boolean.class, null, ObjectModelAttribute.class), + + /** * Tag pour que les entités etendent {@link TopiaEntityContextable} et * se fasse injecter le {@link TopiaDaoSupplier} par rapport aux autres * entités qui ne l'ont pas. @@ -356,6 +371,38 @@ public class TopiaCoreTagValues extends DefaultTagValueMetadatasProvider { return TagValueUtil.findBooleanTagValue(Store.generatePropertyChangeSupport, clazz, modelPackage, model); } + /** + * Check if the given classifier has the {@link Store#entity} stereotype. + * + * @param aPackage FIXME + * @param classifier classifier to test + * @return {@code true} if stereotype was found, {@code false otherwise} + * @see Store#entity + * + * @since 2.5 + */ + public boolean isEntity(ObjectModelClassifier classifier, ObjectModelPackage aPackage) { + boolean hasStereotype = TagValueUtil.findBooleanTagValue(Store.entity, classifier); + if (!hasStereotype && aPackage!=null) { + hasStereotype = TagValueUtil.findBooleanTagValue(Store.entity, aPackage); + } + return hasStereotype; + } + + /** + * Check if the given attribute has the {@link Store#primaryKey} stereotype. + * + * @param attribute attribute to test + * @return {@code true} if stereotype was found, {@code false otherwise} + * @see Store#primaryKey + * @since 2.5 + * @deprecated since 3.0, not used in ToPIA + */ + @Deprecated + public boolean isPrimaryKey(ObjectModelAttribute attribute) { + return TagValueUtil.findBooleanTagValue(Store.primaryKey, attribute); + } + public String getDeprecatedModelTagValueMessage(ObjectModel model, String deprecatedTagValue, String newTagValue, 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 8593dfd..5d7c6ae 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 @@ -32,7 +32,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.eugene.AbstractGenerator; -import org.nuiton.eugene.EugeneCoreStereotypes; +import org.nuiton.eugene.EugeneCoreTagValues; import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.java.ObjectModelTransformerToJava; @@ -553,7 +553,7 @@ public class TopiaGeneratorUtil extends JavaGeneratorUtil { ObjectModelAttribute attr) { if (JavaGeneratorUtil.isOrdered(attr)) { return "list"; - } else if (EugeneCoreStereotypes.hasUniqueStereotype(attr)) { + } else if (EugeneCoreTagValues.isUnique(attr)) { return "set"; } //attr.isOrdered() - On génère le ordered en bag @@ -570,7 +570,7 @@ public class TopiaGeneratorUtil extends JavaGeneratorUtil { */ public static List<ObjectModelClass> getEntityClasses(ObjectModel model, boolean sort) { - return getClassesByStereotype(TopiaCoreStereoTypes.Store.entity.getName(), model, sort); + return getClassesByStereotype(TopiaCoreTagValues.Store.entity.getName(), model, sort); } /** @@ -843,7 +843,7 @@ public class TopiaGeneratorUtil extends JavaGeneratorUtil { * @param model model containing the attribute * @return {@code true} if type of attribute is an entity, * {@code false} otherwise - * @see TopiaCoreStereoTypes.Store#entity + * @see TopiaCoreTagValues.Store#entity * @since 2.7 */ public static boolean isEntity(ObjectModelAttribute attribute, @@ -859,16 +859,16 @@ public class TopiaGeneratorUtil extends JavaGeneratorUtil { /** * Check if the given classifier has the - * {@link TopiaCoreStereoTypes.Store#entity} and is not an enumeration + * {@link TopiaCoreTagValues.Store#entity} and is not an enumeration * * @param classifier classifier to test * @return {@code true} if stereotype was found and classifier is not * enumeration, {@code false} otherwise - * @see TopiaCoreStereoTypes.Store#entity + * @see TopiaCoreTagValues.Store#entity * @since 2.5 */ public static boolean isEntity(ObjectModelClassifier classifier) { - return TopiaCoreStereoTypes.hasEntityStereotype(classifier, null) && !classifier.isEnum(); + return TOPIA_TAG_VALUES.isEntity(classifier, null) && !classifier.isEnum(); } /** @@ -943,7 +943,7 @@ public class TopiaGeneratorUtil extends JavaGeneratorUtil { ObjectModelClass clazz, boolean includeName) { Collection<ObjectModelAttribute> attributeCollection; attributeCollection = getElementsWithStereotype(clazz.getAttributes(), - TopiaCoreStereoTypes.Store.primaryKey.getName()); + TopiaCoreTagValues.Store.primaryKey.getName()); List<String> attributes = Lists.newArrayList(); for (ObjectModelAttribute attr : attributeCollection) { String attribute = attr.getType(); 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 706840f..52ed9e1 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 @@ -62,33 +62,33 @@ public class TopiaStereoTypes extends StereotypeDefinitionProvider { public static final String STEREOTYPE_PRIMARY_KEY = "primaryKey"; /** - * Check if the given classifier has the {@link TopiaCoreStereoTypes.Store#entity} stereotype. + * Check if the given classifier has the {@link #STEREOTYPE_ENTITY} stereotype. * * @param aPackage FIXME * @param classifier classifier to test * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaCoreStereoTypes.Store#entity + * @see #STEREOTYPE_ENTITY * @since 2.5 */ public static boolean hasEntityStereotype(ObjectModelClassifier classifier, ObjectModelPackage aPackage) { - boolean hasStereotype = classifier.hasStereotype(TopiaCoreStereoTypes.Store.entity.getName()); + boolean hasStereotype = classifier.hasStereotype(STEREOTYPE_ENTITY); if (!hasStereotype && aPackage!=null) { - hasStereotype = aPackage.hasStereotype(TopiaCoreStereoTypes.Store.entity.getName()); + hasStereotype = aPackage.hasStereotype(STEREOTYPE_ENTITY); } return hasStereotype; } /** - * Check if the given attribute has the {@link TopiaCoreStereoTypes.Store#primaryKey} stereotype. + * Check if the given attribute has the {@link #STEREOTYPE_PRIMARY_KEY} stereotype. * * @param attribute attribute to test * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaCoreStereoTypes.Store#primaryKey + * @see #STEREOTYPE_PRIMARY_KEY * @since 2.5 * @deprecated since 3.0, not used in ToPIA */ @Deprecated public static boolean hasPrimaryKeyStereotype(ObjectModelAttribute attribute) { - return attribute.hasStereotype(TopiaCoreStereoTypes.Store.primaryKey.getName()); + return attribute.hasStereotype(STEREOTYPE_PRIMARY_KEY); } } 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 281d28e..612fd57 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 @@ -30,7 +30,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.eugene.AbstractGenerator; -import org.nuiton.eugene.EugeneCoreStereotypes; +import org.nuiton.eugene.EugeneCoreTagValues; import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.java.ObjectModelTransformerToJava; @@ -94,11 +94,13 @@ public class TopiaTemplateHelper { protected final ObjectModel model; + protected final EugeneCoreTagValues eugeneTagValues; protected final TopiaCoreTagValues topiaCoreTagValues; protected final TopiaHibernateTagValues topiaHibernateTagValues; public TopiaTemplateHelper(ObjectModel model) { this.model = model; + this.eugeneTagValues = new EugeneCoreTagValues(); this.topiaCoreTagValues = new TopiaCoreTagValues(); this.topiaHibernateTagValues = new TopiaHibernateTagValues(); } @@ -593,7 +595,7 @@ public class TopiaTemplateHelper { ObjectModelAttribute attr) { if (JavaGeneratorUtil.isOrdered(attr)) { return "list"; - } else if (EugeneCoreStereotypes.hasUniqueStereotype(attr)) { + } else if (EugeneCoreTagValues.isUnique(attr)) { return "set"; } //attr.isOrdered() - On génère le ordered en bag @@ -868,7 +870,7 @@ public class TopiaTemplateHelper { * @param model model containing the attribute * @return {@code true} if type of attribute is an entity, * {@code false} otherwise - * @see TopiaCoreStereoTypes.Store#entity + * @see TopiaCoreTagValues.Store#entity * @since 2.7 */ public boolean isEntity(ObjectModelAttribute attribute, @@ -884,17 +886,17 @@ public class TopiaTemplateHelper { /** * Check if the given classifier has the - * {@link TopiaCoreStereoTypes.Store#entity} and is not an enumeration + * {@link TopiaCoreTagValues.Store#entity} and is not an enumeration * * @param classifier classifier to test * @return {@code true} if stereotype was found and classifier is not * enumeration, {@code false} otherwise - * @see TopiaCoreStereoTypes.Store#entity + * @see TopiaCoreTagValues.Store#entity * @since 2.5 */ public boolean isEntity(ObjectModelClassifier classifier) { ObjectModelPackage aPackage = model.getPackage(classifier); - return !classifier.isEnum() && TopiaCoreStereoTypes.hasEntityStereotype(classifier, aPackage); + return !classifier.isEnum() && topiaCoreTagValues.isEntity(classifier, aPackage); } /** @@ -934,8 +936,8 @@ public class TopiaTemplateHelper { public Class<?> getCollectionInstanceType(ObjectModelAttribute attribute) { - boolean unique = EugeneCoreStereotypes.hasUniqueStereotype(attribute); - boolean ordered = EugeneCoreStereotypes.hasOrderedStereotype(attribute); + boolean unique = EugeneCoreTagValues.isUnique(attribute); + boolean ordered = EugeneCoreTagValues.isOrdered(attribute); boolean orderBy = topiaHibernateTagValues.getOrderByTagValue(attribute) != null; Class<?> result; diff --git a/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.extension.stereotype.provider.StereotypeMetadatasProvider b/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.extension.stereotype.provider.StereotypeMetadatasProvider deleted file mode 100644 index f6e805a..0000000 --- a/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.extension.stereotype.provider.StereotypeMetadatasProvider +++ /dev/null @@ -1 +0,0 @@ -org.nuiton.topia.templates.TopiaCoreStereoTypes \ No newline at end of file diff --git a/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaCoreStereoTypesTest.java b/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaCoreStereoTypesTest.java deleted file mode 100644 index 8350ba4..0000000 --- a/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaCoreStereoTypesTest.java +++ /dev/null @@ -1,69 +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.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.nuiton.eugene.models.extension.stereotype.MismatchStereotypeTargetException; -import org.nuiton.eugene.models.extension.stereotype.StereotypeNotFoundException; -import org.nuiton.eugene.models.object.ObjectModel; -import org.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelPackage; - -public class TopiaCoreStereoTypesTest { - - protected TopiaCoreStereoTypes provider; - - @Before - public void setUp() throws Exception { - provider = new TopiaCoreStereoTypes(); - } - - @Test - public void test() { - - validate(TopiaCoreStereoTypes.Store.entity.name(), true, ObjectModelPackage.class, ObjectModelClassifier.class); - validate(TopiaCoreStereoTypes.Store.entity.name(), false, ObjectModel.class, ObjectModelAttribute.class); - - validate(TopiaCoreStereoTypes.Store.entity.name() + System.nanoTime(), false, ObjectModelPackage.class, ObjectModelClassifier.class); - - } - - protected void validate(String name, boolean expected, Class<?>... types) { - for (Class<?> type : types) { - try { - provider.validate(name, type); - Assert.assertTrue(expected); - } catch (StereotypeNotFoundException e) { - Assert.assertFalse(expected); - } catch (MismatchStereotypeTargetException e) { - Assert.assertFalse(expected); - } - } - } - -} \ No newline at end of file diff --git a/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaCoreTagValuesTest.java b/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaCoreTagValuesTest.java index 310ec90..b4d960e 100644 --- a/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaCoreTagValuesTest.java +++ b/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaCoreTagValuesTest.java @@ -29,6 +29,10 @@ import org.junit.Before; import org.junit.Test; import org.nuiton.eugene.models.extension.tagvalue.MismatchTagValueTargetException; import org.nuiton.eugene.models.extension.tagvalue.TagValueNotFoundException; +import org.nuiton.eugene.models.object.ObjectModel; +import org.nuiton.eugene.models.object.ObjectModelAttribute; +import org.nuiton.eugene.models.object.ObjectModelClassifier; +import org.nuiton.eugene.models.object.ObjectModelPackage; import org.nuiton.eugene.models.object.xml.ObjectModelAttributeImpl; import org.nuiton.eugene.models.object.xml.ObjectModelClassImpl; import org.nuiton.eugene.models.object.xml.ObjectModelImpl; @@ -45,7 +49,13 @@ public class TopiaCoreTagValuesTest { @Test public void testDefaultValues() { - Assert.assertEquals(true, provider.getNotGenerateToStringTagValue(new ObjectModelClassImpl(), new ObjectModelPackageImpl(), new ObjectModelImpl())); + + validate(TopiaCoreTagValues.Store.entity.name(), true, ObjectModelPackage.class, ObjectModelClassifier.class); + validate(TopiaCoreTagValues.Store.entity.name(), false, ObjectModel.class, ObjectModelAttribute.class); + + validate(TopiaCoreTagValues.Store.entity.name() + System.nanoTime(), false, ObjectModelPackage.class, ObjectModelClassifier.class); + + Assert.assertEquals(true, provider.getNotGenerateToStringTagValue(new ObjectModelClassImpl(), new ObjectModelPackageImpl(), new ObjectModelImpl())); } protected void validate(String name, boolean expected, Class<?>... types) { -- 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 https://gitlab.nuiton.org/nuiton/topia.git commit 915c6a76565e783561344e6083f77340743d645f Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Oct 8 15:06:49 2016 +0200 Remove old tag values and stereoptyes api --- .../topia/templates/TopiaHibernateTagValues.java | 6 +- .../nuiton/topia/templates/TopiaStereoTypes.java | 94 -- .../org/nuiton/topia/templates/TopiaTagValues.java | 998 --------------------- ....models.stereotype.StereotypeDefinitionProvider | 1 - ...gene.models.tagvalue.TagValueDefinitionProvider | 1 - .../topia/templates/TopiaStereoTypesTest.java | 57 -- .../nuiton/topia/templates/TopiaTagValuesTest.java | 68 -- 7 files changed, 2 insertions(+), 1223 deletions(-) diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaHibernateTagValues.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaHibernateTagValues.java index 0735509..7c0a59d 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaHibernateTagValues.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaHibernateTagValues.java @@ -37,13 +37,11 @@ import org.nuiton.eugene.models.object.ObjectModelClass; import org.nuiton.eugene.models.object.ObjectModelClassifier; import org.nuiton.eugene.models.object.ObjectModelElement; import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.tagvalue.TagValues; import java.sql.Blob; import java.util.Map; import java.util.Set; -import static org.nuiton.eugene.models.tagvalue.TagValues.findTagValue; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -628,7 +626,7 @@ public class TopiaHibernateTagValues extends DefaultTagValueMetadatasProvider { if (value == null) { String tagValueName = TAG_HIBERNATE_ATTRIBUTE_TYPE + "." + attribute.getType(); String defaultValue = HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.get(attribute.getType()); - value = findTagValue(tagValueName, defaultValue, attribute, classifier, aPackage, model); + value = TagValueUtil.findTagValue(tagValueName, defaultValue, attribute, classifier, aPackage, model); } return value; @@ -651,7 +649,7 @@ public class TopiaHibernateTagValues extends DefaultTagValueMetadatasProvider { if (value == null) { String tagValueName = TAG_ATTRIBUTE_TYPE + "." + attribute.getType(); //TODO do not use this deprecated api - value = TagValues.findTagValue(tagValueName, (String) null, attribute, classifier, aPackage, model); + value = TagValueUtil.findTagValue(tagValueName, null, attribute, classifier, aPackage, model); } return value; 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 deleted file mode 100644 index 52ed9e1..0000000 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java +++ /dev/null @@ -1,94 +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.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.stereotype.StereotypeDefinition; -import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider; - -/** - * All extra stereotypes usable in topia generators. - * - * @author Tony Chemit - chemit@codelutin.com - * @plexus.component role="org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider" role-hint="topia-templates" - * @since 2.5 - */ -@Deprecated -public class TopiaStereoTypes extends StereotypeDefinitionProvider { - - /** - * Stéréotype pour les objets devant être générées sous forme d'entités - * - * @see TopiaTemplateHelper#isEntity(ObjectModelClassifier) - * @see #hasEntityStereotype(ObjectModelClassifier , ObjectModelPackage) - */ - @StereotypeDefinition(target = {ObjectModelClassifier.class, ObjectModelPackage.class}, - documentation = "To specify that a class is an Entity") - public static final String STEREOTYPE_ENTITY = "entity"; - - /** - * Stéréotype pour les attributs étant des clés primaires. - * - * @see #hasPrimaryKeyStereotype(ObjectModelAttribute) - * @deprecated since 3.0, use nowhere in ToPIA - */ - @Deprecated - @StereotypeDefinition(target = ObjectModelAttribute.class, - documentation = "To specify that an attribute is part of a primary key (Hibernate mapping)") - public static final String STEREOTYPE_PRIMARY_KEY = "primaryKey"; - - /** - * Check if the given classifier has the {@link #STEREOTYPE_ENTITY} stereotype. - * - * @param aPackage FIXME - * @param classifier classifier to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see #STEREOTYPE_ENTITY - * @since 2.5 - */ - public static boolean hasEntityStereotype(ObjectModelClassifier classifier, ObjectModelPackage aPackage) { - boolean hasStereotype = classifier.hasStereotype(STEREOTYPE_ENTITY); - if (!hasStereotype && aPackage!=null) { - hasStereotype = aPackage.hasStereotype(STEREOTYPE_ENTITY); - } - return hasStereotype; - } - - /** - * Check if the given attribute has the {@link #STEREOTYPE_PRIMARY_KEY} stereotype. - * - * @param attribute attribute to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see #STEREOTYPE_PRIMARY_KEY - * @since 2.5 - * @deprecated since 3.0, not used in ToPIA - */ - @Deprecated - public static boolean hasPrimaryKeyStereotype(ObjectModelAttribute attribute) { - return attribute.hasStereotype(STEREOTYPE_PRIMARY_KEY); - } -} diff --git a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java deleted file mode 100644 index ca854ca..0000000 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java +++ /dev/null @@ -1,998 +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 com.google.common.collect.Maps; -import org.nuiton.eugene.models.object.ObjectModel; -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.ObjectModelElement; -import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.tagvalue.TagValueDefinition; -import org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider; -import org.nuiton.eugene.models.tagvalue.TagValues; -import org.nuiton.eugene.models.tagvalue.matcher.StartsWithTagNameMatcher; -import org.nuiton.topia.persistence.TopiaDaoSupplier; -import org.nuiton.topia.persistence.TopiaEntity; -import org.nuiton.topia.persistence.TopiaEntityContextable; - -import java.sql.Blob; -import java.util.Map; - -/** - * All extra tag values usable in topia generators. - * - * @author Tony Chemit - chemit@codelutin.com - * @plexus.component role="org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider" role-hint="topia-templates" - * @since 2.5 - */ -@Deprecated -public class TopiaTagValues extends TagValueDefinitionProvider { - - /** - * Static singleton instance used to read defaultValue - */ - protected static final TopiaTagValues INSTANCE = new TopiaTagValues(); - - static { - // XXX AThimel 18/06/14 I don't like writing such blocks, but I would like to leave INSTANCE final ... Need time to think about it - INSTANCE.init(); - } - - /** - * Tag pour le type de persistence. - * - * @see TopiaTemplateHelper#getPersistenceType(ObjectModelClassifier) - * @see #getPersistenceTypeTagValue(ObjectModelClassifier) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelClassifier.class}, - documentation = "TODO") - public static final String TAG_PERSISTENCE_TYPE = "persistenceType"; - - /** - * Tag pour que les entités etendent {@link TopiaEntityContextable} et - * se fasse injecter le {@link TopiaDaoSupplier} par rapport aux autres - * entités qui ne l'ont pas. - * - * @since 2.5.3 - */ - @TagValueDefinition(target = {ObjectModelPackage.class, ObjectModelClassifier.class}, documentation = "TODO") - public static final String TAG_CONTEXTABLE = "contextable"; - - /** - * Tag pour le nom du champ / entité en BD. - * - * @see #getDbNameTagValue(ObjectModelElement) - * @see TopiaTemplateHelper#getDbName(ObjectModelElement) - * @see TopiaTemplateHelper#getReverseDbName(ObjectModelAttribute) - */ - @TagValueDefinition(target = {ObjectModelElement.class}, - documentation = "Sets the database name of an element of the model (a table or a column)") - public static final String TAG_DB_NAME = "dbName"; - - /** - * Tag to specify the reverse db name of an attribute in database. - * - * @see TopiaTemplateHelper#getReverseDbName(ObjectModelAttribute) - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets the database name of the reverse db name attribute of the model (a column)") - public static final String TAG_REVERSE_DB_NAME = "reverseDbName"; - - /** - * Tag to specify the reverse db name of an attribute in database. - * - * @see #getManytoManyTableNameTagValue(ObjectModelAttribute) - * @see TopiaTemplateHelper#getManyToManyTableName(ObjectModelAttribute) - * @since 2.9.2 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets the database table name of a many to many relation for a attribute of the model") - public static final String TAG_MANY_TO_MANY_TABLE_NAME = "manyToManyTableName"; - - /** - * Tag pour le nom du schema en BD. - * - * @see #getDbSchemaNameTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelAttribute.class}, - documentation = "Sets the database schema name") - public static final String TAG_SCHEMA_NAME = "dbSchema"; - - /** - * Tag pour la taille du champ en BD. - * - * @see #getLengthTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets the length of an attribute in database") - public static final String TAG_LENGTH = "length"; - - /** - * Tag pour ajouter une annotation à un champ. - * - * @see #getAnnotationTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets an annotation of an attribute") - public static final String TAG_ANNOTATION = "annotation"; - - /** - * Tag pour specfier le type d'acces a un champ. - * - * @see #getAccessTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets the access type of an attribute (Hibernate mapping)") - public static final String TAG_ACCESS = "access"; - - /** - * Tag pour ajouter un attribut dans une clef métier. - * - * @see #getNaturalIdTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets an attribute as part of a natural id (Hibernate Mapping)") - public static final String TAG_NATURAL_ID = "naturalId"; - - /** - * Tag pour specifier si une clef metier est mutable. - * - * @see #getNaturalIdMutableTagValue(ObjectModelClassifier) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelClassifier.class}, - documentation = "Sets if natural id of a entity is mutable (hibernate mapping)") - public static final String TAG_NATURAL_ID_MUTABLE = "naturalIdMutable"; - - /** - * Tag pour permettre de choisir qui contrôle la relation N-N - * bidirectionnelle. A utiliser sur les deux extremités de l'association. - * Mettre inverse=false sur le rôle fils et inverse=true sur le rôle père. - * Par défaut le inverse=true est placé sur le premier rôle trouvé dans - * l'ordre alphabétique. - * - * @see #getInverseTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets which part of a N-N relation is master (inverse=true) and slave (inverse=false) (must be put on each side on a such relation) (Hibernate mapping)") - public static final String TAG_INVERSE = "inverse"; - - /** - * Tag pour spécifier la caractère lazy d'une association multiple. - * - * @see #getLazyTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets if an association should be lazy (Hibernate mapping)") - public static final String TAG_LAZY = "lazy"; - - /** - * Tag pour spécifier la caractère fetch d'une association multiple. - * - * @see #getFetchTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets the fetch caracteristic of an attribute (Hibernate mapping)") - public static final String TAG_FETCH = "fetch"; - - /** - * Tag pour spécifier la caractère order-by d'une association multiple. - * - * @see #getOrderByTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets the order by propertie of an multiple association (Hibernate mapping)") - public static final String TAG_ORDER_BY = "orderBy"; - - /** - * Tag pour spécifier la caractère not-null d'un attribut. - * - * @see #getNotNullTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets if an attribute must be not null (Hibernate mapping)") - public static final String TAG_NOT_NULL = "notNull"; - - /** - * Tag à placer sur un l'attribut d'une entité. Cet attribut est de type - * énumération : l'ajout de la tagValue indique qu'il faut utiliser le - * {@code name} de l'énumération et non l'ordinal pour stocker la valeur en - * base - * - * @see #hasUseEnumerationNameTagValue(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelAttribute.class}, - documentation = "'true' if the value of this attribute of type Enumeration should be stored with its name (instead of using ordinal)", - defaultValue = "true") - public static final String TAG_USE_ENUMERATION_NAME = "useEnumerationName"; - - /** - * Tag pour configurer l'interface du proxy sur autre chose que l'implementation par defaut. - * - * Par defaut : - * null → generere le proxy sur l'interface de l'implementation - * Autre valeur : - * "none" → laisse la configuration par defaut d'hibernate - * - * @see #getPersistenceTypeTagValue(ObjectModelClassifier) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "Configure the proxy interface on something else than the default implementation (null to use our default implementation, none to let hibernate deal it) (Hibernate mapping)") - public static final String TAG_PROXY_INTERFACE = "hibernateProxyInterface"; - - /** - * Tag pour configurer la stategie d'heritage choisie. - * - * Par defaut : union-subclass : Table per class strategy - * Autre valeur : - * "subclass" → Single table per class hierarchy strategy - * "joined-subclass" → Joined subclass strategy - * - * @see #getPersistenceTypeTagValue(ObjectModelClassifier) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "Configure the proxy interface on something else than the default implementation (null to use our default implementation, none to let hibernate deal it) (Hibernate mapping)", - defaultValue = "union-subclass") - public static final String TAG_INHERITANCE_STRATEGY = "inheritanceStrategy"; - - /** - * Tag to skip toString() methods generation on entities. - * - * @see #getNotGenerateToStringTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - defaultValue = "true", - documentation = "Tag to skip toString() methods generation on entities.") - public static final String TAG_NOT_GENERATE_TO_STRING = "notGenerateToString"; - - /** - * Tag pour specifier de trier les attributs par nom lors de la generation. - * - * @see #getSortAttributeTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To sort attribute while generation") - public static final String TAG_SORT_ATTRIBUTE = "sortAttribute"; - - /** - * Tag pour specfier si on doit générer la methode getOperator dans les daohelpers. - * - * @see #getGenerateOperatorForDAOHelperTagValue(ObjectModel) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModel.class}, - documentation = "To generate EntityOperation on generated DAOHelper") - public static final String TAG_GENERATE_OPERATOR_FOR_DAO_HELPER = "generateOperatorForDAOHelper"; - - /** - * Tag pour spécifier le type d'une propriété dans le mapping hibernate. - * - * @see #getTypeTagValue(ObjectModelAttribute) - * @since 2.5 - * @deprecated since 3.0, use now {@link #TAG_HIBERNATE_ATTRIBUTE_TYPE} which - * permits to deal the same thing but at also model and classifier scope. - */ - @Deprecated - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets the hibernate type of an attribute (Hibernate mapping)") - public static final String TAG_TYPE = "type"; - - /** - * Tag pour spécifier le type sql d'une propriété dans le mapping hibernate. - * - * @see #getSqlTypeTagValue(ObjectModelAttribute) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "Sets the sql type of an attribute (Hibernate mapping)") - public static final String TAG_SQL_TYPE = "sqlType"; - - /** - * To specify the abstract dao to use. - * - * If none given, will use the {@code org.nuiton.topia.persistence.TopiaDAOImpl}. - * - * Other value possible is {@code org.nuiton.topia.persistence.TopiaDAOLegacy} - * - * @see #getDaoImplementationTagValue(ObjectModel) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModel.class}, - documentation = "Sets the fully qualified name of the DAO implementation to use in generated DAO (default is DAOImpl (base on TopiaQuery))") - public static final String TAG_DAO_IMPLEMENTATION = "daoImplementation"; - - /** - * Stéréotype pour les attributs avec multiplicité nécessitant la création d'un index. - * - * @see #getIndexForeignKeysTagValue(ObjectModelAttribute, ObjectModelPackage, ObjectModel) - * @since 2.6.5 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelAttribute.class}, - defaultValue = "true", - documentation = "Specifies if an nm-multiplicity attribute (or all nm-multiplicity attributes of a given model) needs an index in db (Hibernate mapping)") - public static final String TAG_INDEX_FOREIGN_KEYS = "indexForeignKeys"; - - /** - * Tag to generate deterministic foreign key names in hibernate mapping files. - * - * @see #isGenerateForeignKeyNames(ObjectModelClassifier, ObjectModel) - * @since 3.0.1 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelClassifier.class}, - documentation = "To generate deterministic foreign keys names in hibernate mappings.") - public static final String TAG_GENERATE_FOREIGN_KEY_NAMES = "generateForeignKeyNames"; - - /** - * Tag to specify a super class to use instead of - * {@link org.nuiton.topia.persistence.internal.AbstractTopiaPersistenceContext}. - * - * <strong>Note:</strong> the class must implements - * {@link org.nuiton.topia.persistence.internal.AbstractTopiaPersistenceContext}. - * - * @see org.nuiton.topia.persistence.internal.AbstractTopiaPersistenceContext - * @see #getPersistenceContextSuperClassTagValue(ObjectModel) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModel.class}, - documentation = "Change the super class to use when generating PersistenceContext.") - public static final String TAG_PERSISTENCE_CONTEXT_SUPER_CLASS = "persistenceContextSuperClass"; - - /** - * Tag to specify a super class to use instead of - * {@link org.nuiton.topia.persistence.internal.AbstractTopiaApplicationContext}. - * - * <strong>Note:</strong> the class must implement - * {@link org.nuiton.topia.persistence.internal.AbstractTopiaApplicationContext}. - * - * @see org.nuiton.topia.persistence.internal.AbstractTopiaApplicationContext - * @see #getApplicationContextSuperClassTagValue(ObjectModel) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModel.class}, - documentation = "Change the super class to use when generating ApplicationContext.") - public static final String TAG_APPLICATION_CONTEXT_SUPER_CLASS = "applicationContextSuperClass"; - - /** - * Tag to specify a super class to use instead of {@link org.nuiton.topia.persistence.internal.AbstractTopiaDao}. - * - * <strong>Note:</strong> the class must implements {@link org.nuiton.topia.persistence.TopiaDao}. - * - * @see org.nuiton.topia.persistence.internal.AbstractTopiaDao - * @see #getDaoSuperClassTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModelClassifier.class, ObjectModelPackage.class, ObjectModel.class}, - documentation = "Change the super class to use when generating dao.") - public static final String TAG_DAO_SUPER_CLASS = "daoSuperClass"; - - /** - * Tag to specify a super class to use instead of {@link org.nuiton.topia.persistence.internal.AbstractTopiaEntity}. - * - * <strong>Note:</strong> the class must implements {@link TopiaEntity}. - * - * @see TopiaEntity - * @see #getEntitySuperClassTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModelClassifier.class, ObjectModelPackage.class, ObjectModel.class}, - documentation = "Change the super class to use when generating Entity.") - public static final String TAG_ENTITY_SUPER_CLASS = "entitySuperClass"; - - /** - * Tag to change the type of an attribute in a hibernate mapping. - * - * This is a special tagValue that is dynamic. - * - * For example to change the type {@code String} into hibernate mapping type {@code text}, add this: - * <pre> - * model.tagValue.hibernateAttributeType.String=text - * </pre> - * - * Before 3.0, you could do the same thing using: - * <pre> - * model.tagValue.String=text - * </pre> - * - * The new way permits us to validate the usage of the tagValue, old way can't. - * - * @see #getHibernateAttributeType(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModel.class}, - documentation = "Change the super class to use when generating Entity.", - matcherClass = StartsWithTagNameMatcher.class) - public static final String TAG_HIBERNATE_ATTRIBUTE_TYPE = "hibernateAttributeType"; - - /** - * Tag to change the type of an attribute. - * - * This is a special tagValue that is dynamic. - * - * For example to change the type {@code String} into type {@code java.lang.String}, add this: - * <pre> - * model.tagValue.attributeType.String=java.lang.String - * </pre> - * - * Before 3.0, you could do the same thing using: - * <pre> - * model.tagValue.String=java.lang.String - * </pre> - * - * The new way permits us to validate the usage of the tagValue, old way can't. - * - * @see #getHibernateAttributeType(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModel.class}, - documentation = "Change an attribute type.", - matcherClass = StartsWithTagNameMatcher.class) - public static final String TAG_ATTRIBUTE_TYPE = "attributeType"; - - /** - * Tag to specify if PropertyChangeListener support should be generated - * - * @see #isGeneratePropertyChangeSupport(ObjectModelClass, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - defaultValue = "false", - documentation = "To generate property change support in entities") - public static final String TAG_GENERATE_PROPERTY_CHANGE_SUPPORT = "generatePropertyChangeSupport"; - - /** - * Obtain the value of the {@link #TAG_PERSISTENCE_TYPE} tag value on the given classifier. - * - * @param classifier classifier to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_PERSISTENCE_TYPE - * @since 2.5 - */ - public String getPersistenceTypeTagValue(ObjectModelClassifier classifier) { - String value = findTagValue(TAG_PERSISTENCE_TYPE, classifier); - return value; - } - - /** - * Obtain the value of the {@link #TAG_INHERITANCE_STRATEGY} tag value on the given classifier. - * - * @param classifier classifier to seek - * @param aPackage package to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_INHERITANCE_STRATEGY - * @since 3.0 - */ - public String getInheritanceStrategyTagValue(ObjectModelClassifier classifier, - ObjectModelPackage aPackage) { - String value = findTagValue(TAG_INHERITANCE_STRATEGY, classifier, aPackage); - return value; - } - - /** - * Obtain the value of the {@link #TAG_DB_NAME} tag value on the given element. - * - * <strong>Note:</strong> We just try a direct search on the element and do not - * walk through his declaring elements if not found (see https://forge.nuiton.org/issues/2342). - * - * @param element element to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_DB_NAME - * @since 2.5 - */ - public String getDbNameTagValue(ObjectModelElement element) { - String value = findDirectTagValue(TAG_DB_NAME, null, element); - return value; - } - - /** - * Obtain the value of the {@link #TAG_SCHEMA_NAME} tag value on the given classifier. - * - * @param classifier classifier to seek - * @param aPackage package to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SCHEMA_NAME - * @since 2.5 - */ - public String getDbSchemaNameTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - String value = findTagValue(TAG_SCHEMA_NAME, classifier, aPackage, model); - return value; - } - - /** - * Obtain the value of the {@link TopiaTagValues#TAG_MANY_TO_MANY_TABLE_NAME} - * tag value on the given attribute. - * - * - * Note that it won't and search on declaring element or anywhere else than on the given element. - * See https://forge.nuiton.org/issues/2342 - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see TopiaTagValues#TAG_MANY_TO_MANY_TABLE_NAME - * @since 2.9.2 - */ - public String getManytoManyTableNameTagValue(ObjectModelAttribute attribute) { - String value = attribute.getTagValue(TopiaTagValues.TAG_MANY_TO_MANY_TABLE_NAME); - return value; - } - - /** - * Obtain the value of the {@link #TAG_LENGTH} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_LENGTH - * @since 2.5 - */ - public String getLengthTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_LENGTH, attribute); - return value; - } - - /** - * Obtain the value of the {@link #TAG_ANNOTATION} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_ANNOTATION - * @since 2.5 - */ - public String getAnnotationTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_ANNOTATION, attribute); - return value; - } - - /** - * Obtain the value of the {@link #TAG_ACCESS} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_ACCESS - * @since 2.5 - */ - public String getAccessTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_ACCESS, attribute); - return value; - } - - /** - * Obtain the value of the {@link #TAG_NATURAL_ID} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_NATURAL_ID - * @since 2.5 - */ - public boolean getNaturalIdTagValue(ObjectModelAttribute attribute) { - boolean value = findBooleanTagValue(TAG_NATURAL_ID, attribute); - return value; - } - - /** - * Obtain the value of the {@link #TAG_NATURAL_ID_MUTABLE} tag value on the given classifier. - * - * @param classifier classifier to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_NATURAL_ID_MUTABLE - * @since 2.5 - */ - public boolean getNaturalIdMutableTagValue(ObjectModelClassifier classifier) { - boolean value = findBooleanTagValue(TAG_NATURAL_ID_MUTABLE, classifier); - return value; - } - - /** - * Obtain the value of the {@link #TAG_CONTEXTABLE} tag value on the given classifier or model. - * - * @param classifier classifier to seek - * @param aPackage FIXME - * @param model model to seek - * @return the boolean value of the found tag value or {@code false} if not found nor empty. - * @see #TAG_CONTEXTABLE - * @since 2.5 - */ - public boolean getContextableTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - boolean value = findBooleanTagValue(TAG_CONTEXTABLE, classifier, aPackage, model); - return value; - } - - /** - * Obtain the value of the {@link #TAG_INVERSE} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_INVERSE - * @since 2.5 - */ - public String getInverseTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_INVERSE, attribute); - return value; - } - - /** - * Obtain the value of the {@link #TAG_LAZY} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_LAZY - * @since 2.5 - */ - public String getLazyTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_LAZY, attribute); - return value; - } - - /** - * Obtain the value of the {@link #TAG_FETCH} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_FETCH - * @since 2.5 - */ - public String getFetchTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_FETCH, attribute); - return value; - } - - /** - * Obtain the value of the {@link #TAG_ORDER_BY} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_ORDER_BY - * @since 2.5 - */ - public String getOrderByTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_ORDER_BY, attribute); - return value; - } - - /** - * Obtain the value of the {@link #TAG_NOT_NULL} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_NOT_NULL - * @since 2.5 - */ - public Boolean getNotNullTagValue(ObjectModelAttribute attribute) { - Boolean value = findNullableBooleanTagValue(TAG_NOT_NULL, attribute); - return value; - } - - /** - * Obtain the value of the {@link #TAG_PROXY_INTERFACE} tag value on the given classifier. - * - * @param classifier classifier to seek - * @param aPackage FIXME - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_PROXY_INTERFACE - * @since 2.5 - */ - public String getProxyInterfaceTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - String value = findTagValue(TAG_PROXY_INTERFACE, classifier, aPackage, model); - return value; - } - - /** - * Obtain the value of the {@link #TAG_NOT_GENERATE_TO_STRING} tag value on the given class. - * - * @param clazz class to seek - * @param aPackage FIXME - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_NOT_GENERATE_TO_STRING - * @since 2.5 - */ - public boolean getNotGenerateToStringTagValue(ObjectModelClassifier clazz, ObjectModelPackage aPackage, ObjectModel model) { - boolean value = findBooleanTagValue(TAG_NOT_GENERATE_TO_STRING, clazz, aPackage, model); - return value; - } - - /** - * Obtain the value of the {@link #TAG_SORT_ATTRIBUTE} tag value on the given classifier. - * - * @param classifier classifier to seek - * @param aPackage FIXME - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SORT_ATTRIBUTE - * @since 2.5 - */ - public boolean getSortAttributeTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - boolean value = findBooleanTagValue(TAG_SORT_ATTRIBUTE, classifier, aPackage, model); - return value; - } - - /** - * Obtain the value of the {@link TopiaTagValues#TAG_GENERATE_FOREIGN_KEY_NAMES} - * tag value on the given model or classifier and returns {@code true} if the tag value was found and value {@code true}. - * - * It will first look on the model, and then in the given classifier. - * - * @param model model to seek - * @param classifier classifier to seek - * @return {@code true} if tag value was found on classifier or model and his value is {@code true}, otherwise {@code false}. - * @see TopiaTagValues#TAG_GENERATE_FOREIGN_KEY_NAMES - * @since 2.10 - */ - public boolean isGenerateForeignKeyNames(ObjectModelClassifier classifier, ObjectModel model) { - boolean value = findBooleanTagValue(TAG_GENERATE_FOREIGN_KEY_NAMES, classifier, model); - return value; - } - - protected static final Map<String, String> HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES = Maps.newHashMap(); - - static { - // String - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(String.class.getSimpleName(), String.class.getName()); - - // primitive types wrappers - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(Boolean.class.getSimpleName(), Boolean.class.getName()); - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(Byte.class.getSimpleName(), Byte.class.getName()); - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(Character.class.getSimpleName(), Character.class.getName()); - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(Short.class.getSimpleName(), Short.class.getName()); - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(Integer.class.getSimpleName(), Integer.class.getName()); - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(Long.class.getSimpleName(), Long.class.getName()); - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(Float.class.getSimpleName(), Float.class.getName()); - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(Double.class.getSimpleName(), Double.class.getName()); - - // some particular types - HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.put(Blob.class.getSimpleName(), Blob.class.getName().toLowerCase()); - } - - /** - * Obtain the value of the {@link #TAG_HIBERNATE_ATTRIBUTE_TYPE} tag value on the given attribute, classifier or model. - * - * @param attribute attribute to seek - * @param aPackage FIXME - * @param model FIXME - * @param classifier FIXME - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_HIBERNATE_ATTRIBUTE_TYPE - * @since 3.0 - */ - public String getHibernateAttributeType(ObjectModelAttribute attribute, ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - - String value = TagValues.findDirectTagValue(TAG_HIBERNATE_ATTRIBUTE_TYPE, null, attribute); - if (value == null) { - String tagValueName = TAG_HIBERNATE_ATTRIBUTE_TYPE + "." + attribute.getType(); - String defaultValue = HIBERNATE_ATTRIBUTE_TYPE_DEFAULT_VALUES.get(attribute.getType()); - value = TagValues.findTagValue(tagValueName, defaultValue, attribute, classifier, aPackage, model); - } - return value; - - } - - /** - * Obtain the value of the {@link #TAG_ATTRIBUTE_TYPE} tag value on the given attribute, classifier or model. - * - * @param attribute attribute to seek - * @param aPackage FIXME - * @param model FIXME - * @param classifier FIXME - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_ATTRIBUTE_TYPE - * @since 3.0.1 - */ - public String getAttributeType(ObjectModelAttribute attribute, ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - - String value = TagValues.findDirectTagValue(TAG_ATTRIBUTE_TYPE, null, attribute); - if (value == null) { - String tagValueName = TAG_ATTRIBUTE_TYPE + "." + attribute.getType(); - value = TagValues.findTagValue(tagValueName, (String)null, attribute, classifier, aPackage, model); - } - return value; - - } - - /** - * Obtain the value of the {@link #TAG_SQL_TYPE} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_TYPE - * @since 2.5 - */ - public String getSqlTypeTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_SQL_TYPE, attribute); - return value; - } - - /** - * Obtains the value of the {@link #TAG_DAO_IMPLEMENTATION} tag value on the given model. - * - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_DAO_IMPLEMENTATION - * @since 2.5 - */ - public String getDaoImplementationTagValue(ObjectModel model) { - String value = findTagValue(TAG_DAO_IMPLEMENTATION, model); - return value; - } - - /** - * Obtains the value of the tag value {@link #TAG_INDEX_FOREIGN_KEYS} on the model or on the - * given attribute. - * - * @param attribute attribute to test - * @param model model to test - * @param aPackage FIXME - * @return none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_INDEX_FOREIGN_KEYS - * @since 2.6.5 - */ - public boolean getIndexForeignKeysTagValue(ObjectModelAttribute attribute, ObjectModelPackage aPackage, ObjectModel model) { - boolean value = findBooleanTagValue(TAG_INDEX_FOREIGN_KEYS, attribute, aPackage, model); - return value; - } - - //TODO Javadoc - public boolean hasUseEnumerationNameTagValue(ObjectModelAttribute attr, ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - boolean value = findBooleanTagValue(TAG_USE_ENUMERATION_NAME, attr, classifier, aPackage, model); - return value; - } - - /** - * Obtains the value of the {@link #TAG_PERSISTENCE_CONTEXT_SUPER_CLASS} tag value on the model. - * - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_PERSISTENCE_CONTEXT_SUPER_CLASS - * @since 3.0 - */ - public String getPersistenceContextSuperClassTagValue(ObjectModel model) { - String value = findTagValue(TAG_PERSISTENCE_CONTEXT_SUPER_CLASS, model); - return value; - } - - /** - * Obtains the value of the {@link #TAG_APPLICATION_CONTEXT_SUPER_CLASS} tag value on the model. - * - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_APPLICATION_CONTEXT_SUPER_CLASS - * @since 3.0 - */ - public String getApplicationContextSuperClassTagValue(ObjectModel model) { - String value = findTagValue(TAG_APPLICATION_CONTEXT_SUPER_CLASS, model); - return value; - } - - /** - * Obtains the value of the {@link #TAG_DAO_SUPER_CLASS} tag value on the given classifier or on the model. - * - * @param model model to seek - * @param aPackage FIXME - * @param classifier FIXME - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_DAO_SUPER_CLASS - * @since 3.0 - */ - public String getDaoSuperClassTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - String value = findTagValue(TAG_DAO_SUPER_CLASS, classifier, aPackage, model); - return value; - } - - /** - * Obtains the value of the {@link #TAG_ENTITY_SUPER_CLASS} tag value on the given classifier or on the model. - * - * @param model model to seek - * @param aPackage FIXME - * @param classifier FIXME - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_ENTITY_SUPER_CLASS - * @since 3.0 - */ - public String getEntitySuperClassTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - String value = findTagValue(TAG_ENTITY_SUPER_CLASS, classifier, aPackage, model); - return value; - } - - /** - * Cherche si le tagvalue {@link #TAG_GENERATE_OPERATOR_FOR_DAO_HELPER} a été activé dans le model. - * - * @param model le modele utilisé - * @return {@code true} si le tag value trouvé dans le modèle, {@code false} - * sinon. - * @since 2.5 - */ - public boolean getGenerateOperatorForDAOHelperTagValue(ObjectModel model) { - boolean value = findBooleanTagValue(TAG_GENERATE_OPERATOR_FOR_DAO_HELPER, model); - return value; - } - - public boolean isGeneratePropertyChangeSupport(ObjectModelClass clazz, ObjectModel model) { - ObjectModelPackage modelPackage = model.getPackage(clazz); - boolean value = findBooleanTagValue(TAG_GENERATE_PROPERTY_CHANGE_SUPPORT, clazz, modelPackage, model); - return value; - } - - //--------------------------------------------------------------------------------------------------------------- - //-- DEPRECATED API TO REMOVE --------------------------------------------------------------------------------- - //--------------------------------------------------------------------------------------------------------------- - - /** - * Obtain the value of the {@link #TAG_TYPE} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_TYPE - * @since 2.5 - * @deprecated since 3.0, use now {@link #getHibernateAttributeType(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage, ObjectModel)} or {@link #getAttributeType(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage, ObjectModel)} - */ - @Deprecated - public String getTypeTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_TYPE, attribute); - return value; - } - - public String getDeprecatedAttributeTagValueMessage(ObjectModelClass clazz, - ObjectModelAttribute attr, - String deprecatedTagValue, - String newTagValue, - String value) { - String tagValuePrefix = clazz.getQualifiedName() + ".attribute." + attr.getName() + ".tagValue."; - - String deprecatedTagName = tagValuePrefix + deprecatedTagValue + "=" + value; - String tagName = tagValuePrefix + newTagValue + "=" + value; - return "\n---------\nYou are using a deprecated tagValue (" + deprecatedTagName + "), replace it by\n" + tagName + "\n---------\n"; - - } - - public String getDeprecatedModelTagValueMessage(ObjectModel model, - String deprecatedTagValue, - String newTagValue, - String value) { - String tagValuePrefix = "model.tagValue."; - - String deprecatedTagName = tagValuePrefix + deprecatedTagValue + "=" + value; - String tagName = tagValuePrefix + newTagValue + "=" + value; - return "\n---------\nYou are using a deprecated tagValue (" + deprecatedTagName + "), replace it by\n" + tagName + "\n---------\n"; - - } - -} diff --git a/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider b/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider deleted file mode 100644 index b53e332..0000000 --- a/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider +++ /dev/null @@ -1 +0,0 @@ -org.nuiton.topia.templates.TopiaStereoTypes \ No newline at end of file diff --git a/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider b/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider deleted file mode 100644 index 61028f3..0000000 --- a/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider +++ /dev/null @@ -1 +0,0 @@ -org.nuiton.topia.templates.TopiaTagValues \ No newline at end of file diff --git a/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaStereoTypesTest.java b/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaStereoTypesTest.java deleted file mode 100644 index b1ae836..0000000 --- a/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaStereoTypesTest.java +++ /dev/null @@ -1,57 +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.junit.Assert; -import org.junit.Before; -import org.nuiton.eugene.models.stereotype.MismatchStereotypeTargetException; -import org.nuiton.eugene.models.stereotype.StereotypeNotFoundException; - -@Deprecated -public class TopiaStereoTypesTest { - - protected TopiaStereoTypes provider; - - @Before - public void setUp() throws Exception { - provider = new TopiaStereoTypes(); - provider.init(); - } - - - protected void validate(String name, boolean expected, Class<?>... types) { - for (Class<?> type : types) { - try { - provider.validate(name, type); - Assert.assertTrue(expected); - } catch (StereotypeNotFoundException e) { - Assert.assertFalse(expected); - } catch (MismatchStereotypeTargetException e) { - Assert.assertFalse(expected); - } - } - } - -} \ No newline at end of file diff --git a/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaTagValuesTest.java b/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaTagValuesTest.java deleted file mode 100644 index 75d5d86..0000000 --- a/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaTagValuesTest.java +++ /dev/null @@ -1,68 +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.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.nuiton.eugene.models.object.xml.ObjectModelAttributeImpl; -import org.nuiton.eugene.models.object.xml.ObjectModelClassImpl; -import org.nuiton.eugene.models.object.xml.ObjectModelImpl; -import org.nuiton.eugene.models.object.xml.ObjectModelPackageImpl; -import org.nuiton.eugene.models.tagvalue.MismatchTagValueTargetException; -import org.nuiton.eugene.models.tagvalue.TagValueNotFoundException; - -@Deprecated -public class TopiaTagValuesTest { - - protected TopiaTagValues provider; - - @Before - public void setUp() throws Exception { - provider = new TopiaTagValues(); - provider.init(); - } - - @Test - public void testDefaultValues() { - Assert.assertEquals("union-subclass", provider.getInheritanceStrategyTagValue(new ObjectModelClassImpl(), new ObjectModelPackageImpl())); - Assert.assertEquals(true, provider.getNotGenerateToStringTagValue(new ObjectModelClassImpl(), new ObjectModelPackageImpl(), new ObjectModelImpl())); - Assert.assertEquals(true, provider.getIndexForeignKeysTagValue(new ObjectModelAttributeImpl(), new ObjectModelPackageImpl(), new ObjectModelImpl())); - } - - protected void validate(String name, boolean expected, Class<?>... types) { - for (Class<?> type : types) { - try { - provider.validate(name, type); - Assert.assertTrue(expected); - } catch (TagValueNotFoundException e) { - Assert.assertFalse(expected); - } catch (MismatchTagValueTargetException e) { - Assert.assertFalse(expected); - } - } - } - -} \ No newline at end of file -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm