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.1 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java:1.2 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java:1.1 Sun Jun 6 22:25:40 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java Sun Jun 20 21:58:10 2004 @@ -2,7 +2,6 @@ import java.io.IOException; import java.io.Writer; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -14,14 +13,80 @@ public class GeneratorEntityServicesJava extends ObjectModelGenerator { + // ---------------------------------------------------------------------- + // method for generation Retreiving operation + // ---------------------------------------------------------------------- + private void generateRetreiveObject(Writer output, ObjectModelClass clazz, ObjectModelAttribute AttrComposite, String ident) throws IOException { + String entityName = clazz.getName(); + ObjectModelClass classComposite = null; + if (AttrComposite != null){ + classComposite = (ObjectModelClass) AttrComposite.getDeclaringElement(); + String classCompositeName = classComposite.getName(); + String primaryKeyAsParam="", primaryKeyNotNull=""; + ListPkAttribute listPrimaryKey = new ListPkAttribute(model, classComposite, false); + for (int j=0; j <%=attributeKeyType%> <%=fieldName%>= (<%=attributeKeyType%>) context.get("<%=fieldName%>"); +}*/ + if (j <%=classCompositeName%> <%=Util.toLowerCaseFirstLetter(classCompositeName)%> = null; +<%=ident%> if (<%=primaryKeyNotNull%> ){ +<%=ident%> <%=Util.toLowerCaseFirstLetter(classCompositeName)%> = new <%=classCompositeName%>(delegator, <%=primaryKeyAsParam%>); +<%=ident%> } +}*/ + } + + // initialisation of the primaryKeyList + String primaryKeyAsParam="", primaryKeyAsMap="", primaryKeyNotNull=""; + if (AttrComposite != null ){ + primaryKeyNotNull = Util.toLowerCaseFirstLetter(classComposite.getName())+".isAlreadyPersistant() && "; + primaryKeyAsParam = Util.toLowerCaseFirstLetter(classComposite.getName()) + ", "; + } + ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazz, false, classComposite); + for(int j=0; j <%=attributeKeyType%> <%=attributeKeyName%> = (<%=attributeKeyType%>) context.get("<%=attributeKeyName%>"); +}*/ + if (j if (<%=primaryKeyNotNull%> ){ +<%=ident%> <%=entityName%> <%=Util.toLowerCaseFirstLetter(entityName)%> = new <%=entityName%>(delegator, <%=primaryKeyAsParam%>); + +}*/ + } + public String getFilenameForClass(ObjectModelClass clazz){ Map nameMap = Util.initPackageName(clazz); String packageName = (String) nameMap.get("packageName"); return packageName+"/src/org/ofbiz/"+packageName+"/"+((String)nameMap.get("subpackageName"))+"/"+clazz.getName()+"Services.java"; } + // --------------------------------------------- + // Main method for generation + // --------------------------------------------- public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { if (! Util.isEntity(clazz) ) return; + if (! Util.hasGuiEdit(clazz) && ! Util.isEditViaAssoc(model, clazz) ) return; Map nameMap = Util.initPackageName(clazz); String packageName = (String) nameMap.get("packageName"); String subpackageName = (String)nameMap.get("subpackageName"); @@ -48,7 +113,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // @author Olivier.Heintz@nereide.biz -// @version $Revision: 1.1 $ +// @version $Revision: 1.2 $ // @since 3.1 // // This file has been generated, and will be re-generated, @@ -109,27 +174,10 @@ if (actionForm.startsWith("commit") ){ actionForm = actionForm.substring(6); }*/ - // initialisation of the primaryKeyList - String primaryKeyAsParam="", primaryKeyAsMap="", primaryKeyNotNull=""; - List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = new ArrayList(); - Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType, false); - for(int j=0; j <%=attributeKeyName%> = (<%=attributeKeyType%>) context.get("<%=attributeKeyName%>"); -}*/ - if (j ){ - <%=entityName%> <%=Util.toLowerCaseFirstLetter(entityName)%> = new <%=entityName%>(delegator, <%=primaryKeyAsParam%>); - if (actionForm.equals("add") ){ if (<%=Util.toLowerCaseFirstLetter(entityName)%>.isAlreadyPersistant() ){ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonIdAlreadyExist", locale)); @@ -144,7 +192,7 @@ Map relationKeyName = Util.getRelationOneFieldName(model, attribute); List listName = (List) relationKeyName.get("listName"); ObjectModelClass classAssociated = (ObjectModelClass) ((Map) relationKeyName ).get("clazzAssociated"); - primaryKeyAsParam = ""; primaryKeyNotNull = ""; + String primaryKeyAsParam = "", primaryKeyNotNull = ""; for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){ Map fieldNameMap = (Map) iterList.next(); String fieldName = (String) fieldNameMap.get("fieldName"); @@ -197,26 +245,9 @@ Locale locale = (Locale) context.get("locale"); }*/ - // initialisation of the primaryKeyList - primaryKeyAsParam=""; primaryKeyAsMap=""; primaryKeyNotNull=""; - listPrimaryKeyName.clear(); listPrimaryKeyType.clear(); - Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType, false); - for(int j=0; j <%=attributeKeyName%> = (<%=attributeKeyType%>) context.get("<%=attributeKeyName%>"); -}*/ - if (j ){ - <%=entityName%> <%=Util.toLowerCaseFirstLetter(entityName)%> = new <%=entityName%>(delegator, <%=primaryKeyAsParam%>); if (! <%=Util.toLowerCaseFirstLetter(entityName)%>.isAlreadyPersistant() ){ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonIdDoesNotExist", locale)); } 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.3 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.4 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.3 Sun Jun 13 22:56:56 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java Sun Jun 20 21:58:10 2004 @@ -2,7 +2,6 @@ import java.io.IOException; import java.io.Writer; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -26,6 +25,7 @@ String packageName = (String) nameMap.get("packageName"); String subpackageName = (String)nameMap.get("subpackageName"); String entityName = clazz.getName(); + String varEntityName = Util.toLowerCaseFirstLetter(entityName); /*{ // @@ -48,7 +48,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // @author Olivier.Heintz@nereide.biz -// @version $Revision: 1.3 $ +// @version $Revision: 1.4 $ // @since 3.1 // // This file has been generated, and will be re-generated, @@ -58,28 +58,18 @@ package org.ofbiz.<%=packageName%>.<%=subpackageName%>; -import java.lang.*; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Locale; import java.util.Map; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.base.util.UtilProperties; -import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.condition.EntityExpr; -import org.ofbiz.entity.condition.EntityOperator; -import org.ofbiz.entity.util.EntityTypeUtil; -import org.ofbiz.entity.util.EntityUtil; public class <%=entityName%> { @@ -89,38 +79,93 @@ protected GenericValue <%=Util.toLowerCaseFirstLetter(entityName)%>; }*/ + ObjectModelAttribute AttrComposite = Util.isComposition(model, clazz); + ObjectModelClass classComposite = null; + if (AttrComposite != null){ + classComposite = (ObjectModelClass) AttrComposite.getDeclaringElement(); + String classCompositeName = classComposite.getName(); +/*{ + protected <%=classCompositeName%> <%=Util.toLowerCaseFirstLetter(classCompositeName)%>; +}*/ + } + // initialisation of the primaryKeyList - String primaryKeyAsParam="", primaryKeyAsMap="", primaryKeyNotEmpty="! UtilValidate.isEmpty("; - List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = new ArrayList(); - Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType, false); - for(int j=0; j <%=attributeKeyName%>; }*/ - if (j(GenericValue <%=varEntityName%>){ + if (<%=varEntityName%> != null ){ + this.<%=varEntityName%> = <%=varEntityName%>; + alreadyPersistant = true; + } + } + public <%=entityName%>(GenericDelegator delegator, <%=primaryKeyAsParam%>){ }*/ - for(int j=0; j = <%=fieldCompositeName%>; +}*/ + String pKeyCompositeNotNull = "", pKeyCompositeAsMap=""; + ListPkAttribute listPKeyComposite = new ListPkAttribute(model, classComposite, false); + String prefixFieldName = (AttrComposite.getReverseAttribute() != null ) ? + Util.getAttributeShortName(AttrComposite.getReverseAttribute() ) : + Util.getClassShortName(classComposite); + for (int j=0; j = <%=(String) listPrimaryKeyName.get(j)%>; + <%=attributeKeyType%> <%=fieldName%> = null; +}*/ + } + primaryKeyNotNull = pKeyCompositeNotNull + primaryKeyNotNull; + primaryKeyAsMap = pKeyCompositeAsMap + primaryKeyAsMap; +/*{ + if (<%=fieldCompositeName%> != null ){ +}*/ + for (int j=0; j = <%=fieldCompositeName%>.get<%=Util.toUpperCaseFirstLetter(attributeKeyName)%>(); +}*/ + } +/*{ + } +}*/ + } + for(int j=0; j = <%=(String) listPrimaryKey.getName().get(j)%>; }*/ } /*{ try { - if (<%=primaryKeyNotEmpty%>)) { + if (<%=primaryKeyNotNull%>) { this.<%=Util.toLowerCaseFirstLetter(entityName)%> = delegator.findByPrimaryKey("<%=entityName%>",UtilMisc.toMap(<%=primaryKeyAsMap%>) ); if (! exist() ){ this.<%=Util.toLowerCaseFirstLetter(entityName)%> = delegator.makeValue("<%=entityName%>",UtilMisc.toMap(<%=primaryKeyAsMap%>) ); @@ -148,11 +193,11 @@ return <%=Util.toLowerCaseFirstLetter(entityName)%>; } }*/ - for(int j=0; j get<%=Util.toUpperCaseFirstLetter((String) listPrimaryKeyName.get(j) )%>(){ - if (exist() ) return <%=(String) listPrimaryKeyName.get(j)%>; + public <%=(String) listPrimaryKey.getType().get(j)%> get<%=Util.toUpperCaseFirstLetter((String) listPrimaryKey.getName().get(j) )%>(){ + if (exist() ) return <%=(String) listPrimaryKey.getName().get(j)%>; return null; } }*/ @@ -166,13 +211,12 @@ List listName = (List) relationKeyName.get("listName"); ObjectModelClass classAssociated = (ObjectModelClass) ((Map) relationKeyName ).get("clazzAssociated"); primaryKeyAsParam=""; - listPrimaryKeyName.clear(); listPrimaryKeyType.clear(); - Util.getListPrimaryKeyAttr(model, classAssociated, listPrimaryKeyName, listPrimaryKeyType, false); - for(int j=0; j 1 + String associationEntityName = Util.toUpperCaseFirstLetter(attribute.getName() ); +/*{ + + public List get<%=associationEntityName%>s(){ + if (exist() ) { + try { + return <%=Util.toLowerCaseFirstLetter(entityName)%>.getRelated("<%=associationEntityName%>"); + } + catch (GenericEntityException e) { + Debug.logError("Error <%=entityName%>.getRelated <%=associationEntityName%> :" + e.getMessage(), module); + } + } + return null; + } + +}*/ + // TODO : methode add remove for item of the list in case of agregation or association } } else { // it's a standard attribute String attOfbizJavaType = Util.getOfbizJavaType(attribute); 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.21 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.22 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.21 Thu Jun 10 08:55:39 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java Sun Jun 20 21:58:10 2004 @@ -2,7 +2,6 @@ import java.io.IOException; import java.io.Writer; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -78,6 +77,7 @@ + "Forms" + clazz.getName()+".xml"; } +// =============================================================================== /** * create the parameters which is needed to be able to call the Show(_attribute.getClassifier). * @param _attribute @@ -113,9 +113,207 @@ return "${uiLabelMap." + packageName + Util.toUpperCaseFirstLetter( _attributeName )+ "}"; } +//=============================================================================== + /** + * List Method generation, used for List, subList + * =========================== + */ + private void generateList(Writer output, ObjectModelClass clazz, ObjectModelAttribute attrEditAssoc, String entityRemoveName) throws IOException { + String entityName = clazz.getName(); +/*{ + title="listSelect<%=entityName%>" + default-title-style="tableheadtext" default-widget-style="tabletext" default-tooltip-style="tabletext"> + +}*/ + if (attrEditAssoc != null){ +/*{ + +}*/ + } + // add field for link with getMaxMultiplicity = 1 and not navigable for this class + List classAssocWithoutNav = Util.getClassAssocWithoutNav(model, clazz); + if (classAssocWithoutNav.size() > 0 ){ + for (Iterator iterClass=classAssocWithoutNav.iterator(); iterClass.hasNext(); ){ + ObjectModelAttribute attrAssociated = (ObjectModelAttribute) iterClass.next(); + ObjectModelClass classAssociated = (ObjectModelClass) attrAssociated.getDeclaringElement(); + String relationName = (attrAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName())) ) ? + Util.toLowerCaseFirstLetter(classAssociated.getName()) : + attrAssociated.getName(); + ListPkAttribute listPrimaryKey = new ListPkAttribute(model, classAssociated, false); + for(int i=0; i +}*/ + } else { +/*{ + +}*/ + } + } + } + } + for (Iterator iter = listAttList.iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if (attribute.referenceClassifier() ){ + String call = getCallForAssociation( attribute ); + String classAssociatedName = Util.toLowerCaseFirstLetter(attribute.getClassifier().getName()); +/*{ + + + +}*/ + }else { +/*{ + +}*/ + } + } + listValAtt = ""; + ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazz, false); + for(int j=0; j + + + + + +}*/ + } - //Fonction Pincipal de generation +//=============================================================================== + /** + * Edit Method generation, used for Edit, subEdit + * ============================ + */ + private void generateEdit(Writer output, ObjectModelClass clazz, ObjectModelAttribute attrEditAssoc) throws IOException { + String entityName = clazz.getName(); +/*{ + default-title-style="tableheadtext" default-widget-style="tabletext" default-tooltip-style="tabletext"> + +}*/ + if (attrEditAssoc != null){ +/*{ + +}*/ + } + // add field for link with getMaxMultiplicity = 1 and not navigable for this class + List classAssocWithoutNav = Util.getClassAssocWithoutNav(model, clazz); + if (classAssocWithoutNav.size() > 0 ){ + for (Iterator iterClass=classAssocWithoutNav.iterator(); iterClass.hasNext(); ){ + ObjectModelAttribute attrAssociated = (ObjectModelAttribute) iterClass.next(); + ObjectModelClass classAssociated = (ObjectModelClass) attrAssociated.getDeclaringElement(); + String relationName = (attrAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName())) ) ? + Util.toLowerCaseFirstLetter(classAssociated.getName()) : + attrAssociated.getName(); + ListPkAttribute listPrimaryKey = new ListPkAttribute(model, classAssociated, true); + for(int i=0; i +}*/ + } else { +/*{ + }*/ + if ("date-time".equals(listPrimaryKey.getType().get(i) ) ) { /*{}*/ } + else { /*{}*/ } + /*{ + +}*/ + } + } + } + } + for ( Iterator iter = clazz.getAttributes().iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + System.out.println( " Boucle " + attribute.getName() + " suivant? " + iter.hasNext() ); + if (! Util.hasGuiHidden(attribute) ){ + if (Util.hasGuiCalculated(attribute) ){ +/*{ + +}*/ + } else if (attribute.referenceClassifier() ){ + if (attribute.getMaxMultiplicity() == 1 ){ + Map relationKeyName = Util.getRelationOneFieldName(model, attribute); + ObjectModelClass clazzAssociated = (ObjectModelClass) relationKeyName.get("clazzAssociated"); + String relationName = clazzAssociated.getName(); + String descriptionFieldName = Util.getAttributeDescription(clazzAssociated); + String iDFieldName = Util.getAttributeName(clazzAssociated); + List listName = (List) relationKeyName.get("listName"); + for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){ + Map fieldNameMap = (Map) iterList.next(); + String attributeKeyName = (String) fieldNameMap.get("fieldName"); + String relAttributeKeyName = (String) fieldNameMap.get("relFieldName"); +/*{ + +}*/ + if (Util.hasGuiDropDown(clazzAssociated) ){ +/*{ + + + + + + +}*/ + } else { + if (Util.hasGuiLookup(clazzAssociated) ){ +/*{ + +}*/ + } else { +/*{ + +}*/ + } +/*{ + + +}*/ + } + } + } + } else if (Util.isPrimaryKey(attribute) ){ +/*{ + }*/ + if (Util.isDate(attribute.getType() ) ) { /*{}*/ } + else { /*{}*/ } + /*{ + + +}*/ + } else { // a standard edit attribute +/*{ + }*/ + if (Util.isDate(attribute.getType() ) ) { /*{}*/ } + else { /*{}*/ } + /*{ +}*/ + } + } + } +/*{ + + + +}*/ + } + +//=============================================================================== + /** + * Main method for generation. + * ================= + */ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { Iterator iter, iter2; @@ -125,6 +323,7 @@ packageName = Util.toUpperCaseFirstLetter(packageName); System.out.println( "generateFromClass " + clazz.getName() + " packageName="+packageName ); initListAtt( clazz ); + ObjectModelAttribute AttrComposite = Util.isComposition(model, clazz); String entityName = clazz.getName(); ObjectModelAttribute att; @@ -154,7 +353,7 @@ * *@author Olivier.Heintz@nereide.biz *@author malin.nicolas@nereide.biz -*@version $Revision: 1.21 $ +*@version $Revision: 1.22 $ *@since 3.1 * * This file has been generated, and will be re-generated, @@ -238,7 +437,7 @@ // Generation List without any selection //================================== - if( Util.hasGuiListAll( clazz ) ){ + if( Util.hasGuiShowList( clazz ) ){ System.out.println( "List " + clazz.getName() ); /*{ @@ -271,80 +470,49 @@ } - //========================================= - // Generation List whith selection to be able to Edit - //========================================= - if (Util.hasGuiList( clazz ) || Util.hasGuiSubList( clazz ) ){ - System.out.println( "Beginning ListEdit " ); + //========================================= + // Generation List whith selection to be able to Edit + //========================================= + if (Util.hasGuiList( clazz ) || Util.hasGuiListAll( clazz ) ){ + System.out.println( "Beginning ListEdit " ); /*{
- -}*/ - // add field for link with getMaxMultiplicity = 1 and not navigable for this class - List classAssocWithoutNav = Util.getClassAssocWithoutNav(model, clazz); - if (classAssocWithoutNav.size() > 0 ){ - for (Iterator iterClass=classAssocWithoutNav.iterator(); iterClass.hasNext(); ){ - ObjectModelAttribute attrAssociated = (ObjectModelAttribute) iterClass.next(); - ObjectModelClass classAssociated = (ObjectModelClass) attrAssociated.getDeclaringElement(); - String relationName = (attrAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName())) ) ? - Util.toLowerCaseFirstLetter(classAssociated.getName()) : - attrAssociated.getName(); - ListPkAttribute listPrimaryKey = new ListPkAttribute(model, classAssociated, false); - for(int i=0; i -}*/ - } - } - } - for ( iter = listAttList.iterator(); iter.hasNext(); ){ - att = (ObjectModelAttribute) iter.next(); - if (att.referenceClassifier() ){ - String call = getCallForAssociation( att ); - String classAssociatedName = Util.toLowerCaseFirstLetter(att.getClassifier().getName()); -/*{ - - - -}*/ - }else { -/*{ - -}*/ - } - } - listValAtt = ""; - List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = new ArrayList(); - Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType); - for(int j=0; j - - - - - + target="<%=entityName%>Selection" paginate-target="/List<%=entityName%>" }*/ + generateList(output, clazz, null, entityName); } - /* - ================================= - Generation Edit/Ajout - ================================= - */ + //========================================= + // Generation SubList whith selection to be able to Edit + //========================================= + if (Util.isEditViaAssoc(model, clazz ) ){ + System.out.println( "Beginning SubListEdit " ); + List editAssocList = Util.getEditAssocList(model, clazz); + for (Iterator iterED=editAssocList.iterator(); iterED.hasNext(); ){ + ObjectModelAttribute attributeAssociated = (ObjectModelAttribute) iterED.next(); + String fromEntityName = (attributeAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName() ) ) ) ? + Util.toUpperCaseFirstLetter(attributeAssociated.getDeclaringElement().getName() ): + Util.toUpperCaseFirstLetter(attributeAssociated.getName() ); + String entityUriName = entityName +fromEntityName; +/*{ + + + +
- - }*/ - // add field for link with getMaxMultiplicity = 1 and not navigable for this class - List classAssocWithoutNav = Util.getClassAssocWithoutNav(model, clazz); - if (classAssocWithoutNav.size() > 0 ){ - for (Iterator iterClass=classAssocWithoutNav.iterator(); iterClass.hasNext(); ){ - ObjectModelAttribute attrAssociated = (ObjectModelAttribute) iterClass.next(); - ObjectModelClass classAssociated = (ObjectModelClass) attrAssociated.getDeclaringElement(); - String relationName = (attrAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName())) ) ? - Util.toLowerCaseFirstLetter(classAssociated.getName()) : - attrAssociated.getName(); - ListPkAttribute listPrimaryKey = new ListPkAttribute(model, classAssociated, true); - for(int i=0; i}*/ - if ("date-time".equals(listPrimaryKey.getType().get(i) ) ) { /*{}*/ } - else { /*{}*/ } - /*{ - -}*/ - } - } - } - for ( iter = clazz.getAttributes().iterator(); iter.hasNext(); ){ - ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); - System.out.println( " Boucle " + attribute.getName() + " suivant? " + iter.hasNext() ); - if (! Util.hasGuiHidden(attribute) ){ - if (Util.hasGuiCalculated(attribute) ){ -/*{ - -}*/ - } else if (attribute.referenceClassifier() ){ - if (attribute.getMaxMultiplicity() == 1 ){ - Map relationKeyName = Util.getRelationOneFieldName(model, attribute); - ObjectModelClass clazzAssociated = (ObjectModelClass) relationKeyName.get("clazzAssociated"); - String relationName = clazzAssociated.getName(); - String descriptionFieldName = Util.getAttributeDescription(clazzAssociated); - String iDFieldName = Util.getAttributeName(clazzAssociated); - List listName = (List) relationKeyName.get("listName"); - for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){ - Map fieldNameMap = (Map) iterList.next(); - String attributeKeyName = (String) fieldNameMap.get("fieldName"); - String relAttributeKeyName = (String) fieldNameMap.get("relFieldName"); -/*{ - -}*/ - if (Util.hasGuiDropDown(clazzAssociated) ){ -/*{ - - - - - - -}*/ - } else { - if (Util.hasGuiLookup(clazzAssociated) ){ -/*{ - -}*/ - } else { -/*{ - -}*/ - } -/*{ - - -}*/ - } - } - } - } else if (Util.isPrimaryKey(attribute) ){ -/*{ - }*/ - if (Util.isDate(attribute.getType() ) ) { /*{}*/ } - else { /*{}*/ } - /*{ - - -}*/ - } else { // a standard edit attribute -/*{ - }*/ - if (Util.isDate(attribute.getType() ) ) { /*{}*/ } - else { /*{}*/ } - /*{ -}*/ - } - } - } + generateEdit(output, clazz, null); + } + + + //================================= + // Generation SubEdit/Add + //================================= + if( Util.isEditViaAssoc(model, clazz ) ){ + System.out.println( "SubEdit " + clazz.getName() ); + List editAssocList = Util.getEditAssocList(model, clazz); + for (Iterator iterED=editAssocList.iterator(); iterED.hasNext(); ){ + ObjectModelAttribute attributeAssociated = (ObjectModelAttribute) iterED.next(); + String fromEntityName = (attributeAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName() ) ) ) ? + Util.toUpperCaseFirstLetter(attributeAssociated.getDeclaringElement().getName() ): + Util.toUpperCaseFirstLetter(attributeAssociated.getName() ); /*{ - - + + +
With<%=associatClazz.getName()%> --> - - - -}*/ - for ( iter2 = listAttPrimaryKey.iterator(); iter.hasNext(); ){ - att = (ObjectModelAttribute) iter.next(); - - /*{ - "/> - -}*/ - } - - for ( iter2 = listAttAssociatList.iterator(); iter.hasNext(); ){ - attAssoc = (ObjectModelAttribute) iter.next(); - - /*{ - -
- -}*/ - } - } /*{ 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.19 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.20 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.19 Mon Jun 14 22:14:09 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java Sun Jun 20 21:58:11 2004 @@ -1,7 +1,7 @@ /* *##% -* Copyright (C) 2002, 2003, 2004 Code Lutin - * Copyright (c) 2004 Nereide - www.nereide.biz - * Copyright (c) 2004 Neogia - www.neogia.org +* Copyright (C) 2002, 2003, 2004 Code Lutin +* Copyright (c) 2004 Nereide - www.nereide.biz +* Copyright (c) 2004 Neogia - www.neogia.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,9 +28,9 @@ * Copyright Code Lutin * Copyright Nereide * Copyright Neogia -* @version $Revision: 1.19 $ +* @version $Revision: 1.20 $ * -* Last update : $Date: 2004/06/14 22:14:09 $ +* Last update : $Date: 2004/06/20 21:58:11 $ * by : $Author: holivier $ */ package org.nereide.ofbiz.neogia.generators; @@ -46,7 +46,6 @@ 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; @@ -440,21 +439,6 @@ } /** - * useable to test if the element has a tagvalue=="gui" and if its value contain the word "subEdit". - * @param element - * @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 ); - for( ; guiTag.hasMoreTokens(); ){ - if( guiTag.nextToken().startsWith( "subEdit" )){ - return true; - } - } - return false; - } - - /** * useable to test if the clazz has a tagvalue=="gui" and if its value contain the word "edit". * @param clazz * @return true if clazz has a tagvalue=="gui" and if its value contain the word "edit". @@ -507,29 +491,26 @@ } /** - * useable to test if the element has a tagvalue=="gui" and if its value contain the word "subList". - * @param element - * @return true if element has a tagvalue=="gui" and if its value contain the word "subList". + * useable to test if the clazz has a tagvalue=="gui" and if its value contain the word "listAll". + * @param clazz + * @return true if clazz has a tagvalue=="gui" and if its value contain the word "listAll". */ - public static boolean hasGuiSubList( ObjectModelElement element ){ - StringTokenizer guiTag = new StringTokenizer( element.getTagValue( "gui" ) != null ? element.getTagValue( "gui" ) : "", tagSeparator ); - for( ; guiTag.hasMoreTokens(); ){ - if( guiTag.nextToken().startsWith( "subList" )){ - return true; - } - } + public static boolean hasGuiListAll( ObjectModelClass clazz ){ + StringTokenizer guiTag = new StringTokenizer(clazz.getTagValue("gui")!=null?clazz.getTagValue("gui"):"", tagSeparator); + for (;guiTag.hasMoreTokens();) + if (guiTag.nextToken().equals("listAll")) return true; return false; } /** - * useable to test if the clazz has 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 "showList". * @param clazz - * @return true if clazz has 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 "showList". */ - public static boolean hasGuiListAll( ObjectModelClass clazz ){ + public static boolean hasGuiShowList( ObjectModelClass clazz ){ StringTokenizer guiTag = new StringTokenizer(clazz.getTagValue("gui")!=null?clazz.getTagValue("gui"):"", tagSeparator); for (;guiTag.hasMoreTokens();) - if (guiTag.nextToken().equals("listAll")) return true; + if (guiTag.nextToken().equals("showList")) return true; return false; } @@ -574,7 +555,33 @@ } /** + * Give the list of all the attribute in the other association which are associated with class with a tag editAsssoc. + * @param model + * @param _clazz + * @return a List of attribute which are an association and have a tagvalue=="gui" and if its value contain the word "editAssoc" and point on _clazz. + */ + public static List getEditAssocList( ObjectModel model, ObjectModelClass _clazz ){ + List associationList = new ArrayList(); + 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) ) associationList.add(reverseAttribute ); + } + } + List nonNavAttribute = getClassAssocWithoutNav(model, _clazz); + if (nonNavAttribute.size() > 0 ){ + for (Iterator iter=nonNavAttribute.iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if ( hasGuiEditAssoc(attribute) ) associationList.add(attribute ); + } + } + 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 model * @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. */ @@ -599,6 +606,31 @@ } } return false; + } + + /** + * give if there is one association from an other class which is composite() the attribute composite. + * @param model + * @param _clazz + * @return attributeAssoc if _clazz has one association from an other class (for ex : clazzA.attributeAssoc) with clazzA.attributeAssoc.iscomposite() == true, + * null otherwise. + */ + public static ObjectModelAttribute isComposition( 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 && reverseAttribute.isComposite() ) return reverseAttribute; + } + } + List nonNavAttribute = getClassAssocWithoutNav(model, _clazz); + if (nonNavAttribute.size() > 0 ){ + for (Iterator iter=nonNavAttribute.iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if ( attribute.isComposite() ) return attribute; + } + } + return null; } /** 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.2 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java:1.3 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java:1.2 Fri May 28 20:45:25 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java Sun Jun 20 21:58:11 2004 @@ -27,7 +27,7 @@ System.out.println("XXXXXXXX1Debug clazz.getName="+clazz.getName()); /*{ -// $Id: GeneratorFindBsh.java,v 1.2 2004/05/28 20:45:25 holivier Exp $ +// $Id: GeneratorFindBsh.java,v 1.3 2004/06/20 21:58:11 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.2 $ +// @version $Revision: 1.3 $ // @since 3.1 // // Calls Find on a dynamiqueView to return an EntityListIterator of the @@ -226,7 +226,7 @@ EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); // using list iterator - EntityListIterator listIt = delegator.findListIteratorByCondition(dynamicView, mainCond, null, null, orderBy, findOpts); + EntityListIterator listIt = delegator.findListIteratorByCondition(dynamicView, mainCond, null, null, orderByList, findOpts); request.setAttribute("listIt", listIt); String queryString = UtilHttp.urlEncodeArgs(inputFields); Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditAssocBsh.java diff -u /dev/null ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditAssocBsh.java:1.1 --- /dev/null Sun Jun 20 21:58:16 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditAssocBsh.java Sun Jun 20 21:58:11 2004 @@ -0,0 +1,565 @@ +package org.nereide.ofbiz.neogia.generators; + +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelClass; + + +public class GeneratorEditAssocBsh extends ObjectModelGenerator { + + + public String getFilenameForClass(ObjectModelClass clazz){ + Map nameMap = Util.initPackageName(clazz); + return ((String)nameMap.get("packageName"))+"/webapp/"+((String)nameMap.get("packageName"))+"/WEB-INF/actions/"+((String)nameMap.get("subpackageName"))+"/EditAssoc"+clazz.getName()+".bsh"; + } + + public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { + if(! Util.isEntity(clazz)) return; + if (! Util.hasGuiEditAssoc(clazz)) return; + Map nameMap = Util.initPackageName(clazz); + String packageName=(String) nameMap.get("packageName"); + String subPackageName=(String) nameMap.get("subpackageName"); + List associationList = Util.getAssocList(clazz); + String entityName = clazz.getName(); + + System.out.println("XXXXXXXX1Debug clazz.getName="+entityName); + + // same code are in the GeneratorEditBsh + List listAttributeName = new ArrayList(); // list of all attribute which must be declare or read + List listAttCalculated = new ArrayList(); // list of read only attribute + List listAttAssoc = new ArrayList(); // list of the association with MaxMultiplicity() == 1 + + // initialisation of the three lists + for (Iterator iter=clazz.getAttributes().iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if (! Util.hasGuiHidden(attribute) && ! Util.isPrimaryKey(attribute)){ + if (Util.hasGuiCalculated(attribute)){ + listAttCalculated.add(attribute.getName()); + } else { + if (attribute.referenceClassifier() ){ + if (attribute.getMaxMultiplicity() == 1){ + Map relationKeyName = Util.getRelationOneFieldName(model, attribute); + listAttAssoc.add(relationKeyName); + List listName = (List) relationKeyName.get("listName"); + for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){ + Map fieldNameMap = (Map) iterList.next(); + String attributeKeyName = (String) fieldNameMap.get("fieldName"); + listAttributeName.add(attributeKeyName); + } + } + } else listAttributeName.add(attribute.getName() ); + } + } + } + // end of same code + + +/*{ +// $Id: GeneratorEditAssocBsh.java,v 1.1 2004/06/20 21:58:11 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 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// @author Olivier.Heintz@nereide.biz +// @version $Revision: 1.1 $ +// @since 3.1 +// +// Calls Find on a dynamiqueView to return an EntityListIterator of the +// entities found from the parameter map selection criteria. +// +// This file has been generated, and will be re-generated, +// so no modification must be done whitout copying it with a other name. +// + +import java.util.*; +import org.ofbiz.common.FindServices; +import org.ofbiz.base.util.*; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.content.widget.html.HtmlFormWrapper; +import org.ofbiz.entity.condition.EntityConditionList; +import org.ofbiz.entity.condition.EntityJoinOperator; +import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.model.DynamicViewEntity; +import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.entity.util.EntityFindOptions; +import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.manufacturing.NsingleHtmlFormWrapper; + +delegator = request.getAttribute("delegator"); +HashMap formsData= new HashMap(); + +String actionForm = request.getParameter("actionForm"); + +String association = request.getParameter("association"); +if (UtilValidate.isEmpty(association)) association = "<%=( (ObjectModelAttribute) associationList.get(0)).getName()%>"; +}*/ + if (associationList.size() > 1){ + for (Iterator iter=associationList.iterator(); iter.hasNext(); ){ + ObjectModelAttribute association = (ObjectModelAttribute) iter.next(); +/*{ +if (association.equals("<%=association.getName()%>") ) { + page.setProperty("tabButtonItem", page.getProperty("tabButtonItem<%=Util.toUpperCaseFirstLetter(association.getName())%>") ); +} +}*/ + } + } +/*{ +context.put("association",association); + +}*/ + ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazz, false); + String primaryKeysEmpty = " UtilValidate.isEmpty("; + String primaryKeysMap = "\""; + for(int i=0; i = request.getParameter("<%=attributeKeyName%>"); +}*/ + } + primaryKeysEmpty += ")"; +/*{ +if (<%=primaryKeysEmpty%>) { +}*/ + for (Iterator iter=associationList.iterator(); iter.hasNext(); ){ + ObjectModelAttribute association = (ObjectModelAttribute) iter.next(); +/*{ + if (association.equals("<%=association.getName()%>") ){ +}*/ + String reverseAttributeName = ( association.getReverseAttribute() != null ) ? + Util.getAttributeShortName(association.getReverseAttribute()) : + Util.getClassShortName(clazz); + for(int i=0; i = request.getParameter("<%=reverseAttributeName%><%=Util.toUpperCaseFirstLetter(attributeKeyName)%>"); +}*/ + } +/*{ + } +}*/ + } +/*{ +} +}*/ + for (Iterator iter=associationList.iterator(); iter.hasNext(); ){ + ObjectModelAttribute association = (ObjectModelAttribute) iter.next(); + String reverseAttributeName = ( association.getReverseAttribute() != null ) ? + Util.getAttributeShortName(association.getReverseAttribute()) : + Util.getClassShortName(clazz); + String assocPkParameters = "\""; + for(int i=0; iPkParameters",<%=assocPkParameters%>); +}*/ + } +/*{ + +if ( ! ( <%=primaryKeysEmpty%> ) ) { + // TODO : use the <%=entityName%> object and its methods to access the attributes + GenericValue <%=Util.toLowerCaseFirstLetter(entityName)%> = delegator.findByPrimaryKey("<%=entityName%>", UtilMisc.toMap(<%=primaryKeysMap%>)); + + String }*/ + for (int i=0; i}*/ + if (i = request.getParameter("<%=attributeName%>"); +}*/ + } +/*{ + + if (<%=Util.toLowerCaseFirstLetter(entityName)%> != null){ +}*/ + for(int j=0; j", <%=attributeKeyName%>); + formsData.put("<%=attributeKeyName%>",<%=attributeKeyName%>); + +}*/ + } +/*{ + // FOR attribue with calculated + // formsData.put("%attribue%",<%=Util.toLowerCaseFirstLetter(entityName)%>.get("%attribue%")); + // + +}*/ + for (int i=0; i != null) formsData.put("<%=attributeName%>",<%=attributeName%>); + else formsData.put("<%=attributeName%>",<%=Util.toLowerCaseFirstLetter(entityName)%>.get("<%=attributeName%>" )); + +}*/ + } + for (int i=0; i",<%=Util.toLowerCaseFirstLetter(entityName)%>.get("<%=attributeName%>" )); +}*/ + } + for (int i=0; i = <%=Util.toLowerCaseFirstLetter(entityName)%>.getRelatedOne("<%=relationName%>"); + if (<%=Util.toLowerCaseFirstLetter(relationName )%> != null){ + formsData.put("<%=Util.toLowerCaseFirstLetter(relationName )%>Description", <%=Util.toLowerCaseFirstLetter(relationName )%>.get("<%=descriptionFieldName%>") ); + formsData.put("<%=Util.toLowerCaseFirstLetter(relationName )%>Name", <%=Util.toLowerCaseFirstLetter(relationName )%>.get("<%=idNameFieldName%>") ); + } + +}*/ + } +/*{ + HtmlFormWrapper singleWrapper = new NsingleHtmlFormWrapper("/<%=subPackageName%>/Forms<%=entityName%>.xml", "show<%=entityName%>", request, response, formsData); + context.put("singleWrapper", singleWrapper); + +}*/ + for (Iterator iterAssoc=associationList.iterator(); iterAssoc.hasNext(); ){ + ObjectModelAttribute association = (ObjectModelAttribute) iterAssoc.next(); + ObjectModelClass classAssociated = (ObjectModelClass) association.getClassifier(); + String subPackageAssoc = (String) Util.initPackageName(classAssociated).get("subpackageName"); + String fromEntityName = (association.getName().equals(Util.toLowerCaseFirstLetter(classAssociated.getName() ) ) ) ? + entityName : + Util.toUpperCaseFirstLetter(association.getName() ); + String reverseAttributeName = ( association.getReverseAttribute() != null ) ? + Util.getAttributeShortName(association.getReverseAttribute()) : + Util.getClassShortName(clazz); +/*{ + // ************************************************************************************************ + // prepare <%=Util.toUpperCaseFirstLetter(association.getName())%> List & edit or add depending of the actionForm value + // ************************************************************************************************ + if (association.equals("<%=association.getName()%>") ){ + // ============== + // List Preparation + // ============== + page.setProperty("formDefFile","/<%=subPackageAssoc%>/Forms<%=classAssociated.getName()%>.xml"); + page.setProperty("listFormName","subList<%=classAssociated.getName()%><%=fromEntityName%>"); + page.setProperty("entityName","<%=classAssociated.getName()%>"); + request.setAttribute("association",association); + + // Static field from the main entity + Map inputFields = new HashMap(); +}*/ + for(int j=0; j<%=Util.toUpperCaseFirstLetter(attributeKeyName)%>", <%=attributeKeyName%>); +}*/ + } +/*{ + + // create the dynamic view entity + DynamicViewEntity dynamicView = new DynamicViewEntity(); + + // default view settings <%=classAssociated.getName()%> + dynamicView.addMemberEntity("EE", "<%=classAssociated.getName()%>"); + +}*/ + for(int j=0; j<%=Util.toUpperCaseFirstLetter(attributeKeyName)%>"); +}*/ + } + List listAssoc = new ArrayList(); + List attributesListOrIndexed = Util.getAttributesList(classAssociated); + List attributesIndexed = new ArrayList(); + // add attributes with gui indexed if there are not already in the list + for (Iterator iter=classAssociated.getAttributes().iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if (Util.hasGuiIndexed(attribute)){ + if (! attribute.referenceClassifier()) attributesIndexed.add(attribute.getName()); + if (attributesListOrIndexed.indexOf(attribute) == -1) attributesListOrIndexed.add(attribute); + } + } + List listAttNameAssoc = new ArrayList(); + for (Iterator iter=attributesListOrIndexed.iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if ( attribute.referenceClassifier() ){ + if ( attribute.getMaxMultiplicity() == 1 ) listAssoc.add(attribute); + } else{ + listAttNameAssoc.add(attribute.getName()); +/*{ + dynamicView.addAlias("EE", "<%=attribute.getName()%>"); +}*/ + } + } + + // add in the dynamicView all the associated entity + int nbAssoc = 1; + for (Iterator iter=listAssoc.iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + Map relationKeyName = Util.getRelationOneFieldName(model, attribute); + ObjectModelClass clazzAssoc = (ObjectModelClass) relationKeyName.get("clazzAssociated"); + String relationName = clazzAssoc.getName(); +/*{ + + // Associated entities + dynamicView.addMemberEntity("E<%=String.valueOf(nbAssoc)%>", "<%=relationName%>"); + dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(relationName)%>Name","<%=Util.getAttributeName(clazzAssoc)%>",null,null,null,null); + dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(relationName)%>Description","<%=Util.getAttributeDescription(clazzAssoc)%>",null,null,null,null); + +}*/ + if (Util.hasGuiIndexed(attribute) ){ + attributesIndexed.add(Util.toLowerCaseFirstLetter(relationName)+"Name"); + attributesIndexed.add(Util.toLowerCaseFirstLetter(relationName)+"Description"); + } + + // check and add if necessary, the field relation maker + List listName = (List) relationKeyName.get("listName"); + for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){ + Map relationItem = (Map) iterList.next(); + String fieldName = (String) relationItem.get("fieldName"); + if (listAttributeName.indexOf(fieldName) == -1){ // adding the field in the dynamicView + listAttributeName.add(fieldName); +/*{ + dynamicView.addAlias("EE", "<%=fieldName%>"); +}*/ + } + } + // Add the classAssoc attributes with the tag gui listInAssoc + for (Iterator iterAssocB=clazzAssoc.getAttributes().iterator(); iterAssocB.hasNext(); ){ + ObjectModelAttribute attributeAssoc = (ObjectModelAttribute) iterAssocB.next(); + if ( Util.hasGuiListInAssoc(attributeAssoc) ){ +/*{ + dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(relationName)%><%=Util.toUpperCaseFirstLetter(attributeAssoc.getName())%>","<%=attributeAssoc.getName()%>",null,null,null,null); +}*/ + } + } +/*{ + dynamicView.addViewLink("EE", "E<%=String.valueOf(nbAssoc)%>", Boolean.TRUE, ModelKeyMap.makeKeyMapList( +}*/ + boolean first = true; + for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){ + Map relationItem = (Map) iterList.next(); + if ( ! first ){ +/*{, }*/ + } +/*{ + "<%=(String) relationItem.get("fieldName")%>","<%=(String) relationItem.get("relFieldName")%>"}*/ + first = false; + } +/*{ )); +}*/ + nbAssoc += 1; + } +/*{ + + // read and analyse the inputFields + Map queryStringMap = new HashMap(); + Map origValueMap = new HashMap(); + HashMap normalizedFields = FindServices.prepareField((Map) inputFields,(Map) queryStringMap,(Map) origValueMap); + + // compare the normalizedFields with the field the user can query on + List keys = new ArrayList(); +}*/ + for (Iterator iter=attributesIndexed.iterator(); iter.hasNext(); ){ + String attributeName = (String) iter.next(); +/*{ + keys.add("<%=attributeName%>"); +}*/ + } + for(int j=0; j<%=Util.toUpperCaseFirstLetter(attributeKeyName)%>"); +}*/ + } + // +/*{ + ArrayList tmpList = FindServices.createCondition(keys, normalizedFields, queryStringMap, origValueMap); + + //create the entity condition + EntityOperator entOp = EntityOperator.AND; + EntityConditionList mainCond = new EntityConditionList(tmpList, (EntityJoinOperator) entOp); + + // create the orderBy + List orderByList = null; + + // set entityFindOptions + EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); + + // using list iterator + EntityListIterator listIt = delegator.findListIteratorByCondition(dynamicView, mainCond, null, null, orderByList, findOpts); + request.setAttribute("listIt", listIt); + + String queryString = UtilHttp.urlEncodeArgs(inputFields); + context.put("queryString", queryString); + + // ================= + // Edit or Add preparation + // ================== + if (! UtilValidate.isEmpty(actionForm)){ + if (actionForm.startsWith("commit") ) actionForm = actionForm.substring(6); + Map <%=association.getName()%>FD = new HashMap(); + +}*/ + // same code are in the GeneratorEditBsh + List listAttributeNameB = new ArrayList(); // list of all attribute which must be declare or read + List listAttCalculatedB = new ArrayList(); // list of read only attribute + List listAttAssocB = new ArrayList(); // list of the association with MaxMultiplicity() == 1 + + // initialisation of the three lists + for (Iterator iter=classAssociated.getAttributes().iterator(); iter.hasNext(); ){ + ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); + if (! Util.hasGuiHidden(attribute) && ! Util.isPrimaryKey(attribute)){ + if (Util.hasGuiCalculated(attribute)){ + listAttCalculatedB.add(attribute.getName()); + } else { + if (attribute.referenceClassifier() ){ + if (attribute.getMaxMultiplicity() == 1){ + Map relationKeyName = Util.getRelationOneFieldName(model, attribute); + listAttAssocB.add(relationKeyName); + List listName = (List) relationKeyName.get("listName"); + for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){ + Map fieldNameMap = (Map) iterList.next(); + String attributeKeyName = (String) fieldNameMap.get("fieldName"); + listAttributeNameB.add(attributeKeyName); + } + } + } else listAttributeNameB.add(attribute.getName() ); + } + } + } + // end of same code + + // initialisation of the primaryList + ListPkAttribute listPrimaryKeyB = new ListPkAttribute(model, classAssociated, false); + String primaryKeysEmptyB = "! UtilValidate.isEmpty("; + String primaryKeysMapB = "\""; + for(int j=0; j = request.getParameter("<%=attributeKeyName%>"); + context.put("<%=attributeKeyName%>", <%=attributeKeyName%>); + <%=association.getName()%>FD.put("<%=attributeKeyName%>",<%=attributeKeyName%>); + +}*/ + primaryKeysEmptyB = primaryKeysEmptyB + attributeKeyName; + primaryKeysMapB = primaryKeysMapB + attributeKeyName + "\"," + attributeKeyName; + if (j < listPrimaryKeyB.getName().size()-1){ + primaryKeysEmptyB += ") && ! UtilValidate.isEmpty("; + primaryKeysMapB += ",\""; + } + } + primaryKeysEmptyB += ")"; +/*{ + if (<%=primaryKeysEmptyB%>) { + GenericValue <%=Util.toLowerCaseFirstLetter(classAssociated.getName())%> = delegator.findByPrimaryKey("<%=classAssociated.getName()%>", UtilMisc.toMap(<%=primaryKeysMapB%>)); + + String }*/ + for (int i=0; i}*/ + if (i = request.getParameter("<%=attributeName%>"); +}*/ + } +/*{ + + if (<%=Util.toLowerCaseFirstLetter(classAssociated.getName())%> != null){ + if (actionForm.equals("add") ) actionForm = "edit"; + // FOR attribue with calculated + // <%=association.getName()%>FD.put("%attribue%",<%=Util.toLowerCaseFirstLetter(entityName)%>.get("%attribue%")); + // + +}*/ + for (int i=0; i != null) <%=association.getName()%>FD.put("<%=attributeName%>",<%=attributeName%>); + else <%=association.getName()%>FD.put("<%=attributeName%>",<%=Util.toLowerCaseFirstLetter(classAssociated.getName())%>.get("<%=attributeName%>" )); + +}*/ + } + for (int i=0; iFD.put("<%=attributeName%>",<%=Util.toLowerCaseFirstLetter(classAssociated.getName())%>.get("<%=attributeName%>" )); +}*/ + } + for (int i=0; i = <%=Util.toLowerCaseFirstLetter(classAssociated.getName())%>.getRelatedOne("<%=relationName%>"); + if (<%=Util.toLowerCaseFirstLetter(relationName )%> != null){ + <%=association.getName()%>FD.put("<%=Util.toLowerCaseFirstLetter(relationName )%>Description", <%=Util.toLowerCaseFirstLetter(relationName )%>.get("<%=descriptionFieldName%>") ); + <%=association.getName()%>FD.put("<%=Util.toLowerCaseFirstLetter(relationName )%>Name", <%=Util.toLowerCaseFirstLetter(relationName )%>.get("<%=idNameFieldName%>") ); + } + +}*/ + } +/*{ + } + } + request.setAttribute("actionForm",actionForm); + HtmlFormWrapper <%=association.getName()%>Wrapper = new NsingleHtmlFormWrapper("/<%=subPackageAssoc%>/Forms<%=classAssociated.getName()%>.xml", "subEdit<%=classAssociated.getName()%><%=fromEntityName%>", request, response, <%=association.getName()%>FD); + <%=association.getName()%>Wrapper.putInContext("association",association); + context.put("<%=association.getName()%>Wrapper", <%=association.getName()%>Wrapper); + } + } + } +} +request.setAttribute("actionForm",actionForm); +context.put("actionForm",actionForm); + +}*/ + } + } +} + +