Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.2 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.3 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.2 Sun Jun 6 22:25:40 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java Sun Jun 13 22:56:56 2004 @@ -48,7 +48,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // @author Olivier.Heintz@nereide.biz -// @version $Revision: 1.2 $ +// @version $Revision: 1.3 $ // @since 3.1 // // This file has been generated, and will be re-generated, @@ -136,7 +136,7 @@ } public boolean exist(){ - if (techDataCalendar != null) return true; + if (<%=Util.toLowerCaseFirstLetter(entityName)%> != null) return true; else return false; } @@ -151,7 +151,7 @@ for(int j=0; j(){ + public <%=(String) listPrimaryKeyType.get(j)%> get<%=Util.toUpperCaseFirstLetter((String) listPrimaryKeyName.get(j) )%>(){ if (exist() ) return <%=(String) listPrimaryKeyName.get(j)%>; return null; } Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorServicesXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorServicesXml.java:1.2 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorServicesXml.java:1.3 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorServicesXml.java:1.2 Thu Jun 10 08:47:55 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorServicesXml.java Sun Jun 13 22:56:56 2004 @@ -49,7 +49,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * *@author Olivier.Heintz@nereide.biz - *@version $Revision: 1.2 $ + *@version $Revision: 1.3 $ *@since 3.1 * * This file has been generated, and will be re-generated, @@ -72,7 +72,7 @@ if(Util.isEntity(clazz) && clazz.getPackageName().startsWith(packageParam)){ entityName = clazz.getName(); subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName())); - if (Util.hasGuiEdit(clazz) ){ + if (Util.hasGuiEdit(clazz) || Util.isEditViaAssoc(model, clazz) ){ /*{ 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.17 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.18 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.17 Sun Jun 6 22:25:40 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java Sun Jun 13 22:56:56 2004 @@ -28,9 +28,9 @@ * Copyright Code Lutin * Copyright Nereide * Copyright Neogia -* @version $Revision: 1.17 $ +* @version $Revision: 1.18 $ * -* Last update : $Date: 2004/06/06 22:25:40 $ +* Last update : $Date: 2004/06/13 22:56:56 $ * by : $Author: holivier $ */ package org.nereide.ofbiz.neogia.generators; @@ -46,6 +46,7 @@ import java.util.Properties; import java.util.StringTokenizer; +import org.apache.xpath.axes.IteratorPool; import org.codelutin.generator.models.object.ObjectModel; import org.codelutin.generator.models.object.ObjectModelAssociationClass; import org.codelutin.generator.models.object.ObjectModelAttribute; @@ -122,7 +123,7 @@ ObjectModelAttribute attribute = (ObjectModelAttribute) iterAttr.next(); if (clazz.equals(attribute.getClassifier())){ if (attribute.getReverseAttribute() == null && ! attribute.hasAssociationClass() - && attribute.getMaxMultiplicity() > 1 ){ + && (attribute.getMaxMultiplicity() > 1 || attribute.getMaxMultiplicity() == -1) ){ System.out.println("XXXXXXX-getClassAssocWithoutNav1-Debug one found classAsso="+ classAssociated.getName()+" attribute.getName="+attribute.getName()+ " "); @@ -202,6 +203,7 @@ } /** + * Depreciated, now use class ListPkAttribute. * Returns all attributes that are part of the primary key for this class and for all the superClass of this class. * TODO : change Collection to List as return type when the org.codelutin.topia.Util.getPrimaryKeyAttributes * will be change. @@ -399,9 +401,9 @@ } /** - * useable to test if the _att as a tagvalue=="gui" and if its value contain the word "calculated". + * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "calculated". * @param _att - * @return true if _att as a tagvalue=="gui" and if its value contain the word "calculated". + * @return true if _att has a tagvalue=="gui" and if its value contain the word "calculated". */ public static boolean hasGuiCalculated( ObjectModelAttribute _att ){ StringTokenizer guiTag = new StringTokenizer( _att.getTagValue( "gui" ) != null ? _att.getTagValue( "gui" ) : "" , tagSeparator); @@ -412,9 +414,9 @@ } /** - * useable to test if the _att as a tagvalue=="gui" and if its value contain the word "description". + * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "description". * @param _att - * @return true if _att as a tagvalue=="gui" and if its value contain the word "description". + * @return true if _att has a tagvalue=="gui" and if its value contain the word "description". */ public static boolean hasGuiDescription( ObjectModelAttribute _att ){ StringTokenizer guiTag = new StringTokenizer( _att.getTagValue( "gui" ) != null ? _att.getTagValue( "gui" ) : "", tagSeparator ); @@ -425,9 +427,9 @@ } /** - * useable to test if the _att as a tagvalue=="gui" and if its value contain the word "dropDown". + * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "dropDown". * @param _att - * @return true if _att as a tagvalue=="gui" and if its value contain the word "dropDown". + * @return true if _att has a tagvalue=="gui" and if its value contain the word "dropDown". */ public static boolean hasGuiDropDown( ObjectModelClass _clazz ){ StringTokenizer guiTag = new StringTokenizer( _clazz.getTagValue( "gui" ) != null ? _clazz.getTagValue( "gui" ) : "", tagSeparator ); @@ -438,9 +440,9 @@ } /** - * useable to test if the element as a tagvalue=="gui" and if its value contain the word "subEdit". + * useable to test if the element has a tagvalue=="gui" and if its value contain the word "subEdit". * @param element - * @return true if element as a tagvalue=="gui" and if its value contain the word "subEdit". + * @return true if element has a tagvalue=="gui" and if its value contain the word "subEdit". */ public static boolean hasGuiSubEdit( ObjectModelClass clazz ){ StringTokenizer guiTag = new StringTokenizer( clazz.getTagValue( "gui" ) != null ? clazz.getTagValue( "gui" ) : "", tagSeparator ); @@ -453,9 +455,9 @@ } /** - * useable to test if the clazz as a tagvalue=="gui" and if its value contain the word "edit". + * useable to test if the clazz has a tagvalue=="gui" and if its value contain the word "edit". * @param clazz - * @return true if clazz as a tagvalue=="gui" and if its value contain the word "edit". + * @return true if clazz has a tagvalue=="gui" and if its value contain the word "edit". */ public static boolean hasGuiEdit( ObjectModelClass clazz ){ StringTokenizer guiTag = new StringTokenizer( clazz.getTagValue( "gui" ) != null ? clazz.getTagValue( "gui" ) : "", tagSeparator ); @@ -466,9 +468,9 @@ } /** - * useable to test if the _att as a tagvalue=="gui" and if its value contain the word "hidden". + * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "hidden". * @param _att - * @return true if _att as a tagvalue=="gui" and if its value contain the word "hidden". + * @return true if _att has a tagvalue=="gui" and if its value contain the word "hidden". */ public static boolean hasGuiHidden( ObjectModelAttribute _att ){ StringTokenizer guiTag = new StringTokenizer( _att.getTagValue( "gui" ) != null ? _att.getTagValue( "gui" ) : "", tagSeparator ); @@ -479,9 +481,9 @@ } /** - * useable to test if the _att as a tagvalue=="gui" and if its value contain the word "indexed". + * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "indexed". * @param _att - * @return true if _att as a tagvalue=="gui" and if its value contain the word "indexed". + * @return true if _att has a tagvalue=="gui" and if its value contain the word "indexed". */ public static boolean hasGuiIndexed( ObjectModelAttribute _att ){ StringTokenizer guiTag = new StringTokenizer( _att.getTagValue( "gui" ) != null ? _att.getTagValue( "gui" ) : "", tagSeparator ); @@ -492,9 +494,9 @@ } /** - * useable to test if the element as a tagvalue=="gui" and if its value contain the word "list". + * useable to test if the element has a tagvalue=="gui" and if its value contain the word "list". * @param element - * @return true if element as a tagvalue=="gui" and if its value contain the word "list". + * @return true if element has a tagvalue=="gui" and if its value contain the word "list". */ public static boolean hasGuiList( ObjectModelElement element ){ StringTokenizer guiTag = new StringTokenizer( element.getTagValue( "gui" ) != null ? element.getTagValue( "gui" ) : "", tagSeparator ); @@ -505,9 +507,9 @@ } /** - * useable to test if the element as a tagvalue=="gui" and if its value contain the word "subList". + * useable to test if the element has a tagvalue=="gui" and if its value contain the word "subList". * @param element - * @return true if element as a tagvalue=="gui" and if its value contain the word "subList". + * @return true if element has a tagvalue=="gui" and if its value contain the word "subList". */ public static boolean hasGuiSubList( ObjectModelElement element ){ StringTokenizer guiTag = new StringTokenizer( element.getTagValue( "gui" ) != null ? element.getTagValue( "gui" ) : "", tagSeparator ); @@ -520,9 +522,9 @@ } /** - * useable to test if the clazz as a tagvalue=="gui" and if its value contain the word "listAll". + * useable to test if the clazz has a tagvalue=="gui" and if its value contain the word "listAll". * @param clazz - * @return true if clazz as a tagvalue=="gui" and if its value contain the word "listAll". + * @return true if clazz has a tagvalue=="gui" and if its value contain the word "listAll". */ public static boolean hasGuiListAll( ObjectModelClass clazz ){ StringTokenizer guiTag = new StringTokenizer(clazz.getTagValue("gui")!=null?clazz.getTagValue("gui"):"", tagSeparator); @@ -532,22 +534,77 @@ } /** - * useable to test if the _att as a tagvalue=="gui" and if its value contain the word "editAssoc". + * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "editAssoc". * @param _att - * @return true if _att as a tagvalue=="gui" and if its value contain the word "editAssoc". + * @return true if _att has a tagvalue=="gui" and if its value contain the word "editAssoc". */ public static boolean hasGuiEditAssoc( ObjectModelAttribute _att ){ StringTokenizer guiTag = new StringTokenizer( _att.getTagValue( "gui" ) != null ? _att.getTagValue( "gui" ) : "", tagSeparator ); for( ; guiTag.hasMoreTokens(); ) - if( guiTag.nextToken().equals( "editAssoc" ) && _att.getMaxMultiplicity() == 1 ) + if( guiTag.nextToken().equals( "editAssoc" ) ) return true; return false; } /** - * useable to test if the _att as a tagvalue=="gui" and if its value contain the word "listInAssoc". + * useable to test if the _clazz has one or more association with a tagvalue=="gui" and if its value contain the word "editAssoc". + * @param _clazz + * @return true if _clazz has at least one association with a tagvalue=="gui" and if its value contain the word "editAssoc". + */ + public static boolean hasGuiEditAssoc( ObjectModelClass _clazz ){ + for (Iterator iter=_clazz.getAttributes().iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if (attribute.referenceClassifier() && hasGuiEditAssoc(attribute) ) return true; + } + return false; + } + + /** + * Give the list of all the association's Name with a tag editAsssoc + * @param _clazz + * @return a List of String with the attributeName which are an association and have a tagvalue=="gui" and if its value contain the word "editAssoc". + */ + public static List getAssocList( ObjectModelClass _clazz ){ + List associationList = new ArrayList(); + for (Iterator iter=_clazz.getAttributes().iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if (attribute.referenceClassifier() && hasGuiEditAssoc(attribute) ) associationList.add(attribute.getName() ); + } + return associationList; + } + + /** + * Test if there is (at least) an association from an other class with gui editAssoc, useable to know if the subEdit screen, is used or not. + * @param _clazz + * @return true if _clazz has at least one association with a tagvalue=="gui" and if its value contain the word "editAssoc" from an other class. + */ + public static boolean isEditViaAssoc( ObjectModel model, ObjectModelClass _clazz ){ + for (Iterator iter=_clazz.getAttributes().iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if (attribute.referenceClassifier() ){ + ObjectModelAttribute reverseAttribute = attribute.getReverseAttribute(); + if ( reverseAttribute != null && hasGuiEditAssoc( reverseAttribute ) ) return true; + } + } + if (_clazz instanceof ObjectModelAssociationClass ){ + Map listMapParticipant =((ObjectModelAssociationClass) _clazz).getParticipants(); + for (Iterator iterPart=listMapParticipant.keySet().iterator(); iterPart.hasNext(); ){ + if ( hasGuiEditAssoc( (ObjectModelAttribute) listMapParticipant.get( iterPart.next() ) ) ) return true; + } + } + List nonNavAttribute = getClassAssocWithoutNav(model, _clazz); + if (nonNavAttribute.size() > 0 ){ + for (Iterator iter=nonNavAttribute.iterator(); iter.hasNext(); ){ + if ( hasGuiEditAssoc((ObjectModelAttribute) iter.next() ) ) return true; + } + } + return false; + } + + /** + * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "listInAssoc". * @param _att - * @return true if _att as a tagvalue=="gui" and if its value contain the word "listInAssoc". + * @return true if _att has a tagvalue=="gui" and if its value contain the word "listInAssoc". */ public static boolean hasGuiListInAssoc( ObjectModelAttribute _att ){ StringTokenizer guiTag = new StringTokenizer( _att.getTagValue( "gui" ) != null ? _att.getTagValue( "gui" ) : "", tagSeparator ); @@ -558,9 +615,9 @@ } /** - * useable to test if the _att as a tagvalue=="gui" and if its value contain the word "listLookup". + * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "listLookup". * @param _att - * @return true if _att as a tagvalue=="gui" and if its value contain the word "listLookup". + * @return true if _att has a tagvalue=="gui" and if its value contain the word "listLookup". */ public static boolean hasGuiListLookup( ObjectModelAttribute _att ){ StringTokenizer guiTag = new StringTokenizer( _att.getTagValue( "gui" ) != null ? _att.getTagValue( "gui" ) : "", tagSeparator ); @@ -571,9 +628,9 @@ } /** - * useable to test if the clazz as a tagvalue=="gui" and if its value contain the word "lookup". + * useable to test if the clazz has a tagvalue=="gui" and if its value contain the word "lookup". * @param clazz - * @return true if clazz as a tagvalue=="gui" and if its value contain the word "lookup". + * @return true if clazz has a tagvalue=="gui" and if its value contain the word "lookup". */ public static boolean hasGuiLookup( ObjectModelClass clazz ){ StringTokenizer guiTag = new StringTokenizer( clazz.getTagValue( "gui" ) != null ? clazz.getTagValue( "gui" ) : "", tagSeparator ); @@ -584,9 +641,9 @@ } /** - * useable to test if the _att as a tagvalue=="gui" and if its value contain the word "name". + * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "name". * @param _att - * @return true if _att as a tagvalue=="gui" and if its value contain the word "name". + * @return true if _att has a tagvalue=="gui" and if its value contain the word "name". */ public static boolean hasGuiIdName( ObjectModelAttribute _att ){ StringTokenizer guiTag = new StringTokenizer( _att.getTagValue( "gui" ) != null ? _att.getTagValue( "gui" ) : "", tagSeparator ); @@ -597,9 +654,9 @@ } /** - * useable to test if the clazz as a tagvalue=="gui" and if its value contain the word "show". + * useable to test if the clazz has a tagvalue=="gui" and if its value contain the word "show". * @param clazz - * @return true if clazz as a tagvalue=="gui" and if its value contain the word "show". + * @return true if clazz has a tagvalue=="gui" and if its value contain the word "show". */ public static boolean hasGuiShow( ObjectModelClass clazz ){ StringTokenizer guiTag = new StringTokenizer( clazz.getTagValue( "gui" ) != null ? clazz.getTagValue( "gui" ) : "", tagSeparator ); Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java:1.8 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java:1.9 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java:1.8 Thu Jun 10 08:41:07 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java Sun Jun 13 22:56:56 2004 @@ -3,6 +3,7 @@ import java.io.IOException; import java.io.Writer; import java.util.Iterator; +import java.util.List; import org.codelutin.generator.ObjectModelGenerator; import org.codelutin.generator.models.object.ObjectModel; @@ -49,7 +50,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * *@author Olivier.Heintz@nereide.biz - *@version $Revision: 1.8 $ + *@version $Revision: 1.9 $ *@since 3.1 * * This file has been generated, and will be re-generated, @@ -101,6 +102,33 @@ }*/ } + if(Util.hasGuiEditAssoc(clazz) ) { + List associationList = Util.getAssocList(clazz); +/*{ + + + + + +}*/ + for (Iterator iter=associationList.iterator(); iter.hasNext(); ){ + String associationName = (String) iter.next(); +/*{ + + + + + + + + + + + + +}*/ + } + } if (Util.hasGuiLookup(clazz)){ /*{ @@ -142,6 +170,12 @@ if (Util.hasGuiEdit(clazz)){ /*{ + +}*/ + } + if (Util.hasGuiEditAssoc(clazz)){ +/*{ + }*/ } Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java diff -u /dev/null ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java:1.1 --- /dev/null Sun Jun 13 22:57:02 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java Sun Jun 13 22:56:56 2004 @@ -0,0 +1,64 @@ +package org.nereide.ofbiz.neogia.generators; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModelClass; + +public class GeneratorPagedefsEditAssocXml extends ObjectModelGenerator { + + public String getFilenameForClass(ObjectModelClass clazz){ + Map nameMap = Util.initPackageName(clazz); + return ((String)nameMap.get("packageName"))+"/webapp/"+((String)nameMap.get("packageName"))+"/WEB-INF/pagedefs/"+((String)nameMap.get("subpackageName"))+"/EditAssoc"+clazz.getName()+"G.xml"; + } + + public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { + if(! Util.isEntity(clazz)) return; + 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()%> + <%=subpackageName%> + /<%=subpackageName%>/TabBarSubMenu.ftl +}*/ + if (associationList.size() == 1){ + String associationName = (String) associationList.get(0); +/*{ + <%=associationName%> +}*/ + } else { + for (Iterator iter=associationList.iterator(); iter.hasNext(); ){ + String associationName = (String) iter.next(); +/*{ + <%=associationName%> +}*/ + } + } +/*{ + 20 + <%=packageName.toUpperCase()%> + _UPDATE + simple + + + + +}*/ + } +} + +