Author: tchemit Date: 2010-05-14 16:18:23 +0200 (Fri, 14 May 2010) New Revision: 1963 Url: http://nuiton.org/repositories/revision/topia/1963 Log: - introduce EntityTransformer to generate TopiaEntity api - clean code - rename clazz parameter to input Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityImplTransformer.java trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Abstract.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/package-info.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/FakeService.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/TestService.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/package-info.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -88,43 +88,43 @@ } @Override - public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { - String persistenceType = TopiaGeneratorUtil.getPersistenceType(clazz); - if (!clazz.hasStereotype(STEREOTYPE_ENTITY) && PERSISTENCE_TYPE_HIBERNATE.equals(persistenceType)) { + public void generateFromClass(Writer output, ObjectModelClass input) throws IOException { + String persistenceType = TopiaGeneratorUtil.getPersistenceType(input); + if (!input.hasStereotype(STEREOTYPE_ENTITY) && PERSISTENCE_TYPE_HIBERNATE.equals(persistenceType)) { return; } /*{<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> -<hibernate-mapping default-access="field" auto-import="true" package="<%=clazz.getPackageName()%>"> +<hibernate-mapping default-access="field" auto-import="true" package="<%=input.getPackageName()%>"> }*/ - boolean haveSuper = clazz.getSuperclasses().size() > 0; + boolean haveSuper = input.getSuperclasses().size() > 0; // la liste des attributs faisant parti de la clef metier List<ObjectModelAttribute> naturalAttributes = new ArrayList<ObjectModelAttribute>(); // la liste des autres attributs List<ObjectModelAttribute> noneNaturalAttributes = new ArrayList<ObjectModelAttribute>(); - String clazzDOType = TopiaGeneratorUtil.getDOType(clazz, model); - String tableName = TopiaGeneratorUtil.getDBName(clazz); - String isAbstract = BooleanUtils.toStringTrueFalse(clazz.isAbstract()); - String clazzFQN = clazz.getQualifiedName(); + String clazzDOType = TopiaGeneratorUtil.getDOType(input, model); + String tableName = TopiaGeneratorUtil.getDBName(input); + String isAbstract = BooleanUtils.toStringTrueFalse(input.isAbstract()); + String clazzFQN = input.getQualifiedName(); String optionalAttributes = ""; - String schema = TopiaGeneratorUtil.getSchemaName(clazz, model); + String schema = TopiaGeneratorUtil.getSchemaName(input, model); if (schema != null) { optionalAttributes += "schema=\"" + schema + "\" "; } //On précise au proxy de quelle interface hérite l'objet - String proxyTagValue = TopiaGeneratorUtil.findTagValue(TopiaGeneratorUtil.TAG_PROXY_INTERFACE, clazz, model); + String proxyTagValue = TopiaGeneratorUtil.findTagValue(TopiaGeneratorUtil.TAG_PROXY_INTERFACE, input, model); if (proxyTagValue == null || !proxyTagValue.equals("none")) { optionalAttributes += "proxy=\"" + clazzFQN + "\" "; } if (haveSuper) { - ObjectModelClass superClass = clazz.getSuperclasses().iterator().next(); + ObjectModelClass superClass = input.getSuperclasses().iterator().next(); String superClassname = superClass.getQualifiedName(); if (log.isDebugEnabled()) { - log.debug("superClass for " + clazz.getQualifiedName() + " is " + superClassname); + log.debug("superClass for " + input.getQualifiedName() + " is " + superClassname); } String superClassDOType = TopiaGeneratorUtil.getDOType(superClassname, model); @@ -132,13 +132,13 @@ <!--key column="topiaId"/--> }*/ // FIXME mieux gerer le cas haveSuper - noneNaturalAttributes.addAll(clazz.getAttributes()); + noneNaturalAttributes.addAll(input.getAttributes()); } else { /*{ <class name="<%=clazzDOType%>" table="<%=tableName%>" node="<%=clazzDOType%>" abstract="<%=isAbstract%>" <%=optionalAttributes%>> <id name="topiaId" type="string" length="255" node="@topiaId"/> }*/ // on detecte les attributs des clef metiers - for (ObjectModelAttribute attr : clazz.getAttributes()) { + for (ObjectModelAttribute attr : input.getAttributes()) { if (TopiaGeneratorUtil.isNaturalId(attr)) { // attribut metier naturalAttributes.add(attr); @@ -149,14 +149,14 @@ } if (!naturalAttributes.isEmpty()) { // generation de la clef metier - boolean mutable = TopiaGeneratorUtil.isNaturalIdMutable(clazz); + boolean mutable = TopiaGeneratorUtil.isNaturalIdMutable(input); String mutableStr = mutable ? " mutable=\"true\"" : ""; if (log.isDebugEnabled()) { - log.debug("natural-id detected for class " + clazz.getName() + " (" + mutableStr + ") attributes : " + naturalAttributes); + log.debug("natural-id detected for class " + input.getName() + " (" + mutableStr + ") attributes : " + naturalAttributes); } /*{ <natural-id<%=mutableStr%>> }*/ - generateAttributes(output, clazz, naturalAttributes, " "); + generateAttributes(output, input, naturalAttributes, " "); /*{ </natural-id> }*/ } @@ -165,7 +165,7 @@ }*/ } - generateAttributes(output, clazz, noneNaturalAttributes, ""); + generateAttributes(output, input, noneNaturalAttributes, ""); if (haveSuper) { /*{ </union-subclass> Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityImplTransformer.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityImplTransformer.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityImplTransformer.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -31,7 +31,6 @@ import org.nuiton.eugene.models.object.ObjectModelClass; import org.nuiton.eugene.models.object.ObjectModelOperation; -import java.io.Serializable; import java.util.Collection; /** Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java (rev 0) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -0,0 +1,1871 @@ +/* + * #%L + * ToPIA :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 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% + */ +package org.nuiton.topia.generator; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.eugene.GeneratorUtil; +import org.nuiton.eugene.java.ObjectModelTransformerToJava; +import org.nuiton.eugene.models.object.ObjectModelAssociationClass; +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.ObjectModelInterface; +import org.nuiton.eugene.models.object.ObjectModelModifier; +import org.nuiton.eugene.models.object.ObjectModelOperation; +import org.nuiton.eugene.models.object.ObjectModelParameter; +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.framework.TopiaContextImplementor; +import org.nuiton.topia.persistence.EntityVisitor; +import org.nuiton.topia.persistence.TopiaEntity; +import org.nuiton.topia.persistence.TopiaEntityAbstract; + +import java.beans.Introspector; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.nuiton.eugene.GeneratorUtil.getSimpleName; +import static org.nuiton.topia.generator.TopiaGeneratorUtil.STEREOTYPE_ENTITY; +import static org.nuiton.topia.generator.TopiaGeneratorUtil.TAG_ANNOTATION; +import static org.nuiton.topia.generator.TopiaGeneratorUtil.TAG_DB_NAME; +import static org.nuiton.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType; +import static org.nuiton.topia.generator.TopiaGeneratorUtil.isDateType; +import static org.nuiton.topia.generator.TopiaGeneratorUtil.isPrimitiveType; +import static org.nuiton.topia.generator.TopiaGeneratorUtil.shouldBeAbstract; + + + +/*{generator option: parentheses = false}*/ +/*{generator option: writeString = +}*/ + +/** + * A template to generate all the {@link TopiaEntity} api for all classifier + * with a {@code entity} stereotype. + * + * For example, given a {@code House} entity, it will generates : + * <ul> + * <li>{@code House} : contract of entity</li> + * <li>{@code AbstractHouse} : default abstract implementation of entity</li> + * <li>{@code HouseImpl} : default impl of abstract entity</li> + * </ul> + * + * <b>Note: </b> The impl will ony be generated in these cases : + * <ul> + * <li>There is no abstract method</li> + * <li>There is no already defined such class in class-path</li> + * </ul> + * + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.topia.generator.EntityTransformer" + */ +public class EntityTransformer extends ObjectModelTransformerToJava { + + /** Logger */ + private static final Log log = LogFactory.getLog(EntityTransformer.class); + + @Override + public void transformFromClass(ObjectModelClass input) { + + if (!input.hasStereotype(STEREOTYPE_ENTITY)) { + + // not an entity, skip class. + return; + } + + if (log.isDebugEnabled()) { + log.debug("for entity : "+input.getQualifiedName()); + log.info("Will use classLoader "+ getClassLoader()); + } + + // fix once for all the constant prefix to use + + String prefix = getConstantPrefix(input, ""); + + if (StringUtils.isEmpty(prefix)) { + + // no specific prefix, so no prefix + if (log.isWarnEnabled()) { + log.warn("[" + input.getName() + "] Will generate constants with NO prefix, not a good idea..."); + } + } + + setConstantPrefix(prefix); + + String clazzName = input.getName(); + String packageName = input.getPackageName(); + + Collection<ObjectModelAttribute> attributes = input.getAttributes(); + + Collection<ObjectModelOperation> operations = input.getOperations(); + + ObjectModelClassifier output; + + // generate interface + + { + output = createInterface(clazzName, packageName); + generateInterface(input, (ObjectModelInterface) output, attributes, operations); + } + + // generate abstract + + { + output = createAbstractClass( clazzName + "Abstract", packageName); + generateAbstract(input, (ObjectModelClass) output, attributes, operations); + + } + + boolean generateImpl = isGenerateImpl(input, operations); + + if (generateImpl) { + + String implName = clazzName + "Impl"; + if (isVerbose()) { + log.info("Will generate [" + implName + "]"); + } + + if (isAbstract(input)) { + output = createAbstractClass(implName, packageName); + } else { + output = createClass(implName, packageName); + } + + // generate impl + generateImpl(input, (ObjectModelClass) output); + } + } + + protected boolean isGenerateImpl(ObjectModelClass input, + Collection<ObjectModelOperation> operations) { + + String fqn = input.getQualifiedName() + "Impl"; + + URL fileLocation = getFileInClassPath(fqn); + + if (fileLocation != null) { + + // there is already a existing file in class-path, skip + if (isVerbose()) { + log.info("Will not generate [" + fqn + "], found existing file in class-path : " + fileLocation); + } + return false; + } + + // On ne génère pas le impl si l'entité a des opérations qui ne sont + // pas seulement pour le DAO + if (!operations.isEmpty()) { + + if (isVerbose()) { + log.info("Will not generate [" + fqn + "], there is some operations and not only DAO ones"); + } + return false; + } + + //De même, on ne génère pas le impl si il y a des opérations venant des + // superclasses non implémentées + for (ObjectModelOperation otherOp : input.getAllOtherOperations(false)) { + if (otherOp.isAbstract()) { + if (isVerbose()) { + log.info("Will not generate [" + fqn + "], there is a abstract operation [" + otherOp.getName() + "] in allOtherOperations."); + } + return false; + } + } + + return true; + } + + protected void generateInterface(ObjectModelClass input, + ObjectModelInterface output, + Collection<ObjectModelAttribute> attributes, + Collection<ObjectModelOperation> operations) { + + addImport(output, TopiaEntity.class); + + if (TopiaGeneratorUtil.hasDocumentation(input)) { + setDocumentation(output,input.getDocumentation()); + } + + // super classes + + for (ObjectModelClassifier parent : input.getInterfaces()) { + addInterface(output,parent.getQualifiedName()); + } + + boolean needTopiaEntity = true; + for (ObjectModelClassifier parent : input.getSuperclasses()) { + if (parent.hasStereotype(STEREOTYPE_ENTITY)) { + addInterface(output,parent.getQualifiedName()); + needTopiaEntity = false; + break; + } + } + + if (needTopiaEntity) { + addInterface(output, TopiaEntity.class); + } + + generateInterfaceStaticColumnNames(input, output); + + // attributes + + for (ObjectModelAttribute attr : attributes) { + ObjectModelAttribute reverse = attr.getReverseAttribute(); + if (!attr.isNavigable() && + !TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType( + reverse, model)) { + continue; + } + + if (attr.hasAssociationClass()) { + + addInterfaceAssociationAttribute(output, attr); + + } else { + + addInterfaceNoneAssociationAttribute(output, attr); + } + } + + //Méthodes d'accès aux attributs d'une classe d'associations + + if (input instanceof ObjectModelAssociationClass) { + ObjectModelAssociationClass assoc = + (ObjectModelAssociationClass) input; + for (ObjectModelAttribute attr : + assoc.getParticipantsAttributes()) { + if (attr != null) { + String type = attr.getType(); + String name = attr.getName(); + generateInterfaceAssociationAccessors(output, name, type); + if (attr.getReverseAttribute() == null) { + type = ((ObjectModelClassifier) + attr.getDeclaringElement()).getQualifiedName(); + name = attr.getDeclaringElement().getName(); + generateInterfaceAssociationAccessors(output, name, type); + } + } + } + } + + for (ObjectModelOperation operation : operations) { + generateInterfaceOperation(operation, output); + } + } + + protected void generateAbstract(ObjectModelClass input, + ObjectModelClass output, + Collection<ObjectModelAttribute> attributes, + Collection<ObjectModelOperation> operations) { + + String clazzName = input.getName(); + String clazzFQN = TopiaGeneratorUtil.getSimpleName( + input.getQualifiedName()); + + addInterface(output, clazzName); + + addImport(output, ArrayList.class); + addImport(output, List.class); + addImport(output, TopiaEntity.class); + addImport(output, TopiaContextImplementor.class); + + // javadoc + + StringBuilder doc = new StringBuilder(); + doc.append("Implantation POJO pour l'entité {@link "); + doc.append(StringUtils.capitalize(clazzFQN)); + doc.append("}\n"); + + { + String dbName = input.getTagValue(TAG_DB_NAME); + if (dbName != null) { + doc.append("<p>Nom de l'entité en BD : "); + doc.append(dbName); + doc.append(".</p>"); + } + } + + setDocumentation(output, doc.toString()); + + // super classes + + for (ObjectModelClass parent : input.getSuperclasses()) { + String extendClass = parent.getQualifiedName(); + //Si une des classes parentes définies des méthodes abstraites, son + // impl ne sera pas créé + boolean abstractParent = shouldBeAbstract(parent); + if (parent.hasStereotype(STEREOTYPE_ENTITY)) { + if (abstractParent) { + extendClass += "Abstract"; + } else { + extendClass += "Impl"; + } + } + setSuperClass(output, extendClass); + } + + if (output.getSuperclasses().isEmpty()) { + setSuperClass(output, TopiaEntityAbstract.class); + } + + // serialVersionUID + + String svUID = TopiaGeneratorUtil.findTagValue("serialVersionUID", + input, model); + if (svUID != null) { + + addConstant(output, "serialVersionUID", long.class, svUID, + ObjectModelModifier.PRIVATE + ); + } + + ObjectModelParameter attr2; + + for (ObjectModelAttribute attr : attributes) { + ObjectModelAttribute reverse = attr.getReverseAttribute(); + + // pour les asso quoi qu'il arrive il faut les lier des 2 cotes + // pour pouvoir supprimer en cascade l'asso lors de la suppression + // d'un des cotes + if (!(attr.isNavigable() + || hasUnidirectionalRelationOnAbstractType(reverse, model) + || attr.hasAssociationClass())) { + continue; + } + + String type; + String name; + + if (!attr.hasAssociationClass()) { + String attrName = attr.getName(); + name = attrName; + type = attr.getType(); + } else { + String assocAttrName = GeneratorUtil.getAssocAttrName(attr); + //TODO THIMEL : Je pense que les + // GeneratorUtil.toLowerCaseFirstLetter sont inutiles + // ici, ou alors il faudrait le faire partout + name = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName); + type = attr.getAssociationClass().getQualifiedName(); + } + + if (GeneratorUtil.isNMultiplicity(attr)) { + String collectionType = + TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr); + type = collectionType + '<' + type + '>'; + } + + String attrVisibility = attr.getVisibility(); + + attr2 = addAttribute(output, name, type, null, + ObjectModelModifier.toValue(attrVisibility), + ObjectModelModifier.PROTECTED + ); + + doc = new StringBuilder(); + + if (TopiaGeneratorUtil.hasDocumentation(attr) || + attr.hasTagValue(TAG_DB_NAME)) { + if (TopiaGeneratorUtil.hasDocumentation(attr)) { + String attrDocumentation = attr.getDocumentation(); + doc.append(attrDocumentation).append('\n'); + } + if (attr.hasTagValue(TAG_DB_NAME)) { + String dbName = + attr.getTagValue(TAG_DB_NAME); + doc.append("Nom de l'attribut en BD : "); + doc.append(dbName); + doc.append('\n'); + } + } + + setDocumentation(attr2, doc.toString()); + + + if (attr.hasTagValue(TAG_ANNOTATION)) { + String annotation = attr.getTagValue(TAG_ANNOTATION); + //FIXME Make annotation works... + //TODO tchemit 20100513 Test it still works + addAnnotation(output, attr2, annotation); + } + } + + //Déclaration des attributs d'une classe d'associations + if (input instanceof ObjectModelAssociationClass) { + ObjectModelAssociationClass assoc = + (ObjectModelAssociationClass) input; + for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) { + if (attr != null) { + String attrVisibility = attr.getVisibility(); + String attrType = attr.getType(); + String attrName = attr.getName(); + addAttribute(output, + GeneratorUtil.toLowerCaseFirstLetter(attrName), + attrType, null, + ObjectModelModifier.toValue(attrVisibility)); + } + } + } + + ObjectModelOperation op = addOperation(output, "update", "void", + ObjectModelModifier.PUBLIC); + addException(op, TopiaException.class); + setDocumentation(op,"@deprecated since 2.4, use the DAO api instead."); + addAnnotation(output, op, Deprecated.class.getSimpleName()); + addAnnotation(output, op, Override.class.getSimpleName()); + setOperationBody(op, "" +/*{ + ((TopiaContextImplementor)getTopiaContext()).getDAO(<%=clazzName%>.class).update(this); +}*/ + ); + + op = addOperation(output, "delete", "void", ObjectModelModifier.PUBLIC); + addException(op, TopiaException.class); + setDocumentation(op,"@deprecated since 2.4, use the DAO api instead."); + addAnnotation(output, op, Deprecated.class.getSimpleName()); + addAnnotation(output, op, Override.class.getSimpleName()); + setOperationBody(op, "" +/*{ + ((TopiaContextImplementor)getTopiaContext()).getDAO(<%=clazzName%>.class).delete(this); +}*/ + ); + + generateAcceptMethod(output, input); + + generateAggregateMethod(output, input); + + generateCompositeMethod(output, input); + + + for (ObjectModelAttribute attr : attributes) { + ObjectModelAttribute reverse = attr.getReverseAttribute(); + + if (!(attr.isNavigable() + || hasUnidirectionalRelationOnAbstractType(reverse, model))) { + continue; + } + + transformAttribute(output, attr, reverse); + } + + + //Méthodes d'accès aux attributs d'une classe d'associations + if (input instanceof ObjectModelAssociationClass) { + + for (ObjectModelAttribute attr : + ((ObjectModelAssociationClass) input).getParticipantsAttributes()) { + if (attr != null) { + String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType()); + String attrName = attr.getName(); + generateAssociationAccessors(output, attrName, attrType); + } + } + } + + generateAbstractMethods(output, input); + + boolean doGenerateToString = TopiaGeneratorUtil.generateToString(input, + model); + if (doGenerateToString) { + addImport(output, ToStringBuilder.class); + generateToStringMethod(output, input); + } + + String i18nPrefix = TopiaGeneratorUtil.getI18nPrefix(input, model); + if (!StringUtils.isEmpty(i18nPrefix)) { + // generate i18n prefix + generateI18n(output, i18nPrefix, input); + } + } + + protected void generateImpl(ObjectModelClass input, + ObjectModelClass output) { + + setDocumentation(output, "Implantation des operations pour l'entité " + + input.getName() + "."); + setSuperClass(output, input.getQualifiedName() + "Abstract"); + } + + + // ------------------------------------------------------------------------- + // Interface generation + // ------------------------------------------------------------------------- + + private void generateInterfaceStaticColumnNames(ObjectModelClass input, + ObjectModelInterface output) { + + for (ObjectModelAttribute attr : input.getAttributes()) { + ObjectModelAttribute reverse = attr.getReverseAttribute(); + if (!(attr.isNavigable() || + TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType( + reverse, model) + || attr.hasAssociationClass())) { + continue; + } + String attrName; + if (!attr.hasAssociationClass()) { + attrName = attr.getName(); + } else { + String assocAttrName = GeneratorUtil.getAssocAttrName(attr); + attrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName); + } + String attrColName = getConstantName(attrName); + addAttribute(output, + attrColName, + String.class, + "\"" + attrName + "\"", + ObjectModelModifier.PACKAGE); + } + + //Déclaration des noms des champs des attributs d'une classe d'associations + if (input instanceof ObjectModelAssociationClass) { + ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) input; + for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) { + if (attr != null) { + String attrName = attr.getName(); + String attrColName = getConstantName(attrName); + addAttribute(output, + attrColName, + String.class, + "\"" + attrName + "\"", + ObjectModelModifier.PACKAGE); + } + } + } + } + + protected void addInterfaceNoneAssociationAttribute(ObjectModelInterface output, + ObjectModelAttribute attr) { + String attrName = attr.getName(); + String attrType = attr.getType(); + ObjectModelOperation op; + ObjectModelParameter attr2; + + if (!GeneratorUtil.isNMultiplicity(attr)) { + + // setXXX + + op = addOperation(output, + "set" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PACKAGE); + if (TopiaGeneratorUtil.hasDocumentation(attr)) { + setDocumentation(op, attr.getDocumentation()); + } + attr2 = addParameter(op, attrType, + GeneratorUtil.toLowerCaseFirstLetter(attrName)); + setDocumentation(attr2, "La valeur de l'attribut " + attrName + + " à positionner."); + + // getXXX + + op = addOperation(output, + "get" + StringUtils.capitalize(attrName), + attrType, + ObjectModelModifier.PACKAGE); + if (TopiaGeneratorUtil.hasDocumentation(attr)) { + setDocumentation(op, attr.getDocumentation()); + } + } else { + String collectionInterface = + TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr); + + // addXXX + + op = addOperation(output, + "add" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PACKAGE); + if (TopiaGeneratorUtil.hasDocumentation(attr)) { + setDocumentation(op, attr.getDocumentation()); + } + attr2 = addParameter(op, attrType, + GeneratorUtil.toLowerCaseFirstLetter(attrName)); + setDocumentation(attr2, + "L'instance de " + attrName + " à ajouter"); + + // addAllXXX + + op = addOperation(output, + "addAll" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PACKAGE); + if (TopiaGeneratorUtil.hasDocumentation(attr)) { + setDocumentation(op, attr.getDocumentation()); + } + attr2 = addParameter(op, + collectionInterface + "<" + attrType + ">", + GeneratorUtil.toLowerCaseFirstLetter(attrName)); + setDocumentation(attr2, + "Les instances de " + attrName + " à ajouter"); + + // setXXX + + op = addOperation(output, + "set" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PACKAGE); + if (TopiaGeneratorUtil.hasDocumentation(attr)) { + setDocumentation(op, attr.getDocumentation()); + } + attr2 = addParameter(op, + collectionInterface + "<" + attrType + ">", + GeneratorUtil.toLowerCaseFirstLetter(attrName)); + setDocumentation(attr2, + "La Collection de " + attrName + " à ajouter"); + + // removeXXX + + op = addOperation(output, + "remove" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PACKAGE); + if (TopiaGeneratorUtil.hasDocumentation(attr)) { + setDocumentation(op, attr.getDocumentation()); + } + attr2 = addParameter(op, + attrType, + GeneratorUtil.toLowerCaseFirstLetter(attrName)); + setDocumentation(attr2, + "L'instance de " + attrName + " à retirer"); + + // clearXXX + + op = addOperation(output, + "clear" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PACKAGE); + if (TopiaGeneratorUtil.hasDocumentation(attr)) { + setDocumentation(op, attr.getDocumentation()); + } + setDocumentation(attr2, "Vide la Collection de " + attrName); + + // getXXX + + op = addOperation(output, + "get" + StringUtils.capitalize(attrName), + collectionInterface + "<" + attrType + ">", + ObjectModelModifier.PACKAGE); + if (TopiaGeneratorUtil.hasDocumentation(attr)) { + setDocumentation(op, "Retourne la collection."); + } + + if (!TopiaGeneratorUtil.isPrimitiveType(attr) && + !TopiaGeneratorUtil.isDateType(attr)) { + + // getXXXByTopiaId + + op = addOperation(output, + "get" + StringUtils.capitalize(attrName) + "ByTopiaId", + attrType, + ObjectModelModifier.PACKAGE); + setDocumentation(op, "Recupère l'attribut " + attrName + " à partir de son topiaId"); + attr2 = addParameter(op, String.class, "topiaId"); + setDocumentation(attr2, "le topia id de l'entité recherchée"); + } + + // sizeXXX + + op = addOperation(output, + "size" + StringUtils.capitalize(attrName), + int.class, + ObjectModelModifier.PACKAGE); + setDocumentation(op, "Retourne le nombre d'éléments de la collection " + attrName); + + // isXXXEmpty + + op = addOperation(output, + "is" + StringUtils.capitalize(attrName) + "Empty", + boolean.class, + ObjectModelModifier.PACKAGE); + setDocumentation(op, "Retourne {@code true} si la collection " + attrName + " est vide."); + } + } + + protected void addInterfaceAssociationAttribute(ObjectModelInterface output, + ObjectModelAttribute attr) { + String attrName = attr.getName(); + String attrType = attr.getType(); + String assocAttrName = GeneratorUtil.getAssocAttrName(attr); + String assocClassFQN = attr.getAssociationClass().getQualifiedName(); + String assocClassName = attr.getAssociationClass().getName(); + + ObjectModelOperation op; + ObjectModelParameter attr2; + + if (!GeneratorUtil.isNMultiplicity(attr)) { + + // setXXX + + op = addOperation(output, + "set" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PACKAGE); + attr2 = addParameter(op, assocClassFQN, GeneratorUtil.toLowerCaseFirstLetter(assocClassName)); + setDocumentation(attr2, "La valeur de l'attribut " + assocClassName + " à positionner"); + + // getXXX + + addOperation(output, + "get" + StringUtils.capitalize(assocAttrName), + assocClassFQN, + ObjectModelModifier.PACKAGE); + + } else { + String collectionInterface = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr); + + // addXXX + + op = addOperation(output, + "add" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PACKAGE); + attr2 = addParameter(op, assocClassFQN, GeneratorUtil.toLowerCaseFirstLetter(assocClassName)); + setDocumentation(attr2, "L'instance de " + assocClassName + " à ajouter"); + + // addAllXXX + + op = addOperation(output, + "addAll" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PACKAGE); + attr2 = addParameter(op, collectionInterface + "<" + assocClassFQN + ">", GeneratorUtil.toLowerCaseFirstLetter(assocClassName)); + setDocumentation(attr2, "Les instances de " + assocClassName + " à ajouter"); + + // setXXX + + op = addOperation(output, + "set" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PACKAGE); + attr2 = addParameter(op, collectionInterface + "<" + assocClassFQN + ">", GeneratorUtil.toLowerCaseFirstLetter(assocClassName)); + setDocumentation(attr2, "La Collection de " + assocClassName + " à ajouter"); + + // removeXXX + + op = addOperation(output, + "remove" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PACKAGE); + attr2 = addParameter(op, assocClassFQN, GeneratorUtil.toLowerCaseFirstLetter(assocClassName)); + setDocumentation(attr2, "L'instance de " + assocClassName + " à retirer"); + + // clearXXX + + op = addOperation(output, + "clear" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PACKAGE); + setDocumentation(op, "Vide la Collection de " + assocClassName + " ."); + + // getXXX + + addOperation(output, + "get" + StringUtils.capitalize(assocAttrName), + collectionInterface + "<" + assocClassFQN + ">", + ObjectModelModifier.PACKAGE); + + if (!TopiaGeneratorUtil.isPrimitiveType(attr) && !TopiaGeneratorUtil.isDateType(attr)) { + + // getXXXByTopiaId + + op = addOperation(output, + "get" + StringUtils.capitalize(assocAttrName) + "ByTopiaId", + assocClassFQN, + ObjectModelModifier.PACKAGE); + setDocumentation(op, "Recupère l'attribut " + attrName + " à partir de son topiaId"); + attr2 = addParameter(op, String.class, "topiaId"); + setDocumentation(attr2, "le topia id de l'entité recherchée"); + } + + // getXXX + + op = addOperation(output, + "get" + StringUtils.capitalize(assocAttrName), + assocClassFQN); + addParameter(op, attrType, "value"); + + + // sizeXXX + + addOperation(output, + "size" + StringUtils.capitalize(assocAttrName), + int.class, + ObjectModelModifier.PACKAGE); + + + // isXXXEmpty + + addOperation(output, + "is" + StringUtils.capitalize(assocAttrName) + "Empty", + boolean.class, + ObjectModelModifier.PACKAGE); + } + } + + private void generateInterfaceOperation(ObjectModelOperation op, + ObjectModelInterface output) { + + + String visibility = op.getVisibility(); + if (op.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO) || + !visibility.equals(ObjectModelModifier.PUBLIC.toString())) { + // Pas de génération des signatures de méthodes pour celles à intégrer au DAO de l'entité + return; + } + + String opName = op.getName(); + String opType = op.getReturnType(); + + ObjectModelOperation op2 = addOperation(output, opName, opType, ObjectModelModifier.PACKAGE); + if (TopiaGeneratorUtil.hasDocumentation(op)) { + setDocumentation(op2, op.getDocumentation()); + } + + for (ObjectModelParameter param : op.getParameters()) { + String paramName = param.getName(); + String paramType = param.getType(); + ObjectModelParameter param2 = addParameter(op2, paramType, paramName); + if (TopiaGeneratorUtil.hasDocumentation(param)) { + setDocumentation(param2, param.getDocumentation()); + } + } + for (String exception : op.getExceptions()) { + addException(op2, exception); + } + } + + private void generateInterfaceAssociationAccessors(ObjectModelInterface output, + String attrName, + String attrType) { + + ObjectModelOperation op; + ObjectModelParameter param; + + op = addOperation(output, + "set" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PACKAGE); + param = addParameter(op, attrType, "value"); + setDocumentation(param, "La valeur de l'attribut " + attrName + " à positionner."); + + op = addOperation(output, + "get" + StringUtils.capitalize(attrName), + attrType, + ObjectModelModifier.PACKAGE); + setDocumentation(op, "Retourne la valeur de l'attribut " + attrName + "."); + } + + // ------------------------------------------------------------------------- + // Abstract generation + // ------------------------------------------------------------------------- + + protected void transformAttribute(ObjectModelClass result, + ObjectModelAttribute attr, + ObjectModelAttribute reverse) { + + String attrName = attr.getName(); + String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType()); + addImport(result, attrType); + + attrType = TopiaGeneratorUtil.getSimpleName(attrType); + + ObjectModelOperation op; + + if (!GeneratorUtil.isNMultiplicity(attr)) { + + if (attr.hasAssociationClass()) { + String assocAttrName = GeneratorUtil.getAssocAttrName(attr); + String assocClassFQN = attr.getAssociationClass().getQualifiedName(); + addImport(result, assocClassFQN); + assocClassFQN = TopiaGeneratorUtil.getSimpleName(assocClassFQN); + String name = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName); + + // setXXX + + op = addOperation(result, + "set" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, assocClassFQN, "association"); + setOperationBody(op, "" +/*{ + <%=assocClassFQN%> _oldValue = this.<%=name%>; + fireOnPreWrite(<%=getConstantName(name)%>, _oldValue, association); + this.<%=name%> = association; + fireOnPostWrite(<%=getConstantName(name)%>, _oldValue, association); +}*/ + ); + + // getXXX + + op = addOperation(result, + "get" + StringUtils.capitalize(assocAttrName), + assocClassFQN, ObjectModelModifier.PUBLIC); + setOperationBody(op, "" +/*{ + return <%=name%>; +}*/ + ); + } else { + + // setXXX + + op = addOperation(result, + "set" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, attrType, "value"); + setOperationBody(op, "" +/*{ + <%=attrType%> _oldValue = this.<%=attrName%>; + fireOnPreWrite(<%=getConstantName(attrName)%>, _oldValue, value); + this.<%=attrName%> = value; + fireOnPostWrite(<%=getConstantName(attrName)%>, _oldValue, value); +}*/ + + ); + + // getXXX + + op = addOperation(result, + "get" + StringUtils.capitalize(attrName), + attrType, + ObjectModelModifier.PUBLIC); + setOperationBody(op, "" +/*{ + fireOnPreRead(<%=getConstantName(attrName)%>, <%=attrName%>); + <%=attrType%> result = this.<%=attrName%>; + fireOnPostRead(<%=getConstantName(attrName)%>, <%=attrName%>); + return result; +}*/ + ); + } + } else { //NMultiplicity + String collectionInterface = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr); + String collectionObject = TopiaGeneratorUtil.getNMultiplicityObjectType(attr); + addImport(result, collectionInterface); + addImport(result, collectionObject); + collectionInterface = TopiaGeneratorUtil.getSimpleName(collectionInterface); + collectionObject = getSimpleName(collectionObject); + + if (!attr.hasAssociationClass()) { + //Méthodes remplacées par des accesseurs sur les classes d'assoc + + // addXXX + + op = addOperation(result, + "add" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, attrType, attrName); + StringBuilder body = new StringBuilder(); + + body.append("" +/*{ + fireOnPreWrite(<%=getConstantName(attrName)%>, null, <%=attrName%>); + if (this.<%=attrName%> == null) { + this.<%=attrName%> = new <%=collectionObject%><<%=attrType%>>(); + } +}*/ + ); + + if (reverse != null && (reverse.isNavigable() || + hasUnidirectionalRelationOnAbstractType(attr, model))) { + String reverseAttrName = reverse.getName(); + String reverseAttrType = TopiaGeneratorUtil.getSimpleName(reverse.getType()); + if (!GeneratorUtil.isNMultiplicity(reverse)) { + body.append("" +/*{ <%=attrName%>.set<%=StringUtils.capitalize(reverseAttrName)%>(this); +}*/ + ); + } else { + body.append("" +/*{ if (<%=attrName%>.get<%=StringUtils.capitalize(reverseAttrName)%>() == null) { + <%=attrName%>.set<%=StringUtils.capitalize(reverseAttrName)%>(new <%=collectionObject%><<%=reverseAttrType%>>()); + } + <%=attrName%>.get<%=StringUtils.capitalize(reverseAttrName)%>().add(this); +}*/ + ); + } + } + body.append("" +/*{ this.<%=attrName%>.add(<%=attrName%>); + fireOnPostWrite(<%=getConstantName(attrName)%>, this.<%=attrName%>.size(), null, <%=attrName%>); +}*/ + ); + setOperationBody(op, body.toString()); + + // addAllXXX + + op = addOperation(result, + "addAll" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, collectionInterface + '<' + attrType + '>', "values"); + + setOperationBody(op, "" +/*{ + if (values == null) { + return; + } + for (<%=attrType%> item : values) { + add<%=StringUtils.capitalize(attrName)%>(item); + } +}*/ + ); + + if (!isPrimitiveType(attr) && !isDateType(attr)) { + + op = addOperation(result, + "get" + StringUtils.capitalize(attrName) + "ByTopiaId", + attrType, + ObjectModelModifier.PUBLIC); + addParameter(op, String.class, "topiaId"); + setOperationBody(op, "" +/*{ + return org.nuiton.topia.persistence.util.TopiaEntityHelper.getEntityByTopiaId(<%=attrName%>, topiaId); + }*/ + ); + + } + + // setXXX + + op = addOperation(result, + "set" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, collectionInterface + '<' + attrType + '>', "values"); + + setOperationBody(op, "" +/*{ + <%=collectionInterface%><<%=attrType%>> _oldValue = <%=attrName%>; + fireOnPreWrite(<%=getConstantName(attrName)%>, _oldValue, values); + <%=attrName%> = values; + fireOnPostWrite(<%=getConstantName(attrName)%>, _oldValue, values); +}*/ + ); + + + // removeXXX + + + op = addOperation(result, + "remove" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, attrType, "value"); + body = new StringBuilder(); + + body.append("" +/*{ + fireOnPreWrite(<%=getConstantName(attrName)%>, value, null); + if ((this.<%=attrName%> == null) || (!this.<%=attrName%>.remove(value))) { + throw new IllegalArgumentException("List does not contain given element"); + } +}*/ + ); + + if (reverse != null && (reverse.isNavigable() || + hasUnidirectionalRelationOnAbstractType(attr, model))) { + String reverseAttrName = reverse.getName(); + if (!GeneratorUtil.isNMultiplicity(reverse)) { + body.append("" +/*{ value.set<%=StringUtils.capitalize(reverseAttrName)%>(null); +}*/ + ); + } else { + body.append("" +/*{ value.get<%=StringUtils.capitalize(reverseAttrName)%>().remove(this); +}*/ + ); + } + } + body.append("" +/*{ fireOnPostWrite(<%=getConstantName(attrName)%>, this.<%=attrName%>.size()+1, value, null); +}*/ + ); + setOperationBody(op, body.toString()); + + + // clearXXX + + op = addOperation(result, + "clear" + StringUtils.capitalize(attrName), + "void", + ObjectModelModifier.PUBLIC); + + body = new StringBuilder(); + + body.append("" +/*{ + if (this.<%=attrName%> == null) { + return; + } +}*/ + ); + + if (reverse != null && (reverse.isNavigable() || + hasUnidirectionalRelationOnAbstractType(attr, model))) { + String reverseAttrName = reverse.getName(); + body.append("" +/*{ for (<%=attrType%> item : this.<%=attrName%>) { +}*/ + ); + if (!GeneratorUtil.isNMultiplicity(reverse)) { + body.append("" +/*{ item.set<%=StringUtils.capitalize(reverseAttrName)%>(null); +}*/ + ); + } else { + body.append("" +/*{ item.get<%=StringUtils.capitalize(reverseAttrName)%>().remove(this); +}*/ + ); + } + body.append("" +/*{ } +}*/ + ); + } + body.append("" +/*{ <%=collectionInterface%><<%=attrType%>> _oldValue = new <%=collectionObject%><<%=attrType%>>(this.<%=attrName%>); + fireOnPreWrite(<%=getConstantName(attrName)%>, _oldValue, this.<%=attrName%>); + this.<%=attrName%>.clear(); + fireOnPostWrite(<%=getConstantName(attrName)%>, _oldValue, this.<%=attrName%>); +}*/ + ); + + setOperationBody(op, body.toString()); + + } else { + + + String assocAttrName = GeneratorUtil.getAssocAttrName(attr); + String assocClassFQN = attr.getAssociationClass().getQualifiedName(); +// String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName()); + + // addXXX + + op = addOperation(result, + "add" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, assocClassFQN, "value"); + + StringBuilder body = new StringBuilder(); + + body.append("" +/*{ + fireOnPreWrite(<%=getConstantName(GeneratorUtil.toLowerCaseFirstLetter(assocAttrName))%>, null, value); + if (this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) { + this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = new <%=collectionObject%><<%=assocClassFQN%>>(); + } +}*/ + ); + if (reverse != null && (reverse.isNavigable() || + hasUnidirectionalRelationOnAbstractType(attr, model))) { + String reverseAttrName = reverse.getName(); + body.append("" +/*{ value.set<%=StringUtils.capitalize(reverseAttrName)%>(this); +}*/ + ); + } + body.append("" +/*{ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.add(value); + fireOnPostWrite(<%=getConstantName(GeneratorUtil.toLowerCaseFirstLetter(assocAttrName))%>, this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.size(), null, value); +}*/ + ); + setOperationBody(op, body.toString()); + + + if (!isPrimitiveType(attr) && !isDateType(attr)) { + + // getXXXByTopiaId + + op = addOperation(result, + "get" + StringUtils.capitalize(assocAttrName) + "ByTopiaId", + assocClassFQN, + ObjectModelModifier.PUBLIC); + addParameter(op, String.class, "topiaId"); + setOperationBody(op, "" +/*{ + return org.nuiton.topia.persistence.util.TopiaEntityHelper.getEntityByTopiaId(<%=assocAttrName%>, topiaId); +}*/ + ); + + } + + // addAllXXX + + op = addOperation(result, + "addAll" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, collectionInterface + '<' + assocClassFQN + '>', "values"); + setOperationBody(op, "" +/*{ + if (values == null) { + return; + } + for (<%=assocClassFQN%> item : values) { + add<%=StringUtils.capitalize(assocAttrName)%>(item); + } +}*/ + ); + + // setXXX + + op = addOperation(result, + "set" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, collectionInterface + '<' + assocClassFQN + '>', "values"); + setOperationBody(op, "" +/*{ +// clear<%=StringUtils.capitalize(assocAttrName)%>(); +// addAll<%=StringUtils.capitalize(assocAttrName)%>(values); +// FIXME + <%=collectionInterface%><<%=assocClassFQN%>> _oldValue = <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>; + fireOnPreWrite(<%=getConstantName(GeneratorUtil.toLowerCaseFirstLetter(assocAttrName))%>, _oldValue, values); + <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = values; + fireOnPostWrite(<%=getConstantName(GeneratorUtil.toLowerCaseFirstLetter(assocAttrName))%>, _oldValue, values); +}*/ + ); + + // removeXXX + + op = addOperation(result, + "remove" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PUBLIC); + addParameter(op, assocClassFQN, "value"); + + body = new StringBuilder(); + + body.append("" +/*{ + fireOnPreWrite(<%=getConstantName(GeneratorUtil.toLowerCaseFirstLetter(assocAttrName))%>, value, null); + if ((this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) || (!this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.remove(value))) { + throw new IllegalArgumentException("List does not contain given element"); + } +}*/ + ); + if (reverse != null && (reverse.isNavigable() || + hasUnidirectionalRelationOnAbstractType(attr, model))) { + String reverseAttrName = reverse.getName(); + body.append("" +/*{ value.set<%=StringUtils.capitalize(reverseAttrName)%>(null); +}*/ + ); + } + body.append("" +/*{ fireOnPostWrite(<%=getConstantName(GeneratorUtil.toLowerCaseFirstLetter(assocAttrName))%>, this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.size()+1, value, null); +}*/ + ); + + setOperationBody(op, body.toString()); + + // clearXXX + + op = addOperation(result, + "clear" + StringUtils.capitalize(assocAttrName), + "void", + ObjectModelModifier.PUBLIC); + + body = new StringBuilder(); + + body.append("" +/*{ + if (this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) { + return; + } +}*/ + ); + + if (reverse != null && (reverse.isNavigable() || + hasUnidirectionalRelationOnAbstractType(attr, model))) { + String reverseAttrName = reverse.getName(); + body.append("" +/*{ for (<%=assocClassFQN%> item : this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>) { + item.set<%=StringUtils.capitalize(reverseAttrName)%>(null); + } +}*/ + ); + } + body.append("" +/*{ <%=collectionInterface%><<%=assocClassFQN%>> _oldValue = new <%=collectionObject%><<%=assocClassFQN%>>(this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>); + fireOnPreWrite(<%=getConstantName(GeneratorUtil.toLowerCaseFirstLetter(assocAttrName))%>, _oldValue, null); + this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.clear(); + fireOnPostWrite(<%=getConstantName(GeneratorUtil.toLowerCaseFirstLetter(assocAttrName))%>, _oldValue, null); +}*/ + ); + setOperationBody(op, body.toString()); + } + + if (!attr.hasAssociationClass()) { + + // getXXX + + op = addOperation(result, + "get" + StringUtils.capitalize(attrName), + collectionInterface + '<' + attrType + '>', + ObjectModelModifier.PUBLIC); + setOperationBody(op, "" +/*{ + return <%=attrName%>; +}*/ + ); + + // sizeXXX + + op = addOperation(result, + "size" + StringUtils.capitalize(attrName), + int.class, + ObjectModelModifier.PUBLIC); + setOperationBody(op, "" +/*{ + if (<%=attrName%> == null) { + return 0; + } + return <%=attrName%>.size(); +}*/ + ); + + // isXXXEmpty + + op = addOperation(result, + "is" + StringUtils.capitalize(attrName) + "Empty", + boolean.class, + ObjectModelModifier.PUBLIC); + setOperationBody(op, "" +/*{ + int size = size<%=StringUtils.capitalize(attrName)%>(); + return size == 0; +}*/ + ); + + } else { + String assocAttrName = GeneratorUtil.getAssocAttrName(attr); + String assocClassFQN = attr.getAssociationClass().getQualifiedName(); +// String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName()); + + // getXXX + + op = addOperation(result, + "get" + StringUtils.capitalize(assocAttrName), + collectionInterface + '<' + assocClassFQN + '>', + ObjectModelModifier.PUBLIC); + setOperationBody(op, "" +/*{ + return <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>; +}*/ + ); + + // getXXX + + op = addOperation(result, + "get" + StringUtils.capitalize(assocAttrName), + assocClassFQN, + ObjectModelModifier.PUBLIC); + addParameter(op, attrType, "value"); + setOperationBody(op, "" +/*{ + if (value == null || <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) { + return null; + } + for (<%=assocClassFQN%> item : <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>) { + if (value.equals(item.get<%=StringUtils.capitalize(attrName)%>())) { + return item; + } + } + return null; +}*/ + ); + + + // sizeXXX + + op = addOperation(result, + "size" + StringUtils.capitalize(assocAttrName), + int.class, + ObjectModelModifier.PUBLIC); + setOperationBody(op, "" +/*{ + if (<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) { + return 0; + } + return <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.size(); +}*/ + ); + + //isXXXEmpty + + op = addOperation(result, + "is" + StringUtils.capitalize(assocAttrName) + "Empty", + boolean.class, + ObjectModelModifier.PUBLIC); + setOperationBody(op, "" +/*{ + int size = size<%=StringUtils.capitalize(assocAttrName)%>(); + return size == 0; +}*/ + ); + + } + } + } + + protected void generateToStringMethod(ObjectModelClass output, + ObjectModelClass clazz) { + if (log.isDebugEnabled()) { + log.debug("generate toString method for clazz " + + clazz.getQualifiedName()); + } + ObjectModelOperation op = addOperation(output, + "toString", + String.class, + ObjectModelModifier.PUBLIC); + addAnnotation(output, op, Override.class.getSimpleName()); + StringBuilder body = new StringBuilder(); + + + body.append("" +/*{ + String result = new ToStringBuilder(this). +}*/ + ); + for (ObjectModelAttribute attr : clazz.getAttributes()) { + //FIXME possibilité de boucles (non directes) + ObjectModelClass attrEntity = null; + if (model.hasClass(attr.getType())) { + attrEntity = model.getClass(attr.getType()); + } + boolean isEntity = attrEntity != null && + attrEntity.hasStereotype(STEREOTYPE_ENTITY); + ObjectModelAttribute reverse = attr.getReverseAttribute(); + if (isEntity && (reverse == null || !reverse.isNavigable()) + && !attr.hasAssociationClass() || !isEntity) { + String attrName = attr.getName(); + body.append("" +/*{ append(<%=getConstantName(attrName)%>, this.<%=attrName%>). +}*/ + ); + } + } + body.append("" +/*{ toString(); + return result; +}*/ + ); + setOperationBody(op, body.length() == 0 ? " " : body.toString()); + + } + + protected void generateCompositeMethod(ObjectModelClass output, + ObjectModelClass clazz) { + + ObjectModelOperation op = addOperation(output, + "getComposite", + List.class.getName() + '<' + TopiaEntity.class.getName() + '>', + ObjectModelModifier.PUBLIC); + addException(op, TopiaException.class); + addAnnotation(output, op, Override.class.getSimpleName()); + StringBuilder body = new StringBuilder(); + body.append("" +/*{ + List<TopiaEntity> tmp = new ArrayList<TopiaEntity>(); + + // pour tous les attributs rechecher les composites et les class d'asso + // on les ajoute dans tmp +}*/ + ); + for (ObjectModelAttribute attr : clazz.getAttributes()) { + if (attr.referenceClassifier() && + attr.getClassifier().hasStereotype( + STEREOTYPE_ENTITY)) { + if (attr.isComposite()) { + String attrName = attr.getName(); + String getterName = "get" + StringUtils.capitalize(attrName); + if (GeneratorUtil.isNMultiplicity(attr)) { + body.append("" +/*{ if (<%=getterName%>() != null) { + tmp.addAll(<%=getterName%>()); + } +}*/ + ); + } else { + body.append("" +/*{ tmp.add(<%=getterName%>()); +}*/ + ); + } + } else if (attr.hasAssociationClass()) { + String assocAttrName = GeneratorUtil.getAssocAttrName( + attr); + String assocClassFQN = TopiaGeneratorUtil.getSimpleName( + attr.getAssociationClass().getQualifiedName()); + String ref = "this." + GeneratorUtil.toLowerCaseFirstLetter( + assocAttrName); + if (!GeneratorUtil.isNMultiplicity(attr)) { + body.append("" +/*{ + if (<%=ref%> != null) { + tmp.add(<%=ref%>); + } +}*/ + ); + } else { + ObjectModelAttribute reverse = attr.getReverseAttribute(); + String reverseAttrName = reverse.getName(); + // On utilise pas l'attribut car il est potentiellement + // pas a jour, car pour les asso avec cardinalité + // personne ne fait de add. Ce qui est normal, mais + // pour pouvoir faire tout de meme des delete en cascade + // sur les asso, le champs est dans le mapping + // hibernate et donc il le faut aussi dans la classe + // sinon hibernate rale lorsqu'il charge l'objet +// if (<%=ref%> != null) { +// tmp.addAll(<%=ref%>); +// } + body.append("" +/*{ + { + org.nuiton.topia.persistence.TopiaDAO<<%=assocClassFQN%>> dao = ((TopiaContextImplementor) getTopiaContext()).getDAO(<%=assocClassFQN%>.class); + List<<%=assocClassFQN%>> findAllByProperties = dao.findAllByProperties("<%=reverseAttrName%>", this); + if (findAllByProperties != null) { + tmp.addAll(findAllByProperties); + } + } +}*/ + ); + } + } + } + } + body.append("" +/*{ + // on refait un tour sur chaque entity de tmp pour recuperer leur + // composite + List<TopiaEntity> result = new ArrayList<TopiaEntity>(); + for (TopiaEntity entity : tmp) { + if (entity != null) { + result.add(entity); + result.addAll(entity.getComposite()); + } + } + + return result; + }*/ + ); + + setOperationBody(op, body.length() == 0 ? " " : body.toString()); + } + + protected void generateAggregateMethod(ObjectModelClass output, + ObjectModelClass clazz) { + + ObjectModelOperation op = addOperation(output, + "getAggregate", + List.class.getName() + '<' + TopiaEntity.class.getName() + '>', + ObjectModelModifier.PUBLIC); + addException(op, TopiaException.class); + addAnnotation(output, op, Override.class.getSimpleName()); + StringBuilder body = new StringBuilder(); + body.append("" +/*{ + List<TopiaEntity> tmp = new ArrayList<TopiaEntity>(); + + // pour tous les attributs rechecher les composites et les class d'asso + // on les ajoute dans tmp +}*/ + ); + for (ObjectModelAttribute attr : clazz.getAttributes()) { + if (attr.referenceClassifier() && + attr.getClassifier().hasStereotype( + STEREOTYPE_ENTITY)) { + if (attr.isAggregate()) { + String attrName = attr.getName(); + String getterName = "get" + StringUtils.capitalize(attrName); + if (GeneratorUtil.isNMultiplicity(attr)) { + body.append("" +/*{ tmp.addAll(<%=getterName%>()); +}*/ + ); + } else { + body.append("" +/*{ tmp.add(<%=getterName%>()); +}*/ + ); + } + } + } + } + body.append("" +/*{ + // on refait un tour sur chaque entity de tmp pour recuperer leur + // composite + List<TopiaEntity> result = new ArrayList<TopiaEntity>(); + for (TopiaEntity entity : tmp) { + result.add(entity); + result.addAll(entity.getAggregate()); + } + + return result; +}*/ + ); + + setOperationBody(op, body.length() == 0 ? " " : body.toString()); + } + + protected void generateAcceptMethod(ObjectModelClass output, + ObjectModelClass clazz) { + + ObjectModelOperation op = addOperation(output, + "accept", + "void", + ObjectModelModifier.PUBLIC); + addException(op, TopiaException.class); + addAnnotation(output, op, Override.class.getSimpleName()); + setDocumentation(op, "Envoi via les methodes du visitor l'ensemble des " + + "champs de l'entity\n" + + "avec leur nom, type et valeur."); + { + ObjectModelParameter attr = addParameter(op, EntityVisitor.class, + "visitor"); + setDocumentation(attr, "le visiteur de l'entite."); + } + StringBuilder body = new StringBuilder(); + body.append("" +/*{ + visitor.start(this); +}*/ + ); + for (ObjectModelAttribute attr : clazz.getAttributes()) { + ObjectModelAttribute reverse = attr.getReverseAttribute(); + + // pour les asso quoi qu'il arrive il faut les lier des 2 cotes + // pour pouvoir supprimer en cascade l'asso lors de la suppression + // d'un des cotes + if (!(attr.isNavigable() + || hasUnidirectionalRelationOnAbstractType(reverse, model) + || attr.hasAssociationClass())) { + continue; + } + + if (!attr.hasAssociationClass()) { + String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType()); + String attrName = attr.getName(); + if (!GeneratorUtil.isNMultiplicity(attr)) { + body.append("" +/*{ visitor.visit(this, <%=getConstantName(attrName)%>, <%=attrType%>.class, <%=attrName%>); +}*/ + ); + } else { + String collectionType = TopiaGeneratorUtil.getSimpleName( + TopiaGeneratorUtil.getNMultiplicityInterfaceType( + attr)); + body.append("" +/*{ visitor.visit(this, <%=getConstantName(attrName)%>, <%=collectionType%>.class, <%=attrType%>.class, <%=attrName%>); +}*/ + ); + } + } else { + String assocAttrName = GeneratorUtil.getAssocAttrName(attr); + assocAttrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName); + String assocClassFQN = TopiaGeneratorUtil.getSimpleName( + attr.getAssociationClass().getQualifiedName()); + if (!GeneratorUtil.isNMultiplicity(attr)) { + body.append("" +/*{ visitor.visit(this, <%=getConstantName(assocAttrName)%>, <%=assocClassFQN%>.class, <%=assocAttrName%>); +}*/ + ); + } else { + String collectionType = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr); + body.append("" +/*{ visitor.visit(this, <%=getConstantName(assocAttrName)%>, <%=collectionType%>.class, <%=assocClassFQN%>.class, <%=assocAttrName%>); +}*/ + ); + } + } + } + + //Déclaration des attributs d'une classe d'associations + if (clazz instanceof ObjectModelAssociationClass) { + ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz; + for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) { + if (attr != null) { + String attrType = TopiaGeneratorUtil.getSimpleName( + attr.getType()); + String attrName = attr.getName(); + attrName = GeneratorUtil.toLowerCaseFirstLetter(attrName); + body.append("" +/*{ visitor.visit(this, <%=getConstantName(attrName)%>, <%=attrType%>.class, <%=attrName%>); +}*/ + ); + } + } + } + body.append("" +/*{ visitor.end(this); +}*/ + ); + + setOperationBody(op, body.length() == 0 ? " " : body.toString()); + } + + + private void generateAssociationAccessors(ObjectModelClass output, + String name, String type) { + ObjectModelOperation op; + op = addOperation(output, + "set" + StringUtils.capitalize(name), + "void", + ObjectModelModifier.PUBLIC); + addAnnotation(output, op, Override.class.getSimpleName()); + ObjectModelParameter param = addParameter(op, type, "value"); + setDocumentation(param, "La valeur de l'attribut " + name + + " à positionner."); + setOperationBody(op, "" +/*{ + <%=type%> _oldValue = this.<%=GeneratorUtil.toLowerCaseFirstLetter(name)%>; + fireOnPreWrite("<%=name%>", _oldValue, value); + this.<%=GeneratorUtil.toLowerCaseFirstLetter(name)%> = value; + fireOnPostWrite("<%=name%>", _oldValue, value); +}*/ + ); + + op = addOperation(output, + "get" + StringUtils.capitalize(name), + type, + ObjectModelModifier.PUBLIC); + addAnnotation(output, op, Override.class.getSimpleName()); + setOperationBody(op, "" +/*{ + return <%=GeneratorUtil.toLowerCaseFirstLetter(name)%>; +}*/ + ); + + } + + /** + * Generate entity methods which have not a public visibility. In this case, they will not be + * generated in the EntityInterface, so they will be generated here, in the EntityAbstract + * with abstract modifier to keep consistency with the model. + * @param output ObjectModelClass result corresponding to the EntityAbstract + * @param input ObjectModelClass source from ObjectModel + */ + private void generateAbstractMethods(ObjectModelClass output, + ObjectModelClass input) { + for (ObjectModelOperation op : input.getOperations()) { + if (log.isDebugEnabled()) { + log.debug("clazz : " + input.getQualifiedName() + + " - method : " + op.getName() + + " - visibility : " + op.getVisibility()); + } + String visibility = op.getVisibility(); + ObjectModelModifier visibilityModifier = ObjectModelModifier.toValue(visibility); + if (!visibilityModifier.equals(ObjectModelModifier.PUBLIC)) { + addOperation(output, + op.getName(), + op.getReturnType(), + visibilityModifier, + ObjectModelModifier.ABSTRACT); + } + } + } + + private void generateI18n(ObjectModelClass result, String i18nPrefix, + ObjectModelClass clazz) { + + StringBuilder buffer = new StringBuilder(300); + addI18n(buffer, i18nPrefix, Introspector.decapitalize(clazz.getName())); + for (ObjectModelAttribute attr : clazz.getAttributes()) { + //TC-20100225 only treate navigable relations + if (attr.isNavigable()) { + addI18n(buffer, i18nPrefix, Introspector.decapitalize(attr.getName())); + } + } + + //FIXME : use a block extension for java + ObjectModelOperation op = addBlock(result, ObjectModelModifier.STATIC); + setOperationBody(op, buffer.toString()); + } + + private void addI18n(StringBuilder buffer, String i18nPrefix, + String suffix) { + buffer.append("\n org.nuiton.i18n.I18n.n_(\""); + buffer.append(i18nPrefix); + buffer.append(suffix); + buffer.append("\");"); + } + + + // ------------------------------------------------------------------------- + // Impl generation + // ------------------------------------------------------------------------- + + protected boolean isAbstract(ObjectModelClass clazz) { + if (clazz.isAbstract()) { + return true; + } + + //Une classe peut être abstraite si elle a des méthodes définies dans + // ses superinterface et non implantées dans ses superclasses + Collection<ObjectModelOperation> allInterfaceOperations = + clazz.getAllInterfaceOperations(true); + allInterfaceOperations.removeAll(clazz.getAllOtherOperations(true)); + for (ObjectModelOperation op : allInterfaceOperations) { + boolean implementationFound = false; + for (ObjectModelClass superClazz : clazz.getSuperclasses()) { + for (ObjectModelOperation matchingOp : + superClazz.getOperations(op.getName())) { + implementationFound = op.equals(matchingOp) && + !matchingOp.isAbstract(); + if (implementationFound) { + break; + } + } + if (implementationFound) { + break; + } + } + if (!implementationFound) { + if (log.isDebugEnabled()) { + log.debug(clazz.getName() + " : abstract operation " + op); + } + return true; + } + } + return false; + } + +} Property changes on: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -1,3 +1,27 @@ +/* + * #%L + * ToPIA :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 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% + */ package org.nuiton.topia.framework; import org.apache.commons.logging.Log; Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -1,3 +1,27 @@ +/* + * #%L + * ToPIA :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 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% + */ package org.nuiton.topiatest.persistence; import org.nuiton.topia.persistence.TopiaEntity; Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Abstract.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Abstract.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Abstract.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -1,3 +1,27 @@ +/* + * #%L + * ToPIA :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 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% + */ package org.nuiton.topiatest.persistence; import org.nuiton.topia.TopiaException; Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -1,3 +1,27 @@ +/* + * #%L + * ToPIA :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 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% + */ package org.nuiton.topiatest.persistence; import org.nuiton.topia.TopiaException; Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/package-info.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/package-info.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/package-info.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -1,3 +1,27 @@ +/* + * #%L + * ToPIA :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 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% + */ /** * Contains persistent entities for Tests. */ Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/FakeService.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/FakeService.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/FakeService.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -1,3 +1,27 @@ +/* + * #%L + * ToPIA :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 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% + */ package org.nuiton.topiatest.service; import org.nuiton.topia.framework.TopiaContextImpl; Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/TestService.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/TestService.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/TestService.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -1,3 +1,27 @@ +/* + * #%L + * ToPIA :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 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% + */ package org.nuiton.topiatest.service; import org.junit.Ignore; Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/package-info.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/package-info.java 2010-05-14 14:16:46 UTC (rev 1962) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/service/package-info.java 2010-05-14 14:18:23 UTC (rev 1963) @@ -1,3 +1,27 @@ +/* + * #%L + * ToPIA :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 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% + */ /** * This package contains classes which implements {@link * org.nuiton.topia.framework.TopiaService} to test services API.