Author: thimel Date: 2009-01-29 13:46:04 +0000 (Thu, 29 Jan 2009) New Revision: 1331 Modified: topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java Log: ServiceInterfaceGenerator refactored Modified: topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java =================================================================== --- topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 11:46:59 UTC (rev 1330) +++ topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 13:46:04 UTC (rev 1331) @@ -31,8 +31,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.generator.Generator; +import org.codelutin.generator.GeneratorUtil; import org.codelutin.generator.ObjectModelGenerator; -import org.codelutin.generator.GeneratorUtil; import org.codelutin.generator.models.object.ObjectModelAssociationClass; import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; @@ -120,20 +120,21 @@ // methodes du service public String[] methods = { }*/ - String vir=" "; - for(String m : methods){ -/*{ <%=vir%>"<%=m%>" + String comma=" "; + for(String method : methods){ +/*{ <%=comma%>"<%=method%>" }*/ - vir=", "; + comma=", "; } -/*{ }; }*/ -/*{ - } //<%=interfacez.getName()%> +/*{ }; + +} //<%=interfacez.getName()%> }*/ } private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException { String copyright = TopiaGeneratorUtil.getCopyright(model); + String classifierName = classifier.getName(); if (TopiaGeneratorUtil.notEmpty(copyright)) { /*{<%=copyright%> }*/ @@ -141,20 +142,22 @@ /*{package <%=classifier.getPackageName()%>; import java.util.List; +import java.util.Collection; import org.codelutin.topia.TopiaException; +import org.codelutin.topia.service.TopiaApplicationService; }*/ if (TopiaGeneratorUtil.hasDocumentation(classifier)) { + String documentation = classifier.getDocumentation(); /*{ /** - * <%=classifier.getDocumentation()%> + * <%=documentation%> *) }*/ } -/*{public interface <%=classifier.getName()%> extends }*/ +/*{public interface <%=classifierName%> extends }*/ String extendClass = ""; - for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) { - ObjectModelClassifier parent = (ObjectModelClassifier)i.next(); + for (ObjectModelClassifier parent : classifier.getInterfaces()) { // pas pour les interfaces de DAO if(!parent.hasStereotype(DAO)){ extendClass += parent.getQualifiedName(); @@ -164,8 +167,7 @@ if (classifier instanceof ObjectModelClass) { ObjectModelClass clazz = (ObjectModelClass)classifier; - for (Iterator i=clazz.getSuperclasses().iterator(); i.hasNext();) { - ObjectModelClassifier parent = (ObjectModelClassifier)i.next(); + for (ObjectModelClass parent : clazz.getSuperclasses()) { if (parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) { extendClass += parent.getQualifiedName(); } @@ -173,7 +175,7 @@ } } -/*{<%=extendClass%>org.codelutin.topia.service.TopiaApplicationService { +/*{<%=extendClass%>TopiaApplicationService { }*/ } @@ -181,61 +183,65 @@ private void generateMethodsGetter(Writer output, ObjectModelClassifier classifier) throws IOException { /*{ public abstract String[] getMethods(); - // =====> methodes utilisant celles des entites <==== + // methodes utilisant celles des entites }*/ } private void generateInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException { - for (Iterator it = classifier.getOperations().iterator(); it.hasNext();) { - ObjectModelOperation op = (ObjectModelOperation)it.next(); - - String method = op.getReturnType()+ " "+op.getName()+"("; + for (ObjectModelOperation op : classifier.getOperations()) { + String opName = op.getName(); + String opVisibility = op.getVisibility(); + String opType = op.getReturnType(); + String method = opType + " " + opName + "("; /*{ /** - * Methode metier + * Methode <%=opName%>. }*/ if (TopiaGeneratorUtil.hasDocumentation(op)) { -/*{ * <%=op.getName()%> : <%=op.getDocumentation()%> + String opDocumentation = op.getDocumentation(); +/*{ * <%=opName%> : <%=opDocumentation%> }*/ } Collection<ObjectModelParameter> params = (Collection<ObjectModelParameter>)op.getParameters(); for(ObjectModelParameter param : params) { - if(log.isTraceEnabled()) {log.trace("Param" + param);} -/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%> -}*/ + if (TopiaGeneratorUtil.hasDocumentation(param)) { + String paramName = param.getName(); + String paramDocumentation = param.getDocumentation(); +/*{ * @param <%=paramName%> <%=paramDocumentation%> +}*/ + } } /*{ *) - <%=op.getVisibility()%> <%=op.getReturnType()%> <%=op.getName()%>(}*/ - String vir = ""; + <%=opVisibility%> <%=opType%> <%=opName%>(}*/ + String comma = ""; for(ObjectModelParameter param : params){ - method += " " + param.getType()+" "+param.getName(); - if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);} -/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/ - vir = ", "; + String paramName = param.getName(); + String paramType = param.getType(); + method += comma + paramType + " " + paramName; +/*{<%=comma%><%=paramType%> <%=paramName%>}*/ + comma = ", "; } /*{)}*/ - Set<String> exceptions = (Set<String>)op.getExceptions(); - vir = " throws "; + Set<String> exceptions = op.getExceptions(); + comma = " throws "; for (String exception : exceptions) { - if(log.isTraceEnabled()) {log.trace("exception" + exception + " vir" + vir);} -/*{<%=vir%><%=exception%>}*/ - vir = ", "; +/*{<%=comma%><%=exception%>}*/ + comma = ", "; } /*{; }*/ // ajout des methodes - methods.add(method+")"); + methods.add(method + ")"); } } private void generateInheritedInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException { /*{ - // =====> methodes utilisant celles des daos <==== + // methodes utilisant celles des daos }*/ - for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) { - ObjectModelClassifier parent = (ObjectModelClassifier)i.next(); + for (ObjectModelInterface parent : classifier.getInterfaces()) { // pour tous les DAOInterface if(parent.hasStereotype(DAO)){ @@ -244,51 +250,52 @@ entityClassName = parent.getQualifiedName().replace("DAO", ""); if(getModel().hasClass(entityClassName)){ ObjectModelClass clazz = getModel().getClass(entityClassName); + String clazzName = clazz.getName(); + String clazzFQN = clazz.getQualifiedName(); if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) { return; } // ajouter les methodes à la liste - methods.add("void delete"+clazz.getName()+"("+clazz.getName()+" entity)"); - methods.add(clazz.getName()+" create"+clazz.getName()+"(Object ... properties)"); - methods.add(clazz.getName()+" update"+clazz.getName()+"("+clazz.getName()+")"); - methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"()"); - methods.add(clazz.getName()+" find"+clazz.getName()+"ByTopiaId(String v)"); + methods.add("void delete"+clazzName+"("+clazzName+" entity)"); + methods.add(clazzName+" create"+clazzName+"(Object ... properties)"); + methods.add(clazzName+" update"+clazzName+"("+clazzName+")"); + methods.add("List<"+clazzName+"> findAll"+clazzName+"()"); + methods.add(clazzName+" find"+clazzName+"ByTopiaId(String v)"); /*{ /** - * Supprime l'entite <%=clazz.getName()%> passee en parametre + * Supprime l'entite <%=clazzName%> passee en parametre * @param entity l'entite a supprimer *) - public abstract void delete<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException; + public abstract void delete<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException; /** - * Creer l'entite <%=clazz.getName()%> avec les proprietes passees en parametre + * Creer l'entite <%=clazzName%> avec les proprietes passees en parametre * @param entity l'entite a mettre a jour *) - public abstract <%=clazz.getQualifiedName()%> create<%=clazz.getName()%>(Object ... properties) throws TopiaException; + public abstract <%=clazzFQN%> create<%=clazzName%>(Object ... properties) throws TopiaException; /** - * Mise a jour de l'entite <%=clazz.getName()%> passee en parametre + * Mise a jour de l'entite <%=clazzName%> passee en parametre * @param properties les proprietes de l'entite a creer *) - public abstract <%=clazz.getQualifiedName()%> update<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException; + public abstract <%=clazzFQN%> update<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException; /** - * Retourne tous les <%=clazz.getName()%> + * Retourne tous les <%=clazzName%> * @return une liste *) - public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>() throws TopiaException; + public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>() throws TopiaException; /** - * Retourne le <%=clazz.getName()%> par son TopiaId - * @return le <%=clazz.getName()%> + * Retourne le <%=clazzName%> par son TopiaId + * @return le <%=clazzName%> *) - public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>ByTopiaId(String v) throws TopiaException; + public abstract <%=clazzFQN%> find<%=clazzName%>ByTopiaId(String v) throws TopiaException; }*/ - for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) { - ObjectModelAttribute attr = (ObjectModelAttribute)it.next(); + for (ObjectModelAttribute attr : clazz.getAttributes()) { if (!attr.isNavigable()) { continue; } @@ -302,14 +309,12 @@ if (clazz instanceof ObjectModelAssociationClass) { ObjectModelAssociationClass assocClass = (ObjectModelAssociationClass)clazz; - Iterator it = assocClass.getParticipantsAttributes().iterator(); - while (it.hasNext()) { - ObjectModelAttribute attr = (ObjectModelAttribute)it.next(); + for (ObjectModelAttribute attr : assocClass.getParticipantsAttributes()) { if (attr != null) { if (!GeneratorUtil.isNMultiplicity(attr)) { generateNoNMultiplicity(output, attr, clazz, true); } else { - generateNMultiplicity(output, attr, clazz, true); + generateNMultiplicity(output, attr, clazz, true); } } } @@ -318,72 +323,82 @@ } } } - + protected void generateNoNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException { - String propertyName = attr.getName(); + String attrName = attr.getName(); + String propertyName = attrName; + String attrType = attr.getType(); + String clazzName = clazz.getName(); + String clazzFQN = clazz.getQualifiedName(); if (!isAssoc && attr.hasAssociationClass()) { propertyName = TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName; } // ajouter les methodes à la liste - methods.add(clazz.getName()+" find"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)"); - methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)"); + methods.add(clazzName+" find"+clazzName+"By"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" v)"); + methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" v)"); /*{ /** * Retourne le premier element trouve ayant comme valeur pour l'attribut - * <%=attr.getName()%> le parametre - * @param v la valeur que doit avoir <%=attr.getName()%> + * <%=attrName%> le parametre + * @param v la valeur que doit avoir <%=attrName%> * @return un element ou null *) - public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException; + public abstract <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException; /** * Retourne les éléments ayant comme valeur pour l'attribut - * <%=attr.getName()%> le paramêtre - * @param v la valeur que doit avoir <%=attr.getName()%> + * <%=attrName%> le paramêtre + * @param v la valeur que doit avoir <%=attrName%> * @return une liste *) - public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException; + public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException; }*/ if (attr.hasAssociationClass()) { - methods.add(clazz.getName() +" find"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)"); - methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)"); + String assocClassName = attr.getAssociationClass().getName(); + String assocClassFQN = attr.getAssociationClass().getQualifiedName(); + methods.add(clazzName +" find"+clazzName+"By"+TopiaGeneratorUtil.capitalize(assocClassName)+"("+assocClassFQN+" value)"); + methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+TopiaGeneratorUtil.capitalize(assocClassName)+"("+assocClassFQN+" value)"); /*{ /** * Retourne le premier element trouve ayant comme valeur pour l'attribut - * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le parametre - * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> + * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> le parametre + * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> * @return un element ou null *) - public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException; + public abstract <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException; /** * Retourne les éléments ayant comme valeur pour l'attribut - * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le paramêtre - * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> + * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> le paramêtre + * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> * @return une liste *) - public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException; + public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException; }*/ } } protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException { - methods.add(clazz.getName() + " find"+clazz.getName()+"Contains"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)"); - methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"Contains"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)"); + String attrName = attr.getName(); + String attrType = attr.getType(); + String clazzName = clazz.getName(); + String clazzFQN = clazz.getQualifiedName(); + methods.add(clazzName + " find"+clazzName+"Contains"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" ... v)"); + methods.add("List<"+clazzName+"> findAll"+clazzName+"Contains"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" ... v)"); /*{ /** * Retourne le premier element trouve dont l'attribut - * <%=attr.getName()%> contient le parametre - * @param v la valeur que doit contenir <%=attr.getName()%> + * <%=attrName%> contient le parametre + * @param v la valeur que doit contenir <%=attrName%> * @return un element ou null *) - public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException; + public abstract <%=clazzFQN%> find<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException; /** * Retourne les elements trouve dont l'attribut - * <%=attr.getName()%> contient le parametre - * @param v la valeur que doit contenir <%=attr.getName()%> + * <%=attrName%> contient le parametre + * @param v la valeur que doit contenir <%=attrName%> * @return une liste *) - public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException; + public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException; }*/ } @@ -392,7 +407,7 @@ ObjectModelClassifier parent = (ObjectModelClassifier)i.next(); // pour tous les DAOInterface if(parent.hasStereotype(DAO)){ - // r�cup�rer la classe de l'object model correspondant à la DAO + // récupérer la classe de l'object model correspondant à la DAO String entityClassName = null; entityClassName = parent.getQualifiedName().replace("DAO", ""); if(getModel().hasClass(entityClassName)){ @@ -409,8 +424,10 @@ return; } - for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) { - ObjectModelAttribute attr = (ObjectModelAttribute)it.next(); + String clazzName = clazz.getName(); + for (ObjectModelAttribute attr : clazz.getAttributes()) { + String attrName = attr.getName(); + String attrType = attr.getType(); ObjectModelAttribute reverse = attr.getReverseAttribute(); if (!attr.isNavigable() && !hasUnidirectionalRelationOnAbstractType(reverse, model)) { @@ -421,43 +438,44 @@ /*{ /** }*/ if (TopiaGeneratorUtil.hasDocumentation(attr)) { - methods.add("void set"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")"); + methods.add("void set"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+attrType+ " "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")"); -/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%> +/*{ * <%=attrName%> : <%=attr.getDocumentation()%> }*/ } -/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> à positionner. +/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> La valeur de l'attribut <%=attrName%> à positionner. *) - public abstract void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException; + public abstract void set<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException; }*/ /*{ /** }*/ if (TopiaGeneratorUtil.hasDocumentation(attr)) { - methods.add(attr.getType()+" get"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)"); -/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%> + methods.add(attrType+" get"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)"); +/*{ * <%=attrName%> : <%=attr.getDocumentation()%> }*/ } -/*{ * @return La valeur de l'attribut <%=attr.getName()%>. +/*{ * @return La valeur de l'attribut <%=attrName%>. *) - public abstract <%=attr.getType()%> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException; + public abstract <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException; }*/ } else { String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr); + String assocClassName = attr.getAssociationClass().getName(); + String assocClassFQN = attr.getAssociationClass().getQualifiedName(); if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); } - methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")"); - methods.add(attr.getAssociationClass().getName()+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)"); - + methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+assocClassName+" "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")"); + methods.add(assocClassName+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId)"); /*{ /** - * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner. + * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> La valeur de l'attribut <%=assocClassName%> à positionner. *) - public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException; + public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException; /** - * @return La valeur de l'attribut <%=attr.getAssociationClass().getName()%>. + * @return La valeur de l'attribut <%=assocClassName%>. *) - public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException; + public abstract <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException; }*/ } @@ -466,92 +484,94 @@ /*{ /** }*/ if (TopiaGeneratorUtil.hasDocumentation(attr)) { - methods.add("void add"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")"); -/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%> + methods.add("void add"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+attrType+" "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")"); +/*{ * <%=attrName%> : <%=attr.getDocumentation()%> }*/ } -/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à ajouter. +/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> L'instance de <%=attrName%> à ajouter. *) - public abstract void add<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException; + public abstract void add<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException; /** }*/ if (TopiaGeneratorUtil.hasDocumentation(attr)) { - methods.add("void addAll"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");; + methods.add("void addAll"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attrType+"> "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");; -/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%> +/*{ * <%=attrName%> : <%=attr.getDocumentation()%> }*/ } -/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> à ajouter. +/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> Les instances de <%=attrName%> à ajouter. *) - public abstract void addAll<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException; + public abstract void addAll<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attrType%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException; /** }*/ if (TopiaGeneratorUtil.hasDocumentation(attr)) { - methods.add("void set"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+ (attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")"); -/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%> + methods.add("void set"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+ (attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attrType+"> "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")"); +/*{ * <%=attrName%> : <%=attr.getDocumentation()%> }*/ } -/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> à positionner. +/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> La Collection de <%=attrName%> à positionner. *) - public abstract void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException; + public abstract void set<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attrType%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException; /** }*/ if (TopiaGeneratorUtil.hasDocumentation(attr)) { - methods.add("void remove"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")"); -/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%> + methods.add("void remove"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+attrType+ " "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")"); +/*{ * <%=attrName%> : <%=attr.getDocumentation()%> }*/ } -/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à retirer. +/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> L'instance de <%=attrName%> à retirer. *) - public abstract void remove<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException; + public abstract void remove<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException; /** }*/ if (TopiaGeneratorUtil.hasDocumentation(attr)) { - methods.add("void clear"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)"); -/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%> + methods.add("void clear"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)"); +/*{ * <%=attrName%> : <%=attr.getDocumentation()%> }*/ } -/*{ * Vide la Collection de <%=attr.getName()%>. +/*{ * Vide la Collection de <%=attrName%>. *) - public abstract void clear<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException; + public abstract void clear<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException; }*/ } else { + String assocClassName = attr.getAssociationClass().getName(); + String assocClassFQN = attr.getAssociationClass().getQualifiedName(); String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr); if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); } - methods.add("void add"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")"); - methods.add("void addAll"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")"); - methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")"); - methods.add("void remove"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")"); - methods.add("void clear"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)"); + methods.add("void add"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+assocClassName+" "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")"); + methods.add("void addAll"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+assocClassName+"> "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")"); + methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+assocClassName+"> "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")"); + methods.add("void remove"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+assocClassName+" "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")"); + methods.add("void clear"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId)"); /*{ /** - * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à ajouter. + * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> L'instance de <%=assocClassName%> à ajouter. *) - public abstract void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException; + public abstract void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException; /** - * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> à ajouter. + * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> Les instances de <%=assocClassName%> à ajouter. *) - public abstract void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException; + public abstract void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"List":"Collection")%><<%=assocClassFQN%>> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException; /** - * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> à positionner. + * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> La Collection de <%=assocClassName%> à positionner. *) - public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException; + public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"List":"Collection")%><<%=assocClassFQN%>> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException; /** - * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à retirer. + * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> L'instance de <%=assocClassName%> à retirer. *) - public abstract void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException; + public abstract void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException; /** - * Vide la Collection de <%=attr.getAssociationClass().getName()%>. + * Vide la Collection de <%=assocClassName%>. *) - public abstract void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException; + public abstract void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException; }*/ } @@ -560,42 +580,44 @@ /*{ /** }*/ if (TopiaGeneratorUtil.hasDocumentation(attr)) { - methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> get"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)"); - methods.add("int size"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)"); + methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attrType+"> get"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)"); + methods.add("int size"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)"); -/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%> +/*{ * <%=attrName%> : <%=attr.getDocumentation()%> }*/ } -/*{ * @return La Liste de <%=attr.getName()%>. +/*{ * @return La Liste de <%=attrName%>. *) - public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException; + public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attrType%>> get<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException; /** - * @return Le nombre d'éléments de la collection <%=attr.getName()%>. + * @return Le nombre d'éléments de la collection <%=attrName%>. *) - public abstract int size<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException; + public abstract int size<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException; }*/ } else { String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr); + String assocClassFQN = attr.getAssociationClass().getQualifiedName(); + String assocClassName = attr.getAssociationClass().getName(); if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); } - methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"Of"+clazz.getName()+"(String topiaId)"); - methods.add(attr.getAssociationClass().getName()+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" value)"); - methods.add("int size"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)"); + methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+assocClassName+"> get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"Of"+clazzName+"(String topiaId)"); + methods.add(assocClassName+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+attrType+" value)"); + methods.add("int size"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId)"); /*{ /** - * @return La liste des attributs <%=attr.getAssociationClass().getName()%>. + * @return La liste des attributs <%=assocClassName%>. *) - public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException; + public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=assocClassFQN%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException; /** - * @return L'attribut <%=attr.getAssociationClass().getName()%> associé à la valeur <code>value</code> de l'attribut <%=attr.getName()%>. + * @return L'attribut <%=assocClassName%> associé à la valeur <code>value</code> de l'attribut <%=attrName%>. *) - public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> value) throws TopiaException; + public abstract <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> value) throws TopiaException; /** - * @return Le nombre d'éléments de la collection <%=attr.getName()%>. + * @return Le nombre d'éléments de la collection <%=attrName%>. *) - public abstract int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException; + public abstract int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException; }*/ } @@ -648,7 +670,7 @@ String vir = ""; for(ObjectModelParameter param : params){ if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);} - method += " " + param.getType()+" "+param.getName(); + method += vir + param.getType()+" "+param.getName(); /*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/ vir = ", "; } @@ -671,17 +693,18 @@ } private void generateAssociationAccessors(Writer output, ObjectModelClass clazz, String name, String type) throws IOException { - methods.add("=> "+"void set"+GeneratorUtil.capitalize(name)+"Of"+clazz.getName()+"(String topiaId, "+type+" value)"); - methods.add("=> "+type+" get"+GeneratorUtil.capitalize(name)+"Of"+clazz.getName()+"(String topiaId)"); + String clazzName = clazz.getName(); + methods.add("=> "+"void set"+GeneratorUtil.capitalize(name)+"Of"+clazzName+"(String topiaId, "+type+" value)"); + methods.add("=> "+type+" get"+GeneratorUtil.capitalize(name)+"Of"+clazzName+"(String topiaId)"); /*{ /** * @param value La valeur de l'attribut <%=name%> à positionner. *) - public abstract void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId, <%=type%> value) throws TopiaException; + public abstract void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId, <%=type%> value) throws TopiaException; /** * @return La valeur de l'attribut <%=name%>. *) - public abstract <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException; + public abstract <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId) throws TopiaException; }*/ }