Author: tchemit Date: 2010-11-27 18:52:09 +0100 (Sat, 27 Nov 2010) New Revision: 2154 Url: http://nuiton.org/repositories/revision/topia/2154 Log: Evolution #1108: Introduce contracts *TopiaTagValues* (*TopiaStereoTypes*) to push all constants about tagvalues (stereotypes) usable in topia generators. Evolution #1104: Add a tagvalue commit for operation in ServiceTransformer to auto commit at the end of the executeXXX method Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaStereoTypes.java trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2010-11-27 15:58:11 UTC (rev 2153) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2010-11-27 17:52:09 UTC (rev 2154) @@ -26,10 +26,8 @@ package org.nuiton.topia.generator; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; -import java.util.TreeMap; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DurationFormatUtils; @@ -179,11 +177,6 @@ * </div> * <p>It is smooth, isn't it :p ?</p> * <p> - * TODO : may be refactor to integrate JTA or webservice or may be not in this transformer. - * </p> - * <p> - * TODO : find a good way to change log level - * </p> * * Created: 23 mars 2010 * @@ -192,8 +185,12 @@ * @since 2.3.1 * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.topia.generator.ServiceTransformer" */ +//TODO : find a good way to change log level +// TODO : may be refactor to integrate JTA or webservice or may be not in this transformer. public class ServiceTransformer extends ObjectModelTransformerToJava { + + private static final Log log = LogFactory.getLog(ServiceTransformer.class); protected String modelName; protected String defaultPackageName; @@ -210,10 +207,14 @@ private static final String OP_NAME_BEGIN_TRANSACTION = "beginTransaction"; + private static final String OP_NAME_COMMIT_TRANSACTION = "commitTransaction"; + private static final String OP_NAME_CLOSE_TRANSACTION = "closeTransaction"; private static final String OP_NAME_TREATE_ERROR = "treateError"; + public static final String PARAMETER_TRANSACTION = "transaction"; + protected String getServiceAbstractClassName(String serviceName) { return serviceName + "Abstract"; } @@ -236,8 +237,7 @@ boolean needTransaction = isTransactionNeeded(input); boolean noLog = this.noLog || isNoLog(input,null); - ObjectModelInterface serviceContract = - createServiceContract(input); + ObjectModelInterface serviceContract = createServiceContract(input); createServiceAbstract(input, serviceContract, @@ -288,23 +288,43 @@ protected void createBeginTransactionMethod(ObjectModelInterface source, ObjectModelInterface serviceContract, ObjectModelClass serviceAbstract) { - ObjectModelOperation beginTransaction = + ObjectModelOperation operation = addOperation(serviceAbstract, OP_NAME_BEGIN_TRANSACTION, TopiaContext.class, ObjectModelModifier.ABSTRACT, ObjectModelModifier.PROTECTED); - addException(beginTransaction, TopiaException.class); + addException(operation, TopiaException.class); } + protected void createCommitTransactionMethod(ObjectModelInterface source, + ObjectModelInterface serviceContract, + ObjectModelClass serviceAbstract) { + ObjectModelOperation operation = + addOperation(serviceAbstract, + OP_NAME_COMMIT_TRANSACTION, + "void", + ObjectModelModifier.PROTECTED); + addParameter(operation, TopiaContext.class, PARAMETER_TRANSACTION); + addException(operation, TopiaException.class); + setOperationBody(operation,"" +/*{ + transaction.commitTransaction(); +}*/ + ); + + } + protected void createCloseTransactionMethod(ObjectModelInterface source, ObjectModelInterface serviceContract, ObjectModelClass serviceAbstract) { - ObjectModelOperation closeTransaction = - addOperation(serviceAbstract, OP_NAME_CLOSE_TRANSACTION, "void", + ObjectModelOperation operation = + addOperation(serviceAbstract, + OP_NAME_CLOSE_TRANSACTION, + "void", ObjectModelModifier.ABSTRACT, ObjectModelModifier.PROTECTED); - addParameter(closeTransaction, TopiaContext.class, "transaction"); - addException(closeTransaction, TopiaException.class); + addParameter(operation, TopiaContext.class, PARAMETER_TRANSACTION); + addException(operation, TopiaException.class); } protected void createTreateErrorMethod(ObjectModelInterface source, @@ -313,11 +333,13 @@ boolean needTransaction) { ObjectModelOperation treateError1 = - addOperation(serviceAbstract, OP_NAME_TREATE_ERROR, "void", - ObjectModelModifier.ABSTRACT, - ObjectModelModifier.PROTECTED); + addOperation(serviceAbstract, + OP_NAME_TREATE_ERROR, + "void", + ObjectModelModifier.ABSTRACT, + ObjectModelModifier.PROTECTED); if (needTransaction) { - addParameter(treateError1, TopiaContext.class, "transaction"); + addParameter(treateError1, TopiaContext.class, PARAMETER_TRANSACTION); } addParameter(treateError1, Exception.class, "eee"); addParameter(treateError1, String.class, "message"); @@ -394,6 +416,10 @@ createBeginTransactionMethod(source, serviceContract, serviceAbstract); + + createCommitTransactionMethod(source, + serviceContract, + serviceAbstract); createCloseTransactionMethod(source, serviceContract, @@ -473,7 +499,7 @@ addException(executeOperation, Exception.class); if (needTransaction && isTransactionNeeded(source)) { - addParameter(executeOperation, TopiaContext.class, "transaction"); + addParameter(executeOperation, TopiaContext.class, PARAMETER_TRANSACTION); } if (isErrorArgsNeeded(source)) { @@ -525,9 +551,11 @@ // Implementation of interface operation ObjectModelOperation implOp = - addOperation(serviceAbstract, source.getName(), - source.getReturnType(), - ObjectModelModifier.PUBLIC); + addOperation(serviceAbstract, + source.getName(), + source.getReturnType(), + ObjectModelModifier.PUBLIC); + addAnnotation(serviceAbstract, implOp, Override.class.getSimpleName()); String toStringAppend = ""; @@ -604,17 +632,12 @@ }*/ ); } - if (noLog) { - buffer.append("" - /*{ - <%=abstReturnType%><%=abstName%>(<%=abstParams%>); - <%=abstReturn%> - }*/); - } else { String implName = StringUtils.capitalize(implOp.getName()); String first = modelName.substring(0, 1); + + if (!noLog) { - buffer.append("" + buffer.append("" /*{ long startTime = 0; if (log.isDebugEnabled()) { @@ -626,8 +649,18 @@ toString(); log.trace(message); } + }*/); + } - <%=abstReturnType%><%=abstName%>(<%=abstParams%>); + buffer.append("" + /*{ + <%=abstReturnType%><%=abstName%>(<%=abstParams%>);}*/); + + if (!noLog) { + + buffer.append("" + /*{ + if (log.isDebugEnabled()) { long stopTime = System.currentTimeMillis(); Runtime runtime = Runtime.getRuntime(); @@ -635,9 +668,21 @@ log.debug("<%=first%>:[ end <%=implName%> ] Time = " + DurationFormatUtils.formatDurationHMS( stopTime - startTime) + " _ Memory = " + mem + " Mo"); - } - <%=abstReturn%> }*/); + }}*/ + ); } + if (needTransaction && isCommit(source, model)) { + + // add the commit instruction + buffer.append("" + /*{ + commitTransaction(transaction);}*/); + + } + buffer.append("" + /*{ + <%=abstReturn%>}*/); + if (needTransaction) { // Finally block to close transaction buffer.append("" @@ -685,7 +730,7 @@ * on the method from model. * * @param op where the tagvalue is set - * @return true if transaction is needed + * @return {@code true} if transaction is needed */ protected boolean isTransactionNeeded(ObjectModelElement op) { boolean needTransaction = true; @@ -696,6 +741,9 @@ if (transactionTag != null) { needTransaction = Boolean.parseBoolean(transactionTag); } + if (isVerbose()) { + log.info("transaction needed for op [" + op.getName() + "] : " + needTransaction); + } return needTransaction; } @@ -704,7 +752,7 @@ * * @param op model element where the tagvalue is set * @param model model where to tagvalue can be also set - * @return true if no log will be generated insde body's method + * @return {@code true} if no log will be generated insde body's method * @see TopiaGeneratorUtil#TAG_NO_LOG_IN_SERVICE */ protected boolean isNoLog(ObjectModelElement op, ObjectModel model) { @@ -723,6 +771,32 @@ } /** + * boolean to specify if method needs a commit after the executeXXX code invoked. + * + * @param op model element where the tagvalue is set + * @param model model where to tagvalue can be also set + * @return {@code true} if a commit must be generated after the executeXXX invocation + * @see TopiaGeneratorUtil#TAG_DO_COMMIT + * @since 2.4.4 + */ + protected boolean isCommit(ObjectModelElement op, ObjectModel model) { + boolean needCommit = false; + + String tagValue = GeneratorUtil.findTagValue( + TopiaGeneratorUtil.TAG_DO_COMMIT, + op, + model + ); + if (tagValue != null) { + needCommit = Boolean.parseBoolean(tagValue); + } + if (isVerbose()) { + log.info("commit needed for op [" + op.getName() + "] : " + needCommit); + } + return needCommit; + } + + /** * boolean to specify if the method need error arguments or not * Default set to false but can be override using a tagvalue "errorArgs" on * the method from model. Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java 2010-11-27 15:58:11 UTC (rev 2153) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java 2010-11-27 17:52:09 UTC (rev 2154) @@ -23,21 +23,8 @@ * #L% */ -/******************************************************************************* - * GeneratorUtil.java - * - * Created: 13 déc. 2005 - * - * @author Arnaud Thimel <thimel@codelutin.com> - * - * @version $Revision$ - * - * Mise a jour: $Date$ par : $Author$ - */ package org.nuiton.topia.generator; -import java.util.*; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.eugene.AbstractGenerator; @@ -52,237 +39,63 @@ import org.nuiton.eugene.models.object.ObjectModelInterface; import org.nuiton.eugene.models.object.ObjectModelOperation; import org.nuiton.eugene.models.object.ObjectModelParameter; -import org.nuiton.topia.persistence.TopiaEntityEnum; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + /** * Classe regroupant divers méthodes utiles pour la génération des entités * + * Created: 13 déc. 2005 + * + * @author Arnaud Thimel <thimel@codelutin.com> + * + * @version $Revision$ + * + * Mise a jour: $Date$ par : $Author$ + * * @author tchemit <tchemit@codelutin.com> * @author fdesbois <fdesbois@codelutin.com> * @author chatellier <chatellier@codelutin.com> * @author thimel <thimel@codelutin.com> * @version $Id$ */ -public class TopiaGeneratorUtil extends JavaGeneratorUtil { +public class TopiaGeneratorUtil extends JavaGeneratorUtil implements TopiaTagValues, TopiaStereoTypes { - /** - * Logger - */ + /** Logger */ private static final Log log = LogFactory.getLog(TopiaGeneratorUtil.class); /** - * Stéréotype pour les interfaces devant être générées sous forme de facades - */ - public final static String STEREOTYPE_FACADE = "facade"; - /** - * Stéréotype pour les objets devant être générées sous forme d'entités - */ - public static final String STEREOTYPE_ENTITY = "entity"; - /** - * Stéréotype pour les objets devant être générées sous forme de DTO - */ - public static final String STEREOTYPE_DTO = "dto"; - /** - * Stéréotype pour les objets devant être générées sous forme de bean - * @deprecated since 2.3.4, prefer use the - * {@link JavaGeneratorUtil#STEREOTYPE_BEAN} method. - */ - @Deprecated - public static final String STEREOTYPE_BEAN = "bean"; - /** - * Stéréotype pour les interfaces devant être générées sous forme de - * services - */ - public static final String STEREOTYPE_SERVICE = "service"; - /** - * Stéréotype pour les interfaces devant être générées sous forme de DAO - */ - public static final String STEREOTYPE_DAO = "dao"; - /** - * Stéréotype pour les attributs à indexer en base - */ - public static final String STEREOTYPE_INDEXED = "indexed"; - /** - * Stéréotype pour les collections avec unicité - */ - public static final String STEREOTYPE_UNIQUE = "unique"; - /** - * Stéréotype pour les attributs étant des clés primaires - */ - public static final String STEREOTYPE_PRIMARYKAY = "primaryKey"; - /** - * Stéréotype pour les attributs considérés comme des tableaux - */ - public static final String STEREOTYPE_ARRAY = "array"; - /** * dependency to add extra operations for entity dao. + * * @since 2.3.4 */ public static final String DEPENDENCIES_DAO = "dao"; - /** - * Tag pour le type de persistence - */ - public static final String TAG_PERSISTENCE_TYPE = "persistenceType"; - /** - * Tag pour le nom du champ / entité en BD - */ - public static final String TAG_DB_NAME = "dbName"; - /** - * Tag pour le nom du schema en BD - */ - public static final String TAG_SCHEMA_NAME = "dbSchema"; - /** - * Tag pour la taille du champ en BD - */ - public static final String TAG_LENGTH = "length"; - /** - * Tag pour ajouter une annotation à un champ - */ - public static final String TAG_ANNOTATION = "annotation"; - /** - * Tag pour ajouter specifier le copyright d'un fichier - */ - public static final String TAG_COPYRIGHT = "copyright"; - /** - * Tag pour specfier le type d'acces a un champ - */ - public static final String TAG_ACCESS = "access"; - /** - * Tag pour specfier si on doit générer i18n - */ - public static final String TAG_I18N_PREFIX = "i18n"; - /** - * Tag pour ajouter un attribut dans une clef métier - */ - public static final String TAG_NATURAL_ID = "naturalId"; - /** - * Tag pour specifier si une clef metier est mutable - */ - public static final String TAG_NATURAL_ID_MUTABLE = "naturalIdMutable"; - /** - * Tag pour specifier si une methode a besoin d'une transaction - * (TopiaContext) ou non - * @since 2.3.1 - */ - public static final String TAG_TRANSACTION = "transaction"; - /** - * Tag pour specifier si une methode de service a besoin d'arguments pour - * le message d'erreur ou non - * @since 2.3.1 - */ - public static final String TAG_ERROR_ARGS = "errorArgs"; - /** - * Tag pour specifier l'exception principale de l'application. - * Utiliser dans le ServiceTransformer pour etre automatiquement jeter - * depuis les methodes des services. - * @since 2.3.2 - */ - public static final String TAG_EXCEPTION_CLASS = "exceptionClass"; - /** - * Tag pour permettre de choisir qui contrôle la relation N-N - * bidirectionnelle. A utiliser sur les deux extremités de l'association. - * Mettre inverse=false sur le rôle fils et inverse=true sur le rôle père. - * Par défaut le inverse=true est placé sur le premier rôle trouvé dans - * l'ordre alphabétique. - * @since 2.3.2 - */ - public static final String TAG_INVERSE = "inverse"; - /** - * Tag pour spécifier la caractère lazy d'une association multiple - */ - public static final String TAG_LAZY = "lazy"; - /** - * Tag pour spécifier la caractère fetch d'une association multiple - */ - public static final String TAG_FETCH = "fetch"; - /** - * Tag pour spécifier la caractère order-by d'une association multiple - */ - public static final String TAG_ORDER_BY = "orderBy"; - /** - * Tag pour spécifier la caractère not-null d'un attribut - */ - public static final String TAG_NOT_NULL = "notNull"; - /** - * Tag pour spécifier la caractère embed-xml d'une association - */ - public static final String TAG_EMBED_XML = "embedXml"; - /** - * Tag pour configurer l'interface du proxy sur autre chose que l'implementation par defaut. - * <p/> - * Par defaut : - * null > generere le proxy sur l'interface de l'implementation - * Autre valeur : - * "none" > laisse la configuration par defaut d'hibernate - */ - public static final String TAG_PROXY_INTERFACE = "hibernateProxyInterface"; - /** - * Tag pour spécifier le permissions à la création - */ - public static final String TAG_SECURITY_CREATE = "securityCreate"; - /** - * Tag pour spécifier le permissions au chargement - */ - public static final String TAG_SECURITY_LOAD = "securityLoad"; - /** - * Tag pour spécifier le permissions à la mise à jour - */ - public static final String TAG_SECURITY_UPDATE = "securityUpdate"; - /** - * Tag pour spécifier le permissions à la suppression - */ - public static final String TAG_SECURITY_DELETE = "securityDelete"; - /** - * Tag pour specifier de ne pas generer la methode toString - */ - public static final String TAG_NOT_GENERATE_TO_STRING = "notGenerateToString"; - /** - * Tag pour specifier de trier les attributs par nom lors de la generation - */ - public static final String TAG_SORT_ATTRIBUTE = "sortAttribute"; - /** - * Tag pour specfier si on doit générer la methode getOperator dans les daohelpers ) - */ - public static final String TAG_GENERATE_OPERATOR_FOR_DAO_HELPER = "generateOperatorForDAOHelper"; - /** - * Tag pour spécifier si on doit générer le {@link TopiaEntityEnum} en tant qu'inner classe - * du dao helper ou pas. - * - * <b>Note:</b> Par défaut, on génère en tant qu'inner classe. - * @since 2.4.1 - */ - public static final String TAG_GENERATE_STANDALONE_ENUM_FOR_DAO_HELPER = "generateStandaloneEnumForDAOHelper"; - /** - * Tag pour spécifier le type d'une propriété dans le mapping hibernate - */ - public static final String TAG_TYPE= "type"; - /** - * Tag to specify if we want to add logs in any method of service generated by {@link ServiceTransformer}. - * - * <b>Note:</b> To have no log just use this tag on services or gloabally on model (for all services). - * @since 2.4.4 - */ - public static final String TAG_NO_LOG_IN_SERVICE = "noLogInService"; - /** - * Type de persistence Hibernate - */ + /** Type de persistence Hibernate */ public static final String PERSISTENCE_TYPE_HIBERNATE = "hibernate"; - /** - * Type de persistence LDAP - */ + + /** Type de persistence LDAP */ public static final String PERSISTENCE_TYPE_LDAP = "ldap"; - /** - * Type de persistence par défaut (si aucun précisé) - */ + + /** Type de persistence par défaut (si aucun précisé) */ public static final String PERSISTENCE_TYPE_DEFAULT = PERSISTENCE_TYPE_HIBERNATE; - /** - * Propriété des générateurs indiquant le package par défaut - */ + + /** Propriété des générateurs indiquant le package par défaut */ public static final String PROPERTY_DEFAULT_PACKAGE = "defaultPackage"; - /** - * Le package par défaut si aucun n'est spécifié - */ + + /** Le package par défaut si aucun n'est spécifié */ public static final String DEFAULT_PACKAGE = "org.codelutin.malo"; /** @@ -299,24 +112,6 @@ return packageName; } -// /** -// * @see GeneratorUtil#hasDocumentation -// * @deprecated -// */ -// @Deprecated -// public static boolean hasDocumentation(ObjectModelElement element) { -// return notEmpty(element.getDocumentation()); -// } - -// /** -// * @see GeneratorUtil#notEmpty -// * @deprecated -// */ -// @Deprecated -// public static boolean notEmpty(String s) { -// return (s != null && !"".equals(s)); -// } - /** * Renvoie l'interface DAO associée à la classe passée en paramètre * @@ -403,7 +198,6 @@ public static String getI18nPrefix(ObjectModelElement element, ObjectModel model) { return JavaGeneratorUtil.getI18nPrefix(element, model); -// return GeneratorUtil.findTagValue(TAG_I18N_PREFIX, element, model); } /** @@ -413,7 +207,7 @@ * @param element l'élément à tester * @param model le modele utilisé * @return {@code true} si le tag value trouvé dans le modèle, {@code false} - * sinon. + * sinon. */ public static boolean shouldgenerateOperatorForDAOHelper( ObjectModelElement element, @@ -421,7 +215,7 @@ String tagValue = GeneratorUtil.findTagValue( TAG_GENERATE_OPERATOR_FOR_DAO_HELPER, element, model); boolean generate = GeneratorUtil.notEmpty(tagValue) && - Boolean.valueOf(tagValue); + Boolean.valueOf(tagValue); return generate; } @@ -432,7 +226,7 @@ * @param element l'élément à tester * @param model le modele utilisé * @return {@code true} si le tag value trouvé dans le modèle, {@code false} - * sinon. + * sinon. * @since 2.4.1 */ public static boolean shouldGnerateStandaloneEnumForDAOHelper( @@ -441,7 +235,7 @@ String tagValue = GeneratorUtil.findTagValue( TAG_GENERATE_STANDALONE_ENUM_FOR_DAO_HELPER, element, model); boolean generate = GeneratorUtil.notEmpty(tagValue) && - Boolean.valueOf(tagValue); + Boolean.valueOf(tagValue); return generate; } @@ -498,7 +292,7 @@ String value; value = clazz.getTagValue(TAG_SORT_ATTRIBUTE); if (value == null || value.trim().isEmpty() || - "false".equals(value.trim())) { + "false".equals(value.trim())) { return false; } if ("true".equals(value.trim())) { @@ -507,7 +301,7 @@ value = model.getTagValue(TAG_SORT_ATTRIBUTE); if (value == null || value.trim().isEmpty() || - "false".equals(value.trim())) { + "false".equals(value.trim())) { return false; } if ("true".equals(value.trim())) { @@ -596,7 +390,7 @@ String attributes = ""; Collection<ObjectModelAttribute> attributeCollection; attributeCollection = getElementsWithStereotype(clazz.getAttributes(), - STEREOTYPE_PRIMARYKAY); + STEREOTYPE_PRIMARYKAY); for (ObjectModelAttribute attr : attributeCollection) { attributes += attr.getType(); if (includeName) { @@ -618,7 +412,7 @@ return attr.getReverseAttribute() != null && attr.getDeclaringElement().equals( attr.getReverseAttribute().getDeclaringElement()) && - (!GeneratorUtil.isFirstAttribute(attr)); + !GeneratorUtil.isFirstAttribute(attr); } public static String getDOType(ObjectModelElement elem, ObjectModel model) { @@ -648,9 +442,13 @@ } private static final Set<String> numberTypes = new HashSet<String>(); + private static final Set<String> textTypes = new HashSet<String>(); + private static final Set<String> booleanTypes = new HashSet<String>(); + private static final Set<String> primitiveTypes = new HashSet<String>(); + private static final String VOID_TYPE = "void"; static { @@ -733,7 +531,7 @@ */ public static boolean shouldBeAbstract(ObjectModelClass clazz) { return clazz != null && clazz.isAbstract() && - hasNothingOrAbstractMethods(clazz); + hasNothingOrAbstractMethods(clazz); } /** @@ -757,7 +555,7 @@ ObjectModelAttribute reverse = attr.getReverseAttribute(); //relation 1-n if (reverse != null && isNMultiplicity(attr) && - !isNMultiplicity(reverse)) { + !isNMultiplicity(reverse)) { //Pas de navigabilité if (!reverse.isNavigable()) { //Il s'agit d'une entity Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaStereoTypes.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaStereoTypes.java (rev 0) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaStereoTypes.java 2010-11-27 17:52:09 UTC (rev 2154) @@ -0,0 +1,41 @@ +package org.nuiton.topia.generator; + +/** + * All extra stereotypes usable in topia generators. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.4.4 + */ +public interface TopiaStereoTypes { + + /** Stéréotype pour les interfaces devant être générées sous forme de facades */ + String STEREOTYPE_FACADE = "facade"; + + /** Stéréotype pour les objets devant être générées sous forme d'entités */ + String STEREOTYPE_ENTITY = "entity"; + + /** Stéréotype pour les objets devant être générées sous forme de DTO */ + String STEREOTYPE_DTO = "dto"; + + /** + * Stéréotype pour les interfaces devant être générées sous forme de + * services. + * @see ServiceTransformer + */ + String STEREOTYPE_SERVICE = "service"; + + /** Stéréotype pour les interfaces devant être générées sous forme de DAO */ + String STEREOTYPE_DAO = "dao"; + + /** Stéréotype pour les attributs à indexer en base */ + String STEREOTYPE_INDEXED = "indexed"; + + /** Stéréotype pour les collections avec unicité */ + String STEREOTYPE_UNIQUE = "unique"; + + /** Stéréotype pour les attributs étant des clés primaires */ + String STEREOTYPE_PRIMARYKAY = "primaryKey"; + + /** Stéréotype pour les attributs considérés comme des tableaux */ + String STEREOTYPE_ARRAY = "array"; +} Property changes on: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaStereoTypes.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java (rev 0) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java 2010-11-27 17:52:09 UTC (rev 2154) @@ -0,0 +1,165 @@ +package org.nuiton.topia.generator; + +import org.nuiton.topia.persistence.TopiaEntityEnum; + +/** + * All extra tag values usable in topia generators. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.4.4 + */ +public interface TopiaTagValues { + + /** Tag pour le type de persistence */ + String TAG_PERSISTENCE_TYPE = "persistenceType"; + + /** Tag pour le nom du champ / entité en BD */ + String TAG_DB_NAME = "dbName"; + + /** Tag pour le nom du schema en BD */ + String TAG_SCHEMA_NAME = "dbSchema"; + + /** Tag pour la taille du champ en BD */ + String TAG_LENGTH = "length"; + + /** Tag pour ajouter une annotation à un champ */ + String TAG_ANNOTATION = "annotation"; + + /** Tag pour ajouter specifier le copyright d'un fichier */ + String TAG_COPYRIGHT = "copyright"; + + /** Tag pour specfier le type d'acces a un champ */ + String TAG_ACCESS = "access"; + + /** Tag pour specfier si on doit générer i18n */ + String TAG_I18N_PREFIX = "i18n"; + + /** Tag pour ajouter un attribut dans une clef métier */ + String TAG_NATURAL_ID = "naturalId"; + + /** Tag pour specifier si une clef metier est mutable */ + String TAG_NATURAL_ID_MUTABLE = "naturalIdMutable"; + + /** + * Tag pour permettre de choisir qui contrôle la relation N-N + * bidirectionnelle. A utiliser sur les deux extremités de l'association. + * Mettre inverse=false sur le rôle fils et inverse=true sur le rôle père. + * Par défaut le inverse=true est placé sur le premier rôle trouvé dans + * l'ordre alphabétique. + * + * @since 2.3.2 + */ + String TAG_INVERSE = "inverse"; + + /** Tag pour spécifier la caractère lazy d'une association multiple */ + String TAG_LAZY = "lazy"; + + /** Tag pour spécifier la caractère fetch d'une association multiple */ + String TAG_FETCH = "fetch"; + + /** Tag pour spécifier la caractère order-by d'une association multiple */ + String TAG_ORDER_BY = "orderBy"; + + /** Tag pour spécifier la caractère not-null d'un attribut */ + String TAG_NOT_NULL = "notNull"; + + /** Tag pour spécifier la caractère embed-xml d'une association */ + String TAG_EMBED_XML = "embedXml"; + + /** + * Tag pour configurer l'interface du proxy sur autre chose que l'implementation par defaut. + * <p/> + * Par defaut : + * null > generere le proxy sur l'interface de l'implementation + * Autre valeur : + * "none" > laisse la configuration par defaut d'hibernate + */ + String TAG_PROXY_INTERFACE = "hibernateProxyInterface"; + + /** Tag pour spécifier le permissions à la création */ + String TAG_SECURITY_CREATE = "securityCreate"; + + /** Tag pour spécifier le permissions au chargement */ + String TAG_SECURITY_LOAD = "securityLoad"; + + /** Tag pour spécifier le permissions à la mise à jour */ + String TAG_SECURITY_UPDATE = "securityUpdate"; + + /** Tag pour spécifier le permissions à la suppression */ + String TAG_SECURITY_DELETE = "securityDelete"; + + /** Tag pour specifier de ne pas generer la methode toString */ + String TAG_NOT_GENERATE_TO_STRING = "notGenerateToString"; + + /** Tag pour specifier de trier les attributs par nom lors de la generation */ + String TAG_SORT_ATTRIBUTE = "sortAttribute"; + + /** Tag pour specfier si on doit générer la methode getOperator dans les daohelpers ) */ + String TAG_GENERATE_OPERATOR_FOR_DAO_HELPER = "generateOperatorForDAOHelper"; + + /** + * Tag pour spécifier si on doit générer le {@link TopiaEntityEnum} en tant qu'inner classe + * du dao helper ou pas. + * <p/> + * <b>Note:</b> Par défaut, on génère en tant qu'inner classe. + * + * @since 2.4.1 + */ + String TAG_GENERATE_STANDALONE_ENUM_FOR_DAO_HELPER = "generateStandaloneEnumForDAOHelper"; + + /** Tag pour spécifier le type d'une propriété dans le mapping hibernate */ + String TAG_TYPE = "type"; + + // ------------------------------------------------------------------------- + // ServiceTransformer specific tag values + // ------------------------------------------------------------------------- + + /** + * Tag pour specifier si une methode a besoin d'une transaction + * (TopiaContext) ou non + * + * @see ServiceTransformer + * @since 2.3.1 + */ + String TAG_TRANSACTION = "transaction"; + + /** + * Tag pour specifier si une methode a besoin d'un commit après son + * exécution. + * + * @see ServiceTransformer + * @since 2.4.4 + */ + String TAG_DO_COMMIT = "doCommit"; + + /** + * Tag pour specifier si une methode de service a besoin d'arguments pour + * le message d'erreur ou non + * + * @see ServiceTransformer + * @since 2.3.1 + */ + String TAG_ERROR_ARGS = "errorArgs"; + + /** + * Tag pour specifier l'exception principale de l'application. + * Utiliser dans le ServiceTransformer pour etre automatiquement jeter + * depuis les methodes des services. + * + * @see ServiceTransformer + * @since 2.3.2 + */ + String TAG_EXCEPTION_CLASS = "exceptionClass"; + + /** + * Tag to specify if we want to add logs in any method of service + * generated by {@link ServiceTransformer}. + * <p/> + * <b>Note:</b> To have no log just use this tag on services or gloabaly + * on model (for all services). + * + * @see ServiceTransformer + * @since 2.4.4 + */ + String TAG_NO_LOG_IN_SERVICE = "noLogInService"; +} Property changes on: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native