Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java:1.6 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java:1.7 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java:1.6 Fri Jun 25 19:55:10 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java Mon Jun 28 23:04:22 2004 @@ -25,10 +25,10 @@ Map nameMap = Util.initPackageName(clazz); String packageName=(String) nameMap.get("packageName"); String entityName = clazz.getName(); - System.out.println("XXXXXXXX1Debug clazz.getName="+clazz.getName()); + //System.out.println("XXXXXXXX1Debug clazz.getName="+clazz.getName()); /*{ -// $Id: GeneratorEditBsh.java,v 1.6 2004/06/25 19:55:10 holivier Exp $ +// $Id: GeneratorEditBsh.java,v 1.7 2004/06/28 23:04:22 holivier Exp $ // Copyright (c) 2004 Olivier Heintz - olivier.heintz@nereide.biz // Copyright (c) 2004 Nereide - www.nereide.biz // Copyright (c) 2004 Neogia - www.neogia.org @@ -48,7 +48,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // @author Olivier.Heintz@nereide.biz -// @version $Revision: 1.6 $ +// @version $Revision: 1.7 $ // @since 3.1 // // Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java:1.4 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java:1.5 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java:1.4 Sat Jun 26 17:18:33 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java Mon Jun 28 23:04:22 2004 @@ -113,7 +113,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // @author Olivier.Heintz@nereide.biz -// @version $Revision: 1.4 $ +// @version $Revision: 1.5 $ // @since 3.1 // // This file has been generated, and will be re-generated, @@ -155,13 +155,13 @@ public static final String module = <%=entityName%>Services.class.getName(); public static final String resource = "<%=Util.toUpperCaseFirstLetter(packageName)%>UiLabels"; - // - // Create a <%=entityName%> record - // - // @param ctx - // @param context: a map containing in paramaters - // @return result: a map containing out parameters - // + // + // Create a <%=entityName%> record + // + // @param ctx + // @param context: a map containing in paramaters + // @return result: a map containing out parameters + // public static Map edit<%=entityName%>(DispatchContext ctx, Map context) { GenericDelegator delegator = ctx.getDelegator(); // GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -176,7 +176,9 @@ }*/ ObjectModelAttribute AttrComposite = Util.isComposition(model, clazz); String ident = " "; + // code generation for retreiving objetc generateRetreiveObject(output, clazz, AttrComposite, ident); + // /*{ if (actionForm.equals("add") ){ if (<%=Util.toLowerCaseFirstLetter(entityName)%>.isAlreadyPersistant() ){ Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java:1.3 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java:1.4 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java:1.3 Fri Jun 25 19:55:10 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java Mon Jun 28 23:04:22 2004 @@ -19,17 +19,15 @@ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { if(! Util.isEntity(clazz)) return; - System.out.println("start of class=" + clazz.getName()); + //System.out.println("start of class=" + clazz.getName()); if(! Util.hasGuiEditAssoc(clazz) ) return; - System.out.println(" class selected " ); List associationList = Util.getAssocList(clazz); Map nameMap = Util.initPackageName(clazz); String packageName =Util.toUpperCaseFirstLetter((String) nameMap.get("packageName")); String subpackageName=(String) nameMap.get("subpackageName"); -/*{ - +/*{ <%=packageName%>EditAssoc<%=clazz.getName()%> @@ -38,19 +36,16 @@ }*/ if (associationList.size() == 1){ String associationName = ((ObjectModelAttribute) associationList.get(0) ).getName(); -/*{ - <%=associationName%> +/*{ <%=associationName%> }*/ } else { for (Iterator iter=associationList.iterator(); iter.hasNext(); ){ String associationName = ((ObjectModelAttribute) iter.next() ).getName(); -/*{ - <%=associationName%> +/*{ <%=associationName%> }*/ } } -/*{ - 20 +/*{ 20 <%=packageName.toUpperCase()%> _UPDATE simple Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java:1.2 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java:1.3 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java:1.2 Fri Jun 25 19:55:10 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java Mon Jun 28 23:04:22 2004 @@ -23,8 +23,7 @@ String subpackageName=(String) nameMap.get("subpackageName"); -/*{ - +/*{ <%=packageName%>Show<%=clazz.getName()%> Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.26 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.27 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.26 Mon Jun 28 10:15:22 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java Mon Jun 28 23:04:22 2004 @@ -375,7 +375,7 @@ if( Util.isEntity( clazz )){ initPackageName(clazz); packageName = Util.toUpperCaseFirstLetter(packageName); - System.out.println( "generateFromClass " + clazz.getName() + " packageName="+packageName ); + //System.out.println( "generateFromClass " + clazz.getName() + " packageName="+packageName ); initListAtt( clazz ); ObjectModelAttribute AttrComposite = Util.isComposition(model, clazz); String entityName = clazz.getName(); @@ -406,7 +406,7 @@ * *@author Olivier.Heintz@nereide.biz *@author malin.nicolas@nereide.biz -*@version $Revision: 1.26 $ +*@version $Revision: 1.27 $ *@since 3.1 * * This file has been generated, and will be re-generated, Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.22 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.23 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.22 Sat Jun 26 17:18:33 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java Mon Jun 28 23:04:22 2004 @@ -28,9 +28,9 @@ * Copyright Code Lutin * Copyright Nereide * Copyright Neogia -* @version $Revision: 1.22 $ +* @version $Revision: 1.23 $ * -* Last update : $Date: 2004/06/26 17:18:33 $ +* Last update : $Date: 2004/06/28 23:04:22 $ * by : $Author: holivier $ */ package org.nereide.ofbiz.neogia.generators; @@ -58,6 +58,7 @@ public class Util extends org.codelutin.topia.generators.Util { static private final String tagSeparator = ", "; + static private final String valueSeparator = ": "; /** * Return a List with all the clazz attribute which have the tag gui - listLookup. @@ -76,29 +77,56 @@ /** * Re-organize the getParticipants result to be able to access by index the class and the attributeName. * This methode is used to build field name so the attribute are in reverse mode. + * This metod put sort the association class depending on the tag setDefaultAssoc. * @param clazz * @return a Map with two ArrayList, one with key "classParticipants" and one with "attributeParticipants". */ public static Map getParticipantsWithName(ObjectModelClass clazz){ - List classParticipants = new ArrayList(2); - List attributeParticipants = new ArrayList(2); + List tmpClassParticipants = new ArrayList(2); int id = 0; if (clazz instanceof ObjectModelAssociationClass) { - System.out.println("XXXXXXX-getParticipantsWithName1-Debug associationClass entityName="+clazz.getName()); Map listMapParticipant =((ObjectModelAssociationClass) clazz).getParticipants(); - System.out.println("XXXXXXX-getParticipantsWithName2-Debug associationClass listMapParticipant.size="+listMapParticipant.size()); + //System.out.println("XXXXXXX-getParticipantsWithName2-Debug associationClass listMapParticipant.size="+listMapParticipant.size()); for (Iterator iterPart=listMapParticipant.keySet().iterator(); iterPart.hasNext(); ){ - classParticipants.add(id,iterPart.next()); + tmpClassParticipants.add(id,iterPart.next()); id += 1; } - if (listMapParticipant.get(classParticipants.get(0)) == null) System.out.println("XXXXXXX-getParticipantsWithName3-Debug null for classParticipants.get(0)="+((ObjectModelClass)classParticipants.get(0)).getName()); - if (listMapParticipant.get(classParticipants.get(1)) == null) System.out.println("XXXXXXX-getParticipantsWithName3-Debug null for classParticipants.get(1)="+((ObjectModelClass)classParticipants.get(1)).getName()); - attributeParticipants.add(0, (listMapParticipant.get(classParticipants.get(1)) != null) ? - ((ObjectModelAttribute) listMapParticipant.get(classParticipants.get(1))).getName() : - Util.toLowerCaseFirstLetter(((ObjectModelClass) classParticipants.get(0)).getName())); - attributeParticipants.add(1, (listMapParticipant.get(classParticipants.get(0)) != null) ? - ((ObjectModelAttribute) listMapParticipant.get(classParticipants.get(0))).getName() : - Util.toLowerCaseFirstLetter(((ObjectModelClass) classParticipants.get(1)).getName())); + // find which class put in first + String classAName = ((ObjectModelClass) tmpClassParticipants.get(0)).getName(); + String classBName = ((ObjectModelClass) tmpClassParticipants.get(1)).getName(); + boolean find = false; + int firstClass = 0, secondClass = 1; + List attrAssociationRank = new ArrayList(); + List attrAssociation = getSetDefaultAssoc(clazz, attrAssociationRank); + for (int iAssoc=0; iAssoc 1 || attribute.getMaxMultiplicity() == -1) ){ - System.out.println("XXXXXXX-getClassAssocWithoutNav1-Debug one found classAsso="+ - classAssociated.getName()+" attribute.getName="+attribute.getName()+ - " "); + //System.out.println("XXXXXXX-getClassAssocWithoutNav1-Debug one found classAsso="+classAssociated.getName()+" attribute.getName="+attribute.getName()+" "); classAssocWithoutNav.add(attribute); } } @@ -193,6 +219,40 @@ } /** + * Return the List of all the association with the rank definied in the Tag setDefaultAssoc. + * @param assocRank the out parameters list which contain the rank + * @return the list of the association, the rank is in the assocRank list. + */ + public static List getSetDefaultAssoc(ObjectModelClass clazz, List assocRank){ + List listAssoc = new ArrayList(); + if (clazz.getTagValue("setDefaultAssoc") != null ){ + StringTokenizer guiTag = new StringTokenizer( clazz.getTagValue( "setDefaultAssoc" ) , tagSeparator ); + for( ; guiTag.hasMoreTokens(); ){ + StringTokenizer attributeRank = new StringTokenizer( guiTag.nextToken() , valueSeparator ); + listAssoc.add(attributeRank.nextToken() ); + if (attributeRank.hasMoreTokens() ) assocRank.add( new Integer( attributeRank.nextToken() ) ); + else assocRank.add(new Integer(999) ); + } + } + return listAssoc; + } + + /** + * Return a List with all the clazz attribute with the association in the correct Order. + */ + public static List getAttributes(ObjectModelClass clazz){ + Collection attributesList = clazz.getAttributes(); + List attrAssociationRank = new ArrayList(); + List attrAssociation = getSetDefaultAssoc(clazz, attrAssociationRank); + int k =0; + for (int i =0; i +/*{ <%=packageName%>List<%=clazz.getName()%> @@ -38,16 +37,13 @@ <%=clazz.getName()%> }*/ if (guiList){ -/*{ - N +/*{ N }*/ } else { -/*{ - Y +/*{ Y }*/ } -/*{ - N +/*{ N entityList Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java:1.9 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java:1.10 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java:1.9 Sat Jun 26 17:18:33 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java Mon Jun 28 23:04:22 2004 @@ -55,7 +55,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * *@author Olivier.Heintz@nereide.biz - *@version $Revision: 1.9 $ + *@version $Revision: 1.10 $ *@since 3.1 * * This file has been generated, and will be re-generated, @@ -97,7 +97,6 @@ //System.out.println("XXXXXXXX0Debug PackageName()="+clazz.getPackageName()); if(Util.isEntity(clazz) && clazz.getPackageName().startsWith(packageParam)){ entityName = clazz.getName(); - System.out.println("XXXXXXXX1Debug entityName="+entityName); subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName())); /*{ 0 ){ for (Iterator iterClass=classAssocWithoutNav.iterator(); iterClass.hasNext(); ){ ObjectModelAttribute attrAssociated = (ObjectModelAttribute) iterClass.next(); - System.out.println("XXXXXX-Debug in iterator classAssocWithoutNav attrAssociated=" + attrAssociated.getName()); ObjectModelClass classAssociated = (ObjectModelClass) attrAssociated.getDeclaringElement(); String relationName = (attrAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName())) ) ? Util.toLowerCaseFirstLetter(classAssociated.getName()) : @@ -181,7 +179,6 @@ } } } - System.out.println("YYYYYYYYY-Y1-Debug primaryKey creation clazz=" + clazz.getName()); listPrimaryKeyName.clear(); listPrimaryKeyType.clear(); Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType); for(int i=0; i }*/ } - System.out.println("YYYYYYYYY-Y2-Debug primaryKey creation clazz=" + clazz.getName()); // Add relation for each field for each participant if it's an association class if (participantsWithName != null) { - System.out.println("XXXXXXX-X4-Debug associationClass primaryKey"); for (int i=0; i<2; i++){ ObjectModelClass participantClass = (ObjectModelClass) ((List) participantsWithName.get("classParticipants")).get(i); /*{ Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java:1.2 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java:1.3 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java:1.2 Fri Jun 25 19:55:10 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java Mon Jun 28 23:04:22 2004 @@ -22,8 +22,7 @@ String subpackageName=(String) nameMap.get("subpackageName"); -/*{ - +/*{ <%=packageName%>Edit<%=clazz.getName()%> Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java:1.5 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java:1.6 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java:1.5 Fri Jun 25 19:55:10 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java Mon Jun 28 23:04:22 2004 @@ -24,10 +24,10 @@ if (! Util.hasGuiList(clazz) && ! Util.hasGuiListAll(clazz) ) return; Map nameMap = Util.initPackageName(clazz); String packageName=(String) nameMap.get("packageName"); - System.out.println("XXXXXXXX1Debug clazz.getName="+clazz.getName()); + //System.out.println("XXXXXXXX1Debug clazz.getName="+clazz.getName()); /*{ -// $Id: GeneratorFindBsh.java,v 1.5 2004/06/25 19:55:10 holivier Exp $ +// $Id: GeneratorFindBsh.java,v 1.6 2004/06/28 23:04:22 holivier Exp $ // Copyright (c) 2004 Olivier Heintz - olivier.heintz@nereide.biz // Copyright (c) 2004 Nereide - www.nereide.biz // Copyright (c) 2004 Neogia - www.neogia.org @@ -47,7 +47,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // @author Olivier.Heintz@nereide.biz -// @version $Revision: 1.5 $ +// @version $Revision: 1.6 $ // @since 3.1 // // Calls Find on a dynamiqueView to return an EntityListIterator of the @@ -111,7 +111,7 @@ // add attributes with gui indexed if there are not already in the list for (Iterator iter=clazz.getAttributes().iterator(); iter.hasNext(); ){ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); - System.out.println("XXXXXXXX2Debug attribute.getName="+attribute.getName()); + //System.out.println("XXXXXXXX2Debug attribute.getName="+attribute.getName()); if (Util.hasGuiIndexed(attribute)){ if (! attribute.referenceClassifier()) attributesIndexed.add(attribute.getName()); if (attributesListOrIndexed.indexOf(attribute) == -1) attributesListOrIndexed.add(attribute); @@ -120,7 +120,6 @@ List listAttributeName = new ArrayList(); for (Iterator iter=attributesListOrIndexed.iterator(); iter.hasNext(); ){ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); - System.out.println("XXXXXXXX3Debug attribute.getName="+attribute.getName()); if ( attribute.referenceClassifier() ){ if ( attribute.getMaxMultiplicity() == 1 ) listAssoc.add(attribute); } else{ @@ -135,7 +134,6 @@ int nbAssoc = 1; for (Iterator iter=listAssoc.iterator(); iter.hasNext(); ){ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); - System.out.println("XXXXXXXX4Debug attribute.getName="+attribute.getName()); Map relationKeyName = Util.getRelationOneFieldName(model, attribute); ObjectModelClass clazzAssoc = (ObjectModelClass) relationKeyName.get("clazzAssociated"); String relationName = clazzAssoc.getName(); @@ -167,7 +165,6 @@ // Add the classAssoc attributes with the tag gui listInAssoc for (Iterator iterAssoc=clazzAssoc.getAttributes().iterator(); iterAssoc.hasNext(); ){ ObjectModelAttribute attributeAssoc = (ObjectModelAttribute) iterAssoc.next(); - System.out.println("XXXXXXXX5Debug attributeAssoc.getName="+attributeAssoc.getName()); if ( Util.hasGuiListInAssoc(attributeAssoc) ){ /*{ dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(relationName)%><%=Util.toUpperCaseFirstLetter(attributeAssoc.getName())%>","<%=attributeAssoc.getName()%>",null,null,null,null); @@ -203,7 +200,6 @@ }*/ for (Iterator iter=attributesIndexed.iterator(); iter.hasNext(); ){ String attributeName = (String) iter.next(); - System.out.println("XXXXXXXX7Debug attribute.getName="+attributeName); /*{ keys.add("<%=attributeName%>"); }*/