Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityImplGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityImplGenerator.java:1.12 topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityImplGenerator.java:1.13 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityImplGenerator.java:1.12 Fri Jun 10 08:21:57 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityImplGenerator.java Fri Jun 10 09:43:01 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.12 $ + * @version $Revision: 1.13 $ * - * Mise a jour: $Date: 2005/06/10 08:21:57 $ + * Mise a jour: $Date: 2005/06/10 09:43:01 $ * par : $Author: thimel $ */ @@ -107,25 +107,24 @@ } /*{ protected boolean _<%=attribute.getName()%>Modified_ = false; }*/ + //On calcule le nom de l'association stockée dans order (puis dans nameFor<%=Util.capitalize(attribute.getName())%>) + //De plus, on enregistre dans index<%=Util.capitalize(attribute.getName())%> si l'objet courant est le premier(0) objet de la relation ou le second(1) if (!Util.isBasicAttributeType(attribute)) { int index; String order = ""; if (attribute.getReverseAttribute() != null) { -/*{ //<%=attribute.getName() + "/" + attribute.getReverseAttribute().getName() + " : " + attribute.getName().compareTo(attribute.getReverseAttribute().getName())%> -}*/ if (attribute.getName().compareTo(attribute.getReverseAttribute().getName()) < 0) { //Attribut + petit donc l'objet courant (+ grd) passe en dernier => 1 index = 1; - order = attribute.getType() + Util.capitalize(attribute.getName()) + ((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName() + Util.capitalize(attribute.getReverseAttribute().getName()); + order = attribute.getType() + "-" + attribute.getName() + "--" + ((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName() + "-" + attribute.getReverseAttribute().getName(); } else { index = 0; - order = ((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName() + Util.capitalize(attribute.getReverseAttribute().getName()) + attribute.getType() + Util.capitalize(attribute.getName()); + order = ((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName() + "-" + attribute.getReverseAttribute().getName() + "--" + attribute.getType() + "-" + attribute.getName(); } } else { index = 0; - order = attribute.getType() + Util.capitalize(attribute.getName()); + order = attribute.getType() + "-" + attribute.getName(); } -System.out.println(order + " : " + index); /*{ protected int index<%=Util.capitalize(attribute.getName())%> = <%=index%>; protected String nameFor<%=Util.capitalize(attribute.getName())%> = "<%=order%>"; }*/ @@ -316,19 +315,20 @@ if (doSecurity()) { /*{ TopiaAccessController.checkPermission(this, "write"); }*/ - }//TODO Changement 1 => 0..1 trop laxiste + } if (!Util.isBasicAttributeType(attribute) && Util.is1Multiplicity(attribute)) - if (!Util.is1Multiplicity(attribute.getReverseAttribute())) { // Si c'est une association 1-1, on la considère comme une association 0..1 - 0..1 + if (attribute.isComposite()) { + //TODO Pas adapté au composite !!!! /*{ if (value == null) throw new TopiaException("Cannot set <%=attribute.getName()%> to null - Multiplicity 1"); -}*/ - } else { -/*{ //Multiplicity 1 changed to 0..1 because of 1-1 relation -}*/ +}*/ + } else { // Si ce n'est pas un composite, on la considère comme une association 0..1 +/*{ //Multiplicity 1 changed to 0..1 because of non composite +}*/ } if (attribute.isComposite()) { -/*{ _dependentEntities.remove(this.<%=attribute.getName()%>); - _dependentEntities.add(value); +/*{ remove_dependentEntities_(this.<%=attribute.getName()%>); + add_dependentEntities_(value); }*/ } if (attribute.getReverseAttribute() != null) @@ -413,7 +413,7 @@ }*/ } if (attribute.isComposite()) { -/*{ _dependentEntities.add(value); +/*{ add_dependentEntities_(value); }*/ } /*{ this._<%=attribute.getName()%>Modified_ = true; @@ -450,7 +450,7 @@ }*/ } if (attribute.isComposite()) { -/*{ _dependentEntities.remove(value); +/*{ remove_dependentEntities_(value); }*/ } /*{ this._<%=attribute.getName()%>Modified_ = true; @@ -465,7 +465,7 @@ } if (attribute.isComposite()) { /*{ for (Iterator it = this.<%=attribute.getName()%>.iterator(); it.hasNext(); ) - _dependentEntities.remove(it.next()); + remove_dependentEntities_((TopiaEntity)it.next()); }*/ } /*{ this._<%=attribute.getName()%>Modified_ = true; @@ -495,7 +495,7 @@ <%=attribute.getType()%> value = (<%=attribute.getType()%>)i.next(); }*/ if (attribute.isComposite()) { -/*{ _dependentEntities.add(value); +/*{ add_dependentEntities_(value); }*/ } /*{ add<%=Util.capitalize(attribute.getName())%>(value); @@ -523,8 +523,8 @@ }*/ } if (attribute.isComposite()) { -/*{ _dependentEntities.remove(<%=attribute.getName()%>.get(index)); - _dependentEntities.add(value); +/*{ remove_dependentEntities_((TopiaEntity)<%=attribute.getName()%>.get(index)); + add_dependentEntities_(value); }*/ } /*{ <%=attribute.getName()%>.set(index, value); @@ -590,7 +590,7 @@ public void remove() throws TopiaException{ <%=clazz.getName()%>PersistenceService persistenceService = getPersistenceService(); persistenceService.delete(this); - for (Iterator i = _dependentEntities.iterator(); i.hasNext(); ) + for (Iterator i = iterator_dependentEntities_(); i.hasNext(); ) ((TopiaEntity)i.next()).remove(); } }*/