branch develop updated (2284657 -> 644750d)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository topia. See http://git.nuiton.org/topia.git from 2284657 Do not create tms_version table if flag initSchema is off in configuration (Closes #3767) new b03399e Add attributeType tag value (See #3765) new 644750d Introduce attributeType tag value Closes #3765 Merge branch 'feature/3765' into develop 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 644750d186444449a1fea41128ef0143ec07fd92 Merge: 2284657 b03399e Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Aug 23 18:51:55 2015 +0200 Introduce attributeType tag value Closes #3765 Merge branch 'feature/3765' into develop commit b03399e1c5be82d4cdc3769b5f501e188dc70aa9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Aug 22 20:59:29 2015 +0200 Add attributeType tag value (See #3765) Summary of changes: .../templates/EntityHibernateMappingGenerator.java | 81 ++++++------ .../nuiton/topia/templates/EntityTransformer.java | 140 +++++++++++---------- .../org/nuiton/topia/templates/TopiaTagValues.java | 41 +++++- 3 files changed, 156 insertions(+), 106 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository topia. See http://git.nuiton.org/topia.git commit b03399e1c5be82d4cdc3769b5f501e188dc70aa9 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 9861cf4..9a37a83 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 @@ -405,49 +405,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 09307fa..eda2348 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 develop in repository topia. See http://git.nuiton.org/topia.git commit 644750d186444449a1fea41128ef0143ec07fd92 Merge: 2284657 b03399e Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Aug 23 18:51:55 2015 +0200 Introduce attributeType tag value Closes #3765 Merge branch 'feature/3765' into develop .../templates/EntityHibernateMappingGenerator.java | 81 ++++++------ .../nuiton/topia/templates/EntityTransformer.java | 140 +++++++++++---------- .../org/nuiton/topia/templates/TopiaTagValues.java | 41 +++++- 3 files changed, 156 insertions(+), 106 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm