branch feature/3712 created (now 61bbae7)
This is an automated email from the git hooks/post-receive script. New change to branch feature/3712 in repository topia. See http://git.nuiton.org/topia.git at 61bbae7 Remove attribute scope to generatePropertyChangeSupport tag value. This branch includes the following new commits: new 207ab33 Add attributeType tag value (See #3765) new 61bbae7 Remove attribute scope to generatePropertyChangeSupport tag value. The 2 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 61bbae7a790ba52a785943c42ba8ed1f9d4aeab9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Aug 22 21:24:14 2015 +0200 Remove attribute scope to generatePropertyChangeSupport tag value. See #3712 commit 207ab3391b6ca2d93a3e7dcb3b1b1465e1b49918 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Aug 22 20:59:29 2015 +0200 Add attributeType tag value (See #3765) -- 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 feature/3712 in repository topia. See http://git.nuiton.org/topia.git commit 207ab3391b6ca2d93a3e7dcb3b1b1465e1b49918 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Aug 22 20:59:29 2015 +0200 Add attributeType tag value (See #3765) --- .../templates/EntityHibernateMappingGenerator.java | 81 ++++++------ .../nuiton/topia/templates/EntityTransformer.java | 140 +++++++++++---------- .../org/nuiton/topia/templates/TopiaTagValues.java | 41 +++++- 3 files changed, 156 insertions(+), 106 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 573f270..207fb68 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 @@ -404,49 +404,56 @@ public class EntityHibernateMappingGenerator extends ObjectModelGenerator { type = attrType; } else { - // old code - attrType = topiaTagValues.getTypeTagValue(attr); + attrType = topiaTagValues.getAttributeType(attr, clazz, aPackage, model); if (StringUtils.isNotEmpty(attrType)) { - // tag value detected of the attribute - if (log.isWarnEnabled()) { - String deprecatedTagName = clazz.getQualifiedName() + ".attribute." + - attr.getName() + ".tagValue." + topiaTagValues.TAG_HIBERNATE_ATTRIBUTE_TYPE + - "." + type; - String tagName = clazz.getQualifiedName() + ".attribute." + - attr.getName() + ".tagValue." + topiaTagValues.TAG_HIBERNATE_ATTRIBUTE_TYPE + - "." + type; - log.warn("---------"); - log.warn("You are using a deprecated tagValue (" + deprecatedTagName + "), replace it by"); - log.warn(tagName + "=" + attrType); - } type = attrType; - } else { + } else{ + + // old code + attrType = topiaTagValues.getTypeTagValue(attr); + if (StringUtils.isNotEmpty(attrType)) { + + // tag value detected of the attribute + if (log.isWarnEnabled()) { + String deprecatedTagName = clazz.getQualifiedName() + ".attribute." + + attr.getName() + ".tagValue." + TopiaTagValues.TAG_HIBERNATE_ATTRIBUTE_TYPE + + "." + type; + String tagName = clazz.getQualifiedName() + ".attribute." + + attr.getName() + ".tagValue." + TopiaTagValues.TAG_HIBERNATE_ATTRIBUTE_TYPE + + "." + type; + log.warn("---------"); + log.warn("You are using a deprecated tagValue (" + deprecatedTagName + "), replace it by"); + log.warn(tagName + "=" + attrType); + } + type = attrType; + } else { - String modelType = model.getTagValue(type); - if (StringUtils.isNotEmpty(modelType)) { - - // tag value detected of the model - String deprecatedTagName = "model.tagValue." + type; - String tagName = "model.tagValue." + topiaTagValues.TAG_HIBERNATE_ATTRIBUTE_TYPE + - "." + type; - log.warn("---------"); - log.warn("You are using a deprecated tagValue ("+deprecatedTagName+"), replace it by"); - log.warn(tagName + "=" + modelType); - //TODO tchemit 20100507 Explain What todes it do ? Dont understand the story of columnNamesMap - int bracketIndex = modelType.indexOf('('); - if (bracketIndex != -1) { - type = modelType.substring(0, bracketIndex); - int bracketEndIndex = modelType.indexOf(')', bracketIndex + 1); - String colmunList; - if (bracketEndIndex != -1) { - colmunList = modelType.substring(bracketIndex + 1, bracketEndIndex); + String modelType = model.getTagValue(type); + if (StringUtils.isNotEmpty(modelType)) { + + // tag value detected of the model + String deprecatedTagName = "model.tagValue." + type; + String tagName = "model.tagValue." + topiaTagValues.TAG_HIBERNATE_ATTRIBUTE_TYPE + + "." + type; + log.warn("---------"); + log.warn("You are using a deprecated tagValue ("+deprecatedTagName+"), replace it by"); + log.warn(tagName + "=" + modelType); + //TODO tchemit 20100507 Explain What todes it do ? Dont understand the story of columnNamesMap + int bracketIndex = modelType.indexOf('('); + if (bracketIndex != -1) { + type = modelType.substring(0, bracketIndex); + int bracketEndIndex = modelType.indexOf(')', bracketIndex + 1); + String colmunList; + if (bracketEndIndex != -1) { + colmunList = modelType.substring(bracketIndex + 1, bracketEndIndex); + } else { + colmunList = modelType.substring(bracketIndex); + } + columnNamesMap.put(type, colmunList.split(",")); } else { - colmunList = modelType.substring(bracketIndex); + type = modelType; } - columnNamesMap.put(type, colmunList.split(",")); - } else { - type = modelType; } } } 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 9d2b452..f35c7e4 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 @@ -187,7 +187,7 @@ public class EntityTransformer extends ObjectModelTransformerToJava { createAcceptInternalOperation(input); // Add constant, attribute and operations for each property - generateProperties(input.getAttributes()); + generateProperties(input.getAttributes(), input, aPackage); // Case of association class : properties from participants/extremities // of the association class. @@ -195,7 +195,7 @@ public class EntityTransformer extends ObjectModelTransformerToJava { ObjectModelAssociationClass association = (ObjectModelAssociationClass)input; associationClass = true; - generateProperties(association.getParticipantsAttributes()); + generateProperties(association.getParticipantsAttributes(), input, aPackage); associationClass = false; } @@ -581,10 +581,11 @@ public class EntityTransformer extends ObjectModelTransformerToJava { /** * Generate properties from {@code attributes}. Generate * constant, attribute and operations for each property. - * - * @param attributes Input attributes + * @param attributes Input attributes + * @param aClass + * @param aPackage */ - protected void generateProperties(Collection<ObjectModelAttribute> attributes) { + protected void generateProperties(Collection<ObjectModelAttribute> attributes, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { for (ObjectModelAttribute attribute : attributes) { if (!associationClass) { @@ -593,9 +594,9 @@ public class EntityTransformer extends ObjectModelTransformerToJava { if (!attribute.isNavigable() && attribute.hasAssociationClass()) { generatePropertyConstant(attribute); - generatePropertyAttribute(attribute); + generatePropertyAttribute(attribute, aClass, aPackage); - updateAcceptOperation(attribute); + updateAcceptOperation(attribute, aClass, aPackage); } if (!attribute.isNavigable() && @@ -609,13 +610,13 @@ public class EntityTransformer extends ObjectModelTransformerToJava { generatePropertyConstant(attribute); // attribute - generatePropertyAttribute(attribute); + generatePropertyAttribute(attribute, aClass, aPackage); // operations - generatePropertyOperations(attribute); + generatePropertyOperations(attribute, aClass, aPackage); // update accept body - updateAcceptOperation(attribute); + updateAcceptOperation(attribute, aClass, aPackage); } } @@ -640,10 +641,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { "\"" + attrName + "\""); } - protected void generatePropertyAttribute(ObjectModelAttribute attribute) { + protected void generatePropertyAttribute(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); String collectionType = getCollectionType(attribute); if (collectionType != null) { @@ -689,31 +690,33 @@ public class EntityTransformer extends ObjectModelTransformerToJava { * method (association class, reverse, entity reference, ...). * * @param attribute Input attribute to treate + * @param aClass Input class + * @param aPackage Input package * @see #addSingleGetOperation(ObjectModelAttribute, String, String) - * @see #addSingleSetOperation(ObjectModelAttribute) - * @see #addMultipleAddOperation(ObjectModelAttribute, String) - * @see #addMultipleAddAllOperation(ObjectModelAttribute) - * @see #addMultipleSetOperation(ObjectModelAttribute, String, String) - * @see #addMultipleRemoveOperation(ObjectModelAttribute) - * @see #addMultipleClearOperation(ObjectModelAttribute, String, String) - * @see #addMultipleGetOperation(ObjectModelAttribute, String) - * @see #addMultipleGetByTopiaIdOperation(ObjectModelAttribute) - * @see #addMultipleGetOperationFromEntity(ObjectModelAttribute) + * @see #addSingleSetOperation(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage) + * @see #addMultipleAddOperation(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage, String) + * @see #addMultipleAddAllOperation(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage) + * @see #addMultipleSetOperation(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage, String, String) + * @see #addMultipleRemoveOperation(ObjectModelAttribute,ObjectModelClassifier, ObjectModelPackage) + * @see #addMultipleClearOperation(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage, String, String) + * @see #addMultipleGetOperation(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage, String) + * @see #addMultipleGetByTopiaIdOperation(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage) + * @see #addMultipleGetOperationFromEntity(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage) * @see #addMultipleSizeOperation(ObjectModelAttribute) * @see #addMultipleIsEmptyOperations(ObjectModelAttribute) - * @see #addMultipleGetByIndexOperation(ObjectModelAttribute) + * @see #addMultipleGetByIndexOperation(ObjectModelAttribute, ObjectModelClassifier, ObjectModelPackage) */ - protected void generatePropertyOperations(ObjectModelAttribute attribute) { + protected void generatePropertyOperations(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { if (attribute.getMaxMultiplicity() == 1 || associationClass) { // setXXX - addSingleSetOperation(attribute); + addSingleSetOperation(attribute, aClass, aPackage); boolean booleanProperty = GeneratorUtil.isBooleanPrimitive(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); if (booleanProperty) { @@ -755,49 +758,49 @@ public class EntityTransformer extends ObjectModelTransformerToJava { boolean entity = templateHelper.isEntity(attribute, model); // addXXX - addMultipleAddOperation(attribute, collectionImpl); + addMultipleAddOperation(attribute, aClass, aPackage, collectionImpl); if (ordered && !unique) { // addXXX(index) - addMultipleAddAtIndexOperation(attribute, collectionImpl); + addMultipleAddAtIndexOperation(attribute, aClass, aPackage, collectionImpl); } // addAllXXX - addMultipleAddAllOperation(attribute); + addMultipleAddAllOperation(attribute, aClass, aPackage); // setXXX - addMultipleSetOperation(attribute, collectionInterface, collectionImpl); + addMultipleSetOperation(attribute, aClass, aPackage, collectionInterface, collectionImpl); // removeXXX - addMultipleRemoveOperation(attribute); + addMultipleRemoveOperation(attribute, aClass, aPackage); if (ordered && !unique) { // removeXXX(index) - addMultipleRemoveAtIndexOperation(attribute); + addMultipleRemoveAtIndexOperation(attribute, aClass, aPackage); } // clearXXX - addMultipleClearOperation(attribute, collectionInterface, collectionImpl); + addMultipleClearOperation(attribute, aClass, aPackage, collectionInterface, collectionImpl); // getXXX - addMultipleGetOperation(attribute, collectionInterface); + addMultipleGetOperation(attribute, aClass, aPackage, collectionInterface); if (ordered) { // getXXX(index) - addMultipleGetByIndexOperation(attribute); + addMultipleGetByIndexOperation(attribute, aClass, aPackage); } if (entity) { // getXXXByTopiaId - addMultipleGetByTopiaIdOperation(attribute); + addMultipleGetByTopiaIdOperation(attribute, aClass, aPackage); // getXXXTopiaIds - addMultipleGetTopiaIdsOperation(attribute, collectionInterface, collectionImpl); + addMultipleGetTopiaIdsOperation(attribute, aClass, aPackage, collectionInterface, collectionImpl); } @@ -808,14 +811,14 @@ public class EntityTransformer extends ObjectModelTransformerToJava { addMultipleIsEmptyOperations(attribute); // containsXXX - addMultipleContainsOperation(attribute); + addMultipleContainsOperation(attribute, aClass, aPackage); } } - protected void addSingleSetOperation(ObjectModelAttribute attribute) { + protected void addSingleSetOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); if (log.isDebugEnabled()) { log.debug("Generate single 'set' operation for property : " + attrName + @@ -929,11 +932,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { setOperationBody(implOperation, body.toString()); } - protected void addMultipleAddOperation(ObjectModelAttribute attribute, - String collectionImpl) { + protected void addMultipleAddOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage, String collectionImpl) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); ObjectModelAttribute reverse = attribute.getReverseAttribute(); if (log.isDebugEnabled()) { @@ -1013,11 +1015,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { setOperationBody(implOperation, body.toString()); } - protected void addMultipleAddAtIndexOperation(ObjectModelAttribute attribute, - String collectionImpl) { + protected void addMultipleAddAtIndexOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage, String collectionImpl) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); ObjectModelAttribute reverse = attribute.getReverseAttribute(); if (log.isDebugEnabled()) { @@ -1098,10 +1099,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { setOperationBody(implOperation, body.toString()); } - protected void addMultipleAddAllOperation(ObjectModelAttribute attribute) { + protected void addMultipleAddAllOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); if (log.isDebugEnabled()) { log.debug("Generate multiple 'addAll' operation for property : " + attrName + @@ -1134,11 +1135,12 @@ public class EntityTransformer extends ObjectModelTransformerToJava { } protected void addMultipleSetOperation(ObjectModelAttribute attribute, + ObjectModelClassifier aClass, ObjectModelPackage aPackage, String collectionInterface, String collectionImpl) { String attrName = getPropertyName(attribute); - String referenceType = getPropertyType(attribute); + String referenceType = getPropertyType(attribute, aClass, aPackage); String attrType = collectionInterface + "<" + referenceType + ">"; String constantName = getConstantName(attrName); @@ -1187,10 +1189,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { } - protected void addMultipleRemoveOperation(ObjectModelAttribute attribute) { + protected void addMultipleRemoveOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); ObjectModelAttribute reverse = attribute.getReverseAttribute(); String constantName = getConstantName(attrName); @@ -1257,10 +1259,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { setOperationBody(implOperation, body.toString()); } - protected void addMultipleRemoveAtIndexOperation(ObjectModelAttribute attribute) { + protected void addMultipleRemoveAtIndexOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); ObjectModelAttribute reverse = attribute.getReverseAttribute(); String constantName = getConstantName(attrName); @@ -1331,11 +1333,12 @@ public class EntityTransformer extends ObjectModelTransformerToJava { } protected void addMultipleClearOperation(ObjectModelAttribute attribute, + ObjectModelClassifier aClass, ObjectModelPackage aPackage, String collectionInterface, String collectionImpl) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); ObjectModelAttribute reverse = attribute.getReverseAttribute(); String constantName = getConstantName(attrName); @@ -1416,10 +1419,11 @@ public class EntityTransformer extends ObjectModelTransformerToJava { } protected void addMultipleGetOperation(ObjectModelAttribute attribute, + ObjectModelClassifier aClass, ObjectModelPackage aPackage, String collectionInterface) { String attrName = getPropertyName(attribute); - String attrType = collectionInterface + "<" + getPropertyType(attribute) + ">"; + String attrType = collectionInterface + "<" + getPropertyType(attribute, aClass, aPackage) + ">"; if (log.isDebugEnabled()) { log.debug("Generate multiple 'get' operation for property : " + attrName + @@ -1441,10 +1445,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { ); } - protected void addMultipleGetByIndexOperation(ObjectModelAttribute attribute) { + protected void addMultipleGetByIndexOperation(ObjectModelAttribute attribute,ObjectModelClassifier aClass, ObjectModelPackage aPackage) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); if (log.isDebugEnabled()) { log.debug("Generate multiple 'getByTopiaId' operation for property : " + attrName + @@ -1470,10 +1474,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { }*/ ); } - protected void addMultipleGetByTopiaIdOperation(ObjectModelAttribute attribute) { + protected void addMultipleGetByTopiaIdOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); if (log.isDebugEnabled()) { log.debug("Generate multiple 'getByTopiaId' operation for property : " + attrName + @@ -1500,10 +1504,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { ); } - protected void addMultipleGetTopiaIdsOperation(ObjectModelAttribute attribute, String collectionInterface, String collectionImpl) { + protected void addMultipleGetTopiaIdsOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage, String collectionInterface, String collectionImpl) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); String getterName = getJavaBeanMethodName("get" , attrName); @@ -1536,7 +1540,7 @@ public class EntityTransformer extends ObjectModelTransformerToJava { ); } - protected void addMultipleGetOperationFromEntity(ObjectModelAttribute attribute) { + protected void addMultipleGetOperationFromEntity(ObjectModelAttribute attribute,ObjectModelClassifier aClass, ObjectModelPackage aPackage) { // reference to the real attribute name String referenceName = attribute.getName(); @@ -1545,7 +1549,7 @@ public class EntityTransformer extends ObjectModelTransformerToJava { String referenceGetterName = getJavaBeanMethodName("get", referenceName); // association attribute name String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); if (log.isDebugEnabled()) { log.debug("Generate multiple 'getFromEntity' operation for property : " + attrName + @@ -1648,10 +1652,10 @@ public class EntityTransformer extends ObjectModelTransformerToJava { ); } - protected void addMultipleContainsOperation(ObjectModelAttribute attribute) { + protected void addMultipleContainsOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); + String attrType = getPropertyType(attribute, aClass, aPackage); if (log.isDebugEnabled()) { log.debug("Generate multiple 'contains' operation for property : " + attrName); @@ -1728,11 +1732,11 @@ public class EntityTransformer extends ObjectModelTransformerToJava { } } - protected void updateAcceptOperation(ObjectModelAttribute attribute) { + protected void updateAcceptOperation(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { String attrName = GeneratorUtil.getSimpleName(getPropertyName(attribute)); String attrType = - GeneratorUtil.getSimpleName(getPropertyType(attribute)); + GeneratorUtil.getSimpleName(getPropertyType(attribute, aClass, aPackage)); // remove custom generics http://nuiton.org/issues/3453 attrType = GeneratorUtil.removeAnyGenericDefinition(attrType); String collectionType = getCollectionType(attribute); @@ -1864,8 +1868,8 @@ public class EntityTransformer extends ObjectModelTransformerToJava { return propertyName; } - protected String getPropertyType(ObjectModelAttribute attribute) { - String propertyType = attribute.getType(); + protected String getPropertyType(ObjectModelAttribute attribute, ObjectModelClassifier aClass, ObjectModelPackage aPackage) { + String propertyType = topiaTagValues.getAttributeType(attribute, aClass, aPackage ,model); if (!associationClass && attribute.hasAssociationClass()) { propertyType = attribute.getAssociationClass().getQualifiedName(); } 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 index 3e94b2c..ab11f36 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java @@ -434,6 +434,30 @@ public class TopiaTagValues extends TagValueDefinitionProvider { public static final String TAG_HIBERNATE_ATTRIBUTE_TYPE = "hibernateAttributeType"; /** + * Tag to change the type of an attribute. + * <p/> + * This is a special tagValue that is dynamic. + * <p/> + * 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> + * <p/> + * Before 3.0, you could do the same thing using: + * <pre> + * model.tagValue.String=java.lang.String + * </pre> + * <p/> + * 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(ObjectModelAttribute, ObjectModel) @@ -743,6 +767,21 @@ public class TopiaTagValues extends TagValueDefinitionProvider { } /** + * Obtain the value of the {@link #TAG_ATTRIBUTE_TYPE} tag value on the given attribute, classifier or model. + * + * @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_ATTRIBUTE_TYPE + * @since 3.0.1 + */ + public String getAttributeType(ObjectModelAttribute attribute, ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { + + String tagValueName = TAG_ATTRIBUTE_TYPE + "." + attribute.getType(); + String value = TagValues.findTagValue(tagValueName, attribute.getType(), 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 @@ -879,7 +918,7 @@ public class TopiaTagValues extends TagValueDefinitionProvider { * @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)} + * @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) { -- 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 feature/3712 in repository topia. See http://git.nuiton.org/topia.git commit 61bbae7a790ba52a785943c42ba8ed1f9d4aeab9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Aug 22 21:24:14 2015 +0200 Remove attribute scope to generatePropertyChangeSupport tag value. See #3712 --- .../nuiton/topia/templates/EntityTransformer.java | 22 ++++------------------ .../org/nuiton/topia/templates/TopiaTagValues.java | 5 +++-- 2 files changed, 7 insertions(+), 20 deletions(-) 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 f35c7e4..8e01207 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 @@ -105,6 +105,8 @@ public class EntityTransformer extends ObjectModelTransformerToJava { protected boolean generateBooleanGetMethods; + protected boolean generatePropertyChangeSupport; + protected TopiaTemplateHelper templateHelper; protected TopiaTagValues topiaTagValues; @@ -158,6 +160,7 @@ public class EntityTransformer extends ObjectModelTransformerToJava { } generateBooleanGetMethods = getEugeneTagValues().isGenerateBooleanGetMethods(input, aPackage, model); + generatePropertyChangeSupport = topiaTagValues.isGeneratePropertyChangeSupport(input, model); if (generateInterface) { @@ -291,7 +294,7 @@ public class EntityTransformer extends ObjectModelTransformerToJava { TopiaEntityContextable.class); } - if (topiaTagValues.isGeneratePropertyChangeSupport(input, model)) { + if (generatePropertyChangeSupport) { addInterface(interfaceAlreadyDone, outputInterface, ListenableTopiaEntity.class); @@ -839,8 +842,6 @@ public class EntityTransformer extends ObjectModelTransformerToJava { StringBuilder body = new StringBuilder(); - boolean generatePropertyChangeSupport = topiaTagValues.isGeneratePropertyChangeSupport(attribute, model); - if (generatePropertyChangeSupport) { body.append("" /*{ @@ -902,8 +903,6 @@ public class EntityTransformer extends ObjectModelTransformerToJava { StringBuilder body = new StringBuilder(); - boolean generatePropertyChangeSupport = topiaTagValues.isGeneratePropertyChangeSupport(attribute, model); - if (generatePropertyChangeSupport) { body.append("" /*{ @@ -959,8 +958,6 @@ public class EntityTransformer extends ObjectModelTransformerToJava { StringBuilder body = new StringBuilder(); - boolean generatePropertyChangeSupport = topiaTagValues.isGeneratePropertyChangeSupport(attribute, model); - if (generatePropertyChangeSupport) { body.append("" /*{ @@ -1043,8 +1040,6 @@ public class EntityTransformer extends ObjectModelTransformerToJava { StringBuilder body = new StringBuilder(); - boolean generatePropertyChangeSupport = topiaTagValues.isGeneratePropertyChangeSupport(attribute, model); - if (generatePropertyChangeSupport) { body.append("" /*{ @@ -1161,8 +1156,6 @@ public class EntityTransformer extends ObjectModelTransformerToJava { StringBuilder body = new StringBuilder(); - boolean generatePropertyChangeSupport = topiaTagValues.isGeneratePropertyChangeSupport(attribute, model); - if (generatePropertyChangeSupport) { body.append("" /*{ @@ -1215,8 +1208,6 @@ public class EntityTransformer extends ObjectModelTransformerToJava { StringBuilder body = new StringBuilder(); - boolean generatePropertyChangeSupport = topiaTagValues.isGeneratePropertyChangeSupport(attribute, model); - if (generatePropertyChangeSupport) { body.append("" /*{ @@ -1284,8 +1275,6 @@ public class EntityTransformer extends ObjectModelTransformerToJava { StringBuilder body = new StringBuilder(); - boolean generatePropertyChangeSupport = topiaTagValues.isGeneratePropertyChangeSupport(attribute, model); - if (generatePropertyChangeSupport) { body.append("" /*{ @@ -1391,9 +1380,6 @@ public class EntityTransformer extends ObjectModelTransformerToJava { ); } - - boolean generatePropertyChangeSupport = topiaTagValues.isGeneratePropertyChangeSupport(attribute, model); - if (generatePropertyChangeSupport) { body.append("" /*{ <%=collectionInterface%><<%=attrType%>> oldValue = new <%=collectionImpl%><<%=attrType%>>(this.<%=attrName%>); 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 index ab11f36..b36766f 100644 --- a/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java +++ b/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java @@ -461,9 +461,10 @@ public class TopiaTagValues extends TagValueDefinitionProvider { * Tag to specify if PropertyChangeListener support should be generated * * @see #isGeneratePropertyChangeSupport(ObjectModelAttribute, ObjectModel) + * @see #isGeneratePropertyChangeSupport(ObjectModelClass, ObjectModel) * @since 3.0 */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelAttribute.class}, + @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"; @@ -897,7 +898,7 @@ public class TopiaTagValues extends TagValueDefinitionProvider { ObjectModelElement clazz = attribute.getDeclaringElement(); Preconditions.checkState(clazz instanceof ObjectModelClass); ObjectModelPackage modelPackage = model.getPackage((ObjectModelClass) clazz); - boolean value = findBooleanTagValue(TAG_GENERATE_PROPERTY_CHANGE_SUPPORT, attribute, clazz, modelPackage, model); + boolean value = findBooleanTagValue(TAG_GENERATE_PROPERTY_CHANGE_SUPPORT, clazz, modelPackage, model); return value; } -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm