r3086 - in trunk/topia-templates/src: main/java/org/nuiton/topia/templates main/resources/META-INF/services test/java/org/nuiton/topia/templates
Author: tchemit Date: 2014-04-27 15:36:11 +0200 (Sun, 27 Apr 2014) New Revision: 3086 Url: http://forge.nuiton.org/projects/topia/repository/revisions/3086 Log: fixes #3177: Use eugene 2.9 new Stereotype and TagValue API Added: trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaStereoTypesTest.java trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaTagValuesTest.java Removed: trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.metas.ModelPropertiesProvider trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaModelPropertiesProviderTest.java Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/ApplicationContextTransformer.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/DAOHelperTransformer.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/DTOTransformer.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDTOTransformer.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDaoTransformer.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityEnumTransformer.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/PersistenceContextTransformer.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaGeneratorUtil.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaModelPropertiesProvider.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/ApplicationContextTransformer.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/ApplicationContextTransformer.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/ApplicationContextTransformer.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -80,7 +80,7 @@ String className) { // try to find a super class by tag-value - String superClass = TopiaGeneratorUtil.getApplicationContextSuperClassTagValue(model); + String superClass = TopiaTagValues.getApplicationContextSuperClassTagValue(model); if (superClass == null) { @@ -111,7 +111,7 @@ String entityEnumName = modelName + "EntityEnum"; boolean generateOperator = - TopiaGeneratorUtil.shouldGenerateOperatorForDAOHelper(model); + TopiaTagValues.getGenerateOperatorForDAOHelperTagValue(model); addImport(output, TopiaEntity.class); Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/DAOHelperTransformer.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/DAOHelperTransformer.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/DAOHelperTransformer.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -77,7 +77,7 @@ TopiaGeneratorUtil.getEntityClasses(model, true); boolean generateOperator = - TopiaGeneratorUtil.shouldGenerateOperatorForDAOHelper(model); + TopiaTagValues.getGenerateOperatorForDAOHelperTagValue(model); // boolean generateStandaloneEnum = // TopiaGeneratorUtil.shouldGenerateStandaloneEnumForDAOHelper(model); Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/DTOTransformer.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/DTOTransformer.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/DTOTransformer.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -31,7 +31,7 @@ import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.java.ObjectModelTransformerToJava; -import org.nuiton.eugene.metas.TagValues; +import org.nuiton.eugene.models.tagvalue.TagValues; import org.nuiton.eugene.models.object.*; import java.beans.PropertyChangeListener; @@ -61,7 +61,7 @@ @Override public void transformFromClass(ObjectModelClass clazz) { - if (!TopiaGeneratorUtil.hasDtoStereotype(clazz)) { + if (!TopiaStereoTypes.hasDtoStereotype(clazz)) { return; } String clazzName = clazz.getName(); @@ -83,7 +83,7 @@ addInterface(result, Serializable.class); for (ObjectModelInterface parentInterface : clazz.getInterfaces()) { - if (TopiaGeneratorUtil.hasDtoStereotype(parentInterface)) { + if (TopiaStereoTypes.hasDtoStereotype(parentInterface)) { addInterface(result, parentInterface.getName() + "DTO"); } else { addInterface(result, parentInterface.getName()); @@ -175,7 +175,7 @@ if (TopiaGeneratorUtil.hasDocumentation(attr)) { setDocumentation(attr2, attr.getDocumentation()); } - String annotation = TopiaGeneratorUtil.getAnnotationTagValue(attr); + String annotation = TopiaTagValues.getAnnotationTagValue(attr); if (StringUtils.isNotEmpty(annotation)) { addAnnotation(result, attr2, annotation); } @@ -455,7 +455,7 @@ public boolean isDTO(String type) { ObjectModelClassifier clazz = model.getClassifier(type); - return clazz != null && TopiaGeneratorUtil.hasDtoStereotype(clazz); + return clazz != null && TopiaStereoTypes.hasDtoStereotype(clazz); } Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDTOTransformer.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDTOTransformer.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDTOTransformer.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -28,7 +28,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.java.ObjectModelTransformerToJava; -import org.nuiton.eugene.metas.TagValues; +import org.nuiton.eugene.models.tagvalue.TagValues; import org.nuiton.eugene.models.object.ObjectModelAssociationClass; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; @@ -42,7 +42,6 @@ import java.io.Serializable; import static org.nuiton.topia.templates.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType; -import static org.nuiton.topia.templates.TopiaGeneratorUtil.shouldGenerateDTOTopiaIdTagValue; /*{generator option: parentheses = false}*/ @@ -104,7 +103,7 @@ addAttribute(result, "serialVersionUID", "long", svUID, ObjectModelJavaModifier.FINAL, ObjectModelJavaModifier.PUBLIC, ObjectModelJavaModifier.STATIC); } - boolean generateDTOId = shouldGenerateDTOTopiaIdTagValue(clazz, model); + boolean generateDTOId = TopiaTagValues.shouldGenerateDTOTopiaIdTagValue(clazz, model); if (generateDTOId) { addAttribute(result, "topiaId", "String"); } @@ -149,7 +148,7 @@ setDocumentation(attr2, attr.getDocumentation()); } - String annotation = TopiaGeneratorUtil.getAnnotationTagValue(attr); + String annotation = TopiaTagValues.getAnnotationTagValue(attr); if (!StringUtils.isEmpty(annotation)) { addAnnotation(result, attr2, annotation); } @@ -178,7 +177,7 @@ protected void addOperations(ObjectModelClass result,ObjectModelClass clazz) { - boolean generateDTOId = shouldGenerateDTOTopiaIdTagValue(clazz, model); + boolean generateDTOId = TopiaTagValues.shouldGenerateDTOTopiaIdTagValue(clazz, model); ObjectModelOperation op; if (generateDTOId) { op = addOperation(result, "setTopiaId", "void", ObjectModelJavaModifier.PUBLIC); Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDaoTransformer.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDaoTransformer.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityDaoTransformer.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -126,7 +126,7 @@ Collection<ObjectModelOperation> daoOperations = new HashSet<ObjectModelOperation>(); for (ObjectModelOperation op : entity.getOperations()) { - if (TopiaGeneratorUtil.hasDaoStereotype(op)) { + if (TopiaStereoTypes.hasDaoStereotype(op)) { daoOperations.add(op); } } @@ -141,7 +141,7 @@ @Override public void transformFromInterface(ObjectModelInterface interfacez) { - if (!TopiaGeneratorUtil.hasDaoStereotype(interfacez)) { + if (!TopiaStereoTypes.hasDaoStereotype(interfacez)) { return; } @@ -385,7 +385,7 @@ } } if (superClassName == null) { - superClassName = TopiaGeneratorUtil.getDaoSuperClassTagValue(clazz, model); + superClassName = TopiaTagValues.getDaoSuperClassTagValue(clazz, model); if (superClassName == null) { superClassName = TopiaGeneratorUtil.getParentDaoFqn(this, model); addImport(daoAbstractClass, superClassName); Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityEnumTransformer.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityEnumTransformer.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityEnumTransformer.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -69,7 +69,7 @@ String entityEnumName = TopiaGeneratorUtil.getEntityEnumName(model); boolean generateOperator = - TopiaGeneratorUtil.shouldGenerateOperatorForDAOHelper(model); + TopiaTagValues.getGenerateOperatorForDAOHelperTagValue(model); generateEntityEnum(packageName, entityEnumName, generateOperator); Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityHibernateMappingGenerator.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.eugene.EugeneStereoTypes; import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.models.object.ObjectModelAssociationClass; import org.nuiton.eugene.models.object.ObjectModelAttribute; @@ -119,13 +120,13 @@ String clazzFQN = input.getQualifiedName(); String optionalAttributes = ""; - String schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(input, model); + String schema = TopiaTagValues.getDbSchemaNameTagValue(input, model); if (schema != null) { optionalAttributes += "schema=\"" + schema + "\" "; } //On précise au proxy de quelle interface hérite l'objet - String proxyTagValue = TopiaGeneratorUtil.getProxyInterfaceTagValue(input, model); + String proxyTagValue = TopiaTagValues.getProxyInterfaceTagValue(input, model); if (StringUtils.isEmpty(proxyTagValue) || !proxyTagValue.equals("none")) { optionalAttributes += "proxy=\"" + clazzFQN + "\" "; } @@ -138,7 +139,7 @@ log.debug("superClass for " + input.getQualifiedName() + " is " + superClassname); } String superClassDOType = TopiaGeneratorUtil.getDOType(superClassname, model); - inheritanceStrategy = TopiaGeneratorUtil.getInheritanceStrategyTagValue(superClass); + inheritanceStrategy = TopiaGeneratorUtil.getInheritanceStrategy(superClass); if ("joined-subclass".equals(inheritanceStrategy) || "union-subclass".equals(inheritanceStrategy)) { optionalAttributes += "table=\"" + tableName + "\""; } @@ -159,7 +160,7 @@ }*/ // cas où on defini la super class, il faut un discriminator seulement dans le cas de // la strategy subclass - String currentInheritanceStrategy = TopiaGeneratorUtil.getInheritanceStrategyTagValue(input); + String currentInheritanceStrategy = TopiaGeneratorUtil.getInheritanceStrategy(input); if ("subclass".equals(currentInheritanceStrategy)) { /*{ <discriminator column="topiaDiscriminator" type="string" /> }*/ @@ -167,7 +168,7 @@ // on detecte les attributs des clef metiers for (ObjectModelAttribute attr : input.getAttributes()) { - if (TopiaGeneratorUtil.isNaturalId(attr)) { + if (TopiaTagValues.getNaturalIdTagValue(attr)) { // attribut metier naturalAttributes.add(attr); } else { @@ -177,7 +178,7 @@ } if (!naturalAttributes.isEmpty()) { // generation de la clef metier - boolean mutable = TopiaGeneratorUtil.isNaturalIdMutable(input); + boolean mutable = TopiaTagValues.getNaturalIdMutableTagValue(input); String mutableStr = mutable ? " mutable=\"true\"" : ""; if (log.isDebugEnabled()) { log.debug("natural-id detected for class " + input.getName() + " (" + mutableStr + ") attributes : " + naturalAttributes); @@ -226,8 +227,8 @@ continue; } - String indexForeignKeys = - TopiaGeneratorUtil.getIndexForeignKeys(attribute, model); + String indexForeignKeys = + TopiaTagValues.getIndexForeignKeysTagValue(attribute, model); if (StringUtils.isEmpty(indexForeignKeys) || !Boolean.valueOf(indexForeignKeys)) { @@ -255,7 +256,7 @@ } // add schema if exist (http://nuiton.org/issues/2052) - String schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(clazz, model); + String schema = TopiaTagValues.getDbSchemaNameTagValue(clazz, model); if (StringUtils.isNotEmpty(schema)) { tableName = schema + "." + tableName; } @@ -320,7 +321,7 @@ String notNull = " " + generateFromTagValue(HIBERNATE_ATTRIBUTE_NOT_NULL, "true"); // AThimel 14/03/2014 I think both assoc class participants must always be not-null String attrName = getName(attr, true); String attrType = getType(clazz, attr, true); - String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaGeneratorUtil.getLazyTagValue(attr)); + String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaTagValues.getLazyTagValue(attr)); String attrColumn = TopiaGeneratorUtil.getDbName(attr); /*{<%=prefix%> <many-to-one name="<%=attrName%>" class="<%=attrType%>" <%=lazy%>column="<%=attrColumn%>" node="<%=attrName%>/@topiaId" <%=notNull%>/> }*/ @@ -366,14 +367,14 @@ } String type = attr.getType(); - String attrType = TopiaGeneratorUtil.getHibernateAttributeType(attr, clazz, model); + String attrType = TopiaTagValues.getHibernateAttributeType(attr, clazz, model); if (StringUtils.isNotEmpty(attrType)) { // tag value detected of the attribute type = attrType; } else { // old code - attrType = TopiaGeneratorUtil.getTypeTagValue(attr); + attrType = TopiaTagValues.getTypeTagValue(attr); if (StringUtils.isNotEmpty(attrType)) { // tag value detected of the attribute @@ -433,7 +434,7 @@ String attrType = getType(clazz, attr); String accessField = "field"; - String tagValue = TopiaGeneratorUtil.getAccessTagValue(attr); + String tagValue = TopiaTagValues.getAccessTagValue(attr); if (StringUtils.isNotEmpty(tagValue)) { accessField = tagValue; } @@ -448,7 +449,7 @@ attrType = attrType.trim().substring(0, attrType.trim().length()-2); String optionalAttributes = ""; - String schema = TopiaGeneratorUtil.getDbSchemaNameTagValue(attr, model); + String schema = TopiaTagValues.getDbSchemaNameTagValue(attr, model); if (schema != null) { optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_SCHEMA, schema); // optionalAttributes += "schema=\"" + schema + "\" "; @@ -474,12 +475,12 @@ // optionalAttributes += "index=\"" + indexName + "\""; } - if (TopiaGeneratorUtil.hasUniqueStereotype(attr)) { + if (EugeneStereoTypes.hasUniqueStereotype(attr)) { // the trim method is called on optionalAttributes after this set to suppress unusual space if no index is set on this attribute optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_UNIQUE, "true"); // optionalAttributes += " unique=\"true\""; } - optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_NOT_NULL, TopiaGeneratorUtil.getNotNullTagValue(attr)); + optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_NOT_NULL, TopiaTagValues.getNotNullTagValue(attr)); /*{<%=prefix%> <property name="<%=attrName%>" access="<%=accessField%>"}*/ if ( ! attrIsEnumeration) { /*{ type="<%=attrType%>"}*/ @@ -495,7 +496,7 @@ String defaultValue = attr.getDefaultValue().trim(); columnAttributes.put(HIBERNATE_ATTRIBUTE_DEFAULT, defaultValue); } - String sqlType = TopiaGeneratorUtil.getSqlTypeTagValue(attr); + String sqlType = TopiaTagValues.getSqlTypeTagValue(attr); if (!StringUtils.isEmpty(sqlType)) { // an specific sql type was specified for the attribute, use it @@ -503,7 +504,7 @@ } // add length attribute if required - String lengthTagValue = TopiaGeneratorUtil.getLengthTagValue(attr); + String lengthTagValue = TopiaTagValues.getLengthTagValue(attr); if (!StringUtils.isEmpty(lengthTagValue)) { optionalAttributes += generateFromTagValue(HIBERNATE_ATTRIBUTE_LENGTH, lengthTagValue); @@ -533,7 +534,7 @@ // if the user tuned the model to use name instead of // ordinal to store the values, we must add a clause - boolean useEnumerationName = TopiaGeneratorUtil.hasUseEnumerationNameTagValue(clazz, attr, model); + boolean useEnumerationName = TopiaTagValues.hasUseEnumerationNameTagValue(attr, clazz, model); if (useEnumerationName) { String enumSQLType = String.valueOf(Types.VARCHAR); /*{ @@ -612,16 +613,16 @@ String attrName = getName(attr); // ??? String attrType = getType(clazz, attr); String reverseAttrDBName = TopiaGeneratorUtil.getReverseDbName(attr); - String orderBy = generateFromTagValue(HIBERNATE_ATTRIBUTE_ORDER_BY, TopiaGeneratorUtil.getOrderByTagValue(attr)); + String orderBy = generateFromTagValue(HIBERNATE_ATTRIBUTE_ORDER_BY, TopiaTagValues.getOrderByTagValue(attr)); String cascade = ""; if (attr.isComposite() || attr.hasAssociationClass()) { cascade += "cascade=\"all,delete-orphan\" "; } - String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaGeneratorUtil.getLazyTagValue(attr), "true"); + String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaTagValues.getLazyTagValue(attr), "true"); - String fetch = generateFromTagValue(HIBERNATE_ATTRIBUTE_FETCH, TopiaGeneratorUtil.getFetchTagValue(attr)); + String fetch = generateFromTagValue(HIBERNATE_ATTRIBUTE_FETCH, TopiaTagValues.getFetchTagValue(attr)); String collType = TopiaGeneratorUtil.getNMultiplicityHibernateType(attr); String inverse = ""; @@ -648,6 +649,10 @@ return generateFromTagValue(attributeName, tagValue, null); } + private String generateFromTagValue(String attributeName, Boolean tagValue) { + return generateFromTagValue(attributeName, tagValue == null ? null : String.valueOf(tagValue), null); + } + /** * Generate hibernate xml attribute with a final space. */ @@ -658,15 +663,6 @@ } else if (defaultValue != null) { result+= attributeName + "=\"" + defaultValue +"\" "; } -// if (attr.hasTagValue(tagName) || defaultValue != null) { -// result+= attributeName + "=\""; -// if (attr.hasTagValue(tagName)) { -// result += attr.getTagValue(tagName); -// } else { -// result += defaultValue; -// } -// result += "\" "; -// } return result; } @@ -678,7 +674,7 @@ String attrName = getName(attr); String attrType = getType(clazz, attr); String collType = TopiaGeneratorUtil.getNMultiplicityHibernateType(attr); - String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaGeneratorUtil.getLazyTagValue(attr)); + String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaTagValues.getLazyTagValue(attr)); String attrColumn = TopiaGeneratorUtil.getDbName(attr); boolean attrIsEnumeration = attr.getClassifier() != null && attr.getClassifier().isEnum(); @@ -692,7 +688,7 @@ } if (attrIsEnumeration) { - boolean useEnumerationName = TopiaGeneratorUtil.hasUseEnumerationNameTagValue(clazz, attr, model); + boolean useEnumerationName = TopiaTagValues.hasUseEnumerationNameTagValue(attr, clazz, model); /*{<%=prefix%> <element column="<%=attrColumn%>" node="id"> <%=prefix%> <type name="org.hibernate.type.EnumType"> <%=prefix%> <param name="<%=org.hibernate.type.EnumType.ENUM%>"><%=attrType%></param> @@ -742,9 +738,9 @@ /*{access="field" }*/ } // vérifier si le tag lazy est defini par defaut dans le fichier de proprietes - String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaGeneratorUtil.getLazyTagValue(attr)); + String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaTagValues.getLazyTagValue(attr)); /*{<%=lazy%>}*/ - String notNull = generateFromTagValue(HIBERNATE_ATTRIBUTE_NOT_NULL, TopiaGeneratorUtil.getNotNullTagValue(attr)); + String notNull = generateFromTagValue(HIBERNATE_ATTRIBUTE_NOT_NULL, TopiaTagValues.getNotNullTagValue(attr)); /*{<%=notNull%>}*/ if (isUnique) { /*{unique="true" }*/ @@ -770,7 +766,7 @@ // Le tagvalue "inverse" permet de spécifier qui possède le // inverse="true". Il est impératif de l'utiliser sur les deux // extrémités pour ne pas avoir de surprise. - String inverseValue = TopiaGeneratorUtil.getInverseTagValue(attr); + String inverseValue = TopiaTagValues.getInverseTagValue(attr); if (StringUtils.isNotEmpty(inverseValue)) { isInverse &= Boolean.parseBoolean(inverseValue); // Si aucun tagvalue n'est défini, le choix est arbitraire : le @@ -789,8 +785,8 @@ String attrType = getType(clazz, attr); String attrName = getName(attr); String attrColumn = TopiaGeneratorUtil.getDbName(attr); - String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaGeneratorUtil.getLazyTagValue(attr), "true"); - String orderBy = generateFromTagValue(HIBERNATE_ATTRIBUTE_ORDER_BY, TopiaGeneratorUtil.getOrderByTagValue(attr)); + String lazy = generateFromTagValue(HIBERNATE_ATTRIBUTE_LAZY, TopiaTagValues.getLazyTagValue(attr), "true"); + String orderBy = generateFromTagValue(HIBERNATE_ATTRIBUTE_ORDER_BY, TopiaTagValues.getOrderByTagValue(attr)); String collType = TopiaGeneratorUtil.getNMultiplicityHibernateType(attr); String tableName = TopiaGeneratorUtil.getManyToManyTableName(attr); String inverse = ""; Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/EntityTransformer.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -31,7 +31,7 @@ import org.nuiton.eugene.EugeneTagValues; import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.java.ObjectModelTransformerToJava; -import org.nuiton.eugene.metas.TagValues; +import org.nuiton.eugene.models.tagvalue.TagValues; import org.nuiton.eugene.models.object.ObjectModelAssociationClass; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; @@ -140,7 +140,7 @@ generateAbstract = isGenerateAbstract(input); generateImpl = isGenerateImpl(input); - generateBooleanGetMethods = TopiaGeneratorUtil.isDoNotGenerateBooleanGetMethods(model, input); + generateBooleanGetMethods = EugeneTagValues.isDoNotGenerateBooleanGetMethods(input, model); if (generateInterface) { @@ -160,7 +160,7 @@ } // Generate i18n block - String i18nPrefix = TopiaGeneratorUtil.getI18nPrefixTagValue(input, model); + String i18nPrefix = EugeneTagValues.getI18nPrefixTagValue(input, model); if (!StringUtils.isEmpty(i18nPrefix)) { generateI18nBlock(input, outputAbstract, i18nPrefix); } @@ -190,7 +190,7 @@ generateExtraOperations(input); // Implement toString operation - if (TopiaGeneratorUtil.generateToString(input, model)) { + if (!TopiaTagValues.getNotGenerateToStringTagValue(input, model)) { generateToStringOperation(input); } @@ -258,7 +258,7 @@ Class<?> interfaze = TopiaEntity.class; - if (TopiaGeneratorUtil.isContextable(input)) { + if (TopiaTagValues.getContextableTagValue(input, model)) { interfaze = TopiaEntityContextable.class; } @@ -266,7 +266,7 @@ outputInterface, interfaze); - } else if (TopiaGeneratorUtil.isContextable(input)) { + } else if (TopiaTagValues.getContextableTagValue(input, model)) { // Even if there is no need to implement TopiaEntity, it might be // necessary to implement TopiaEntityContextable addInterface(interfaceAlreadyDone, @@ -319,14 +319,14 @@ // Extends AbstractTopiaEntity (only if hasn't parent entity) if (outputAbstract.getSuperclasses().isEmpty()) { - String superClassName = TopiaGeneratorUtil.getEntitySuperClassTagValue(input, model); + String superClassName = TopiaTagValues.getEntitySuperClassTagValue(input, model); if (superClassName == null) { superClassName = AbstractTopiaEntity.class.getName(); } setSuperClass(outputAbstract, superClassName); } - if (TopiaGeneratorUtil.isContextable(input)) { + if (TopiaTagValues.getContextableTagValue(input, model)) { addContextableMethods(input, outputAbstract); } } @@ -529,7 +529,7 @@ // Deprecated from 2.3.4 // Pas de génération des signatures de méthodes pour celles à intégrer au DAO de l'entité - if (TopiaGeneratorUtil.hasDaoStereotype(operation)) { + if (TopiaStereoTypes.hasDaoStereotype(operation)) { return; // Generate entity methods which have not a public visibility. @@ -641,7 +641,7 @@ setDocumentation(property, buffer.toString()); // Annotation - String annotation = TopiaGeneratorUtil.getAnnotationTagValue(attribute); + String annotation = TopiaTagValues.getAnnotationTagValue(attribute); if (!StringUtils.isEmpty(annotation)) { //FIXME Make annotation works... //TODO tchemit 20100513 Test it still works Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/PersistenceContextTransformer.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/PersistenceContextTransformer.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/PersistenceContextTransformer.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -134,7 +134,7 @@ ObjectModelClass output = createAbstractClass(className, packageName); // try to find a super class by tag-value - String superClass = TopiaGeneratorUtil.getPersistenceContextSuperClassTagValue(model); + String superClass = TopiaTagValues.getPersistenceContextSuperClassTagValue(model); if (superClass == null) { Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaGeneratorUtil.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaGeneratorUtil.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaGeneratorUtil.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -30,10 +30,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.eugene.AbstractGenerator; +import org.nuiton.eugene.EugeneStereoTypes; import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.java.ObjectModelTransformerToJava; -import org.nuiton.eugene.metas.TagValues; import org.nuiton.eugene.models.object.ObjectModel; import org.nuiton.eugene.models.object.ObjectModelAssociationClass; import org.nuiton.eugene.models.object.ObjectModelAttribute; @@ -85,7 +85,12 @@ /** Type de persistence Hibernate */ public static final String PERSISTENCE_TYPE_HIBERNATE = "hibernate"; - /** Type de persistence LDAP */ + /** + * Type de persistence LDAP + * + * @deprecated since 3.0, use nowhere in ToPIA. + */ + @Deprecated public static final String PERSISTENCE_TYPE_LDAP = "ldap"; /** Type de persistence par défaut (si aucun précisé) */ @@ -199,11 +204,6 @@ return input.getName() + "Dao"; } - @Deprecated - public static String getLegacyDaoName(ObjectModelClass input) { - return input.getName() + "DAO"; - } - public static String getAbstractDaoFqn(ObjectModelClass input) { return input.getPackageName() + "." + getAbstractDaoName(input); } @@ -219,7 +219,6 @@ public static String getEntityPackage(ObjectModelTransformerToJava transformer, ObjectModel model, ObjectModelClassifier input) { - String result = input.getPackageName(); return result; } @@ -236,7 +235,7 @@ for (Object o : model.getInterfaces()) { ObjectModelInterface daoInterface = (ObjectModelInterface) o; if (daoInterface.getName().equals(clazz.getName() + "DAO")) { - if (hasDaoStereotype(daoInterface)) { + if (TopiaStereoTypes.hasDaoStereotype(daoInterface)) { return daoInterface; } } @@ -253,8 +252,8 @@ * @since 2.5 */ public static String getPersistenceType(ObjectModelClassifier classifier) { - String tag = getPersistenceTypeTagValue(classifier); - if (StringUtils.isEmpty(tag)) { + String tag = TopiaTagValues.getPersistenceTypeTagValue(classifier); + if (tag == null) { tag = PERSISTENCE_TYPE_DEFAULT; } return tag; @@ -289,30 +288,14 @@ if (element == null) { return null; } - String value = getDbNameTagValue(element); - if (!StringUtils.isEmpty(value)) { + String value = TopiaTagValues.getDbNameTagValue(element); + if (value != null) { return value; } return toLowerCaseFirstLetter(element.getName()); } /** - * Cherche si le tagvalue {@link TopiaTagValues#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 static boolean shouldGenerateOperatorForDAOHelper(ObjectModel model) { - String tagValue = getGenerateOperatorForDAOHelperTagValue(model); - boolean generate = StringUtils.isNotEmpty(tagValue) && - Boolean.valueOf(tagValue); - return generate; - } - - /** * Cherche et renvoie la liste des attributs constituant la clef metier * d'une classe. * @@ -326,7 +309,7 @@ Set<ObjectModelAttribute> results = new LinkedHashSet<ObjectModelAttribute>(); for (ObjectModelAttribute attr : clazz.getAttributes()) { - if (isNaturalId(attr)) { + if (TopiaTagValues.getNaturalIdTagValue(attr)) { results.add(attr); } } @@ -354,7 +337,7 @@ Set<ObjectModelAttribute> results = new LinkedHashSet<ObjectModelAttribute>(); for (ObjectModelAttribute attr : clazz.getAttributes()) { - if (isNotNull(attr)) { + if (isAttributeNotNull(attr)) { results.add(attr); } } @@ -375,128 +358,23 @@ } /** - * Test if we need to generate {@code toString} method for the given class. - * - * @param clazz class to test - * @param model model - * @return {@code true} if {@code toString} should be generated. - * clef métier. - */ - public static boolean generateToString(ObjectModelClass clazz, - ObjectModel model) { - String value = getNotGenerateToStringTagValue(clazz, model); - return StringUtils.isEmpty(value); - } - - - /** - * Cherche et renvoie la liste des attributs constituant la clef metier - * d'une classe. - * - * @param clazz la classe à tester - * @param model le modele - * @return la liste des attributs de la clef métier ou null si pas de - * clef métier. - */ - public static boolean sortAttribute(ObjectModelClass clazz, - ObjectModel model) { - String value = getSortAttributeTagValue(clazz, model); - return "true".equals(value); - } - - /** - * Detecte si un attribut fait partie d'une clef metier. - * - * @param attribute l'attribut à tester - * @return {@code true} si l'attribut fait partie d'une clef metier, - * <code>false</cdoe> sinon. - */ - public static boolean isNaturalId(ObjectModelAttribute attribute) { - String value = getNaturalIdTagValue(attribute); - if (StringUtils.isEmpty(value)) { - // valeur null, donc pas positionnee - return false; - } - try { - return Boolean.valueOf(value.trim()); - } catch (Exception e) { - // on a pas reussi a convertir en boolean. - //todo peut-être declancher une exception ? - return false; - } - } - - /** * Detecte si un attribut est marqué comme non null. - * Les naturalId {@link #isNaturalId} sont not null par défaut + * Les naturalId sont not null par défaut * * @param attribute l'attribut à tester * @return {@code true} si l'attribut doit être non null, - * par défaut pour les naturalId, {@code false} sinon.. + * par défaut pour les naturalId, {@code false} sinon.. * @since 2.6.9 */ - public static boolean isNotNull(ObjectModelAttribute attribute) { - String value = getNotNullTagValue(attribute); - if (StringUtils.isEmpty(value)) { + public static boolean isAttributeNotNull(ObjectModelAttribute attribute) { + Boolean value = TopiaTagValues.getNotNullTagValue(attribute); + if (value == null) { // valeur null, donc pas positionnee - return isNaturalId(attribute); + return TopiaTagValues.getNaturalIdTagValue(attribute); } - try { - return Boolean.valueOf(value.trim()); - } catch (Exception e) { - // on a pas reussi a convertir en boolean. - //todo peut-être declancher une exception ? - return false; - } + return value; } - public static <Type extends ObjectModelElement> Collection<Type> getElementsWithStereotype( - Collection<Type> elements, String... stereotypes) { - Collection<Type> result = new ArrayList<Type>(); - for (Type element : elements) { - if (hasStereotypes(element, stereotypes)) { - result.add(element); - } - } - return result; - } - - public static boolean hasStereotypes(ObjectModelElement element, - String... stereotypes) { - for (String stereotype : stereotypes) { - if (!element.hasStereotype(stereotype)) { - return false; - } - } - return true; - } - - public static String getPrimaryKeyAttributesListDeclaration( - ObjectModelClass clazz, boolean includeName) { - String attributes = ""; - Collection<ObjectModelAttribute> attributeCollection; - attributeCollection = getElementsWithStereotype(clazz.getAttributes(), - TopiaStereoTypes.STEREOTYPE_PRIMARY_KEY); - for (ObjectModelAttribute attr : attributeCollection) { - attributes += attr.getType(); - if (includeName) { - attributes += ' ' + attr.getName(); - } - attributes += ", "; - } - if (attributes.length() > 0) { - attributes = attributes.substring(0, attributes.length() - 2); - } - return attributes; - } - - public static boolean isAssociationClassDoublon(ObjectModelAttribute attr) { - return attr.getReverseAttribute() != null && - attr.getDeclaringElement().equals( - attr.getReverseAttribute().getDeclaringElement()) && - !GeneratorUtil.isFirstAttribute(attr); - } - public static String getDOType(ObjectModelElement elem, ObjectModel model) { String type = elem.getName(); if (elem instanceof ObjectModelAttribute) { @@ -610,34 +488,6 @@ } /** - * Indique si la classe specifiee n'a aucune ou que des methodes abstraites - * - * @param clazz l'instance de ObjectModelClass - * @return true si la classe n'a que des operations abstraite ou aucune - * operation - */ - public static boolean hasNothingOrAbstractMethods(ObjectModelClass clazz) { - boolean result = true; - Iterator<?> operations = clazz.getOperations().iterator(); - while (result && operations.hasNext()) { - ObjectModelOperation op = (ObjectModelOperation) operations.next(); - result = op.isAbstract(); - } - return result; - } - - /** - * Indique si la classe specifiee devrait etre abstraite - * - * @param clazz l'instance de ObjectModelClass - * @return true dans ce cas, false sinon - */ - public static boolean shouldBeAbstract(ObjectModelClass clazz) { - return clazz != null && clazz.isAbstract() && - hasNothingOrAbstractMethods(clazz); - } - - /** * <p> * Cette méthode permet de détecter si * - l'attribut représente une relation 1-n @@ -712,7 +562,7 @@ */ public static String getNMultiplicityHibernateType( ObjectModelAttribute attr) { - if (hasUniqueStereotype(attr)) { + if (EugeneStereoTypes.hasUniqueStereotype(attr)) { return "set"; } else if (JavaGeneratorUtil.isOrdered(attr)) { return "list"; @@ -771,48 +621,6 @@ }; /** - * Detecte si la clef metier d'une classe est mutable ou pas. - * <p/> - * On respecte la valeur par defaut d'hibernate, à savoir que par default - * une clef metier est non mutable. - * - * @param clazz la classe a tester - * @return {@code true} si le tag value a ete positionne sur la classe - * via le tag {@link TopiaTagValues#TAG_NATURAL_ID_MUTABLE}, {@code false} - * sinon. - */ - public static boolean isNaturalIdMutable(ObjectModelClass clazz) { - String value = getNaturalIdMutableTagValue(clazz); - if (StringUtils.isEmpty(value)) { - // valeur null, donc par default positionnee - return false; - } - try { - return Boolean.valueOf(value.trim()); - } catch (Exception e) { - // on a pas reussi a convertir en boolean. - //todo peut-être declancher une exception ? - return false; - } - } - - /** - * Retourne true si le tagValue {@link TopiaTagValues#TAG_CONTEXTABLE} - * à la valeur {@code true}. - * - * @param classifier classifier to test - * @return {@code true} si {@link TopiaTagValues#TAG_CONTEXTABLE} == {@code true} - */ - public static boolean isContextable(ObjectModelClassifier classifier) { - boolean result = false; - String value = classifier.getTagValue(TopiaTagValues.TAG_CONTEXTABLE); - if (StringUtils.equalsIgnoreCase(value, "true")) { - result = true; - } - return result; - } - - /** * Obtain the list of fqn of object involed in the given class. * * @param aClass the clazz to inspect @@ -829,22 +637,6 @@ } /** - * Obtain the list of fqn of object involed in the given interface. - * - * @param anInterface the interface to inspect - * @param incomingFqns incoming fqns - * @return the list of fqn of attributes - */ - public static List<String> getImports(ObjectModelInterface anInterface, - String... incomingFqns) { - Set<String> tmp = new HashSet<String>(); - tmp.addAll(Arrays.asList(incomingFqns)); - getImports(anInterface, tmp); - List<String> result = cleanImports(anInterface.getPackageName(), tmp); - return result; - } - - /** * Obtain the list of fqn of object involed in the given class. * * @param aClass the class to inspect @@ -967,37 +759,6 @@ return result; } - /** - * Obtain the class to use as abstract dao. - * <p/> - * It will look after a tag value {@link TopiaTagValues#TAG_DAO_IMPLEMENTATION} in model - * and if not found will use the default value which is {@link AbstractTopiaDao}. - * - * @param model the model which could contains - * @return the type of the abstract dao to use - * @since 2.5 - * @deprecated since 3.0-alpha-8, replaced by {@link #getDaoSuperClassTagValue(ObjectModelClassifier, ObjectModel)} - */ - @Deprecated - public static Class<?> getDAOImplementation(ObjectModel model) { - String daoImpl = getDaoImplementationTagValue(model); - Class<?> result; - if (StringUtils.isEmpty(daoImpl)) { - - // use the default dao implementation of topia - result = AbstractTopiaDao.class; - } else { - try { - result = Class.forName(daoImpl); - } catch (ClassNotFoundException e) { - String message = "Could not find dao implementation named " + daoImpl; - log.error(message); - throw new IllegalStateException(message, e); - } - } - return result; - } - public static Map<ObjectModelClass, Set<ObjectModelClass>> searchDirectUsages(ObjectModel model) { List<ObjectModelClass> allEntities; @@ -1087,25 +848,12 @@ } /** - * Check if the given classifier has the - * {@link TopiaStereoTypes#STEREOTYPE_ENTITY} stereotype. - * - * @param classifier classifier to test - * @return {@code true} if stereotype was found, {@code false} otherwise - * @see TopiaStereoTypes#STEREOTYPE_ENTITY - * @since 2.5 - */ - public static boolean hasEntityStereotype(ObjectModelClassifier classifier) { - return classifier.hasStereotype(TopiaStereoTypes.STEREOTYPE_ENTITY); - } - - /** * Check if the given attribute type is an entity. * * @param attribute attribute to test * @param model model containing the attribute * @return {@code true} if type of attribute is an entity, - * {@code false} otherwise + * {@code false} otherwise * @see TopiaStereoTypes#STEREOTYPE_ENTITY * @since 2.7 */ @@ -1126,544 +874,184 @@ * * @param classifier classifier to test * @return {@code true} if stereotype was found and classifier is not - * enumeration, {@code false} otherwise + * enumeration, {@code false} otherwise * @see TopiaStereoTypes#STEREOTYPE_ENTITY * @since 2.5 */ public static boolean isEntity(ObjectModelClassifier classifier) { - return hasEntityStereotype(classifier) && !classifier.isEnum(); + return TopiaStereoTypes.hasEntityStereotype(classifier) && !classifier.isEnum(); } /** - * Check if the given attribute has the - * {@link TopiaStereoTypes#STEREOTYPE_ENTITY} stereotype. + * Obtain the value of the {@link TopiaTagValues#TAG_INHERITANCE_STRATEGY} tag value on the given classifier. * - * @param attribute attribute to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaStereoTypes#STEREOTYPE_ENTITY - * @since 2.5 - */ - public static boolean hasEntityStereotype(ObjectModelAttribute attribute) { - return attribute.hasStereotype(TopiaStereoTypes.STEREOTYPE_ENTITY); - } - - /** - * Check if the given classifier has the - * {@link TopiaStereoTypes#STEREOTYPE_DTO} stereotype. - * - * @param classifier classifier to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaStereoTypes#STEREOTYPE_DTO - * @since 2.5 - */ - public static boolean hasDtoStereotype(ObjectModelClassifier classifier) { - return classifier.hasStereotype(TopiaStereoTypes.STEREOTYPE_DTO); - } - - /** - * Check if the given classifier has the - * {@link TopiaStereoTypes#STEREOTYPE_DAO} stereotype. - * - * @param classifier classifier to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaStereoTypes#STEREOTYPE_DAO - * @since 2.5 - */ - public static boolean hasDaoStereotype(ObjectModelClassifier classifier) { - return classifier.hasStereotype(TopiaStereoTypes.STEREOTYPE_DAO); - } - - /** - * Check if the given operation has the - * {@link TopiaStereoTypes#STEREOTYPE_DAO} stereotype. - * - * @param operation operation to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaStereoTypes#STEREOTYPE_DAO - * @since 2.5 - */ - public static boolean hasDaoStereotype(ObjectModelOperation operation) { - return operation.hasStereotype(TopiaStereoTypes.STEREOTYPE_DAO); - } - - /** - * Check if the given attribute has the - * {@link TopiaStereoTypes#STEREOTYPE_UNIQUE} stereotype. - * - * @param attribute attribute to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaStereoTypes#STEREOTYPE_UNIQUE - * @since 2.5 - */ - public static boolean hasUniqueStereotype(ObjectModelAttribute attribute) { - return attribute.hasStereotype(TopiaStereoTypes.STEREOTYPE_UNIQUE); - } - - /** - * Check if the given attribute has the - * {@link TopiaStereoTypes#STEREOTYPE_PRIMARY_KEY} stereotype. - * - * @param attribute attribute to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see TopiaStereoTypes#STEREOTYPE_PRIMARY_KEY - * @since 2.5 - */ - public static boolean hasPrimaryKeyStereotype(ObjectModelAttribute attribute) { - return attribute.hasStereotype(TopiaStereoTypes.STEREOTYPE_PRIMARY_KEY); - } - - /** - * Obtain the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_PERSISTENCE_TYPE - * @since 2.5 - */ - public static String getPersistenceTypeTagValue(ObjectModelClassifier classifier) { -// String value = findTagValue(TopiaTagValues.TAG_PERSISTENCE_TYPE, classifier, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_PERSISTENCE_TYPE, classifier); - return value; - } - - /** - * Obtain the value of the {@link TopiaTagValues#TAG_INHERITANCE_STRATEGY} - * 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 TopiaTagValues#TAG_INHERITANCE_STRATEGY * @since 3.0 */ - public static String getInheritanceStrategyTagValue(ObjectModelClassifier classifier) { -// String value = findTagValue(TopiaTagValues.TAG_INHERITANCE_STRATEGY, classifier, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_INHERITANCE_STRATEGY, classifier); + public static String getInheritanceStrategy(ObjectModelClassifier classifier) { + String value = TopiaTagValues.getInheritanceStrategyTagValue(classifier); if (value == null) { - value = DEFAULT_INHERITANCE_STRATEGY; + value = TopiaGeneratorUtil.DEFAULT_INHERITANCE_STRATEGY; } return value; } - /** - * Obtain the value of the {@link TopiaTagValues#TAG_DB_NAME} - * tag value on the given classifier. - * - * @param element classifier to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see TopiaTagValues#TAG_DB_NAME - * @since 2.5 - */ - public static String getDbNameTagValue(ObjectModelElement element) { -// String value = findTagValue(TopiaTagValues.TAG_DB_NAME, element, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_DB_NAME, element); - return value; - } + //--------------------------------------------------------------------------------------------------------------- + //-- DEPRECATED API TO REMOVE --------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------- - /** - * Obtain the value of the {@link TopiaTagValues#TAG_SCHEMA_NAME} - * tag value on the given classifier. - * - * @param classifier classifier 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 TopiaTagValues#TAG_SCHEMA_NAME - * @since 2.5 - */ - public static String getDbSchemaNameTagValue(ObjectModelClassifier classifier, ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_SCHEMA_NAME, classifier, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_SCHEMA_NAME, classifier, model); - return value; + @Deprecated + public static String getLegacyDaoName(ObjectModelClass input) { + return input.getName() + "DAO"; } /** - * Obtain the value of the {@link TopiaTagValues#TAG_SCHEMA_NAME} - * tag value on the given attribute. - * - * @param attribute attribute 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 TopiaTagValues#TAG_SCHEMA_NAME - * @since 2.5 + * @deprecated since 3.0, not used anywhere in ToPIA */ - public static String getDbSchemaNameTagValue(ObjectModelAttribute attribute, ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_SCHEMA_NAME, attribute, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_SCHEMA_NAME, attribute, model); - return value; + @Deprecated + public static <Type extends ObjectModelElement> Collection<Type> getElementsWithStereotype( + Collection<Type> elements, String... stereotypes) { + Collection<Type> result = new ArrayList<Type>(); + for (Type element : elements) { + if (hasStereotypes(element, stereotypes)) { + result.add(element); + } + } + return result; } /** - * Obtain the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_LENGTH - * @since 2.5 + * @deprecated since 3.0, not used anywhere in ToPIA */ - public static String getLengthTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_LENGTH, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_LENGTH, attribute); - return value; + @Deprecated + public static boolean hasStereotypes(ObjectModelElement element, + String... stereotypes) { + for (String stereotype : stereotypes) { + if (!element.hasStereotype(stereotype)) { + return false; + } + } + return true; } /** - * Obtain the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_ANNOTATION - * @since 2.5 + * @deprecated since 3.0, not used anywhere in ToPIA */ - public static String getAnnotationTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_ANNOTATION, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_ANNOTATION, attribute); - return value; + @Deprecated + public static String getPrimaryKeyAttributesListDeclaration( + ObjectModelClass clazz, boolean includeName) { + String attributes = ""; + Collection<ObjectModelAttribute> attributeCollection; + attributeCollection = getElementsWithStereotype(clazz.getAttributes(), + TopiaStereoTypes.STEREOTYPE_PRIMARY_KEY); + for (ObjectModelAttribute attr : attributeCollection) { + attributes += attr.getType(); + if (includeName) { + attributes += ' ' + attr.getName(); + } + attributes += ", "; + } + if (attributes.length() > 0) { + attributes = attributes.substring(0, attributes.length() - 2); + attributes = attributes.substring(0, attributes.length() - 2); + } + return attributes; } /** - * Obtain the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_ACCESS - * @since 2.5 + * @deprecated since 3.0, not used anywhere in ToPIA */ - public static String getAccessTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_ACCESS, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_ACCESS, attribute); - return value; + @Deprecated + public static boolean isAssociationClassDoublon(ObjectModelAttribute attr) { + return attr.getReverseAttribute() != null && + attr.getDeclaringElement().equals( + attr.getReverseAttribute().getDeclaringElement()) && + !GeneratorUtil.isFirstAttribute(attr); } - /** - * Obtain the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_NATURAL_ID - * @since 2.5 - */ - public static String getNaturalIdTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_NATURAL_ID, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_NATURAL_ID, attribute); - return value; - } /** - * Obtain the value of the {@link TopiaTagValues#TAG_NATURAL_ID_MUTABLE} - * tag value on the given classifier. + * Obtain the list of fqn of object involed in the given interface. * - * @param classifier classifier to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see TopiaTagValues#TAG_NATURAL_ID_MUTABLE - * @since 2.5 + * @param anInterface the interface to inspect + * @param incomingFqns incoming fqns + * @return the list of fqn of attributes + * @deprecated since 3.0, not used anywhere in ToPIA */ - public static String getNaturalIdMutableTagValue(ObjectModelClassifier classifier) { -// String value = findTagValue(TopiaTagValues.TAG_NATURAL_ID_MUTABLE, classifier, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_NATURAL_ID_MUTABLE, classifier); - return value; + @Deprecated + public static List<String> getImports(ObjectModelInterface anInterface, + String... incomingFqns) { + Set<String> tmp = new HashSet<String>(); + tmp.addAll(Arrays.asList(incomingFqns)); + getImports(anInterface, tmp); + List<String> result = cleanImports(anInterface.getPackageName(), tmp); + return result; } /** - * Obtain the value of the {@link TopiaTagValues#TAG_INVERSE} - * tag value on the given attribute. + * Indique si la classe specifiee n'a aucune ou que des methodes abstraites * - * @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_INVERSE - * @since 2.5 + * @param clazz l'instance de ObjectModelClass + * @return true si la classe n'a que des operations abstraite ou aucune + * operation + * @deprecated since 3.0, used nowhere in ToPIA */ - public static String getInverseTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_INVERSE, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_INVERSE, attribute); - return value; + @Deprecated + public static boolean hasNothingOrAbstractMethods(ObjectModelClass clazz) { + boolean result = true; + Iterator<?> operations = clazz.getOperations().iterator(); + while (result && operations.hasNext()) { + ObjectModelOperation op = (ObjectModelOperation) operations.next(); + result = op.isAbstract(); + } + return result; } /** - * Obtain the value of the {@link TopiaTagValues#TAG_LAZY} - * tag value on the given attribute. + * Indique si la classe specifiee devrait etre abstraite * - * @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_LAZY - * @since 2.5 + * @param clazz l'instance de ObjectModelClass + * @return true dans ce cas, false sinon + * @deprecated since 3.0, used nowhere in ToPIA */ - public static String getLazyTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_LAZY, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_LAZY, attribute); - return value; + @Deprecated + public static boolean shouldBeAbstract(ObjectModelClass clazz) { + return clazz != null && clazz.isAbstract() && + hasNothingOrAbstractMethods(clazz); } /** - * Obtain the value of the {@link TopiaTagValues#TAG_FETCH} - * tag value on the given attribute. + * Obtain the class to use as abstract dao. + * <p/> + * It will look after a tag value {@link TopiaTagValues#TAG_DAO_IMPLEMENTATION} in model + * and if not found will use the default value which is {@link AbstractTopiaDao}. * - * @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_FETCH + * @param model the model which could contains + * @return the type of the abstract dao to use * @since 2.5 + * @deprecated since 3.0-alpha-8, replaced by {@link TopiaTagValues#getDaoSuperClassTagValue(ObjectModelClassifier, ObjectModel)} */ - public static String getFetchTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_FETCH, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_FETCH, attribute); - return value; - } - - /** - * Obtain the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_ORDER_BY - * @since 2.5 - */ - public static String getOrderByTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_ORDER_BY, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_ORDER_BY, attribute); - return value; - } - - /** - * Obtain the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_NOT_NULL - * @since 2.5 - */ - public static String getNotNullTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_NOT_NULL, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_NOT_NULL, attribute); - return value; - } - - /** - * Obtain the value of the {@link TopiaTagValues#TAG_PROXY_INTERFACE} - * tag value on the given classifier. - * - * @param classifier classifier 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 TopiaTagValues#TAG_PROXY_INTERFACE - * @since 2.5 - */ - public static String getProxyInterfaceTagValue(ObjectModelClassifier classifier, ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_PROXY_INTERFACE, classifier, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_PROXY_INTERFACE, classifier, model); - return value; - } - - /** - * Obtain the value of the {@link TopiaTagValues#TAG_NOT_GENERATE_TO_STRING} - * tag value on the given class. - * - * @param clazz class 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 TopiaTagValues#TAG_NOT_GENERATE_TO_STRING - * @since 2.5 - */ - public static String getNotGenerateToStringTagValue(ObjectModelClassifier clazz, ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_NOT_GENERATE_TO_STRING, clazz, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_NOT_GENERATE_TO_STRING, clazz, model); - return value; - } - - /** - * Obtain the value of the {@link TopiaTagValues#TAG_SORT_ATTRIBUTE} - * tag value on the given classifier. - * - * @param classifier classifier 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 TopiaTagValues#TAG_SORT_ATTRIBUTE - * @since 2.5 - */ - public static String getSortAttributeTagValue(ObjectModelClassifier classifier, ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_SORT_ATTRIBUTE, classifier, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_SORT_ATTRIBUTE, classifier, model); - return value; - } - - /* Obtain the value of the {@link TopiaTagValues#TAG_GENERATE_OPERATOR_FOR_DAO_HELPER} - * 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 TopiaTagValues#TAG_GENERATE_OPERATOR_FOR_DAO_HELPER - * @since 2.5 - */ - public static String getGenerateOperatorForDAOHelperTagValue(ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_GENERATE_OPERATOR_FOR_DAO_HELPER, null, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_GENERATE_OPERATOR_FOR_DAO_HELPER, model); - return value; - } - - /** - * Obtain the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_TYPE - * @since 2.5 - * @deprecated since 3.0, use now {@link #getHibernateAttributeType(ObjectModelAttribute, ObjectModelClassifier, ObjectModel)} - */ @Deprecated - public static String getTypeTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_TYPE, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_TYPE, attribute); - return value; - } + public static Class<?> getDAOImplementation(ObjectModel model) { + String daoImpl = TopiaTagValues.getDaoImplementationTagValue(model); + Class<?> result; + if (StringUtils.isEmpty(daoImpl)) { - public static String getHibernateAttributeType(ObjectModelAttribute attribute, ObjectModelClassifier classifier, ObjectModel model) { - String tagValueName = TopiaTagValues.TAG_HIBERNATE_ATTRIBUTE_TYPE + "." + attribute.getType(); - String value = TagValues.findTagValue(tagValueName, attribute, classifier, model); - return value; + // use the default dao implementation of topia + result = AbstractTopiaDao.class; + } else { + try { + result = Class.forName(daoImpl); + } catch (ClassNotFoundException e) { + String message = "Could not find dao implementation named " + daoImpl; + log.error(message); + throw new IllegalStateException(message, e); + } + } + return result; } - /** - * Obtain the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_TYPE - * @since 2.5 - */ - public static String getSqlTypeTagValue(ObjectModelAttribute attribute) { -// String value = findTagValue(TopiaTagValues.TAG_SQL_TYPE, attribute, null); - String value = TagValues.findTagValue(TopiaTagValues.TAG_SQL_TYPE, attribute); - return value; - } - - /** - * Obtains the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_DAO_IMPLEMENTATION - * @since 2.5 - */ - public static String getDaoImplementationTagValue(ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_DAO_IMPLEMENTATION, null, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_DAO_IMPLEMENTATION, model); - return value; - } - - /** - * Obtains the value of the tag value - * {@link TopiaTagValues#TAG_INDEX_FOREIGN_KEYS} on the model or on the - * given attribute. - * - * @param attribute attribute to test - * @param model model to test - * @return none empty value of the found tag value or {@code null} if not found nor empty. - * @see TopiaTagValues#TAG_INDEX_FOREIGN_KEYS - * @since 2.6.5 - */ - public static String getIndexForeignKeys(ObjectModelAttribute attribute, ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_INDEX_FOREIGN_KEYS, attribute, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_INDEX_FOREIGN_KEYS, attribute, model); - return value; - } - - //TODO Javadoc - public static boolean hasUseEnumerationNameTagValue(ObjectModelClassifier classifier, ObjectModelAttribute attr, ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_USE_ENUMERATION_NAME, classifier, model); -// if (value == null) { -// // try on attribute -// value = findTagValue(TopiaTagValues.TAG_USE_ENUMERATION_NAME, attr); -// } -// return Boolean.parseBoolean(value); - boolean value = TagValues.findBooleanTagValue(TopiaTagValues.TAG_USE_ENUMERATION_NAME, attr, classifier, model); - return value; - } - - /** - * Search if the TagValue {@link TopiaTagValues#TAG_GENERATE_TOPIA_ID_IN_DTO} has been - * activated in the model. - * - * @param classifier classifier 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 TopiaTagValues#TAG_GENERATE_TOPIA_ID_IN_DTO - * @since 2.6.7 - */ - public static boolean shouldGenerateDTOTopiaIdTagValue(ObjectModelClassifier classifier, ObjectModel model) { -// String tagValue = findTagValue(TopiaTagValues.TAG_GENERATE_TOPIA_ID_IN_DTO, classifier, model); -// boolean generate = StringUtils.isNotEmpty(tagValue) && Boolean.valueOf(tagValue); -// return generate; - boolean value = TagValues.findBooleanTagValue(TopiaTagValues.TAG_GENERATE_TOPIA_ID_IN_DTO, classifier, model); - return value; - } - - /** - * Obtains the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_PERSISTENCE_CONTEXT_SUPER_CLASS - * @since 3.0 - */ - public static String getPersistenceContextSuperClassTagValue(ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_PERSISTENCE_CONTEXT_SUPER_CLASS, null, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_PERSISTENCE_CONTEXT_SUPER_CLASS, model); - return value; - } - - /** - * Obtains the value of the {@link TopiaTagValues#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 TopiaTagValues#TAG_APPLICATION_CONTEXT_SUPER_CLASS - * @since 3.0 - */ - public static String getApplicationContextSuperClassTagValue(ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_APPLICATION_CONTEXT_SUPER_CLASS, null, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_APPLICATION_CONTEXT_SUPER_CLASS, model); - return value; - } - - /** - * Obtains the value of the {@link TopiaTagValues#TAG_DAO_SUPER_CLASS} - * tag value on the given classifier or 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 TopiaTagValues#TAG_DAO_SUPER_CLASS - * @since 3.0 - */ - public static String getDaoSuperClassTagValue(ObjectModelClassifier classifier, ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_DAO_SUPER_CLASS, classifier, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_DAO_SUPER_CLASS, classifier, model); - return value; - } - - /** - * Obtains the value of the {@link TopiaTagValues#TAG_ENTITY_SUPER_CLASS} - * tag value on the given classifier or 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 TopiaTagValues#TAG_ENTITY_SUPER_CLASS - * @since 3.0 - */ - public static String getEntitySuperClassTagValue(ObjectModelClassifier classifier, ObjectModel model) { -// String value = findTagValue(TopiaTagValues.TAG_ENTITY_SUPER_CLASS, classifier, model); - String value = TagValues.findTagValue(TopiaTagValues.TAG_ENTITY_SUPER_CLASS, classifier, model); - return value; - } - } // TopiaGeneratorUtil Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaModelPropertiesProvider.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaModelPropertiesProvider.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaModelPropertiesProvider.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -1,18 +1,21 @@ package org.nuiton.topia.templates; -import org.nuiton.eugene.metas.ModelPropertiesProvider; +import org.nuiton.eugene.ModelPropertiesUtil; + /** * The ToPIA provider of tag values and stereotypes. * * @author tchemit <chemit@codelutin.com> * @plexus.component role="org.nuiton.eugene.metas.ModelPropertiesProvider" role-hint="topia" * @since 2.3 + * @deprecated since 3.0, no more used. Use now {@link TopiaStereoTypes} and {@link TopiaTagValues}. */ -public class TopiaModelPropertiesProvider extends ModelPropertiesProvider { +@Deprecated +public class TopiaModelPropertiesProvider extends ModelPropertiesUtil.ModelPropertiesProvider { @Override - public void initStores() throws IllegalAccessException { + public void init() throws IllegalAccessException { scanStereotypeClass(TopiaStereoTypes.class); scanTagValueClass(TopiaTagValues.class); } Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaStereoTypes.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -24,56 +24,132 @@ * #L% */ -import org.nuiton.eugene.EugeneStereoTypes; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClassifier; import org.nuiton.eugene.models.object.ObjectModelOperation; +import org.nuiton.eugene.models.stereotype.StereotypeDefinition; +import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider; -import org.nuiton.eugene.metas.StereotypeDefinition; - /** * All extra stereotypes usable in topia generators. * * @author tchemit <chemit@codelutin.com> + * @plexus.component role="org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider" role-hint="topia" * @since 2.5 */ -public interface TopiaStereoTypes extends EugeneStereoTypes { +public class TopiaStereoTypes extends StereotypeDefinitionProvider { /** * Stéréotype pour les objets devant être générées sous forme d'entités * * @see TopiaGeneratorUtil#isEntity(ObjectModelClassifier) - * @see TopiaGeneratorUtil#hasEntityStereotype(ObjectModelAttribute) + * @see #hasEntityStereotype(ObjectModelAttribute) */ @StereotypeDefinition(target = {ObjectModelClassifier.class, ObjectModelAttribute.class}, documentation = "To specify that a class is an Entity") - String STEREOTYPE_ENTITY = "entity"; + public static final String STEREOTYPE_ENTITY = "entity"; /** * Stéréotype pour les objets devant être générées sous forme de DTO. * - * @see TopiaGeneratorUtil#hasDtoStereotype(ObjectModelClassifier) + * @see #hasDtoStereotype(ObjectModelClassifier) */ @StereotypeDefinition(target = ObjectModelClassifier.class, documentation = "to specify that a class is a DTO") - String STEREOTYPE_DTO = "dto"; + public static final String STEREOTYPE_DTO = "dto"; /** * Stéréotype pour les interfaces devant être générées sous forme de DAO. * - * @see TopiaGeneratorUtil#hasDaoStereotype(ObjectModelClassifier) - * @see TopiaGeneratorUtil#hasDaoStereotype(ObjectModelOperation) + * @see #hasDaoStereotype(ObjectModelClassifier) + * @see #hasDaoStereotype(ObjectModelOperation) */ @StereotypeDefinition(target = {ObjectModelClassifier.class, ObjectModelOperation.class}, documentation = "To Specify that a classifier or an operation should be generated as (or in) a DAO") - String STEREOTYPE_DAO = "dao"; + public static final String STEREOTYPE_DAO = "dao"; /** * Stéréotype pour les attributs étant des clés primaires. * - * @see TopiaGeneratorUtil#hasPrimaryKeyStereotype(ObjectModelAttribute) + * @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)") - String STEREOTYPE_PRIMARY_KEY = "primaryKey"; + public static final String STEREOTYPE_PRIMARY_KEY = "primaryKey"; + + /** + * Check if the given classifier has the {@link TopiaStereoTypes#STEREOTYPE_ENTITY} stereotype. + * + * @param classifier classifier to test + * @return {@code true} if stereotype was found, {@code false otherwise} + * @see TopiaStereoTypes#STEREOTYPE_ENTITY + * @since 2.5 + */ + public static boolean hasEntityStereotype(ObjectModelClassifier classifier) { + return classifier.hasStereotype(TopiaStereoTypes.STEREOTYPE_ENTITY); + } + + /** + * Check if the given attribute has the {@link TopiaStereoTypes#STEREOTYPE_ENTITY} stereotype. + * + * @param attribute attribute to test + * @return {@code true} if stereotype was found, {@code false otherwise} + * @see TopiaStereoTypes#STEREOTYPE_ENTITY + * @since 2.5 + */ + public static boolean hasEntityStereotype(ObjectModelAttribute attribute) { + return attribute.hasStereotype(TopiaStereoTypes.STEREOTYPE_ENTITY); + } + + /** + * Check if the given classifier has the {@link TopiaStereoTypes#STEREOTYPE_DTO} stereotype. + * + * @param classifier classifier to test + * @return {@code true} if stereotype was found, {@code false otherwise} + * @see TopiaStereoTypes#STEREOTYPE_DTO + * @since 2.5 + */ + public static boolean hasDtoStereotype(ObjectModelClassifier classifier) { + return classifier.hasStereotype(TopiaStereoTypes.STEREOTYPE_DTO); + } + + /** + * Check if the given classifier has the {@link TopiaStereoTypes#STEREOTYPE_DAO} stereotype. + * + * @param classifier classifier to test + * @return {@code true} if stereotype was found, {@code false otherwise} + * @see TopiaStereoTypes#STEREOTYPE_DAO + * @since 2.5 + */ + public static boolean hasDaoStereotype(ObjectModelClassifier classifier) { + return classifier.hasStereotype(TopiaStereoTypes.STEREOTYPE_DAO); + } + + /** + * Check if the given operation has the {@link TopiaStereoTypes#STEREOTYPE_DAO} stereotype. + * + * @param operation operation to test + * @return {@code true} if stereotype was found, {@code false otherwise} + * @see TopiaStereoTypes#STEREOTYPE_DAO + * @since 2.5 + */ + public static boolean hasDaoStereotype(ObjectModelOperation operation) { + return operation.hasStereotype(TopiaStereoTypes.STEREOTYPE_DAO); + } + + /** + * Check if the given attribute has the {@link TopiaStereoTypes#STEREOTYPE_PRIMARY_KEY} stereotype. + * + * @param attribute attribute to test + * @return {@code true} if stereotype was found, {@code false otherwise} + * @see TopiaStereoTypes#STEREOTYPE_PRIMARY_KEY + * @since 2.5 + * @deprecated since 3.0, not used in ToPIA + */ + @Deprecated + public static boolean hasPrimaryKeyStereotype(ObjectModelAttribute attribute) { + return attribute.hasStereotype(TopiaStereoTypes.STEREOTYPE_PRIMARY_KEY); + } } Modified: trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java =================================================================== --- trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/java/org/nuiton/topia/templates/TopiaTagValues.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -24,14 +24,14 @@ * #L% */ -import org.nuiton.eugene.EugeneTagValues; -import org.nuiton.eugene.metas.TagValueDefinition; -import org.nuiton.eugene.metas.matcher.PrefixTagNameMatchTagValueMatcher; 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.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.TopiaEntityContextable; @@ -39,20 +39,21 @@ * All extra tag values usable in topia generators. * * @author tchemit <chemit@codelutin.com> + * @plexus.component role="org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider" role-hint="topia" * @since 2.5 */ -public interface TopiaTagValues extends EugeneTagValues { +public class TopiaTagValues extends TagValueDefinitionProvider { /** * Tag pour le type de persistence. * * @see TopiaGeneratorUtil#getPersistenceType(ObjectModelClassifier) - * @see TopiaGeneratorUtil#getPersistenceTypeTagValue(ObjectModelClassifier) + * @see #getPersistenceTypeTagValue(ObjectModelClassifier) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelClassifier.class}, documentation = "TODO") - String TAG_PERSISTENCE_TYPE = "persistenceType"; + public static final String TAG_PERSISTENCE_TYPE = "persistenceType"; /** * Tag pour que les entités etendent {@link TopiaEntityContextable} et @@ -62,81 +63,79 @@ * @since 2.5.3 */ @TagValueDefinition(target = {ObjectModelClassifier.class}, documentation = "TODO") - String TAG_CONTEXTABLE = "contextable"; + public static final String TAG_CONTEXTABLE = "contextable"; /** * Tag pour le nom du champ / entité en BD. * - * @see TopiaGeneratorUtil#getDbNameTagValue(ObjectModelElement) + * @see #getDbNameTagValue(ObjectModelElement) * @see TopiaGeneratorUtil#getDbName(ObjectModelElement) * @see TopiaGeneratorUtil#getReverseDbName(ObjectModelAttribute) */ @TagValueDefinition(target = {ObjectModelElement.class}, documentation = "Sets the database name of an element of the model (a table or a column)") - String TAG_DB_NAME = "dbName"; + public static final String TAG_DB_NAME = "dbName"; /** * Tag pour le nom du schema en BD. * - * @see TopiaGeneratorUtil#getDbSchemaNameTagValue(ObjectModelClassifier, ObjectModel) - * @see TopiaGeneratorUtil#getDbSchemaNameTagValue(ObjectModelAttribute, ObjectModel) + * @see #getDbSchemaNameTagValue(ObjectModelClassifier, ObjectModel) + * @see #getDbSchemaNameTagValue(ObjectModelAttribute, ObjectModel) * @since 2.5 */ @TagValueDefinition(target = {ObjectModel.class, ObjectModelClassifier.class, ObjectModelAttribute.class}, documentation = "Sets the database schema name") - String TAG_SCHEMA_NAME = "dbSchema"; + public static final String TAG_SCHEMA_NAME = "dbSchema"; /** * Tag pour la taille du champ en BD. * - * @see TopiaGeneratorUtil#getLengthTagValue(ObjectModelAttribute) + * @see #getLengthTagValue(ObjectModelAttribute) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets the length of an attribute in database") - String TAG_LENGTH = "length"; + public static final String TAG_LENGTH = "length"; /** * Tag pour ajouter une annotation à un champ. * - * @see TopiaGeneratorUtil#getAnnotationTagValue(ObjectModelAttribute) + * @see #getAnnotationTagValue(ObjectModelAttribute) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets an annotation of an attribute") - String TAG_ANNOTATION = "annotation"; + public static final String TAG_ANNOTATION = "annotation"; /** * Tag pour specfier le type d'acces a un champ. * - * @see TopiaGeneratorUtil#getAccessTagValue(ObjectModelAttribute) + * @see #getAccessTagValue(ObjectModelAttribute) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets the access type of an attribute (Hibernate mapping)") - String TAG_ACCESS = "access"; + public static final String TAG_ACCESS = "access"; /** * Tag pour ajouter un attribut dans une clef métier. * - * @see TopiaGeneratorUtil#getNaturalIdTagValue(ObjectModelAttribute) - * @see TopiaGeneratorUtil#isNaturalId(ObjectModelAttribute) + * @see #getNaturalIdTagValue(ObjectModelAttribute) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets an attribute as part of a natural id (Hibernate Mapping)") - String TAG_NATURAL_ID = "naturalId"; + public static final String TAG_NATURAL_ID = "naturalId"; /** * Tag pour specifier si une clef metier est mutable. * - * @see TopiaGeneratorUtil#getNaturalIdMutableTagValue(ObjectModelClassifier) - * @see TopiaGeneratorUtil#isNaturalIdMutable(ObjectModelClass) + * @see #getNaturalIdMutableTagValue(ObjectModelClassifier) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelClassifier.class}, documentation = "Sets if natural id of a entity is mutable (hibernate mapping)") - String TAG_NATURAL_ID_MUTABLE = "naturalIdMutable"; + public static final String TAG_NATURAL_ID_MUTABLE = "naturalIdMutable"; /** * Tag pour permettre de choisir qui contrôle la relation N-N @@ -145,52 +144,52 @@ * Par défaut le inverse=true est placé sur le premier rôle trouvé dans * l'ordre alphabétique. * - * @see TopiaGeneratorUtil#getInverseTagValue(ObjectModelAttribute) + * @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)") - String TAG_INVERSE = "inverse"; + public static final String TAG_INVERSE = "inverse"; /** * Tag pour spécifier la caractère lazy d'une association multiple. * - * @see TopiaGeneratorUtil#getLazyTagValue(ObjectModelAttribute) + * @see #getLazyTagValue(ObjectModelAttribute) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets if an association should be lazy (Hibernate mapping)") - String TAG_LAZY = "lazy"; + public static final String TAG_LAZY = "lazy"; /** * Tag pour spécifier la caractère fetch d'une association multiple. * - * @see TopiaGeneratorUtil#getFetchTagValue(ObjectModelAttribute) + * @see #getFetchTagValue(ObjectModelAttribute) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets the fetch caracteristic of an attribute (Hibernate mapping)") - String TAG_FETCH = "fetch"; + public static final String TAG_FETCH = "fetch"; /** * Tag pour spécifier la caractère order-by d'une association multiple. * - * @see TopiaGeneratorUtil#getOrderByTagValue(ObjectModelAttribute) + * @see #getOrderByTagValue(ObjectModelAttribute) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets the order by propertie of an multiple association (Hibernate mapping)") - String TAG_ORDER_BY = "orderBy"; + public static final String TAG_ORDER_BY = "orderBy"; /** * Tag pour spécifier la caractère not-null d'un attribut. * - * @see TopiaGeneratorUtil#getNotNullTagValue(ObjectModelAttribute) + * @see #getNotNullTagValue(ObjectModelAttribute) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets if an attribute must be not null (Hibernate mapping)") - String TAG_NOT_NULL = "notNull"; + public static final String TAG_NOT_NULL = "notNull"; /** * Tag à placer sur un l'attribut d'une entité. Cet attribut est de type @@ -198,12 +197,12 @@ * {@code name} de l'énumération et non l'ordinal pour stocker la valeur en * base * - * @see TopiaGeneratorUtil#hasUseEnumerationNameTagValue(ObjectModelClassifier, ObjectModelAttribute, ObjectModel) + * @see #hasUseEnumerationNameTagValue(ObjectModelAttribute, ObjectModelClassifier, ObjectModel) * @since 3.0 */ @TagValueDefinition(target = {ObjectModel.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)") - String TAG_USE_ENUMERATION_NAME = "useEnumerationName"; + public static final String TAG_USE_ENUMERATION_NAME = "useEnumerationName"; /** * Tag pour configurer l'interface du proxy sur autre chose que l'implementation par defaut. @@ -213,12 +212,12 @@ * Autre valeur : * "none" > laisse la configuration par defaut d'hibernate * - * @see TopiaGeneratorUtil#getPersistenceTypeTagValue(ObjectModelClassifier) + * @see #getPersistenceTypeTagValue(ObjectModelClassifier) * @since 2.5 */ @TagValueDefinition(target = {ObjectModel.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)") - String TAG_PROXY_INTERFACE = "hibernateProxyInterface"; + public static final String TAG_PROXY_INTERFACE = "hibernateProxyInterface"; /** * Tag pour configurer la stategie d'heritage choisie. @@ -228,51 +227,49 @@ * "subclass" > Single table per class hierarchy strategy * "joined-subclass" > Joined subclass strategy * - * @see TopiaGeneratorUtil#getPersistenceTypeTagValue(ObjectModelClassifier) + * @see #getPersistenceTypeTagValue(ObjectModelClassifier) * @since 3.0 */ @TagValueDefinition(target = {ObjectModel.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)") - String TAG_INHERITANCE_STRATEGY = "inheritanceStrategy"; + 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 pour specifier de ne pas generer la methode toString. * - * @see TopiaGeneratorUtil#getNotGenerateToStringTagValue(ObjectModelClassifier, ObjectModel) - * @see TopiaGeneratorUtil#generateToString(ObjectModelClass, ObjectModel) + * @see #getNotGenerateToStringTagValue(ObjectModelClassifier, ObjectModel) * @since 2.5 */ @TagValueDefinition(target = {ObjectModel.class, ObjectModelClassifier.class}, defaultValue = "true", documentation = "To not generate the toString method on entities") - String TAG_NOT_GENERATE_TO_STRING = "notGenerateToString"; + public static final String TAG_NOT_GENERATE_TO_STRING = "notGenerateToString"; /** * Tag pour specifier de trier les attributs par nom lors de la generation. * - * @see TopiaGeneratorUtil#getSortAttributeTagValue(ObjectModelClassifier, ObjectModel) - * @see TopiaGeneratorUtil#sortAttribute(ObjectModelClass, ObjectModel) + * @see #getSortAttributeTagValue(ObjectModelClassifier, ObjectModel) * @since 2.5 */ @TagValueDefinition(target = {ObjectModel.class, ObjectModelClassifier.class}, documentation = "To sort attribute while generation") - String TAG_SORT_ATTRIBUTE = "sortAttribute"; + public static final String TAG_SORT_ATTRIBUTE = "sortAttribute"; /** * Tag pour specfier si on doit générer la methode getOperator dans les daohelpers. * - * @see TopiaGeneratorUtil#getGenerateOperatorForDAOHelperTagValue(ObjectModel) - * @see TopiaGeneratorUtil#shouldGenerateOperatorForDAOHelper(ObjectModel) + * @see #getGenerateOperatorForDAOHelperTagValue(ObjectModel) * @since 2.5 */ @TagValueDefinition(target = {ObjectModel.class}, documentation = "To generate EntityOperation on generated DAOHelper") - String TAG_GENERATE_OPERATOR_FOR_DAO_HELPER = "generateOperatorForDAOHelper"; + 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 TopiaGeneratorUtil#getTypeTagValue(ObjectModelAttribute) + * @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. @@ -280,17 +277,17 @@ @Deprecated @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets the hibernate type of an attribute (Hibernate mapping)") - String TAG_TYPE = "type"; + public static final String TAG_TYPE = "type"; /** * Tag pour spécifier le type sql d'une propriété dans le mapping hibernate. * - * @see TopiaGeneratorUtil#getSqlTypeTagValue(ObjectModelAttribute) + * @see #getSqlTypeTagValue(ObjectModelAttribute) * @since 2.5 */ @TagValueDefinition(target = {ObjectModelAttribute.class}, documentation = "Sets the sql type of an attribute (Hibernate mapping)") - String TAG_SQL_TYPE = "sqlType"; + public static final String TAG_SQL_TYPE = "sqlType"; /** * To specify the abstract dao to use. @@ -299,38 +296,37 @@ * <p/> * Other value possible is {@code org.nuiton.topia.persistence.TopiaDAOLegacy} * - * @see TopiaGeneratorUtil#getDaoImplementationTagValue(ObjectModel) + * @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))") - String TAG_DAO_IMPLEMENTATION = "daoImplementation"; + 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 TopiaGeneratorUtil#getIndexForeignKeys(ObjectModelAttribute, ObjectModel) + * @see #getIndexForeignKeysTagValue(ObjectModelAttribute, ObjectModel) * @since 2.6.5 */ @TagValueDefinition(target = {ObjectModel.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)") - String TAG_INDEX_FOREIGN_KEYS = "indexForeignKeys"; + public static final String TAG_INDEX_FOREIGN_KEYS = "indexForeignKeys"; /** * Tag to specify if we want to add an "id" property in DTO generated by * {@link EntityDTOTransformer}. - * <p/> * * @see EntityDTOTransformer - * @see TopiaGeneratorUtil#shouldGenerateDTOTopiaIdTagValue(ObjectModelClassifier, ObjectModel) + * @see #shouldGenerateDTOTopiaIdTagValue(ObjectModelClassifier, ObjectModel) * @since 2.6.7 * @deprecated since 3.0, will be removed at the same time that {@link EntityDTOTransformer}. */ @Deprecated @TagValueDefinition(target = {ObjectModel.class, ObjectModelClassifier.class}, documentation = "Add a \"id\" property with its getter/setter on a DTO.") - String TAG_GENERATE_TOPIA_ID_IN_DTO = "generateDTOTopiaId"; + public static final String TAG_GENERATE_TOPIA_ID_IN_DTO = "generateDTOTopiaId"; /** @@ -341,12 +337,12 @@ * {@link org.nuiton.topia.persistence.internal.AbstractTopiaPersistenceContext}. * * @see org.nuiton.topia.persistence.internal.AbstractTopiaPersistenceContext - * @see TopiaGeneratorUtil#getPersistenceContextSuperClassTagValue(org.nuiton.eugene.models.object.ObjectModel) + * @see #getPersistenceContextSuperClassTagValue(org.nuiton.eugene.models.object.ObjectModel) * @since 3.0 */ @TagValueDefinition(target = {ObjectModel.class}, documentation = "Change the super class to use when generating PersistenceContext.") - String TAG_PERSISTENCE_CONTEXT_SUPER_CLASS = "persistenceContextSuperClass"; + public static final String TAG_PERSISTENCE_CONTEXT_SUPER_CLASS = "persistenceContextSuperClass"; /** * Tag to specify a super class to use instead of @@ -356,12 +352,12 @@ * {@link org.nuiton.topia.persistence.internal.AbstractTopiaApplicationContext}. * * @see org.nuiton.topia.persistence.internal.AbstractTopiaApplicationContext - * @see TopiaGeneratorUtil#getApplicationContextSuperClassTagValue(org.nuiton.eugene.models.object.ObjectModel) + * @see #getApplicationContextSuperClassTagValue(org.nuiton.eugene.models.object.ObjectModel) * @since 3.0 */ @TagValueDefinition(target = {ObjectModel.class}, documentation = "Change the super class to use when generating ApplicationContext.") - String TAG_APPLICATION_CONTEXT_SUPER_CLASS = "applicationContextSuperClass"; + 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}. @@ -369,12 +365,12 @@ * <strong>Note:</strong> the class must implements {@link org.nuiton.topia.persistence.TopiaDao}. * * @see org.nuiton.topia.persistence.internal.AbstractTopiaDao - * @see TopiaGeneratorUtil#getDaoSuperClassTagValue(org.nuiton.eugene.models.object.ObjectModelClassifier, org.nuiton.eugene.models.object.ObjectModel) + * @see #getDaoSuperClassTagValue(org.nuiton.eugene.models.object.ObjectModelClassifier, org.nuiton.eugene.models.object.ObjectModel) * @since 3.0 */ @TagValueDefinition(target = {ObjectModelClassifier.class, ObjectModel.class}, documentation = "Change the super class to use when generating dao.") - String TAG_DAO_SUPER_CLASS = "daoSuperClass"; + 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}. @@ -382,12 +378,12 @@ * <strong>Note:</strong> the class must implements {@link org.nuiton.topia.persistence.TopiaEntity}. * * @see org.nuiton.topia.persistence.TopiaEntity - * @see TopiaGeneratorUtil#getEntitySuperClassTagValue(org.nuiton.eugene.models.object.ObjectModelClassifier, org.nuiton.eugene.models.object.ObjectModel) + * @see #getEntitySuperClassTagValue(org.nuiton.eugene.models.object.ObjectModelClassifier, org.nuiton.eugene.models.object.ObjectModel) * @since 3.0 */ @TagValueDefinition(target = {ObjectModelClassifier.class, ObjectModel.class}, documentation = "Change the super class to use when generating Entity.") - String TAG_ENTITY_SUPER_CLASS = "entitySuperClass"; + public static final String TAG_ENTITY_SUPER_CLASS = "entitySuperClass"; /** * Tag to change the type of an attribute in a hibernate mapping. @@ -406,12 +402,424 @@ * <p/> * The new way permits us to validate the usage of the tagValue, old way can't. * - * @see TopiaGeneratorUtil#getHibernateAttributeType(ObjectModelAttribute, ObjectModelClassifier, ObjectModel) + * @see #getHibernateAttributeType(ObjectModelAttribute, ObjectModelClassifier, ObjectModel) * @since 3.0 */ @TagValueDefinition(target = {ObjectModelAttribute.class, ObjectModelClassifier.class, ObjectModel.class}, documentation = "Change the super class to use when generating Entity.", - matcherClass = PrefixTagNameMatchTagValueMatcher.class) - String TAG_HIBERNATE_ATTRIBUTE_TYPE = "hibernateAttributeType"; + matcherClass = StartsWithTagNameMatcher.class) + public static final String TAG_HIBERNATE_ATTRIBUTE_TYPE = "hibernateAttributeType"; + /** + * 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 static String getPersistenceTypeTagValue(ObjectModelClassifier classifier) { + String value = TagValues.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 + * @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 static String getInheritanceStrategyTagValue(ObjectModelClassifier classifier) { + String value = TagValues.findTagValue(TAG_INHERITANCE_STRATEGY, classifier); + return value; + } + + /** + * Obtain the value of the {@link #TAG_DB_NAME} tag value on the given classifier. + * + * @param element classifier 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 static String getDbNameTagValue(ObjectModelElement element) { + String value = TagValues.findTagValue(TAG_DB_NAME, element); + return value; + } + + /** + * Obtain the value of the {@link #TAG_SCHEMA_NAME} tag value on the given classifier. + * + * @param classifier classifier 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 static String getDbSchemaNameTagValue(ObjectModelClassifier classifier, ObjectModel model) { + String value = TagValues.findTagValue(TAG_SCHEMA_NAME, classifier, model); + return value; + } + + /** + * Obtain the value of the {@link #TAG_SCHEMA_NAME} tag value on the given attribute. + * + * @param attribute attribute 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 static String getDbSchemaNameTagValue(ObjectModelAttribute attribute, ObjectModel model) { + String value = TagValues.findTagValue(TAG_SCHEMA_NAME, attribute, model); + 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 static String getLengthTagValue(ObjectModelAttribute attribute) { + String value = TagValues.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 static String getAnnotationTagValue(ObjectModelAttribute attribute) { + String value = TagValues.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 static String getAccessTagValue(ObjectModelAttribute attribute) { + String value = TagValues.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 static boolean getNaturalIdTagValue(ObjectModelAttribute attribute) { + boolean value = TagValues.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 static boolean getNaturalIdMutableTagValue(ObjectModelClassifier classifier) { + boolean value = TagValues.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 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 static boolean getContextableTagValue(ObjectModelClassifier classifier, ObjectModel model) { + boolean value = TagValues.findBooleanTagValue(TAG_CONTEXTABLE, classifier, 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 static String getInverseTagValue(ObjectModelAttribute attribute) { + String value = TagValues.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 static String getLazyTagValue(ObjectModelAttribute attribute) { + String value = TagValues.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 static String getFetchTagValue(ObjectModelAttribute attribute) { + String value = TagValues.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 static String getOrderByTagValue(ObjectModelAttribute attribute) { + String value = TagValues.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 static Boolean getNotNullTagValue(ObjectModelAttribute attribute) { + Boolean value = TagValues.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 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 static String getProxyInterfaceTagValue(ObjectModelClassifier classifier, ObjectModel model) { + String value = TagValues.findTagValue(TAG_PROXY_INTERFACE, classifier, 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 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 static boolean getNotGenerateToStringTagValue(ObjectModelClassifier clazz, ObjectModel model) { + boolean value = TagValues.findBooleanTagValue(TAG_NOT_GENERATE_TO_STRING, clazz, model); + return value; + } + + /** + * Obtain the value of the {@link #TAG_SORT_ATTRIBUTE} tag value on the given classifier. + * + * @param classifier classifier 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_SORT_ATTRIBUTE + * @since 2.5 + */ + public static boolean getSortAttributeTagValue(ObjectModelClassifier classifier, ObjectModel model) { + boolean value = TagValues.findBooleanTagValue(TAG_SORT_ATTRIBUTE, classifier, model); + return value; + } + + /** + * Obtain the value of the {@link #TAG_HIBERNATE_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_HIBERNATE_ATTRIBUTE_TYPE + * @since 3.0 + */ + + public static String getHibernateAttributeType(ObjectModelAttribute attribute, ObjectModelClassifier classifier, ObjectModel model) { + String tagValueName = TAG_HIBERNATE_ATTRIBUTE_TYPE + "." + attribute.getType(); + String value = TagValues.findTagValue(tagValueName, attribute, classifier, 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 static String getSqlTypeTagValue(ObjectModelAttribute attribute) { + String value = TagValues.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 static String getDaoImplementationTagValue(ObjectModel model) { + String value = TagValues.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 + * @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 static String getIndexForeignKeysTagValue(ObjectModelAttribute attribute, ObjectModel model) { + String value = TagValues.findTagValue(TAG_INDEX_FOREIGN_KEYS, attribute, model); + return value; + } + + //TODO Javadoc + public static boolean hasUseEnumerationNameTagValue(ObjectModelAttribute attr, ObjectModelClassifier classifier, ObjectModel model) { + boolean value = TagValues.findBooleanTagValue(TAG_USE_ENUMERATION_NAME, attr, classifier, model); + return value; + } + + /** + * Search if the TagValue {@link #TAG_GENERATE_TOPIA_ID_IN_DTO} has been activated in the model. + * + * @param classifier classifier 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_GENERATE_TOPIA_ID_IN_DTO + * @since 2.6.7 + */ + public static boolean shouldGenerateDTOTopiaIdTagValue(ObjectModelClassifier classifier, ObjectModel model) { + boolean value = TagValues.findBooleanTagValue(TAG_GENERATE_TOPIA_ID_IN_DTO, classifier, 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 static String getPersistenceContextSuperClassTagValue(ObjectModel model) { + String value = TagValues.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 static String getApplicationContextSuperClassTagValue(ObjectModel model) { + String value = TagValues.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 + * @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 static String getDaoSuperClassTagValue(ObjectModelClassifier classifier, ObjectModel model) { + String value = TagValues.findTagValue(TAG_DAO_SUPER_CLASS, classifier, 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 + * @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 static String getEntitySuperClassTagValue(ObjectModelClassifier classifier, ObjectModel model) { + String value = TagValues.findTagValue(TAG_ENTITY_SUPER_CLASS, classifier, 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 static boolean getGenerateOperatorForDAOHelperTagValue(ObjectModel model) { + boolean value = TagValues.findBooleanTagValue(TAG_GENERATE_OPERATOR_FOR_DAO_HELPER, 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, ObjectModel)} + */ + @Deprecated + public static String getTypeTagValue(ObjectModelAttribute attribute) { + String value = TagValues.findTagValue(TAG_TYPE, attribute); + return value; + } } Deleted: trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.metas.ModelPropertiesProvider =================================================================== --- trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.metas.ModelPropertiesProvider 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.metas.ModelPropertiesProvider 2014-04-27 13:36:11 UTC (rev 3086) @@ -1 +0,0 @@ -org.nuiton.topia.templates.TopiaModelPropertiesProvider \ No newline at end of file Added: trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider =================================================================== --- trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider (rev 0) +++ trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider 2014-04-27 13:36:11 UTC (rev 3086) @@ -0,0 +1 @@ +org.nuiton.topia.templates.TopiaStereoTypes \ No newline at end of file Added: trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider =================================================================== --- trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider (rev 0) +++ trunk/topia-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider 2014-04-27 13:36:11 UTC (rev 3086) @@ -0,0 +1 @@ +org.nuiton.topia.templates.TopiaTagValues \ No newline at end of file Deleted: trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaModelPropertiesProviderTest.java =================================================================== --- trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaModelPropertiesProviderTest.java 2014-04-27 06:22:24 UTC (rev 3085) +++ trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaModelPropertiesProviderTest.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -1,80 +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.metas.ModelPropertiesProvider; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelOperation; - -/** - * To test {@link TopiaModelPropertiesProvider}. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.3 - */ -public class TopiaModelPropertiesProviderTest { - - protected ModelPropertiesProvider provider; - - @Before - public void setUp() throws Exception { - provider = new TopiaModelPropertiesProvider(); - provider.init(); - } - - @Test - public void testGetTagValueTarget() throws Exception { - testTagValue(TopiaTagValues.TAG_PERSISTENCE_TYPE, ObjectModelClassifier.class); - //TODO Finish with other tag values... - } - - @Test - public void testGetStereotypeTarget() throws Exception { - - testStereotype(TopiaStereoTypes.STEREOTYPE_DAO, ObjectModelClassifier.class, ObjectModelOperation.class); - //TODO Finish with other stereotypes... - } - - @Test - public void testGetStore() throws Exception { - } - - protected void testStereotype(String name, Class<?>... expected) { - Class<?>[] classes = provider.getStereotypeTarget(name); - Assert.assertNotNull("Could not find target for " + name, classes); - Assert.assertEquals("Should have " + expected.length + " targets for " + name + " but had " + classes.length, classes.length, expected.length); - Assert.assertArrayEquals(expected, classes); - } - - protected void testTagValue(String name, Class<?>... expected) { - Class<?>[] classes = provider.getTagValueTarget(name); - Assert.assertNotNull("Could not find target for " + name, classes); - Assert.assertEquals("Should have " + expected.length + " targets for " + name + " but had " + classes.length, classes.length, expected.length); - Assert.assertArrayEquals(expected, classes); - } -} Added: trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaStereoTypesTest.java =================================================================== --- trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaStereoTypesTest.java (rev 0) +++ trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaStereoTypesTest.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -0,0 +1,32 @@ +package org.nuiton.topia.templates; + +import org.junit.Assert; +import org.junit.Before; +import org.nuiton.eugene.models.stereotype.MismatchStereotypeTargetException; +import org.nuiton.eugene.models.stereotype.StereotypeNotFoundException; + +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 Property changes on: trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaStereoTypesTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaTagValuesTest.java =================================================================== --- trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaTagValuesTest.java (rev 0) +++ trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaTagValuesTest.java 2014-04-27 13:36:11 UTC (rev 3086) @@ -0,0 +1,32 @@ +package org.nuiton.topia.templates; + +import org.junit.Assert; +import org.junit.Before; +import org.nuiton.eugene.models.tagvalue.MismatchTagValueTargetException; +import org.nuiton.eugene.models.tagvalue.TagValueNotFoundException; + +public class TopiaTagValuesTest { + + protected TopiaTagValues provider; + + @Before + public void setUp() throws Exception { + provider = new TopiaTagValues(); + provider.init(); + } + + + 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 Property changes on: trunk/topia-templates/src/test/java/org/nuiton/topia/templates/TopiaTagValuesTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native
participants (1)
-
tchemit@users.nuiton.org