Index: topia/src/java/org/codelutin/topia/generators/Util.java diff -u topia/src/java/org/codelutin/topia/generators/Util.java:1.19 topia/src/java/org/codelutin/topia/generators/Util.java:1.20 --- topia/src/java/org/codelutin/topia/generators/Util.java:1.19 Fri Oct 14 13:13:05 2005 +++ topia/src/java/org/codelutin/topia/generators/Util.java Fri Nov 25 18:46:08 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.19 $ + * @version $Revision: 1.20 $ * - * Mise a jour: $Date: 2005/10/14 13:13:05 $ + * Mise a jour: $Date: 2005/11/25 18:46:08 $ * par : $Author: thimel $ */ @@ -280,15 +280,18 @@ return "true".equals(value); } + public static boolean isOrdered(ObjectModelAttribute attribute) { + return (attribute.hasStereotype("ordered")); + } + public static String getAttributeTypeForDO(ObjectModelParameter attribute) { - String result; if (attribute instanceof ObjectModelAttribute - && isNMultiplicity((ObjectModelAttribute)attribute)){ - result = "java.util.List"; - }else{ - result = attribute.getType(); + && isNMultiplicity((ObjectModelAttribute)attribute) + && attribute.hasStereotype("ordered")) { + return "java.util.List"; + } else { + return getAttributeType(attribute); } - return result; } /** Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java:1.22 topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java:1.23 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java:1.22 Tue Nov 8 17:15:40 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java Fri Nov 25 18:46:08 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.22 $ + * @version $Revision: 1.23 $ * - * Mise a jour: $Date: 2005/11/08 17:15:40 $ + * Mise a jour: $Date: 2005/11/25 18:46:08 $ * par : $Author: thimel $ */ @@ -189,11 +189,22 @@ throws IOException { /*{ <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> - public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; + public <%=Util.getAttributeTypeForDO(attribute)%> _get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; + + /** + * @return the instance of the field <%=attribute.getName()%> + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> + public <%=Util.getAttributeTypeForDO(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; }*/ if (attribute.hasAssociationClass()) { /*{ + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, true, false)%> + public <%=attribute.getAssociationClass().getQualifiedName()%> _get<%=attribute.getAssociationClass().getName()%>() throws TopiaException; + /** + * @return the instance of association class associated to the field <%=attribute.getName()%> + *) <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, true, false)%> public <%=attribute.getAssociationClass().getQualifiedName()%> get<%=attribute.getAssociationClass().getName()%>() throws TopiaException; }*/ @@ -203,28 +214,63 @@ public void generateGetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) throws IOException { /*{ + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> + public <%=Util.getAttributeTypeForDO(attribute)%><<%=attribute.getType()%>> _get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; /** - * @return an unmodifiable collection - *) + * @return an unmodifiable collection + *) <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> - public <%=Util.getAttributeType(attribute)%><<%=attribute.getType()%>> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; + public <%=Util.getAttributeTypeForDO(attribute)%><<%=attribute.getType()%>> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> + public int _sizeOf<%=Util.capitalize(attribute.getName())%>() throws TopiaException; + + /** + * @return the number of elements for the attribute <%=attribute.getName()%> + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> public int sizeOf<%=Util.capitalize(attribute.getName())%>() throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> + public Iterator<<%=attribute.getType()%>> _iteratorOn<%=Util.capitalize(attribute.getName())%>() throws TopiaException; + + /** + * @return an iterator on the collection of <%=attribute.getName()%> + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> public Iterator<<%=attribute.getType()%>> iteratorOn<%=Util.capitalize(attribute.getName())%>() throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> + public boolean _containsIn<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; + + /** + * @return a boolean indicating if the value is included in the collection of <%=attribute.getName()%> + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> public boolean containsIn<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> + public boolean _containsAllIn<%=Util.capitalize(attribute.getName())%>(java.util.Collection values) throws TopiaException; + + /** + * @return a boolean indicating if each element of the values collection are included in the collection of <%=attribute.getName()%> + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> public boolean containsAllIn<%=Util.capitalize(attribute.getName())%>(java.util.Collection values) throws TopiaException; +}*/ + if (Util.isOrdered(attribute)) { +/*{ + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> + public <%=attribute.getType()%> _get<%=Util.capitalize(attribute.getName())%>(int index) throws TopiaException; + /** + * @return the element number index from the collection of <%=attribute.getName()%> + *) <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> public <%=attribute.getType()%> get<%=Util.capitalize(attribute.getName())%>(int index) throws TopiaException; }*/ + } if (attribute.hasAssociationClass()) { //Quand on a une association dont les deux parties sont la même classe avec une classe d'assoc, il ne faut générer qu'une fois ces méthodes. Donc si c'est la deuxième fois, on ignore @@ -233,13 +279,22 @@ } /*{ + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, true, false)%> + public <%=Util.getAttributeTypeForDO(attribute)%><<%=attribute.getAssociationClass().getQualifiedName()%>> _get<%=Util.capitalize(attribute.getAssociationClass().getName())%>() throws TopiaException; + /** - * @return a collection of association classes - *) + * @return a collection of association classes (<%=attribute.getAssociationClass().getQualifiedName()%>) associated to the field <%=attribute.getName()%> + *) <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, true, false)%> - public <%=Util.getAttributeType(attribute)%><<%=attribute.getAssociationClass().getQualifiedName()%>> get<%=Util.capitalize(attribute.getAssociationClass().getName())%>() throws TopiaException; + public <%=Util.getAttributeTypeForDO(attribute)%><<%=attribute.getAssociationClass().getQualifiedName()%>> get<%=Util.capitalize(attribute.getAssociationClass().getName())%>() throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, true, false)%> + public <%=attribute.getAssociationClass().getQualifiedName()%> _get<%=Util.capitalize(attribute.getAssociationClass().getName())%>(<%=attribute.getType()%> value) throws TopiaException; + + /** + * @return the association classe associated to the field <%=attribute.getName()%> which value is value + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, true, false)%> public <%=attribute.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(attribute.getAssociationClass().getName())%>(<%=attribute.getType()%> value) throws TopiaException; }*/ } @@ -249,15 +304,33 @@ throws IOException { /*{ <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> + public TopiaEntity _get_attribute_<%=((Util.isFirstAttribute(attribute)) ? "A" : "B") %>_() throws TopiaException; + + /** + * @return the value of the attribute <%=((Util.isFirstAttribute(attribute)) ? "A" : "B") %> of the association + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> public TopiaEntity get_attribute_<%=((Util.isFirstAttribute(attribute)) ? "A" : "B") %>_() throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> + public <%=attribute.getType()%> _get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; + + /** + * @return the value of the attribute <%=Util.capitalize(attribute.getName())%> of the association + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, false)%> public <%=attribute.getType()%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; }*/ if (attribute.getReverseAttribute() == null) { - //Pas de navigabilité => on veut tout de même l'attribut opposé + //Pas de navigabilité => on veut tout de même l'attribut opposé (forcement B puisque l'attribut courant est le seul de la relation donc forcement le premier) /*{ <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, true)%> + public TopiaEntity _get_attribute_B_() throws TopiaException; + + /** + * @return the value of the attribute B of the association + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, false, true)%> public TopiaEntity get_attribute_B_() throws TopiaException; }*/ @@ -274,55 +347,139 @@ if (!attribute.hasAssociationClass()) { /*{ <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> - public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> value) throws TopiaException; + public void _set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeTypeForDO(attribute)%> value) throws TopiaException; + + /** + * Sets the value of the <%=attribute.getName()%> attribute + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeTypeForDO(attribute)%> value) throws TopiaException; }*/ } else { /*{ <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, true, false)%> + public void _set<%=Util.capitalize(attribute.getAssociationClass().getName())%>(<%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; + + /** + * Sets the value of the association class association associated to the <%=attribute.getName()%> attribute + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, true, false)%> public void set<%=Util.capitalize(attribute.getAssociationClass().getName())%>(<%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> - public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> value, <%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; + public void _set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeTypeForDO(attribute)%> value, <%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; + + /** + * Sets the association class association and its value of the <%=attribute.getName()%> attribute to value + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeTypeForDO(attribute)%> value, <%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; }*/ } } public void generateSetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) throws IOException { + if (Util.isOrdered(attribute)) { /*{ <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _set<%=Util.capitalize(attribute.getName())%>(int index, <%=attribute.getType()%> value) throws TopiaException; + + /** + * Sets the element number index in the <%=attribute.getName()%> collection to value + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> public void set<%=Util.capitalize(attribute.getName())%>(int index, <%=attribute.getType()%> value) throws TopiaException; +}*/ + } +/*{ + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; + /** + * Removes the element number index from the <%=attribute.getName()%> collection + *) <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _clear<%=Util.capitalize(attribute.getName())%>() throws TopiaException; + + /** + * Clears the <%=attribute.getName()%> collection + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> public void clear<%=Util.capitalize(attribute.getName())%>() throws TopiaException; }*/ if (!attribute.hasAssociationClass()) { /*{ <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; + + /** + * Adds the element value to the <%=attribute.getName()%> collection + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> - public void add<%=Util.capitalize(attribute.getName())%>(/*<%=Util.getAttributeType(attribute)%>*)java.util.Collection list) throws TopiaException; + public void _add<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeTypeForDO(attribute)%> coll) throws TopiaException; + /** + * Adds the collection of ellements coll to the <%=attribute.getName()%> collection + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void add<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeTypeForDO(attribute)%> coll) throws TopiaException; + + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _add<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeTypeForDO(attribute)%> coll, boolean duplicate) throws TopiaException; + + /** + * Adds the collection of ellements coll to the <%=attribute.getName()%> collection. If duplicate is set to false, duplicate element would not be added + *) <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> - public void add<%=Util.capitalize(attribute.getName())%>(/*<%=Util.getAttributeType(attribute)%>*)java.util.Collection list, boolean duplicate) throws TopiaException; + public void add<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeTypeForDO(attribute)%> coll, boolean duplicate) throws TopiaException; }*/ } else { + if (Util.isOrdered(attribute)) { /*{ <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _set<%=Util.capitalize(attribute.getName())%>(int index, <%=attribute.getAssociationClass().getQualifiedName()%> value) throws TopiaException; + + /** + * Sets the value of the association class value number index associated to the <%=attribute.getName()%> attribute + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> public void set<%=Util.capitalize(attribute.getName())%>(int index, <%=attribute.getAssociationClass().getQualifiedName()%> value) throws TopiaException; +}*/ + } +/*{ + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value, <%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; + /** + * Adds the association class association and sets its value of the <%=attribute.getName()%> attribute to value + *) <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value, <%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; + + /** + * Adds the value of the association class association associated to the <%=attribute.getName()%> attribute + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> - public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getAssociationClass().getQualifiedName()%> value) throws TopiaException; + public void _remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; + + /** + * Adds the instance of association class association associated to the <%=attribute.getName()%> attribute + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getAssociationClass().getQualifiedName()%> association) throws TopiaException; }*/ } @@ -333,14 +490,32 @@ throws IOException { /*{ <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _set_attribute_<%=((Util.isFirstAttribute(attribute)) ? "A" : "B") %>_(TopiaEntity value) throws TopiaException; + + /** + * Sets the value of the attribute <%=((Util.isFirstAttribute(attribute)) ? "A" : "B") %> of the association + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> public void set_attribute_<%=((Util.isFirstAttribute(attribute)) ? "A" : "B") %>_(TopiaEntity value) throws TopiaException; <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> + public void _set<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; + + /** + * Sets the value of the attribute <%=attribute.getName()%> of the association + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, false)%> public void set<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; }*/ if (attribute.getReverseAttribute() == null) { - //Pas de navigabilité => on veut tout de même l'attribut opposé + //Pas de navigabilité => on veut tout de même l'attribut opposé (forcement B puisque l'attribut courant est le seul de la relation donc forcement le premier) /*{ + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, true)%> + public void _set_attribute_B_(TopiaEntity value) throws TopiaException; + + /** + * Sets the value of the attribute B of the association + *) <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, true, attribute, false, true)%> public void set_attribute_B_(TopiaEntity value) throws TopiaException; }*/