Index: topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityInterfaceGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityInterfaceGenerator.java:1.15 topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityInterfaceGenerator.java:1.16 --- topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityInterfaceGenerator.java:1.15 Mon Jun 21 09:51:17 2004 +++ topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityInterfaceGenerator.java Tue Jun 22 19:01:06 2004 @@ -12,6 +12,7 @@ import org.codelutin.generator.ObjectModelGenerator; import org.codelutin.topia.generators.Util; +import org.codelutin.topia.generators.DefaultObjectModelToJavaGenerator; import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelInterface; @@ -19,34 +20,10 @@ import org.codelutin.generator.models.object.ObjectModelParameter; public class ObjectModelToEntityInterfaceGenerator - extends ObjectModelGenerator { + extends DefaultObjectModelToJavaGenerator { - public String getFilenameForClass(ObjectModelClass clazz) { - return super.getFilenameForClass(clazz) + ".java"; - } - - public void generateFromClass(Writer output, ObjectModelClass clazz) + public void generateClassDeclaration(Writer output, ObjectModelClass clazz) throws IOException { - - // Consider only entities, return immediately if not an entity - if (! Util.isEntity(clazz)) return; - - // ------------- File Header - if (!"".equals(clazz.getPackageName())) { -/*{ -package <%=clazz.getPackageName()%>; - -}*/ - } - - // ------------- Imports -/*{ -import org.codelutin.topia.TopiaEntity; -import org.codelutin.topia.TopiaException; - -}*/ - - // ------------- Interface start /*{ /** <%=clazz.getDocumentation()%> @@ -60,147 +37,72 @@ ObjectModelClass superclass = (ObjectModelClass) i.next(); /*{, <%=superclass.getName()%>}*/ } -/*{ - { - -}*/ + } - // ------------- Operations declarations - // Iterate on each operation to generate declarations - for (Iterator i = clazz.getOperations().iterator(); i.hasNext();) { - ObjectModelOperation operation = (ObjectModelOperation) i.next(); -/*{ /** - <%=operation.getDocumentation()%> - *) - <%=operation.getVisibility()%> <%=operation.getReturnType()%> <%=operation.getName()%>(}*/ - // Iterate on each parameters to declare operation parameters - for (Iterator j = operation.getParameters().iterator(); - j.hasNext(); - ) { - ObjectModelParameter parameter = - (ObjectModelParameter) j.next(); -/*{ -<%=parameter.getType()+" "+parameter.getName()%>}*/ - if (j.hasNext()) { /*{, }*/ - } - } + * Genere la declaration de l'interface, ceci n'inclue pas le { pour la + * declaration du corps de la classe. Cette methode la plus par du temps + * n'a pas besoin d'etre surcharge, il faut utiliser les methodes + * {@link #getClassName}, {@link #getExtendsInterfaceName} + */ + public void generateClassDeclaration(Writer output, ObjectModelInterface interfacez) throws IOException { /*{ -) throws TopiaException; -}*/ +/** +<%=interfacez.getDocumentation()%> + *) +public interface <%=interfacez.getName()%> extends TopiaEntity}*/ + for (Iterator i = interfacez.getInterfaces().iterator(); i.hasNext();){ + ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); +/*{, <%=interfacezz.getName()%>}*/ } -/*{ + } -}*/ + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + /*{; + }*/ + } - // ------------- Accessors - // Iterate on each attribute to declare accessors - for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { - ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); -/*{ /** - Getter on <%=attribute.getName()%>. <%=attribute.getDocumentation()%> - *) - public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; -}*/ - if (! Util.isReadOnly(attribute)) { -/*{ - /** - Setter on <%=attribute.getName()%>. <%=attribute.getDocumentation()%> - *) - public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> <%=attribute.getName()%>) throws TopiaException; -}*/ - } -/*{ - -}*/ - } + * No attribute in interface + */ + public void generateNormalAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + } - // ------------- Interface end + public void generateGetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { /*{ -} + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; }*/ - - } - - public String getFilenameForInterface(ObjectModelInterface interfacez) { - return super.getFilenameForInterface(interfacez) + ".java"; } - public void generateFromInterface( - Writer output, - ObjectModelInterface interfacez) + public void generateGetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) throws IOException { - - // Consider only entities, return immediately if not an entity - if (! Util.isEntity(interfacez)) return; - - // ------------- File Header - if (!"".equals(interfacez.getPackageName())) { /*{ -package <%=interfacez.getPackageName()%>; - + /** + * @return an unmodifiable collection + *) + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; }*/ - } - - // ------------- Imports -/*{ -import org.codelutin.topia.TopiaEntity; -import org.codelutin.topia.TopiaException; -}*/ + } - // ------------- Interface start -/*{ -/** -<%=interfacez.getDocumentation()%> - *) -public interface <%=interfacez.getName()%> extends TopiaEntity}*/ - for (Iterator i = interfacez.getInterfaces().iterator(); - i.hasNext(); - ) { - ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); -/*{, <%=interfacezz.getName()%>}*/ - } + public void generateSetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { /*{ - { - + public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> <%=attribute.getName()%>) throws TopiaException; }*/ + } - // ------------- Operations declarations - // Iterate on each operation to generate declarations - for (Iterator i = interfacez.getOperations().iterator(); - i.hasNext(); - ) { - ObjectModelOperation operation = (ObjectModelOperation) i.next(); -/*{ - /** - <%=operation.getDocumentation()%> - *) - <%=operation.getVisibility()%> <%=operation.getReturnType()%> <%=operation.getName()%> (}*/ - // Iterate on each parameters to declare operation parameters - for (Iterator j = operation.getParameters().iterator(); - j.hasNext(); - ) { - ObjectModelParameter parameter = - (ObjectModelParameter) j.next(); -/*{<%=parameter.getType()+" "+parameter.getName()%>}*/ - if (j.hasNext()) { /*{, }*/ - } - } -/*{ -) throws TopiaException; -}*/ - } + public void generateSetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { /*{ + public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; -}*/ + public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; - // ------------- Interface end -/*{ -} + public void clear<%=Util.capitalize(attribute.getName())%>() throws TopiaException; }*/ - } } Index: topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityPersistenceServiceInterfaceGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityPersistenceServiceInterfaceGenerator.java:1.6 topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityPersistenceServiceInterfaceGenerator.java:1.7 --- topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityPersistenceServiceInterfaceGenerator.java:1.6 Mon Jun 21 09:51:17 2004 +++ topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityPersistenceServiceInterfaceGenerator.java Tue Jun 22 19:01:06 2004 @@ -18,6 +18,7 @@ // Needed imports for processed file import org.codelutin.topia.generators.Util; +import org.codelutin.topia.generators.DefaultObjectModelToJavaGenerator; /** * @author cedric Index: topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityTOClassGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityTOClassGenerator.java:1.21 topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityTOClassGenerator.java:1.22 --- topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityTOClassGenerator.java:1.21 Mon Jun 21 09:51:17 2004 +++ topia/src/java/org/codelutin/topia/generators/commons/ObjectModelToEntityTOClassGenerator.java Tue Jun 22 19:01:06 2004 @@ -13,6 +13,7 @@ import org.codelutin.generator.ObjectModelGenerator; import org.codelutin.topia.generators.Util; +import org.codelutin.topia.generators.DefaultObjectModelToJavaGenerator; import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelClassifier; @@ -21,57 +22,53 @@ import org.codelutin.generator.models.object.ObjectModelParameter; public class ObjectModelToEntityTOClassGenerator - extends ObjectModelGenerator { + extends DefaultObjectModelToJavaGenerator { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// //// //// - //// FOR CLASS + //// COMMON TO CLASS AND INTERFACE //// //// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// - public String getFilenameForClass(ObjectModelClass clazz) { - return (clazz.getPackageName()+".transfer.").replace('.', File.separatorChar)+clazz.getName()+"TO.java"; - } - - public void generateFromClass(Writer output, ObjectModelClass clazz) + /** + * add transfer sub package + */ + public void generatePackageStatement(Writer output, ObjectModelClassifier clazz) throws IOException { + if (!"".equals(clazz.getPackageName())) { +/*{ +package <%=clazz.getPackageName()%>.transfer; - // Consider only entities, return immediately if not an entity - if (! Util.isEntity(clazz)) return; - - // ------------- File Header - generatePackageStatement(output, clazz); - - // ------------- Imports - generateImport(output, clazz); - - // ------------- Class start - generateClassDeclaration(output, clazz); - - // ------------- Attributes - - // ------------- Accessors - for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { - ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); - generateAttributeDeclaration(output, attribute); - generateGetAttributeAccessor(output, attribute); - generateSetAttributeAccessor(output, attribute); +}*/ } - // ------------- Operations declarations - generateOperation(output, clazz); + } - // ---------------- All that framework used - generateFrameworkNeed(output, clazz); + /** + * Importe les classes utilises utilisees le plus souvent + */ + public void generateImportStatement(Writer output, ObjectModelClassifier clazz) throws IOException { + super.generateImportStatement(output, clazz); /*{ - } +import <%=clazz.getQualifiedName()%>; }*/ + for (Iterator i = clazz.getInterfaces().iterator(); i.hasNext();) { + ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); +/*{ +import <%=clazz.getQualifiedName()%>; +}*/ + } + } + + public String getClassName(ObjectModelClassifier clazz){ + return clazz.getName() + "TO"; } + ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// //// @@ -87,310 +84,210 @@ return (interfacez.getPackageName()+".transfer.").replace('.', File.separatorChar)+interfacez.getName()+"TO.java"; } - public void generateFromInterface(Writer output, ObjectModelInterface interfacez) - throws IOException { - - // Consider only entities, return immediately if not an entity - if (! Util.isEntity(interfacez)) return; - - // ------------- File Header - generatePackageStatement(output, interfacez); - - // ------------- Imports -/*{ -import org.codelutin.topia.TopiaEntityTO; -import org.codelutin.topia.TopiaEntityTO; -import org.codelutin.topia.TopiaException; -import <%=interfacez.getQualifiedName()%>; -}*/ - - for (Iterator i = interfacez.getInterfaces().iterator(); i.hasNext();) { - ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); -/*{ -import <%=interfacez.getPackageName()%>.<%=interfacezz.getName()%>; -}*/ - } -/*{ - -}*/ - - // ------------- Interface start -/*{ -public interface <%=interfacez.getName()%>TO}*/ -/*{ extends <%=interfacez.getName()%>, TopiaEntityTO}*/ - for (Iterator i = interfacez.getInterfaces().iterator(); i.hasNext();) { - ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); -/*{, <%=interfacezz.getName()%>}*/ - } -/*{ { -}*/ - generateOperation(output, interfacez); -/*{ - } -}*/ - + public String getExtendsInterfaceName(ObjectModelInterface interfacez){ + return interfacez.getName()+ ", TopiaEntityTO"; } - - ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// //// //// - //// SUB GENERATOR + //// FOR CLASS //// //// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// - - - - - - public void generatePackageStatement(Writer output, ObjectModelClassifier clazz) - throws IOException { - if (!"".equals(clazz.getPackageName())) { -/*{ -package <%=clazz.getPackageName()%>.transfer; - -}*/ - } + public String getFilenameForClass(ObjectModelClass clazz) { + return (clazz.getPackageName()+".transfer.").replace('.', File.separatorChar)+clazz.getName()+"TO.java"; } - - /** - * Permet la generation des imports - */ - protected void generateImport(Writer output, ObjectModelClassifier clazz)throws IOException{ - /*{ -import org.codelutin.topia.TopiaEntity; -import org.codelutin.topia.TopiaEntityTO; -import org.codelutin.topia.AbstractTopiaEntityTO; -import org.codelutin.topia.TopiaUser; -import org.codelutin.topia.TopiaException; -import org.codelutin.topia.TopiaPersistenceService; -import org.codelutin.topia.PrivateTopiaPersistenceService; -import java.util.List; -import java.util.Collections; -import <%=clazz.getQualifiedName()%>; -}*/ - - for (Iterator i = clazz.getInterfaces().iterator(); i.hasNext();) { - ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); -/*{ -import <%=clazz.getPackageName()%>.<%=interfacezz.getName()%>; -}*/ - } + public String getExtendsClassName(ObjectModelClass clazz){ + return "AbstractTopiaEntityTO"; } - - protected void generateClassDeclaration(Writer output, ObjectModelClass clazz) - throws IOException { -/*{ -public<% if(Util.isDerived(clazz)){ %> abstract<% } %> class <%=clazz.getName()%>TO}*/ - Iterator i = clazz.getSuperclasses().iterator(); - if (i.hasNext()) { - ObjectModelClass superclass = (ObjectModelClass) i.next(); - // BB: je ne comprend pas a quoi sert le Extension ? -/*{ extends <%=superclass.getName()%><%if(Util.isDerived(clazz)){%>Extension<%}%>TO}*/ - } else { -/*{ extends AbstractTopiaEntityTO}*/ - } -/*{ implements <%=clazz.getName()%>, TopiaEntityTO}*/ - for (i = clazz.getInterfaces().iterator(); i.hasNext();) { - ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); -/*{, <%=interfacezz.getName()%>}*/ - } -/*{ { }*/ - + public String getImplementsClassName(ObjectModelClass clazz){ + return clazz.getName() + ", TopiaEntityTO"; } - /** - * Permet la generation de la declaration des attributs + * add variable to know if variable is modified or not */ - protected void generateAttributeDeclaration(Writer output, ObjectModelAttribute attribute)throws IOException{ - if(!Util.isDerived(attribute)){ + public void generateNormalAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { + super.generateNormalAttributeDeclaration(output, attribute); /*{ - // variable declaration, the name is prefixed by _ - protected <%=Util.getAttributeType(attribute)%> <%=attribute.getName()%> = <%=Util.getInitValue(attribute)%>; protected boolean _<%=attribute.getName()%>Modified_ = false; }*/ + } - if (attribute.referenceClassifier()) { + public void generateEntityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { + super.generateEntityAttributeDeclaration(output, attribute); /*{ // boolean to know if attribute is allready loaded protected boolean _<%=attribute.getName()%>ReferenceLoaded_ = false; - <% if (Util.isNMultiplicity(attribute)) { %> - // lists des Ids des entities - protected List _<%=attribute.getName()%>Id_ = null; - <% } else { %> // Id of the entity protected Object _<%=attribute.getName()%>Id_ = null; - <% } %> }*/ - } } - } - - - + public void generateEntityNMultiplicityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { + super.generateEntityNMultiplicityAttributeDeclaration(output, attribute); +/*{ + // boolean to know if attribute is allready loaded + protected boolean _<%=attribute.getName()%>ReferenceLoaded_ = false; + // lists des Ids des entities + protected List _<%=attribute.getName()%>Id_ = null; +}*/ + } - /** - * Permet la generation des methode d'acces aux attributs - */ - protected void generateGetAttributeAccessor(Writer output, ObjectModelAttribute attribute)throws IOException{ - if (Util.isDerived(attribute)) { + public void generateGetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) throws IOException { + super.generateGetNormalAttributeAccessor(output, attribute); /*{ - public abstract <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; + public boolean is_<%=attribute.getName()%>Modified_(){ + return this._<%=attribute.getName()%>Modified_; + } }*/ - }else{ + } - // Not a derived attribute : + public void generateGetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + super.generateGetNormalNMultiplicityAttributeAccessor(output, attribute); /*{ public boolean is_<%=attribute.getName()%>Modified_(){ return this._<%=attribute.getName()%>Modified_; } +}*/ + } + public void generateGetEntityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public boolean is_<%=attribute.getName()%>Modified_(){ + return this._<%=attribute.getName()%>Modified_; + } public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + if (! this._<%=attribute.getName()%>ReferenceLoaded_) { + TopiaPersistenceService tps = + getContext().getPersistenceService(<%=attribute.getType()%>.class); + PrivateTopiaPersistenceService ptps = + (PrivateTopiaPersistenceService)tps; + <%=attribute.getName()%> = (<%=Util.getAttributeType(attribute)%>) + ptps.findByTopiaId(_<%=attribute.getName()%>Id_); + this._<%=attribute.getName()%>ReferenceLoaded_ = true; + } - <% if (attribute.referenceClassifier()) { %> + return <%=attribute.getName()%>; + } +}*/ + } + public void generateGetEntityNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public boolean is_<%=attribute.getName()%>Modified_(){ + return this._<%=attribute.getName()%>Modified_; + } + + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException { if (! this._<%=attribute.getName()%>ReferenceLoaded_) { TopiaPersistenceService tps = getContext().getPersistenceService(<%=attribute.getType()%>.class); PrivateTopiaPersistenceService ptps = (PrivateTopiaPersistenceService)tps; - <%=attribute.getName()%> = <%=(Util.isNMultiplicity(attribute)?"":"("+Util.getAttributeType(attribute)+")")%> - ptps.findByTopiaId(_<%=attribute.getName()%>Id_); + <%=attribute.getName()%> = ptps.findByTopiaId(_<%=attribute.getName()%>Id_); this._<%=attribute.getName()%>ReferenceLoaded_ = true; } - <% } - if(Util.isNMultiplicity(attribute)){ - %> - return Collections.unmodifiableList(<%=attribute.getName()%>); - <% }else{ %> - return <%=attribute.getName()%>; - <% } %> + return Collections.unmodifiableCollection(<%=attribute.getName()%>); } }*/ - } } + public void generateSetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> <%=attribute.getName()%>) throws TopiaException { + this._<%=attribute.getName()%>Modified_ = true; + this.<%=attribute.getName()%> = <%=attribute.getName()%>; + } +}*/ + } - /** - * Permet la generation des methode d'acces aux attributs - */ - protected void generateSetAttributeAccessor(Writer output, ObjectModelAttribute attribute)throws IOException{ - if (!Util.isReadOnly(attribute)) { - if (Util.isDerived(attribute)) { + public void generateSetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { /*{ - public abstract void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> <%=attribute.getName()%>) throws TopiaException; + public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> <%=attribute.getName()%>) throws TopiaException { + this._<%=attribute.getName()%>Modified_ = true; + this.<%=attribute.getName()%>.add(<%=attribute.getName()%>); + } + public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException { + this._<%=attribute.getName()%>Modified_ = true; + this.<%=attribute.getName()%>.remove(value); + } + + public void clear<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + this.<%=attribute.getName()%> = <%=Util.getInitValue(attribute)%>; + } }*/ - }else{ - if(!Util.isNMultiplicity(attribute)){ -/*{ + } + + public void generateSetEntityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + /*{ public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> <%=attribute.getName()%>) throws TopiaException { this._<%=attribute.getName()%>Modified_ = true; this.<%=attribute.getName()%> = <%=attribute.getName()%>; - <% if (attribute.referenceClassifier()) { %> this._<%=attribute.getName()%>ReferenceLoaded_ = true; - <% } %> } }*/ - }else{ + } + + public void generateSetEntityNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { /*{ public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> <%=attribute.getName()%>) throws TopiaException { this._<%=attribute.getName()%>Modified_ = true; - <% if (attribute.referenceClassifier()) { %> // on force le chargement get<%=Util.capitalize(attribute.getName())%>(); - <% } %> this.<%=attribute.getName()%>.add(<%=attribute.getName()%>); } - public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> <%=attribute.getName()%>) throws TopiaException { + public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException { this._<%=attribute.getName()%>Modified_ = true; - <% if (attribute.referenceClassifier()) { %> // on force le chargement get<%=Util.capitalize(attribute.getName())%>(); - <% } %> - this.<%=attribute.getName()%>.remove(<%=attribute.getName()%>); + this.<%=attribute.getName()%>.remove(value); } public void clear<%=Util.capitalize(attribute.getName())%>() throws TopiaException { this.<%=attribute.getName()%> = <%=Util.getInitValue(attribute)%>; } }*/ - } - } - } } - - /** - * Permet la generation des methodes - */ - protected void generateOperation(Writer output, ObjectModelClassifier clazz)throws IOException{ - // Iterate on each operation to generate declarations - for (Iterator i = clazz.getOperations().iterator(); i.hasNext();) { - ObjectModelOperation operation = (ObjectModelOperation) i.next(); -/*{ - <%=operation.getVisibility()%> <%=(operation.isAbstract()?"abstract ":"")%><%=operation.getReturnType()%> <%=operation.getName()%> (<%=Util.getMethodParameterDeclaration(operation.getParameters())%>) throws TopiaException}*/ + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + if (operation.isAbstract()){ + /*{; + }*/ + }else{ + super.generateOperationBody(output, operation); } } - - protected void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { - if (operation.isAbstract() - || operation.getDeclaringElement() instanceof ObjectModelInterface) { -/*{;}*/ - } else { -/*{{ - // TODO forward sur le service adéquat -}*/ - if (! "void".equals(operation.getReturnType())) { -/*{ - return <%=Util.getInitValue(operation.getReturnType())%>; -}*/ - } -/*{ - } - -}*/ + public void generateOther(Writer output, ObjectModelClass clazz) throws IOException { + if(clazz.getSuperclasses().size() != 0){ + // on a deja genere la meme choses dans la classe mere, + // on sort tout de suite. + return; } - } - - - public void generateTopiaIdOperation(Writer output, ObjectModelClassifier clazz) - throws IOException { -/*{ - protected Object _topiaId_; - - public Object get_topiaId_() throws TopiaException { - return this._topiaId_; - } - public void set_topiaId_(Object topiaId) throws TopiaException { - this._topiaId_ = topiaId; - } -}*/ - } - - /** - * Permet la generation de tout ce dont a besoin de le framework - */ - protected void generateFrameworkNeed(Writer output, ObjectModelClass clazz)throws IOException{ generateTopiaIdOperation(output, clazz); generateSetAllFrameworkProperties(output, clazz); - /*{ + /*{ /** * Return entity Class managed by this service @@ -434,6 +331,20 @@ }*/ } + public void generateTopiaIdOperation(Writer output, ObjectModelClassifier clazz) + throws IOException { +/*{ + protected Object _topiaId_; + + public Object get_topiaId_() throws TopiaException { + return this._topiaId_; + } + public void set_topiaId_(Object topiaId) throws TopiaException { + this._topiaId_ = topiaId; + } +}*/ + } + protected void generateSetAllFrameworkProperties(Writer output, ObjectModelClass clazz) throws IOException { /*{ /** @@ -489,7 +400,9 @@ // else we use get method for (Iterator i=entity.get<%=Util.capitalize(attribute.getName())%>().iterator(); i.hasNext();) { TopiaEntity te = (TopiaEntity)i.next(); - if (object != null) tmpIds.add(te.get_topiaId_()); + if (te != null){ + tmpIds.add(te.get_topiaId_()); + } } } this._<%=attribute.getName()%>Id_ = tmpIds;