Re: [Lutingenerator-devel] zargo, agrégations et xslt
Romain Manni-Bucau a écrit :
Je mets en PJ le modèle, l'objectmodel et voici le bout du template qui ne marche pas :
Ça reste un peu difficile à analyser.
Util : ------ public static Collection<ObjectModelAttribute> getPrimaryKeyAttributes(ObjectModelClass clazz) { ArrayList<ObjectModelAttribute> primaryKeyAttributes = new ArrayList<ObjectModelAttribute>(); for (ObjectModelAttribute attribute : clazz.getAttributes()) if (isPrimaryKey(attribute)) primaryKeyAttributes.add(attribute); return primaryKeyAttributes; }
ListPkAttribute : ----------------- ... protected List<ObjectModelAttribute> origAttr = new ArrayList<ObjectModelAttribute>(); ...
Constructeur (récursif) : ... for (Iterator iter=Util.getPrimaryKeyAttributes(clazz).iterator(); iter.hasNext(); ){ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); ... this.origAttr.add(attribute); } ...
Générateur : ------------
ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazzAssociated, true); for(int i=0; i<listPrimaryKey.getName().size(); i++ ){ ObjectModelAttribute attributeI = listPrimaryKey.getOrigAttr().get(i); /*{<!-- agg ? <%=attributeI.isAggregate()%> -->}*/ // renvoie toujours false }
Êtes vous sur qu'il affiche "false" pour la bonne classe ? Pouvez vous faire un test avec plus d'infos dans le template : /*{<!-- test : <%=attributeI.getType()%> = <%=attributeI.isAggregate()%>/<%=attributeI.isComposite()%> -->}*/ Il devrait afficher : <!-- test : org.ofbiz.marketing.contact.entities.ContactList = true/false --> -- Éric <chatellier@codelutin.com> Tel: 02 40 50 29 28 http://www.codelutin.com
Je mets entre parenthèse le nom de l'attribut à la suite de la sortie. sortie : <!-- test : java.lang.String = false/false --> (contactListTypeId) <!-- test : java.lang.String = false/false --> (contactMechTypeId) De plus, une recherche de "true/f" ne me renvoie aucun résultat dans le fichier généré. Le mardi 21 juillet 2009 à 16:39 +0200, Eric Chatellier a écrit :
Romain Manni-Bucau a écrit :
Je mets en PJ le modèle, l'objectmodel et voici le bout du template qui ne marche pas :
Ça reste un peu difficile à analyser.
Util : ------ public static Collection<ObjectModelAttribute> getPrimaryKeyAttributes(ObjectModelClass clazz) { ArrayList<ObjectModelAttribute> primaryKeyAttributes = new ArrayList<ObjectModelAttribute>(); for (ObjectModelAttribute attribute : clazz.getAttributes()) if (isPrimaryKey(attribute)) primaryKeyAttributes.add(attribute); return primaryKeyAttributes; }
ListPkAttribute : ----------------- ... protected List<ObjectModelAttribute> origAttr = new ArrayList<ObjectModelAttribute>(); ...
Constructeur (récursif) : ... for (Iterator iter=Util.getPrimaryKeyAttributes(clazz).iterator(); iter.hasNext(); ){ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); ... this.origAttr.add(attribute); } ...
Générateur : ------------
ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazzAssociated, true); for(int i=0; i<listPrimaryKey.getName().size(); i++ ){ ObjectModelAttribute attributeI = listPrimaryKey.getOrigAttr().get(i); /*{<!-- agg ? <%=attributeI.isAggregate()%> -->}*/ // renvoie toujours false }
Êtes vous sur qu'il affiche "false" pour la bonne classe ?
Pouvez vous faire un test avec plus d'infos dans le template :
/*{<!-- test : <%=attributeI.getType()%> = <%=attributeI.isAggregate()%>/<%=attributeI.isComposite()%> -->}*/
Il devrait afficher : <!-- test : org.ofbiz.marketing.contact.entities.ContactList = true/false -->
Romain Manni-Bucau a écrit :
Je mets entre parenthèse le nom de l'attribut à la suite de la sortie.
sortie : <!-- test : java.lang.String = false/false --> (contactListTypeId) <!-- test : java.lang.String = false/false --> (contactMechTypeId)
Ok, donc je pense que vous n'appelez pas isAggregate() sur les bons attributs. A voir les résultats et vos templates, dans la méthode :
public static Collection<ObjectModelAttribute> getPrimaryKeyAttributes(ObjectModelClass clazz) { ArrayList<ObjectModelAttribute> primaryKeyAttributes = new ArrayList<ObjectModelAttribute>(); for (ObjectModelAttribute attribute : clazz.getAttributes()) if (isPrimaryKey(attribute)) primaryKeyAttributes.add(attribute); return primaryKeyAttributes; }
la methode "isPrimaryKey" doit filtrer les attributs qui ont un tagValue <tagValue name="primaryKey" value="true"/> (je présume). Vous avez mit les tagValue sur les attributs "contactListTypeId" et "contactListId", qui ne sont pas des attributs issue d'association, et n'ont donc pas de valeur "aggregate". Ce serait plutôt à faire sur l'association entre "ContactListType" et "ContactList" qui contient l'aggregation que vous rechercher... -- Éric <chatellier@codelutin.com> Tel: 02 40 50 29 28 http://www.codelutin.com
merci, le problème venait effectivement d'une erreur de ma part. Bonne soirée
participants (2)
-
Eric Chatellier -
Romain Manni-Bucau