Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,60 @@
+package org.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.ObjectModelAttribute;
+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"))+"/generated/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;
+ List associationList = Util.getAssocList(clazz);
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName =Util.toUpperCaseFirstLetter((String) nameMap.get("packageName"));
+ String subpackageName=(String) nameMap.get("subpackageName");
+
+
+/*{
+
+ main
+ <%=packageName%>EditAssoc<%=clazz.getName()%>
+ <%=subpackageName%>
+ /<%=subpackageName%>/developed/TabBarSubMenu.ftl
+}*/
+ if (associationList.size() == 1){
+ String associationName = ((ObjectModelAttribute) associationList.get(0) ).getName();
+/*{ <%=associationName%>
+}*/
+ } else {
+ for (Iterator iter=associationList.iterator(); iter.hasNext(); ){
+ String associationName = ((ObjectModelAttribute) iter.next() ).getName();
+/*{ <%=associationName%>
+}*/
+ }
+ }
+/*{ 20
+ <%=packageName.toUpperCase()%>
+ _UPDATE
+ simple
+
+
+
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,47 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorPagedefsShowXml 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"))+"/generated/Show"+clazz.getName()+"G.xml";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if(! Util.isEntity(clazz)) return;
+
+ if(! Util.hasGuiShow(clazz) ) return;
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName =Util.toUpperCaseFirstLetter((String) nameMap.get("packageName"));
+ String subpackageName=(String) nameMap.get("subpackageName");
+
+
+/*{
+
+ main
+ <%=packageName%>Show<%=clazz.getName()%>
+ /<%=subpackageName%>/generated/Forms<%=clazz.getName()%>.xml
+ show<%=clazz.getName()%>
+ <%=subpackageName%>
+ /<%=subpackageName%>/developed/TabBarSubMenu.ftl
+ show
+ <%=clazz.getName()%>
+ <%=packageName.toUpperCase()%>
+ _VIEW
+ simple
+
+
+
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,46 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorPagedefsEditXml 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"))+"/generated/Edit"+clazz.getName()+"G.xml";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if(! Util.isEntity(clazz)) return;
+ if(! Util.hasGuiEdit(clazz) ) return;
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName =Util.toUpperCaseFirstLetter((String) nameMap.get("packageName"));
+ String subpackageName=(String) nameMap.get("subpackageName");
+
+
+/*{
+
+ main
+ <%=packageName%>Edit<%=clazz.getName()%>
+ /<%=subpackageName%>/generated/Forms<%=clazz.getName()%>.xml
+ edit<%=clazz.getName()%>
+ <%=subpackageName%>
+ /<%=subpackageName%>/developed/TabBarSubMenu.ftl
+ edit
+ <%=clazz.getName()%>
+ <%=packageName.toUpperCase()%>
+ _UPDATE
+ simple
+
+
+
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/package.html
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/package.html:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/package.html Tue Jul 6 15:05:04 2004
@@ -0,0 +1,7 @@
+
+
+ofbiz-neogia-generators
+
+Ces fichiers correspondent au générateur nécessaire à la gestion de l'interface utilisateur dans OFBiz, avec neogia.
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorShowFtl.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorShowFtl.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorShowFtl.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,88 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorShowFtl extends ObjectModelGenerator {
+
+
+ public String getFilenameForClass(ObjectModelClass clazz){
+ Map nameMap = Util.initPackageName(clazz);
+ return ((String)nameMap.get("packageName"))+"/webapp/"+((String)nameMap.get("packageName"))+"/"+((String)nameMap.get("subpackageName"))+"/generated/Show"+clazz.getName()+".ftl";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if(! Util.isEntity(clazz)) return;
+ boolean guiListAll = Util.hasGuiListAll(clazz);
+ if (! Util.hasGuiShow(clazz) ) return;
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName= Util.toUpperCaseFirstLetter((String) nameMap.get("packageName") );
+ List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = new ArrayList();
+ Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType);
+ String primaryKeys = "";
+ for(int j=0; j
+<#assign uiLabelMap = requestAttributes.uiLabelMap>
+${pages.get(page.getProperty("subMenu"))}
+
+
+<#if hasPermission>
+ <#if actionForm?has_content >
+
+
+
+
+ ${uiLabelMap.CommonShow} ${uiLabelMap.<%=packageName%><%=clazz.getName()%>Id} : <%=primaryKeys%> |
+
+
+ |
+ |
+ ${singleWrapper.renderFormString()}
+ |
+
+ #if>
+<#else>
+ ${uiLabelMap.CommonPermissionError}
+#if>
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntityServicesJava.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntityServicesJava.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntityServicesJava.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,270 @@
+package org.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.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+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"))+"/generated/"+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");
+ String entityName = clazz.getName();
+ ObjectModelAttribute AttrComposite = Util.isComposition(model, clazz);
+ ObjectModelClass classComposite = null;
+ if (AttrComposite != null){
+ classComposite = (ObjectModelClass) AttrComposite.getDeclaringElement();
+ }
+
+/*{//
+// 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
+//
+// This file has been generated, and will be re-generated,
+// so no modification must be done whitout copying it with a other name.
+//
+
+
+package org.ofbiz.<%=packageName%>.<%=subpackageName%>.generated;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+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.EntityUtil;
+import org.ofbiz.security.Security;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.ModelService;
+import org.ofbiz.service.ServiceUtil;
+
+}*/
+ if (AttrComposite != null){
+ nameMap = Util.initPackageName(classComposite);
+ String classCompositeName = classComposite.getName();
+/*{import org.ofbiz.<%=(String) nameMap.get("packageName")%>.<%=(String)nameMap.get("subpackageName")%>.developed.<%=classCompositeName%>;
+}*/
+ }
+/*{import org.ofbiz.<%=(String) nameMap.get("packageName")%>.<%=(String)nameMap.get("subpackageName")%>.developed.<%=entityName%>;
+
+
+public class <%=entityName%>Services {
+
+ 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
+ //
+ public static Map edit<%=entityName%>(DispatchContext ctx, Map context) {
+ GenericDelegator delegator = ctx.getDelegator();
+// GenericValue userLogin = (GenericValue) context.get("userLogin");
+// Security security = ctx.getSecurity(); currently security is manage in the user interface
+ Map result = new HashMap();
+
+ Locale locale = (Locale) context.get("locale");
+ String actionForm = (String) context.get("actionForm");
+
+ if (actionForm.startsWith("commit") ){
+ actionForm = actionForm.substring(6);
+}*/
+ String ident = " ";
+ // code generation for retreiving objetc
+ generateRetreiveObject(output, clazz, AttrComposite, ident);
+ //
+/*{ if (actionForm.equals("add") ){
+ if (<%=Util.toLowerCaseFirstLetter(entityName)%>.isAlreadyPersistant() ){
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonIdAlreadyExist", locale));
+ }
+ }
+}*/
+ for (Iterator iter=clazz.getAttributes().iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ if (! Util.isPrimaryKey(attribute) ){
+ if (attribute.referenceClassifier() ){
+ if (attribute.getMaxMultiplicity() == 1){
+ if (! (attribute.getReverseAttribute() != null && attribute.getReverseAttribute().isComposite() ) ){ // so this attribute is in the primaryKey so already defined
+ Map relationKeyName = Util.getRelationOneFieldName(model, attribute, clazz);
+ List listName = (List) relationKeyName.get("listName");
+ ObjectModelClass classAssociated = (ObjectModelClass) ((Map) relationKeyName ).get("clazzAssociated");
+ String primaryKeyAsParam = "", primaryKeyNotNull = "";
+/*{
+}*/
+ for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){
+ Map fieldNameMap = (Map) iterList.next();
+ String fieldName = (String) fieldNameMap.get("fieldName");
+ primaryKeyAsParam += fieldName + ( iterList.hasNext() ? ", " : " " );
+ primaryKeyNotNull += fieldName + ( iterList.hasNext() ? " != null && " : " != null " );
+ String fieldType = (String) fieldNameMap.get("fieldType");
+/*{ <%=fieldType%> <%=fieldName%> = (<%=fieldType%>) context.get("<%=fieldName%>");
+}*/
+ }
+/*{ if (<%=primaryKeyNotNull%> ) <%=Util.toLowerCaseFirstLetter(entityName)%>.set<%=classAssociated.getName()%>(<%=primaryKeyAsParam%>);
+}*/
+ }
+ }else{
+ // TODO : methode get add remove for item of the list
+ }
+ } else { // it's a standard attribute
+ String attOfbizJavaType = Util.getOfbizJavaType(attribute);
+ String attributeName = attribute.getName();
+/*{
+ <%=attOfbizJavaType%> <%=attributeName%> = (<%=attOfbizJavaType%>) context.get("<%=attributeName%>");
+ if (<%=attributeName%> != null ) <%=Util.toLowerCaseFirstLetter(entityName)%>.set<%=Util.toUpperCaseFirstLetter(attributeName)%>(<%=attributeName%>);
+}*/
+ }
+ }
+ }
+/*{
+ if (<%=Util.toLowerCaseFirstLetter(entityName)%>.store() ) result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
+ else return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonDatabaseProblem", locale));
+ }
+ }
+ return result;
+ }
+
+ //
+ // Remove a <%=entityName%> record
+ //
+ // @param ctx
+ // @param context: a map containing in paramaters
+ // @return result: a map containing out parameters
+ //
+ public static Map remove<%=entityName%>(DispatchContext ctx, Map context) {
+ GenericDelegator delegator = ctx.getDelegator();
+// GenericValue userLogin = (GenericValue) context.get("userLogin");
+// Security security = ctx.getSecurity(); currently security is manage in the user interface
+ Map result = new HashMap();
+
+ Locale locale = (Locale) context.get("locale");
+}*/
+ ident = " ";
+ generateRetreiveObject(output, clazz, AttrComposite, ident);
+/*{ if (! <%=Util.toLowerCaseFirstLetter(entityName)%>.isAlreadyPersistant() ){
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonIdDoesNotExist", locale));
+ }
+ if (<%=Util.toLowerCaseFirstLetter(entityName)%>.remove() ) result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
+ else return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonDatabaseProblem", locale));
+ }
+ return result;
+ }
+}
+
+}*/
+ }
+}
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorFindBsh.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorFindBsh.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorFindBsh.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,236 @@
+package org.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 GeneratorFindBsh 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"))+"/generated/Find"+clazz.getName()+".bsh";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if(! Util.isEntity(clazz)) return;
+ 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());
+
+/*{
+// $Id: GeneratorFindBsh.java,v 1.1 2004/07/06 15:05:04 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.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.ofbiz.base.util.*;
+import org.ofbiz.common.FindServices;
+import org.ofbiz.entity.*;
+import org.ofbiz.entity.util.*;
+import org.ofbiz.entity.condition.EntityConditionList;
+import org.ofbiz.entity.condition.EntityJoinOperator;
+import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.model.DynamicViewEntity;
+import org.ofbiz.entity.model.ModelKeyMap;
+import org.ofbiz.base.util.BshUtil;
+import bsh.EvalError;
+
+import java.util.ListIterator;
+
+delegator = request.getAttribute("delegator");
+// field from the user query
+Map inputFields = UtilHttp.getParameterMap(request);
+//preload the query
+staticConditionsStr = page.getProperty("staticConditions");
+if (staticConditionsStr != null && staticConditionsStr.length() > 0) {
+ String [] staticConditions = BshUtil.eval("String [] cond="
+ + staticConditionsStr + "; return cond;",new HashMap());
+ for(int i=0; i < staticConditions.length; i += 2) {
+ inputFields.put(staticConditions[i], staticConditions[i+1]);
+ }
+}
+String hideSearch = inputFields.get("hideSearch");
+if (UtilValidate.isEmpty(hideSearch)) hideSearch = page.getProperty("hideSearch");
+context.put("hideSearch",hideSearch);
+
+String showListIfSelection = page.getProperty("showListIfSelection");
+if (UtilValidate.isEmpty(showListIfSelection) || showListIfSelection.equals("Y") || (UtilValidate.isNotEmpty(hideSearch) && hideSearch.equals("Y"))) {
+ context.put("showList", "Y");
+
+ // create the dynamic view entity
+ DynamicViewEntity dynamicView = new DynamicViewEntity();
+
+ // default view settings <%=clazz.getName()%>
+ dynamicView.addMemberEntity("EE", "<%=clazz.getName()%>");
+
+}*/
+ List listAssoc = new ArrayList();
+ List attributesListOrIndexed = Util.getAttributesList(clazz);
+ List attributesIndexed = new ArrayList();
+ // 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());
+ if (Util.hasGuiIndexed(attribute)){
+ if (! attribute.referenceClassifier()) attributesIndexed.add(attribute.getName());
+ if (attributesListOrIndexed.indexOf(attribute) == -1) attributesListOrIndexed.add(attribute);
+ }
+ }
+ List listAttributeName = 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{
+ listAttributeName.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)%>", "<%=attribute.getName()%>Name","<%=Util.getAttributeName(clazzAssoc)%>",null,null,null,null);
+ dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=attribute.getName()%>Description","<%=Util.getAttributeDescription(clazzAssoc)%>",null,null,null,null);
+
+}*/
+ if (Util.hasGuiIndexed(attribute) ){
+ attributesIndexed.add(attribute.getName()+"Name");
+ attributesIndexed.add(attribute.getName()+"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 iterAssoc=clazzAssoc.getAttributes().iterator(); iterAssoc.hasNext(); ){
+ ObjectModelAttribute attributeAssoc = (ObjectModelAttribute) iterAssoc.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%>");
+}*/
+ }
+/*{
+ 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;
+ String orderBy = page.getProperty("orderBy");
+ if (UtilValidate.isNotEmpty(orderBy)) {
+ orderByList = StringUtil.split(orderBy,"|");
+ }
+
+ // 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);
+}
+else context.put("showList", "N");
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntityObjectJava.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntityObjectJava.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,131 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+import org.codelutin.generator.models.object.ObjectModelOperation;
+import org.codelutin.generator.models.object.ObjectModelParameter;
+
+public class GeneratorEntityObjectJava extends ObjectModelGenerator {
+
+
+ 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"))+"/developed/"+clazz.getName()+"G.java";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if (! Util.isEntity(clazz) ) return;
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName = (String) nameMap.get("packageName");
+ String subpackageName = (String)nameMap.get("subpackageName");
+ String entityName = clazz.getName();
+ String varEntityName = Util.toLowerCaseFirstLetter(entityName);
+ ObjectModelAttribute AttrComposite = Util.isComposition(model, clazz);
+ ObjectModelClass classComposite = null;
+ if (AttrComposite != null){
+ classComposite = (ObjectModelClass) AttrComposite.getDeclaringElement();
+ }
+
+ // initialisation of the primaryKeyList
+ String primaryKeyAsParam="", primaryKeyAsParamCall="";
+ if (AttrComposite != null ){
+ primaryKeyAsParam = classComposite.getName() + " " + Util.toLowerCaseFirstLetter(classComposite.getName()) + ", ";
+ primaryKeyAsParamCall = Util.toLowerCaseFirstLetter(classComposite.getName() ) + ", ";
+ }
+ ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazz, false, classComposite);
+ for(int j=0; j.<%=subpackageName%>.developed;
+
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+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.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+
+
+public class <%=entityName%> extends org.ofbiz.<%=packageName%>.<%=subpackageName%>.generated.<%=entityName%>Base {
+
+ public static final String module = <%=entityName%>.class.getName();
+ public static final String resource = "<%=Util.toUpperCaseFirstLetter(packageName)%>UiLabels";
+
+
+ public <%=entityName%>(GenericValue <%=varEntityName%>){
+ super(<%=varEntityName%>);
+ }
+
+ public <%=entityName%>(GenericDelegator delegator, <%=primaryKeyAsParam%>){
+ super(delegator, <%=primaryKeyAsParamCall%>);
+ }
+}*/
+ if (clazz.getOperations().size() > 0 ){
+ for (Iterator iterColl = clazz.getOperations().iterator(); iterColl.hasNext(); ){
+ ObjectModelOperation operation = (ObjectModelOperation) iterColl.next();
+ String operationParam = "";
+ for (Iterator iterParam=operation.getParameters().iterator(); iterParam.hasNext(); ){
+ ObjectModelParameter parameter = (ObjectModelParameter) iterParam.next();
+ operationParam += parameter.getType() + " " + parameter.getName();
+ if (iterParam.hasNext() ) operationParam += ", ";
+ }
+/*{
+ public <%=operation.getReturnType()%> <%=operation.getName()%>(<%=operationParam%>){
+ <%=operation.getReturnType()%> result = null;
+ return result;
+ }
+}*/
+ }
+ }
+
+/*{
+}
+}*/
+ }
+}
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditAssocFtl.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditAssocFtl.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditAssocFtl.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,187 @@
+package org.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.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorEditAssocFtl extends ObjectModelGenerator {
+
+
+ public String getFilenameForClass(ObjectModelClass clazz){
+ Map nameMap = Util.initPackageName(clazz);
+ return ((String)nameMap.get("packageName"))+"/webapp/"+((String)nameMap.get("packageName"))+"/"+((String)nameMap.get("subpackageName"))+"/generated/EditAssoc"+clazz.getName()+".ftl";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if(! Util.isEntity(clazz)) return;
+ if (! Util.hasGuiEditAssoc(clazz) ) return;
+ List associationList = Util.getAssocList(clazz);
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName= Util.toUpperCaseFirstLetter((String) nameMap.get("packageName") );
+
+ ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazz, false);
+
+ String primaryKeys = "", pkHasContent = "";
+ for(int i=0; i
+<#assign uiLabelMap = requestAttributes.uiLabelMap>
+${pages.get(page.getProperty("subMenu"))}
+
+<#if hasCreatePermission>
+
+ <#-- TODO : Add a select field to choose the instance of the entity the user want to edit -->
+#if>
+
+<#if hasPermission>
+ <#if <%=pkHasContent%>>
+
+
+ <#-- <%=clazz.getName()%> Show sub-screen -->
+
+
+
+
+ ${uiLabelMap.<%=packageName%><%=clazz.getName()%>Id} : <%=primaryKeys%> |
+
+
+ ${singleWrapper.renderFormString()}
+ |
+
+ |
+}*/
+ for (Iterator iter=associationList.iterator(); iter.hasNext(); ){
+ ObjectModelAttribute association = (ObjectModelAttribute) iter.next();
+ ObjectModelClass classAssociated = Util.getClassAssociated( association );
+ nameMap = Util.initPackageName(classAssociated);
+ String packageNameAssoc = Util.toUpperCaseFirstLetter((String) nameMap.get("packageName") );
+
+ ListPkAttribute listPrimaryKeyAssoc = new ListPkAttribute(model, classAssociated, false, clazz);
+ String primaryKeysAssoc = "";
+ for(int i=0; i"> <#-- <%=Util.toUpperCaseFirstLetter(association.getName())%> sub-screen Update or Add -->
+ |
+
+ <#if actionForm?has_content >
+
+
+
+
+ <#if actionForm=="add">
+ ${uiLabelMap.<%=packageNameAssoc%><%=Util.toUpperCaseFirstLetter(association.getName())%>Creation} |
+ <#elseif actionForm=="edit">
+ ${uiLabelMap.CommonEdit} ${uiLabelMap.<%=packageNameAssoc%><%=Util.toUpperCaseFirstLetter(association.getName())%>Id} : <%=primaryKeysAssoc%> |
+ <#else>
+ ${uiLabelMap.CommonShow} ${uiLabelMap.<%=packageNameAssoc%><%=Util.toUpperCaseFirstLetter(association.getName())%>Id} : <%=primaryKeysAssoc%> |
+ #if>
+
+
+ |
+ |
+ ${<%=association.getName()%>Wrapper.renderFormString()}
+ |
+
+ #if>
+ |
+ #if>
+}*/
+ }
+/*{
+
+
+
+
+}*/
+ for (Iterator iter=associationList.iterator(); iter.hasNext(); ){
+ ObjectModelAttribute association = (ObjectModelAttribute) iter.next();
+ ObjectModelClass classAssociated = Util.getClassAssociated( association );
+ nameMap = Util.initPackageName(classAssociated);
+ String packageNameAssoc = Util.toUpperCaseFirstLetter((String) nameMap.get("packageName") );
+
+ ListPkAttribute listPrimaryKeyAssoc = new ListPkAttribute(model, classAssociated, false, clazz);
+ String primaryKeysAssoc = "";
+ for(int i=0; i"> <#-- <%=Util.toUpperCaseFirstLetter(association.getName())%> subList, only for one <%=clazz.getName()%> -->
+
+
+
+
+ ${uiLabelMap.<%=packageName%>ListOf<%=clazz.getName()%><%=Util.toUpperCaseFirstLetter(association.getName())%>} |
+
+
+ |
+
+
+ ${listWrapper.renderFormString()}
+ |
+
+ #if>
+}*/
+ }
+/*{
+
+ #if> <#-- idName?hasContent TODO : Add the <#else> to put a message to be able to select a <%=clazz.getName()%>-->
+<#else>
+ ${uiLabelMap.CommonPermissionError}
+#if>
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorControlerXml.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorControlerXml.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorControlerXml.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,193 @@
+package org.ofbiz.neogia.generators;
+
+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;
+import org.codelutin.generator.models.object.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorControlerXml extends ObjectModelGenerator {
+
+ private String packageParam = null;
+ private String packageName = null;
+
+
+ public String getFilenameForModel(ObjectModel model){
+ if (packageName == null) {
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) packageName="error";
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ return packageName+"/webapp/"+packageName+"/WEB-INF/controlerG.xml";
+ }
+
+ public void generateFromModel(Writer output, ObjectModel model) throws IOException {
+
+/*{
+
+
+}*/
+ if (packageParam == null){
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) return;
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ ObjectModelClass clazz;
+ String entityName, subpackageName;
+ for( Iterator iterClazz = model.getClasses().iterator(); iterClazz.hasNext(); ){
+ clazz = (ObjectModelClass) iterClazz.next();
+ if(Util.isEntity(clazz) && clazz.getPackageName().startsWith(packageParam)){
+ entityName = clazz.getName();
+ subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName()));
+ if (Util.hasGuiList(clazz) || Util.hasGuiListAll(clazz)){
+ /*{
+
+
+
+
+
+}*/
+ }
+ if (Util.hasGuiEdit(clazz)){
+/*{
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}*/
+ }
+ if(Util.hasGuiEditAssoc(clazz) ) {
+ List associationList = Util.getAssocList(clazz);
+/*{
+
+
+
+
+
+}*/
+ for (Iterator iter=associationList.iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ String associationName = (attribute.hasAssociationClass() ) ?
+ attribute.getAssociationClass().getName() :
+ attribute.getClassifier().getName();
+ String fromEntityName = (attribute.getName().equals(Util.toLowerCaseFirstLetter(attribute.getClassifier().getName() ) ) ) ?
+ clazz.getName() :
+ Util.toUpperCaseFirstLetter(attribute.getName());
+/*{
+
+
+
+
+
+
+
+
+
+
+
+
+}*/
+ }
+ }
+ if (Util.hasGuiLookup(clazz)){
+/*{
+
+
+
+
+
+
+}*/
+ }
+ if (Util.hasGuiShow(clazz)){
+/*{
+
+
+
+
+
+}*/
+ }
+ }
+ }
+/*{
+
+
+
+
+}*/
+ for( Iterator iterClazz = model.getClasses().iterator(); iterClazz.hasNext(); ){
+ clazz = (ObjectModelClass) iterClazz.next();
+ if(Util.isEntity(clazz) && clazz.getPackageName().startsWith(packageParam) ){
+ entityName = clazz.getName();
+ subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName()));
+ if (Util.hasGuiList(clazz) || Util.hasGuiListAll(clazz)){
+/*{
+
+}*/
+ }
+ if (Util.hasGuiEdit(clazz)){
+/*{
+}*/
+ }
+ if (Util.hasGuiEditAssoc(clazz)){
+/*{
+}*/
+ }
+ if (Util.hasGuiShow(clazz)){
+/*{
+}*/
+ }
+ }
+ }
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditBsh.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditBsh.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditBsh.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,195 @@
+package org.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 GeneratorEditBsh 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"))+"/generated/Edit"+clazz.getName()+".bsh";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if(! Util.isEntity(clazz)) return;
+ if (! Util.hasGuiEdit(clazz) && ! Util.hasGuiShow(clazz) ) return;
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName=(String) nameMap.get("packageName");
+ String entityName = clazz.getName();
+ //System.out.println("XXXXXXXX1Debug clazz.getName="+clazz.getName());
+
+/*{
+// $Id: GeneratorEditBsh.java,v 1.1 2004/07/06 15:05:04 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
+//
+//
+// 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.entity.*;
+import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.base.util.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilValidate;
+
+GenericDelegator delegator=request.getAttribute("delegator");
+HashMap formsData= new HashMap();
+
+actionForm = request.getParameter("actionForm");
+if (UtilValidate.isEmpty(actionForm)) actionForm = "beforeAction";
+if (actionForm.startsWith("commit") ) actionForm = actionForm.substring(6);
+context.put("actionForm",actionForm);
+
+}*/
+ // same code are in the GeneratorEditAssocBsh
+ 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(attribute);
+ 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
+
+ // initialisation of the primaryList
+ ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazz, false);
+ String primaryKeysEmpty = "! UtilValidate.isEmpty(";
+ String primaryKeysMap = "\"";
+ for(int j=0; j = request.getParameter("<%=attributeKeyName%>");
+}*/
+ primaryKeysEmpty = primaryKeysEmpty + attributeKeyName;
+ primaryKeysMap = primaryKeysMap + attributeKeyName + "\"," + attributeKeyName;
+ if (j < listPrimaryKey.getName().size()-1){
+ primaryKeysEmpty = primaryKeysEmpty + ") && ! UtilValidate.isEmpty(";
+ primaryKeysMap = primaryKeysMap + ",\"";
+ }
+ }
+ primaryKeysEmpty = primaryKeysEmpty + ")";
+/*{
+if (<%=primaryKeysEmpty%>) {
+ 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){
+ if (actionForm.equals("add") ) actionForm = "edit";
+}*/
+ 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 (<%=attributeName%> != null){
+ formsData.put("<%=attributeName%>Description", <%=attributeName%>.get("<%=descriptionFieldName%>") );
+ formsData.put("<%=attributeName%>Name", <%=attributeName%>.get("<%=idNameFieldName%>") );
+ }
+
+}*/
+ }
+/*{
+ request.setAttribute("formsData",formsData);
+ }
+}
+request.setAttribute("actionForm",actionForm);
+
+}*/
+ }
+}
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntitygroupXml.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntitygroupXml.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntitygroupXml.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,89 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Iterator;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModel;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorEntitygroupXml extends ObjectModelGenerator {
+
+ private String packageParam = null;
+ private String packageName = null;
+
+
+ public String getFilenameForModel(ObjectModel model){
+ if (packageName == null) {
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) packageName="error";
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ return packageName +File.separatorChar +"entitydef" + File.separatorChar +"entitygroup.xml";
+ }
+
+ public void generateFromModel(Writer output, ObjectModel model) throws IOException {
+
+/*{
+
+
+
+
+
+}*/
+ if (packageParam == null){
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) return;
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ ObjectModelClass clazz;
+ String entityName;
+ for( Iterator iterClazz = model.getClasses().iterator(); iterClazz.hasNext(); ){
+ clazz = (ObjectModelClass) iterClazz.next();
+ if(Util.isEntity(clazz) && clazz.getPackageName().startsWith(packageParam)){
+ entityName = clazz.getName();
+/*{
+}*/
+ }
+ }
+/*{
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/App.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/App.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/App.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,35 @@
+/* *##%%
+* Copyright (C) 2002, 2003 Code Lutin
+*
+* 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.
+*##%%**/
+package org.ofbiz.neogia.generators;
+
+/**
+* @author
+* Copyright Code Lutin
+* @version $Revision: 1.1 $
+*
+* Mise a jour: $Date: 2004/07/06 15:05:04 $
+* par : $Author: holivier $
+*/
+public class App {
+
+ public static void main(final String[] args) {
+ System.out.println("Starting ofbiz-generators...");
+ }
+
+}
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorServicesXml.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorServicesXml.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorServicesXml.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,95 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Iterator;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModel;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorServicesXml extends ObjectModelGenerator {
+
+ private String packageParam = null;
+ private String packageName = null;
+
+
+ public String getFilenameForModel(ObjectModel model){
+ if (packageName == null) {
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) packageName="error";
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ return packageName+"/servicedef/servicesG.xml";
+ }
+
+ public void generateFromModel(Writer output, ObjectModel model) throws IOException {
+
+/*{
+
+
+}*/
+ if (packageParam == null){
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) return;
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ ObjectModelClass clazz;
+ String entityName, subpackageName;
+ for( Iterator iterClazz = model.getClasses().iterator(); iterClazz.hasNext(); ){
+ clazz = (ObjectModelClass) iterClazz.next();
+ if(Util.isEntity(clazz) && clazz.getPackageName().startsWith(packageParam)){
+ entityName = clazz.getName();
+ subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName()));
+ if (Util.hasGuiEdit(clazz) || Util.isEditViaAssoc(model, clazz) ){
+/*{
+
+ Create or Update a <%=entityName%>
+
+
+
+
+ Remove a <%=entityName%>
+
+
+}*/
+ }
+ }
+ }
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/Util.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/Util.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/Util.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,888 @@
+/* *##%
+* 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
+* 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.
+*##%*/
+
+/* *
+* Util.java
+*
+* Created: 13 mai 2004
+*
+* @author Cédric Pineau
+* @author Olivier Heintz
+* Copyright Code Lutin
+* Copyright Nereide
+* Copyright Neogia
+* @version $Revision: 1.1 $
+*
+* Last update : $Date: 2004/07/06 15:05:04 $
+* by : $Author: holivier $
+*/
+package org.ofbiz.neogia.generators;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.codelutin.generator.models.object.ObjectModel;
+import org.codelutin.generator.models.object.ObjectModelAssociationClass;
+import org.codelutin.generator.models.object.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+import org.codelutin.generator.models.object.ObjectModelElement;
+
+/**
+ *
+ */
+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.
+ * This method is call by attributesList.
+ */
+ public static List attributesWithGuiLookup(ObjectModelClass clazz){
+ List attributesWithGuiLookup = new ArrayList();
+ for (Iterator iter=clazz.getAttributes().iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ if (Util.hasGuiListLookup(attribute)) attributesWithGuiLookup.add(attribute);
+ }
+ return attributesWithGuiLookup;
+ }
+
+
+ /**
+ * 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 tmpClassParticipants = new ArrayList(2);
+ int id = 0;
+ if (clazz instanceof ObjectModelAssociationClass) {
+ Map listMapParticipant =((ObjectModelAssociationClass) clazz).getParticipants();
+ //System.out.println("XXXXXXX-getParticipantsWithName2-Debug associationClass listMapParticipant.size="+listMapParticipant.size());
+ for (Iterator iterPart=listMapParticipant.keySet().iterator(); iterPart.hasNext(); ){
+ tmpClassParticipants.add(id,iterPart.next());
+ id += 1;
+ }
+ // 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()+" ");
+ classAssocWithoutNav.add(attribute);
+ }
+ }
+ }
+ }
+ }
+ return classAssocWithoutNav;
+ }
+
+ /**
+ * Give the name of the attribute of the clazz used as description attribute, with tag gui description or named "description".
+ * @param clazz
+ * @return String
+ */
+ public static String getAttributeDescription( ObjectModelClass clazz ){
+ String attributeDescription=null;
+ for (Iterator iter=clazz.getAttributes().iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ if ( Util.hasGuiDescription(attribute) ) return attribute.getName();
+ if ( attribute.getName().equals("description") ) attributeDescription = attribute.getName();
+ }
+ if (attributeDescription == null){
+ System.out.println("UML MODEL ERROR Entity with no description attribute defined; entity="+clazz.getName());
+ return "description";
+ } else return attributeDescription;
+ }
+
+ /**
+ * Give the name of the attribute of the clazz used as idName attribute, with tag gui name or named "idName".
+ * @param clazz
+ * @return String
+ */
+ public static String getAttributeName( ObjectModelClass clazz ){
+ String attributeName=null;
+ for (Iterator iter=clazz.getAttributes().iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ if (Util.hasGuiIdName(attribute)) return attribute.getName();
+ if (attribute.getName().equals("idName")) attributeName = attribute.getName();
+ }
+ if (attributeName == null){
+ System.out.println("UML MODEL ERROR Entity with no name attribute defined entity="+clazz.getName());
+ return "idName";
+ } else return attributeName;
+ }
+
+ /**
+ * Return a List with all the clazz attribute which must be list in a List.
+ * This collection is attributesWithGuiLookup and attributes with tag gui - list,
+ * if the previous result is empty it's all the class attribues execpt which with Tag hidden.
+ */
+ public static List getAttributesList(ObjectModelClass clazz){
+ List attributesList = attributesWithGuiLookup(clazz);
+ List classAttExecptHidden = new ArrayList();
+ for (Iterator iter=clazz.getAttributes().iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ if (Util.hasGuiList(attribute)) attributesList.add(attribute);
+ if (! Util.hasGuiHidden(attribute) &&
+ (! attribute.referenceClassifier() || attribute.getMaxMultiplicity()==1) )
+ classAttExecptHidden.add(attribute);
+ }
+ if (attributesList.size() == 0){
+ attributesList.addAll(classAttExecptHidden);
+ }
+ return attributesList;
+ }
+
+ /**
+ * 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 0 ){
+ for (Iterator iterClass=classAssocWithoutNav.iterator(); iterClass.hasNext(); ){
+ ObjectModelAttribute attrAssociated = (ObjectModelAttribute) iterClass.next();
+ if (attrAssociated.isComposite()){
+ ObjectModelClass classAssociated = (ObjectModelClass) attrAssociated.getDeclaringElement();
+ String relationName = (attrAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName())) ) ?
+ Util.getClassShortName(classAssociated) :
+ Util.toUpperCaseFirstLetter(attrAssociated.getName());
+ List listCompositePrimaryKeyName=new ArrayList(), listCompositePrimaryKeyType=new ArrayList();
+ Util.getListPrimaryKeyAttr(model, classAssociated, listCompositePrimaryKeyName, listCompositePrimaryKeyType, entity);
+ for(int i=0; i"listName" : a list of map, in each map three key "fieldName", "relFieldName" and "fieldType" (OfbizJavaType).
+ *
+ */
+ public static Map getRelationOneFieldName(ObjectModel model, ObjectModelAttribute attribute, ObjectModelClass _classOrigin){
+ List relationOneFieldNames = new ArrayList();
+ ObjectModelClass clazzAssociated;
+ // test if there are an association class for this atribute
+ String prefix=null;
+ boolean thereIsAssociationClass = false;
+
+ if (attribute.hasAssociationClass() ){
+ clazzAssociated = attribute.getAssociationClass();
+ prefix = attribute.getReverseAttribute().getName();
+ ObjectModelClass clazz = (ObjectModelClass) attribute.getDeclaringElement();
+ if (Util.toUpperCaseFirstLetter(prefix).equals(clazz.getName()) ) prefix = Util.getClassShortName(clazz);
+ thereIsAssociationClass = true;
+ } else
+ clazzAssociated = (ObjectModelClass) attribute.getClassifier();
+
+ if (attribute.getMaxMultiplicity() == 1){
+ ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazzAssociated, false, _classOrigin);
+ for(int i=0; i), for an _attribute which is classifer.
+ */
+ public static String getRelationNameForGetRelatedOne( ObjectModelAttribute _attribute, ObjectModelClass _associatedClass){
+ return (_attribute.getName().equals(Util.toLowerCaseFirstLetter(_attribute.getClassifier().getName() ) ) ) ?
+ _associatedClass.getName() :
+ Util.toUpperCaseFirstLetter(_attribute.getName()) + _associatedClass.getName();
+ }
+
+ /**
+ * return toLowerCaseFirstLetter for ( the tag value "shortName" if it exist, getName() otherwise ).
+ * @param clazz
+ * @return the shortName
+ */
+ public static String getClassShortName(ObjectModelClass clazz){
+ return Util.toLowerCaseFirstLetter((clazz.getTagValue("shortName")!=null) ? clazz.getTagValue("shortName") : clazz.getName());
+ }
+
+ /**
+ * return attribute.getName execpt when attribute.getName == attribute.getClassifier.getName,
+ * then return Util.getClassShortName(attribute.getClassifier()).
+ * @param attribute
+ * @return
+ */
+ public static String getAttributeShortName(ObjectModelAttribute attribute){
+ if (! attribute.referenceClassifier()) return attribute.getName();
+ ObjectModelClass classAssociated = (ObjectModelClass)attribute.getClassifier();
+ if (Util.toLowerCaseFirstLetter(classAssociated.getName()).equals(attribute.getName()))
+ return Util.getClassShortName((ObjectModelClass)attribute.getClassifier());
+ return attribute.getName();
+ }
+
+ /**
+ * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "calculated".
+ * @param _att
+ * @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);
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "calculated" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "description".
+ * @param _att
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "description" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "dropDown".
+ * @param _att
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "drop-down" ))
+ 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".
+ */
+ public static boolean hasGuiEdit( ObjectModelClass clazz ){
+ StringTokenizer guiTag = new StringTokenizer( clazz.getTagValue( "gui" ) != null ? clazz.getTagValue( "gui" ) : "", tagSeparator );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "edit" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "hidden".
+ * @param _att
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "hidden" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "indexed".
+ * @param _att
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "indexed" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the element has a tagvalue=="gui" and if its value contain the word "list".
+ * @param element
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "list" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * 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 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 "showList".
+ * @param clazz
+ * @return true if clazz has a tagvalue=="gui" and if its value contain the word "showList".
+ */
+ 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("showList")) return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "editAssoc".
+ * @param _att
+ * @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" ) )
+ return true;
+ return false;
+ }
+
+ /**
+ * 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 attribute-association with a tag editAsssoc
+ * @param _clazz
+ * @return a List of attribute 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 );
+ }
+ return associationList;
+ }
+
+ /**
+ * Give the Association class if exist, otherwise the _attribute.getClassifier.
+ * @param _attribute
+ * @return the Association class if exist, or the _attribute.getClassifier otherwise.
+ */
+ public static ObjectModelClass getClassAssociated( ObjectModelAttribute _attribute ){
+ if ( _attribute.hasAssociationClass() ) return _attribute.getAssociationClass();
+ return (ObjectModelClass) _attribute.getClassifier();
+ }
+
+ /**
+ * 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 );
+ }
+ }
+ if (_clazz instanceof ObjectModelAssociationClass ){
+ Map listMapParticipant =((ObjectModelAssociationClass) _clazz).getParticipants();
+ for (Iterator iterPart=listMapParticipant.keySet().iterator(); iterPart.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) listMapParticipant.get( iterPart.next() );
+ if ( hasGuiEditAssoc(attribute ) ) associationList.add(attribute );
+ }
+ }
+ 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.
+ */
+ 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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "listInAssoc".
+ * @param _att
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "listInAssoc" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "listLookup".
+ * @param _att
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "listLookup" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the clazz has a tagvalue=="gui" and if its value contain the word "lookup".
+ * @param clazz
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "lookup" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the _att has a tagvalue=="gui" and if its value contain the word "name".
+ * @param _att
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "idName" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * useable to test if the clazz has a tagvalue=="gui" and if its value contain the word "show".
+ * @param clazz
+ * @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 );
+ for( ; guiTag.hasMoreTokens(); )
+ if( guiTag.nextToken().equals( "show" ))
+ return true;
+ return false;
+ }
+
+ /**
+ * initialize the String packageName and subpackageName using the neogia package naming convention.
+ * The neogia package naming convention is : all the entities class are in
+ * org.neogia.packageName.subpackageName.entities.
+ * @param clazz : In param, the class for which you want the packageName and subpackageName
+ * @return Map with two elements one with key=="packageName" and one with key=="subpackageName"
+ */
+ public static Map initPackageName(ObjectModelClass clazz){
+ Map result = new HashMap();
+ String subpackage = Util.getParentPackageName(clazz.getPackageName());
+ result.put("subpackageName", Util.getLastWord(subpackage));
+ result.put("packageName", Util.getLastWord(Util.getParentPackageName(subpackage)));
+ return result;
+ }
+
+ /**
+ * return the available entity type in OFBiz for an attribute.
+ * print a message if the type does'nt exist.
+ * @param attribute
+ * @return a String with the Ofbiz type or "name" if there is non corresponding type.
+ */
+ public static String getOfbizType(ObjectModelAttribute attribute){
+ Map typeOfbiz = new HashMap();
+ typeOfbiz.put("java.lang.String","name");
+ typeOfbiz.put("java.lang.Long","numeric");
+ typeOfbiz.put("double","floating-point");
+ typeOfbiz.put("float","floating-point");
+ typeOfbiz.put("java.util.Date","date-time");
+ typeOfbiz.put("int","numeric");
+ typeOfbiz.put("boolean","indicator");
+ String attributeType = (String) typeOfbiz.get(attribute.getType());
+ if (attributeType == null){
+ System.out.println("UML MODEL ERROR Ofbiz type not define for type="+attribute.getType()+" in entity="+attribute.getDeclaringElement().getName());
+ attributeType = "name";
+ }
+ return attributeType;
+ }
+
+ /**
+ * return the available java type in OFBiz for an attribute.
+ * print a message if the type does'nt exist.
+ * @param attribute
+ * @return a String with the Ofbiz type or "String" if there is non corresponding type.
+ */
+ public static String getOfbizJavaType(ObjectModelAttribute attribute){
+ Map typeOfbiz = new HashMap();
+ typeOfbiz.put("java.lang.String","String");
+ typeOfbiz.put("java.lang.Long","Long");
+ typeOfbiz.put("double","Double");
+ typeOfbiz.put("float","Double");
+ typeOfbiz.put("java.util.Date","Timestamp");
+ typeOfbiz.put("int","Long");
+ typeOfbiz.put("boolean","Boolean");
+ String attributeType = (String) typeOfbiz.get(attribute.getType());
+ if (attributeType == null){
+ System.out.println("UML MODEL ERROR Ofbiz type not define for type="+attribute.getType()+" in entity="+attribute.getDeclaringElement().getName());
+ attributeType = "String";
+ }
+ return attributeType;
+ }
+
+ /**
+ * use to test if the attribute.getType == java.util.Date
+ * @param type
+ * @return type.equals("java.util.Date" );
+ */
+ public static boolean isDate(String type){
+ return type.equals("java.util.Date" );
+ }
+
+ /**
+ * retreive from the packageParams.properties file the two parameters.
+ * @param packageParam out parameter
+ * @param packageName out parameter
+ * @return false if there is an IOException true otherwise
+ */
+ public static boolean initPackageParam(String[] packageParam){
+ Properties packageParamFile=new Properties();
+ String paramFileName = "packageParams.properties";
+ try { packageParamFile.load(new FileInputStream(paramFileName));
+ }
+ catch (IOException e) {
+ System.out.println("ERROR IOException e=" + e);
+ System.out.println("ERROR File not found :" + paramFileName);
+ return false;
+ }
+ packageParam[0] = packageParamFile.getProperty("packageParam");
+ packageParam[1] = packageParamFile.getProperty("packageName");
+ return true;
+ }
+}
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditAssocBsh.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditAssocBsh.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditAssocBsh.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,575 @@
+package org.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.ObjectModelAssociationClass;
+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"))+"/generated/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(attribute);
+ 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/07/06 15:05:04 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.model.ModelKeyMap;
+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 = null;
+}*/
+ }
+ 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)%>");
+}*/
+ }
+/*{}
+}*/
+ }
+/*{
+if (<%=primaryKeysEmpty%>) {
+}*/
+ for(int i=0; i = request.getParameter("<%=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 (<%=attributeName%> != null){
+ formsData.put("<%=attributeName%>Description", <%=attributeName%>.get("<%=descriptionFieldName%>") );
+ formsData.put("<%=attributeName%>Name", <%=attributeName%>.get("<%=idNameFieldName%>") );
+ }
+
+}*/
+ }
+/*{ HtmlFormWrapper singleWrapper = new NsingleHtmlFormWrapper("/<%=subPackageName%>/generated/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 = Util.getClassAssociated( association );
+ // initialisation of the primaryList
+ ListPkAttribute listPrimaryKeyB = new ListPkAttribute(model, classAssociated, false);
+ // initialisation Names
+ String subPackageAssoc = (String) Util.initPackageName(classAssociated).get("subpackageName");
+ String fromEntityName = (association.getName().equals(Util.toLowerCaseFirstLetter(association.getClassifier().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%>/generated/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");
+}*/
+ }
+ List listAssoc = new ArrayList();
+ List attributesListOrIndexed = Util.getAttributesList(classAssociated);
+ List attributesIndexed = new ArrayList();
+ 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 if (! Util.isPrimaryKey(attribute) ){
+ listAttNameAssoc.add(attribute.getName());
+/*{ dynamicView.addAlias("EE", "<%=attribute.getName()%>");
+}*/
+ }
+ }
+
+ // if there is an association class add in the dynamicView for the other association Class participant
+ int nbAssoc = 1;
+ if (classAssociated instanceof ObjectModelAssociationClass && Util.hasGuiShow((ObjectModelClass)association.getClassifier() ) ) {
+ ObjectModelClass clazzAssoc = (ObjectModelClass)association.getClassifier();
+ ObjectModelAttribute attribute = association;
+ String relationName = attribute.getName();
+ if (Util.toUpperCaseFirstLetter(relationName).equals(clazzAssoc.getName())) relationName = Util.getClassShortName(clazzAssoc );
+/*{
+ // Association Class member associated entities
+ dynamicView.addMemberEntity("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toUpperCaseFirstLetter(relationName)%>");
+ dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=relationName%>Name","<%=Util.getAttributeName(clazzAssoc)%>",null,null,null,null);
+ dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=relationName%>Description","<%=Util.getAttributeDescription(clazzAssoc)%>",null,null,null,null);
+
+}*/
+ if (Util.hasGuiIndexed(attribute) ){
+ attributesIndexed.add(relationName+"Name");
+ attributesIndexed.add(relationName+"Description");
+ }
+
+ // 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)%>", "<%=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;
+ ListPkAttribute listPrimaryKeyClazzAssoc = new ListPkAttribute(model, clazzAssoc, true);
+ for (int iCassoc=0; iCassoc", "<%=relFieldName%>"}*/
+ first = false;
+ }
+/*{ ));
+}*/
+ nbAssoc += 1;
+ }
+
+ // add in the dynamicView all the associated entity
+ 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)%>", "<%=attribute.getName()%>Name","<%=Util.getAttributeName(clazzAssoc)%>",null,null,null,null);
+ dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=attribute.getName()%>Description","<%=Util.getAttributeDescription(clazzAssoc)%>",null,null,null,null);
+
+}*/
+ if (Util.hasGuiIndexed(attribute) ){
+ attributesIndexed.add(attribute.getName()+"Name");
+ attributesIndexed.add(attribute.getName()+"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(attribute);
+ 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
+
+ String primaryKeysEmptyB = "! UtilValidate.isEmpty(";
+ String primaryKeysMapB = "\"";
+ for(int j=0; j = request.getParameter("<%=attributeKeyName%>");
+ context.put("<%=association.getName()%><%=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 (<%=attributeName%> != null){
+ <%=association.getName()%>FD.put("<%=attributeName%>Description", <%=attributeName%>.get("<%=descriptionFieldName%>") );
+ <%=association.getName()%>FD.put("<%=attributeName%>Name", <%=attributeName%>.get("<%=idNameFieldName%>") );
+ }
+
+}*/
+ }
+/*{ }
+ }
+ request.setAttribute("actionForm",actionForm);
+ HtmlFormWrapper <%=association.getName()%>Wrapper = new NsingleHtmlFormWrapper("/<%=subPackageAssoc%>/generated/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);
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/ListPkAttribute.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/ListPkAttribute.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/ListPkAttribute.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,150 @@
+/* *##%
+ * 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.
+*##%*/
+
+package org.ofbiz.neogia.generators;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.codelutin.generator.models.object.ObjectModel;
+import org.codelutin.generator.models.object.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+/**
+ * @author Olivier Heintz
+ *
+ * return the name and type of all the primaryKey.
+ * Read the primaryKey list for the superClass if it exist, read the participant primaryKeys list if clazz
+ * is an association class
+ * (replacement of the Util.getListPrimaryKeyAttr methode)
+ * @param model to be able to search in all class the association no navigable
+ * @param clazz
+ * @param boolean to say if the ofbizType is an entity OfbizType (true) or java OfbizType (false)
+ * @param _classAssoc to be able to test for not retreiving primaryKey when they coming from _classAssoc.
+ * @version $Revision: 1.1 $
+ *
+ * Last update : $Date: 2004/07/06 15:05:04 $
+ * by : $Author: holivier $
+ */
+public class ListPkAttribute {
+ protected List name = new ArrayList(), type = new ArrayList();
+
+ public ListPkAttribute(ObjectModel model, ObjectModelClass clazz, boolean entity ){
+ ObjectModelClass classAssoc = null;
+ listPkAttribute(model, clazz, entity, classAssoc);
+ }
+ public ListPkAttribute(ObjectModel model, ObjectModelClass clazz, boolean entity, ObjectModelClass _classAssoc ){
+ listPkAttribute(model, clazz, entity, _classAssoc);
+ }
+ private void listPkAttribute(ObjectModel model, ObjectModelClass clazz, boolean entity, ObjectModelClass _classAssoc){
+ // search for non navigable association and composite
+ List classAssocWithoutNav = Util.getClassAssocWithoutNav(model, clazz);
+ if (classAssocWithoutNav.size() > 0 ){
+ for (Iterator iterClass=classAssocWithoutNav.iterator(); iterClass.hasNext(); ){
+ ObjectModelAttribute attrAssociated = (ObjectModelAttribute) iterClass.next();
+ //System.out.println("XXXXXX-DebugUtil in iterator classAssocWithoutNav attrAssociated=" + attrAssociated.getName());
+ if (attrAssociated.isComposite()){
+ ObjectModelClass classAssociated = (ObjectModelClass) attrAssociated.getDeclaringElement();
+ if (! classAssociated.equals(_classAssoc) ){
+ String relationName = (attrAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName())) ) ?
+ Util.getClassShortName(classAssociated) :
+ Util.toUpperCaseFirstLetter(attrAssociated.getName());
+ ListPkAttribute listCompositePrimaryKey = new ListPkAttribute(model, classAssociated, entity);
+ for(int i=0; i}
+ */
+ private String getCallForAssociation( ObjectModelAttribute _attribute ){
+ Map relationKeyName = Util.getRelationOneFieldName(model, _attribute);
+ String relationName = ((ObjectModelClass) relationKeyName.get("clazzAssociated")).getName();
+ String stringReturn = relationName + "?";
+ List listName = (List) relationKeyName.get("listName");
+ for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){
+ Map fieldNameMap = (Map) iterList.next();
+ stringReturn = stringReturn + (String) fieldNameMap.get("relFieldName")
+ + "=${" + (String) fieldNameMap.get("fieldName");
+ if( iterList.hasNext() )
+ stringReturn = stringReturn + "}&";
+ }
+ return stringReturn;
+ }
+
+//===============================================================================
+ /**
+ * create the parameters which is needed to be able to call the Show( associationClass).
+ * @param _attributeName
+ * @param _participantClass
+ * @return string to put after the begining of the URI ex: /Show<%=getCallForAssociationClass(clazz)%>}
+ */
+ private String getCallForAssociationClass(String _participantName, ObjectModelClass _participantClass ){
+ String relationName = _participantName ;
+ if (Util.toUpperCaseFirstLetter( relationName).equals(_participantClass.getName())) relationName = Util.getClassShortName(_participantClass );
+ String stringReturn = Util.toUpperCaseFirstLetter(relationName) + "?";
+ ListPkAttribute listPrimaryKey = new ListPkAttribute(model, _participantClass, false);
+ for(Iterator iterList=listPrimaryKey.getName().iterator(); iterList.hasNext(); ){
+ String fieldName = (String) iterList.next();
+ stringReturn += fieldName + "=${" +relationName + Util.toUpperCaseFirstLetter(fieldName);
+ if( iterList.hasNext() )
+ stringReturn += stringReturn + "}&";
+ }
+ return stringReturn;
+ }
+
+ private boolean putLookup( Writer output, ObjectModelAttribute _att ) throws IOException {
+ if( associe( _att ) ){
+ /*{
+}*/
+ }
+ return associe( _att );
+ }
+
+ private String uiLabel( ObjectModelAttribute _attribute ){
+ return "${uiLabelMap." + packageName + Util.toUpperCaseFirstLetter( _attribute.getName() )+ "}";
+ }
+ private String uiLabel( String _attributeName ){
+ 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">
+
+}*/
+ ObjectModelAttribute attrEditAssocReverse = null;
+ if (attrEditAssoc != null){
+ attrEditAssocReverse = attrEditAssoc.getReverseAttribute();
+/*{
+}*/
+ }
+ // 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 {
+/*{
+}*/
+ }
+ }
+ }
+ }
+ if (clazz instanceof ObjectModelAssociationClass){
+ Map participantsWithName = Util.getParticipantsWithName(clazz);
+ for (int i=0; i<2; i++){
+ ObjectModelClass participantClass = (ObjectModelClass) ((List) participantsWithName.get("classParticipants")).get(i);
+ String participantName = (String) ((List) participantsWithName.get("attributeParticipants")).get(i);
+ if (Util.toUpperCaseFirstLetter(participantName).equals(participantClass.getName())) participantName = Util.getClassShortName(participantClass);
+ ListPkAttribute listParticipantPrimaryKey = new ListPkAttribute(model, participantClass, true);
+ for (int j=0; j
+}*/
+ }
+ if (! participantClass.equals((ObjectModelClass) attrEditAssoc.getDeclaringElement() ) ){
+ if (Util.hasGuiShow(participantClass) ){
+ String call = getCallForAssociationClass(participantName, participantClass );
+/*{
+
+
+}*/
+ }else{
+/*{
+
+
+}*/
+ }
+ }
+ }
+ } else if ( attrEditAssoc != null && attrEditAssocReverse != null ){
+ for (Iterator iterFN=getListFieldNamePKReverse(attrEditAssoc, attrEditAssocReverse).iterator(); iterFN.hasNext(); ){
+ String fieldName = (String) iterFN.next();
+/*{
+}*/
+ }
+ }
+ for (Iterator iter = listAttList.iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ if ( ! attribute.equals(attrEditAssocReverse ) ){
+ if (attribute.referenceClassifier() ){
+ if (Util.hasGuiShow((ObjectModelClass) attribute.getClassifier() ) ){
+ String call = getCallForAssociation( attribute );
+/*{
+
+
+}*/
+ } else{
+/*{
+
+
+}*/
+ }
+ }else {
+/*{
+}*/
+ }
+ }
+ }
+ listValAtt = "";
+ ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazz, false);
+ for(int j=0; j
+
+
+
+
+
+}*/
+ }
+
+//===============================================================================
+ /**
+ * 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">
+
+}*/
+ ObjectModelAttribute attrEditAssocReverse = null;
+ if (attrEditAssoc != null){
+ attrEditAssocReverse = attrEditAssoc.getReverseAttribute();
+/*{
+}*/
+ }
+ // 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 { /*{}*/ }
+ /*{
+
+}*/
+ }
+ }
+ }
+ }
+ if (clazz instanceof ObjectModelAssociationClass){
+ Map participantsWithName = Util.getParticipantsWithName(clazz);
+ for (int i=0; i<2; i++){
+ ObjectModelClass participantClass = (ObjectModelClass) ((List) participantsWithName.get("classParticipants")).get(i);
+ boolean hiddenField = participantClass.equals((ObjectModelClass) attrEditAssoc.getDeclaringElement() );
+ String participantName = (String) ((List) participantsWithName.get("attributeParticipants")).get(i);
+ if (Util.toUpperCaseFirstLetter(participantName).equals(participantClass.getName())) participantName = Util.getClassShortName(participantClass);
+ ListPkAttribute listParticipantPrimaryKey = new ListPkAttribute(model, participantClass, true);
+ for (int j=0; j
+}*/
+ } else {
+/*{ }*/
+ if ("date-time".equals(listParticipantPrimaryKey.getType().get(j) ) ) { /*{}*/ }
+ else { /*{}*/ }
+ /*{
+
+}*/
+ }
+ }
+ }
+ }
+ for ( Iterator iter = clazz.getAttributes().iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ if ( attribute.equals(attrEditAssocReverse ) ){
+ for (Iterator iterFN=getListFieldNamePKReverse(attrEditAssoc, attrEditAssocReverse).iterator(); iterFN.hasNext(); ){
+ String fieldName = (String) iterFN.next();
+/*{
+}*/
+ }
+ } else 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;
+
+ if( Util.isEntity( clazz )){
+ initPackageName(clazz);
+ 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;
+
+/*{
+
+
+
+
+}*/
+
+ //================================
+ // Generation Find - Selection - Lookup
+ //================================
+ if( Util.hasGuiLookup( clazz ) || Util.hasGuiList( clazz ) || Util.hasGuiListAll( clazz ) ){
+ //System.out.println( "Lookup-Find " + clazz.getName() );
+/*{
+
+
+
+
+
+}*/
+ }
+ if( Util.hasGuiLookup( clazz ) ){
+ /*
+ =================================
+ Generation ListLookup
+ =================================
+ */
+/*{
+
+
+
+
+}*/
+ }
+
+
+ //==================================
+ // Generation List without any selection
+ //==================================
+
+ if( Util.hasGuiShowList( clazz ) ){
+/*{
+
+
+
+
+}*/
+ }
+
+
+ //=========================================
+ // Generation List whith selection to be able to Edit
+ //=========================================
+ if (Util.hasGuiList( clazz ) || Util.hasGuiListAll( clazz ) ){
+ //System.out.println( "Beginning ListEdit " );
+/*{
+
+
+
+
+}*/
+ }
+
+/*{
+
+
+}*/
+
+ }
+ }
+}
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsListXml.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsListXml.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorPagedefsListXml.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,63 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorPagedefsListXml 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"))+"/generated/List"+clazz.getName()+"G.xml";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if(! Util.isEntity(clazz)) return;
+ boolean guiList = Util.hasGuiList(clazz);
+ if(! Util.hasGuiListAll(clazz) && ! guiList) return;
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName =Util.toUpperCaseFirstLetter((String) nameMap.get("packageName"));
+ String subpackageName=(String) nameMap.get("subpackageName");
+
+
+/*{
+
+ main
+ <%=packageName%>List<%=clazz.getName()%>
+ /<%=subpackageName%>/generated/Forms<%=clazz.getName()%>.xml
+ find<%=clazz.getName()%>
+ list<%=clazz.getName()%>
+ 20
+ <%=subpackageName%>
+ /<%=subpackageName%>/developed/TabBarSubMenu.ftl
+ find
+ <%=clazz.getName()%>
+}*/
+ if (guiList){
+/*{ N
+}*/
+ } else {
+/*{ Y
+}*/
+ }
+/*{ N
+
+
+ entityList
+ <%=packageName.toUpperCase()%>
+ _VIEW
+ simple
+
+
+
+
+
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditFtl.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditFtl.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEditFtl.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,97 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorEditFtl extends ObjectModelGenerator {
+
+
+ public String getFilenameForClass(ObjectModelClass clazz){
+ Map nameMap = Util.initPackageName(clazz);
+ return ((String)nameMap.get("packageName"))+"/webapp/"+((String)nameMap.get("packageName"))+"/"+((String)nameMap.get("subpackageName"))+"/generated/Edit"+clazz.getName()+".ftl";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if(! Util.isEntity(clazz)) return;
+ if (! Util.hasGuiEdit(clazz) ) return;
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName= Util.toUpperCaseFirstLetter((String) nameMap.get("packageName") );
+ List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = new ArrayList();
+ Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType);
+ String primaryKeys = "";
+ for(int j=0; j
+<#assign uiLabelMap = requestAttributes.uiLabelMap>
+${pages.get(page.getProperty("subMenu"))}
+
+<#if hasCreatePermission>
+
+ <#-- TODO : Add a select field to choose the instance of the entity the user want to edit -->
+#if>
+
+<#if hasPermission>
+ <#if actionForm?has_content >
+
+
+
+
+ <#if actionForm=="add">
+ ${uiLabelMap.<%=packageName%><%=clazz.getName()%>Creation} |
+ <#elseif actionForm=="edit">
+ ${uiLabelMap.CommonEdit} ${uiLabelMap.<%=packageName%><%=clazz.getName()%>Id} : <%=primaryKeys%> |
+ <#else>
+ ${uiLabelMap.CommonShow} ${uiLabelMap.<%=packageName%><%=clazz.getName()%>Id} : <%=primaryKeys%> |
+ #if>
+
+
+ |
+ |
+ ${singleWrapper.renderFormString()}
+ |
+
+ #if>
+<#else>
+ ${uiLabelMap.CommonPermissionError}
+#if>
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntitymodelXml.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntitymodelXml.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntitymodelXml.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,264 @@
+package org.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.ObjectModel;
+import org.codelutin.generator.models.object.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorEntitymodelXml extends ObjectModelGenerator {
+
+ private String packageParam = null;
+ private String packageName = null;
+
+
+ public String getFilenameForModel(ObjectModel model){
+ if (packageName == null) {
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) packageName="error";
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ return packageName+"/entitydef/entitymodel.xml";
+ }
+
+ public void generateFromModel(Writer output, ObjectModel model) throws IOException {
+ ObjectModelClass clazz;
+/*{
+
+
+
+
+
+
+
+
+
+ Entity of the Neogia <%=packageName%> Component
+ None
+ Copyright (c) 2004 - www.neogia.org
+ Misc
+ 1.0
+
+
+
+
+}*/
+ if (packageParam == null){
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) return;
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ ObjectModelAttribute attribute;
+ ObjectModelClass clazzAssociated;
+ ObjectModel objectModel = getModel();
+ String entityName, attributeType, subpackageName;
+ List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = new ArrayList();
+ boolean isAssoc;
+ for( Iterator iterClazz = model.getClasses().iterator(); iterClazz.hasNext(); ){
+ clazz = (ObjectModelClass) iterClazz.next();
+ //System.out.println("XXXXXXXX0Debug PackageName()="+clazz.getPackageName());
+ if(Util.isEntity(clazz) && clazz.getPackageName().startsWith(packageParam)){
+ entityName = clazz.getName();
+ subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName()));
+/*{
+
+}*/
+ // Add field for each participant if it's an association class
+ Map participantsWithName = Util.getParticipantsWithName(clazz);
+ if (participantsWithName != null) {
+ for (int i=0; i<2; i++){
+ ObjectModelClass participantClass = (ObjectModelClass) ((List) participantsWithName.get("classParticipants")).get(i);
+ String participantName = (String) ((List) participantsWithName.get("attributeParticipants")).get(i);
+ //System.out.println("XXXXXXX-X2-Debug associationClass debug ParticipantName="+participantName+" participantClass="+participantClass.getName());
+ if (Util.toUpperCaseFirstLetter(participantName).equals(participantClass.getName())) participantName = Util.getClassShortName(participantClass);
+ listPrimaryKeyName.clear(); listPrimaryKeyType.clear();
+ Util.getListPrimaryKeyAttr(model, participantClass, listPrimaryKeyName, listPrimaryKeyType);
+ for(int j=0; j
+}*/
+ }
+ }
+ }
+ if (! clazz.getSuperclasses().isEmpty()) {
+ for (Iterator iter=clazz.getSuperclasses().iterator();iter.hasNext(); ){
+ ObjectModelClass superClass = (ObjectModelClass) iter.next();
+ listPrimaryKeyName.clear(); listPrimaryKeyType.clear();
+ Util.getListPrimaryKeyAttr(model, superClass, listPrimaryKeyName, listPrimaryKeyType);
+ for(int i=0; i
+}*/
+ }
+ }
+ }
+ // standard attribute
+ for (Iterator iterattribute = clazz.getAttributes().iterator(); iterattribute.hasNext(); ){
+ attribute = (ObjectModelAttribute) iterattribute.next();
+ //System.out.println("XXXXXXXX2Debug attribute="+attribute.getName() );
+ isAssoc = attribute.referenceClassifier();
+ if (! isAssoc){
+ attributeType = Util.getOfbizType(attribute);
+/*{
+}*/
+ } else{
+ if (attribute.getMaxMultiplicity() == 1){
+ clazzAssociated = (ObjectModelClass) attribute.getClassifier();
+ if (clazzAssociated == null ) System.out.println("UML MODEL ERROR non existant class ="+attribute.getType()+" used in class ="+clazz.getName());
+ //System.out.println("XXXXXXXX3Debug clazzAssociated="+clazzAssociated.getName());
+ listPrimaryKeyName.clear(); listPrimaryKeyType.clear();
+ Util.getListPrimaryKeyAttr(model, clazzAssociated, listPrimaryKeyName, listPrimaryKeyType);
+ for(int i=0; i<%=Util.toUpperCaseFirstLetter(attrAssocName)%>" type="<%=attributeType%>">
+}*/
+ }
+ if (listPrimaryKeyName.size()<1) System.out.println("UML MODEL ERROR class without a primaryKey, class ="+clazzAssociated.getName());
+ }
+ }
+ }
+ // 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();
+ listPrimaryKeyName.clear(); listPrimaryKeyType.clear();
+ Util.getListPrimaryKeyAttr(model, classAssociated, listPrimaryKeyName, listPrimaryKeyType);
+ for(int i=0; i
+}*/
+ }
+ }
+ }
+ listPrimaryKeyName.clear(); listPrimaryKeyType.clear();
+ Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType);
+ for(int i=0; i
+}*/
+ }
+ // Add relation for each field for each participant if it's an association class
+ if (participantsWithName != null) {
+ for (int i=0; i<2; i++){
+ ObjectModelClass participantClass = (ObjectModelClass) ((List) participantsWithName.get("classParticipants")).get(i);
+/*{
+}*/
+ String participantName = (String) ((List) participantsWithName.get("attributeParticipants")).get(i);
+ if (Util.toUpperCaseFirstLetter(participantName).equals(participantClass.getName())) participantName = Util.getClassShortName(participantClass);
+ ListPkAttribute listPrimaryKey = new ListPkAttribute(model, participantClass, true);
+ for(int j=0; j
+}*/
+ }
+/*{
+}*/
+ }
+ }
+ for (Iterator iterattribute = clazz.getAttributes().iterator(); iterattribute.hasNext(); ){
+ attribute = (ObjectModelAttribute) iterattribute.next();
+ //System.out.println("XXXXXXXX5Debug attribute="+attribute.getName());
+ if (attribute.referenceClassifier()){
+ Map relationKeyName = Util.getRelationOneFieldName(model, attribute);
+ String relationName = ((ObjectModelClass) relationKeyName.get("clazzAssociated")).getName();
+ boolean ifTitle = ! (Util.toUpperCaseFirstLetter( attribute.getName() ).equals( attribute.getClassifier().getName() ) );
+
+ if (attribute.getMaxMultiplicity() == 1){
+ if (ifTitle){
+/*{
+}*/
+ }else{
+/*{
+}*/
+ }
+ List listName = (List) relationKeyName.get("listName");
+ for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){
+ Map fieldName = (Map) iterList.next();
+/*{ " rel-field-name="<%=(String) fieldName.get("relFieldName")%>"/>
+}*/
+ }
+ } else {
+ if (ifTitle){
+/*{
+}*/
+ }else{
+/*{
+}*/
+ }
+ String reverseAttributeName = ( attribute.getReverseAttribute() != null ) ?
+ Util.getAttributeShortName(attribute.getReverseAttribute()) :
+ Util.getClassShortName(clazz);
+ listPrimaryKeyName.clear(); listPrimaryKeyType.clear();
+ Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType);
+ for(int i=0; i" rel-field-name="<%=reverseAttributeName%><%=Util.toUpperCaseFirstLetter(attrPkName)%>"/>
+}*/
+ }
+ }
+/*{
+}*/
+ }
+
+ }
+/*{
+}*/
+ }
+ }
+/*{
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/listAfaire
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/listAfaire:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/listAfaire Tue Jul 6 15:05:04 2004
@@ -0,0 +1,60 @@
+-ftl fixe ou duplication
+-xml (pagedef) personalisable
+-bsh fixe
+-xml (forms) fixe
+-services.xml ?? fixe
+-controler.xml personalisable
+-UiLabel.properties personalisable
+-UiLabel_fr.properties personalisable
+
+type de transaction :
+ListAll
+List (with selection)
+Edit (&add)
+List associé Edit (&add) pour
+show
+lookup
+
+<>
+webapp/%package%/%sous-package%/%Entity%Forms.xml en fonction du tag gui
+ List
+ ListSelect
+ ListEdit
+ Search
+ Lookup (search)
+ ListLookup
+ Edit
+ show
+
+<>
+Generator webapp/%package%/WEB-INF/controler%Entity%.xml en fonction du tag gui
+ Find
+ Edit
+ Delete
+ Lookup
+ show (TODO : quand il y en aura besoin)
+
+<>
+Generator entitydef/entitygroup.xml
+entitydef/entitymodel.xml
+
+
+ListAll%Entity% :
+Generator webapp/%package%/%sous-package%/ListAll%Entity%.ftl
+Generator webapp/%package%/WEB-INF/pagedefs/%sous-package%/ListAll%Entity%.xml
+ generic dans include
+
+List%Entity% :
+ webapp/%package%/%sous-package%/List%Entity%.ftl
+ webapp/%package%/WEB-INF/pagedefs/%sous-package%/List%Entity%.xml
+ webapp/%package%/WEB-INF/actions/%sous-package%/Find%Entity%.bsh
+ webapp/%package%/%sous-package%/List%Entity%Forms.xml
+
+Edit%Entity%
+ webapp/%package%/%sous-package%/Edit%Entity%.ftl
+ webapp/%package%/WEB-INF/pagedefs/%sous-package%/Edit%Entity%.xml
+ webapp/%package%/WEB-INF/actions/%sous-package%/Edit%Entity%.bsh
+
+
+Lookup cf Nicolas
+Generator src/org/ofbiz/%package%/lookupParams.java
\ No newline at end of file
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorUiLabelProperties.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorUiLabelProperties.java:1.1
--- /dev/null Tue Jul 6 15:05:10 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorUiLabelProperties.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,222 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.Writer;
+import java.lang.Character;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModel;
+import org.codelutin.generator.models.object.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorUiLabelProperties extends ObjectModelGenerator {
+
+ private String packageParam = null;
+ private String packageName = null;
+ private Properties referenceUiLabel=new Properties();
+
+ public void initReferenceUiLabel(){
+ String nomReferenceUiLabel = Util.toUpperCaseFirstLetter(packageName) + "UiLabels.properties";
+ try { referenceUiLabel.load(new FileInputStream(nomReferenceUiLabel));
+ }
+ catch (IOException e) { System.out.println("ERROR file not found :" + nomReferenceUiLabel);};
+ }
+
+ public String putSpaceBeforeUpper(String field){
+ char[] fieldChar = field.toCharArray(), resultChar = new char[100];
+ resultChar[0] = Character.toUpperCase(fieldChar[0]);
+ int j = 1;
+ for (int i=1; iUiLabel.properties file.
+
+}*/
+ if (packageParam == null){
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) return;
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ ObjectModelClass clazz;
+ String entityName, subpackageName;
+ List alreadyCreated = new ArrayList();
+ initReferenceUiLabel();
+ for( Iterator iterClazz = model.getClasses().iterator(); iterClazz.hasNext(); ){
+ clazz = (ObjectModelClass) iterClazz.next();
+ if(Util.isEntity(clazz) && clazz.getPackageName().startsWith(packageParam)){
+ entityName = clazz.getName();
+ subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName()));
+ /*{
+
+# <%=entityName%>
+#<%=Util.toUpperCaseFirstLetter(packageName)%><%=entityName%>=<%=entityName%>
+}*/
+ if (Util.hasGuiList(clazz) || Util.hasGuiListAll(clazz)){
+/*{
+#<%=Util.toUpperCaseFirstLetter(packageName)%>List<%=entityName%>=List <%=entityName%>
+}*/
+ }
+ if (Util.hasGuiEdit(clazz)){
+/*{
+#<%=Util.toUpperCaseFirstLetter(packageName)%>Edit<%=entityName%>=Edit <%=entityName%>
+#<%=Util.toUpperCaseFirstLetter(packageName)%>New<%=entityName%>=New <%=entityName%>
+#<%=Util.toUpperCaseFirstLetter(packageName)%><%=entityName%>Creation=<%=entityName%> Creation
+}*/
+ }
+ if (Util.hasGuiEditAssoc(clazz) ){
+/*{
+#<%=Util.toUpperCaseFirstLetter(packageName)%>EditAssoc<%=entityName%>=Edit <%=entityName%> Association
+}*/
+ List associations = Util.getAssocList(clazz);
+ for (Iterator iter=associations.iterator(); iter.hasNext(); ){
+ ObjectModelAttribute association = (ObjectModelAttribute) iter.next();
+/*{
+#<%=Util.toUpperCaseFirstLetter(packageName)%><%=entityName%><%=Util.toUpperCaseFirstLetter(association.getName() )%>Association=<%=entityName%> <%=Util.toUpperCaseFirstLetter(association.getName() )%> Association
+#<%=Util.toUpperCaseFirstLetter(packageName)%>ListOf<%=entityName%><%=Util.toUpperCaseFirstLetter(association.getName() )%>=List of <%=entityName%> <%=Util.toUpperCaseFirstLetter(association.getName() )%>
+}*/
+ }
+ }
+ if (Util.isEditViaAssoc(model, clazz) ){
+/*{
+#<%=Util.toUpperCaseFirstLetter(packageName)%>Add<%=entityName%>=Add <%=entityName%>
+}*/
+ }
+ if (Util.hasGuiShow(clazz)){
+/*{
+#<%=Util.toUpperCaseFirstLetter(packageName)%>Show<%=entityName%>=Show <%=entityName%>
+}*/
+ }
+/*{
+#<%=Util.toUpperCaseFirstLetter(packageName)%><%=entityName%>Id=<%=entityName%> Id
+
+}*/
+ // all the primaryKeys
+ List entityField = new ArrayList();
+ List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = new ArrayList();
+ Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType);
+ for (int j=0; j
+
+}*/
+ if (packageParam == null){
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) return;
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ System.out.println("Package Name Param is =" + packageName);
+ ObjectModelClass clazz;
+ String entityName, subpackageName;
+ for( Iterator iterClazz = model.getClasses().iterator(); iterClazz.hasNext(); ){
+ clazz = (ObjectModelClass) iterClazz.next();
+ System.out.println("Class Name is =" + clazz.getName() );
+ if(Util.isEntity(clazz) ){
+ entityName = clazz.getName();
+ subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName()));
+ if (clazz.getPackageName().startsWith(packageParam) )
+ System.out.println(" Class is in the package subpackageName =" + subpackageName );
+ else
+ System.out.println(" subpackageName =" + subpackageName );
+ for (Iterator iterAtt=clazz.getAttributes().iterator(); iterAtt.hasNext(); ) {
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iterAtt.next();
+ System.out.println(" Attribute Name =" + attribute.getName() );
+ if (attribute.referenceClassifier() ){
+ if (attribute.hasAssociationClass() ){
+ System.out.println(" Attribute.getClassifier =" + attribute.getClassifier().getName() + " and an association Class =" + attribute.getAssociationClass().getName() );
+ } else
+ System.out.println(" Attribute.getClassifier =" + attribute.getClassifier().getName() );
+ } else {
+ String testSt = Util.getOfbizType(attribute);
+ }
+ }
+ }
+ }
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorListFtl.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorListFtl.java:1.1
--- /dev/null Tue Jul 6 15:05:11 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorListFtl.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,100 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorListFtl extends ObjectModelGenerator {
+
+
+ public String getFilenameForClass(ObjectModelClass clazz){
+ Map nameMap = Util.initPackageName(clazz);
+ return ((String)nameMap.get("packageName"))+"/webapp/"+((String)nameMap.get("packageName"))+"/"+((String)nameMap.get("subpackageName"))+"/generated/List"+clazz.getName()+".ftl";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if(! Util.isEntity(clazz)) return;
+ boolean guiListAll = Util.hasGuiListAll(clazz);
+ if (! Util.hasGuiList(clazz) && ! guiListAll ) return;
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName=(String) nameMap.get("packageName");
+
+/*{
+<#--
+ * 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
+ *
+ * This file has been generated, and will be re-generated,
+ * so no modification must be done whitout copying it with a other name.
+-->
+<#assign uiLabelMap = requestAttributes.uiLabelMap>
+${pages.get(page.getProperty("subMenu"))}
+
+<#if hasPermission>
+
+
+
+
+
+ <#if requestParameters.hideSearch?default("N") == "N">
+ ${uiLabelMap.CommonSelection} |
+ <#else>
+
+
+ #if>
+
+ |
+
+
+ <#if hideSearch?default("N") != "Y">
+
+
+ |
+ ${singleWrapper.renderFormString()}
+ |
+ |
+
+ |
+
+
+ #if>
+ |
+
+
+
+ <#if showList?default("Y") == "Y">
+ ${listWrapper.renderFormString()}
+ #if>
+<#else>
+ ${uiLabelMap.CommonPermissionError}
+#if>
+
+
+
+}*/
+ }
+}
+
+
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntityObjectBaseJava.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntityObjectBaseJava.java:1.1
--- /dev/null Tue Jul 6 15:05:11 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorEntityObjectBaseJava.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,349 @@
+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.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+import org.codelutin.generator.models.object.ObjectModelOperation;
+import org.codelutin.generator.models.object.ObjectModelParameter;
+
+public class GeneratorEntityObjectBaseJava extends ObjectModelGenerator {
+
+
+ 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"))+"/generated/"+clazz.getName()+"Base.java";
+ }
+
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if (! Util.isEntity(clazz) ) return;
+ Map nameMap = Util.initPackageName(clazz);
+ String packageName = (String) nameMap.get("packageName");
+ String subpackageName = (String)nameMap.get("subpackageName");
+ String entityName = clazz.getName();
+ String varEntityName = Util.toLowerCaseFirstLetter(entityName);
+ // test and initialize if clazz is a composition
+ ObjectModelAttribute AttrComposite = Util.isComposition(model, clazz);
+ ObjectModelClass classComposite = null;
+ if (AttrComposite != null){
+ classComposite = (ObjectModelClass) AttrComposite.getDeclaringElement();
+ }
+
+/*{//
+// 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
+//
+// This file has been generated, and will be re-generated,
+// so no modification must be done whitout copying it with a other name.
+//
+
+
+package org.ofbiz.<%=packageName%>.<%=subpackageName%>.generated;
+
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+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.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+
+}*/
+ if (AttrComposite != null){
+ nameMap = Util.initPackageName(classComposite);
+ String classCompositeName = classComposite.getName();
+/*{import org.ofbiz.<%=(String) nameMap.get("packageName")%>.<%=(String)nameMap.get("subpackageName")%>.developed.<%=classCompositeName%>;
+}*/
+ }
+ for (Iterator iter=clazz.getAttributes().iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ if (! Util.isPrimaryKey(attribute) ){
+ if (attribute.referenceClassifier() ){
+ if (attribute.getMaxMultiplicity() == 1){
+ Map relationKeyName = Util.getRelationOneFieldName(model, attribute);
+ ObjectModelClass classAssociated = (ObjectModelClass) ((Map) relationKeyName ).get("clazzAssociated");
+ nameMap = Util.initPackageName(classAssociated);
+/*{import org.ofbiz.<%=(String) nameMap.get("packageName")%>.<%=(String)nameMap.get("subpackageName")%>.developed.<%=classAssociated.getName()%>;
+}*/
+ }
+ }
+ }
+ }
+ if (clazz.getOperations().size() > 0 ) {
+/*{
+
+public abstract class <%=entityName%>Base {
+}*/
+ } else {
+/*{
+
+public class <%=entityName%>Base {
+}*/
+ }
+/*{
+ public static final String module = <%=entityName%>Base.class.getName();
+ public static final String resource = "<%=Util.toUpperCaseFirstLetter(packageName)%>UiLabels";
+
+ protected GenericValue <%=Util.toLowerCaseFirstLetter(entityName)%>;
+}*/
+ if (AttrComposite != null){
+ String classCompositeName = classComposite.getName();
+/*{ protected <%=classCompositeName%> <%=Util.toLowerCaseFirstLetter(classCompositeName)%>;
+}*/
+ }
+
+ // initialisation of the primaryKeyList
+ String primaryKeyAsParam="", primaryKeyAsMap="", primaryKeyNotNull="";
+ if (AttrComposite != null ){
+ primaryKeyAsParam = classComposite.getName() + " " + Util.toLowerCaseFirstLetter(classComposite.getName()) + ", ";
+ }
+ ListPkAttribute listPrimaryKey = new ListPkAttribute(model, clazz, false, classComposite);
+ for(int j=0; j <%=attributeKeyName%>;
+}*/
+ if (jBase(GenericValue <%=varEntityName%>){
+ if (<%=varEntityName%> != null ){
+ this.<%=varEntityName%> = <%=varEntityName%>;
+ alreadyPersistant = true;
+ }
+ }
+
+ public <%=entityName%>Base(GenericDelegator delegator, <%=primaryKeyAsParam%>){
+}*/
+ if (AttrComposite != null ){
+ String fieldCompositeName = Util.toLowerCaseFirstLetter(classComposite.getName());
+/*{ this.<%=fieldCompositeName%> = <%=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 <%=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 (<%=primaryKeyNotNull%>) {
+ this.<%=Util.toLowerCaseFirstLetter(entityName)%> = delegator.findByPrimaryKey("<%=entityName%>",UtilMisc.toMap(<%=primaryKeyAsMap%>) );
+ if (! exist() ){
+ this.<%=Util.toLowerCaseFirstLetter(entityName)%> = delegator.makeValue("<%=entityName%>",UtilMisc.toMap(<%=primaryKeyAsMap%>) );
+ alreadyPersistant = false;
+ } else {
+ alreadyPersistant = true;
+ }
+ }
+ } catch (GenericEntityException e){
+ Debug.logError("findByPrimaryKey in <%=entityName%> constructor :" + e.getMessage(), module);
+ this.<%=Util.toLowerCaseFirstLetter(entityName)%> = null;
+ }
+ }
+
+ public boolean exist(){
+ if (<%=Util.toLowerCaseFirstLetter(entityName)%> != null) return true;
+ else return false;
+ }
+
+ public boolean isAlreadyPersistant(){
+ return alreadyPersistant;
+ }
+
+ public GenericValue getGenericValue(){
+ return <%=Util.toLowerCaseFirstLetter(entityName)%>;
+ }
+}*/
+ if (clazz.getOperations().size() > 0 ){
+ for (Iterator iterColl = clazz.getOperations().iterator(); iterColl.hasNext(); ){
+ ObjectModelOperation operation = (ObjectModelOperation) iterColl.next();
+ String operationParam = "";
+ for (Iterator iterParam=operation.getParameters().iterator(); iterParam.hasNext(); ){
+ ObjectModelParameter parameter = (ObjectModelParameter) iterParam.next();
+ operationParam += parameter.getType() + " " + parameter.getName();
+ if (iterParam.hasNext() ) operationParam += ", ";
+ }
+/*{
+ public abstract <%=operation.getReturnType()%> <%=operation.getName()%>(<%=operationParam%>);
+}*/
+ }
+ }
+ for(int j=0; j get<%=Util.toUpperCaseFirstLetter((String) listPrimaryKey.getName().get(j) )%>(){
+ if (exist() ){
+ if (<%=(String) listPrimaryKey.getName().get(j)%> == null ) return (<%=(String) listPrimaryKey.getType().get(j)%>) <%=Util.toLowerCaseFirstLetter(entityName)%>.get("<%=(String) listPrimaryKey.getName().get(j)%>");
+ else return <%=(String) listPrimaryKey.getName().get(j)%>;
+ }
+ return null;
+ }
+}*/
+ }
+ for (Iterator iter=clazz.getAttributes().iterator(); iter.hasNext(); ){
+ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next();
+ if (! Util.isPrimaryKey(attribute) ){
+ if (attribute.referenceClassifier() ){
+ if (attribute.getMaxMultiplicity() == 1){
+ Map relationKeyName = Util.getRelationOneFieldName(model, attribute, clazz);
+ List listName = (List) relationKeyName.get("listName");
+ ObjectModelClass classAssociated = (ObjectModelClass) ((Map) relationKeyName ).get("clazzAssociated");
+ primaryKeyAsParam="";
+ ListPkAttribute listPrimaryKeyAssoc = new ListPkAttribute(model, classAssociated, false, clazz);
+ for(int j=0; j get<%=classAssociated.getName()%>(){
+ if (exist() )
+ try {
+ return new <%=classAssociated.getName()%>(<%=Util.toLowerCaseFirstLetter(entityName)%>.getRelatedOne("<%=classAssociated.getName()%>") );
+ }
+ catch (GenericEntityException e) {
+ Debug.logError("Error getRelatedOne in <%=entityName%>:" + e.getMessage(), module);
+ }
+ return null;
+ }
+
+ public void set<%=classAssociated.getName()%>(<%=primaryKeyAsParam%> ){
+ if (exist() ) {
+}*/
+ for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){
+ Map fieldNameMap = (Map) iterList.next();
+ String fieldName = (String) fieldNameMap.get("fieldName");
+ String relFieldName = (String) fieldNameMap.get("relFieldName");
+/*{ <%=Util.toLowerCaseFirstLetter(entityName)%>.put("<%=fieldName%>", _<%=relFieldName%>);
+}*/
+ }
+/*{ }
+ return;
+ }
+}*/
+ }else{ // association with MaxMultiplicity > 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);
+/*{
+ public <%=attOfbizJavaType%> get<%=Util.toUpperCaseFirstLetter(attribute.getName() )%>(){
+ if (exist() ) return (<%=attOfbizJavaType%>) <%=Util.toLowerCaseFirstLetter(entityName)%>.get("<%=attribute.getName()%>");
+ return null;
+ }
+
+ public void set<%=Util.toUpperCaseFirstLetter(attribute.getName() )%>(<%=attOfbizJavaType%> _<%=attribute.getName()%> ){
+ if (exist() ) <%=Util.toLowerCaseFirstLetter(entityName)%>.put("<%=attribute.getName()%>", _<%=attribute.getName()%>);
+ return;
+ }
+}*/
+ }
+ }
+ } // TODO : add some controle or actions in the remove method when there are association
+/*{ public boolean store(){
+ if (exist() ){
+ try {
+ if (alreadyPersistant) <%=Util.toLowerCaseFirstLetter(entityName)%>.store();
+ else <%=Util.toLowerCaseFirstLetter(entityName)%>.create();
+ return true;
+ } catch (GenericEntityException e) {
+ Debug.logError("create or strore in <%=entityName%> :" + e.getMessage(), module);
+ }
+ }
+ return false;
+ }
+ public boolean remove(){
+ if (exist() ){
+ try {
+ <%=Util.toLowerCaseFirstLetter(entityName)%>.remove();
+ return true;
+ } catch (GenericEntityException e) {
+ Debug.logError("remove in <%=entityName%> :" + e.getMessage(), module);
+ }
+ }
+ return false;
+ }
+}
+}*/
+ }
+}
Index: ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorLookupJava.java
diff -u /dev/null ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorLookupJava.java:1.1
--- /dev/null Tue Jul 6 15:05:11 2004
+++ ofbiz-neogia-generators/src/java/org/ofbiz/neogia/generators/GeneratorLookupJava.java Tue Jul 6 15:05:04 2004
@@ -0,0 +1,131 @@
+package org.ofbiz.neogia.generators;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.codelutin.generator.ObjectModelGenerator;
+import org.codelutin.generator.models.object.ObjectModel;
+import org.codelutin.generator.models.object.ObjectModelClass;
+
+public class GeneratorLookupJava extends ObjectModelGenerator {
+
+ private String packageParam = null;
+ private String packageName = null;
+
+ public String getFilenameForModel(ObjectModel model){
+ // il faudrait le lancer par subpackage, et alors changer la methode getFilenameForxxxx
+ if (packageName == null) {
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) packageName="error";
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+ return packageName + "/src/org/ofbiz/"+packageName+"/generated/lookupParams.java";
+ }
+
+ public void generateFromModel(Writer output, ObjectModel model) throws IOException {
+ if (packageParam == null){
+ String[] packageParams = new String[2];
+ if (! Util.initPackageParam(packageParams)) return;
+ else{
+ packageParam = packageParams[0];
+ packageName = packageParams[1];
+ }
+ }
+
+/*{//
+// Copyright (c) 2004 Malin Nicolas - malin.nicolas@librenberry.net
+// 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 malin.nicolas@nereide.biz
+// @author Olivier.Heintz@nereide.biz
+// @version $Revision: 1.1 $
+// @since 3.1
+//
+// This file has been generated, and will be re-generated,
+// so no modification must be done whitout copying it with a other name.
+//
+package org.ofbiz.<%=packageName%>.generated;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+
+public class lookupParams {
+
+ public static final String module = lookupParams.class.getName();
+
+}*/
+ ObjectModelClass clazz;
+ String entityName, packageName, subpackageName;
+ for( Iterator iterClazz = model.getClasses().iterator(); iterClazz.hasNext(); ){
+ clazz = (ObjectModelClass) iterClazz.next();
+
+ if(Util.isEntity(clazz) && clazz.getPackageName().startsWith(packageParam)){
+ if (! Util.hasGuiLookup(clazz)) continue;
+ Map nameMap = Util.initPackageName(clazz);
+ packageName = (String) nameMap.get("packageName");
+ subpackageName = (String) nameMap.get("subpackageName");
+ entityName = clazz.getName();
+/*{
+ // Set up parameters to be able to start the generic lockup to have Lookup<%=entityName%>
+ //*@param request The HTTPRequest object for the current request
+ //*@param response The HTTPResponse object for the current request
+ //*@return String specifying the exit status of this event
+ //
+}*/
+/*{
+ public static String lookup<%=entityName%>(HttpServletRequest request, HttpServletResponse response) {
+
+ HttpSession session = ((HttpServletRequest) request).getSession();
+ Map paramLookup = (Map) session.getAttribute("paramLookup");
+ if (paramLookup == null || ! "Lookup<%=entityName%>".equals(paramLookup.get("lookupName"))) {
+ if (paramLookup == null) {
+ paramLookup = new HashMap();
+ session.setAttribute("paramLookup",paramLookup);
+ } else paramLookup.clear();
+ paramLookup.put("lookupName","Lookup<%=entityName%>");
+ paramLookup.put("titleProperty","PageTitleLookup<%=entityName%>");
+ paramLookup.put("formDefFile","/<%=packageName%>/<%=subpackageName%>/generated/<%=entityName%>Forms.xml");
+ paramLookup.put("singleFormName","lookup<%=entityName%>");
+ paramLookup.put("listFormName","listLookup<%=entityName%>");
+ paramLookup.put("entityName","<%=entityName%>");
+ paramLookup.put("viewSize","15");
+ paramLookup.put("permission","<%=packageName.toUpperCase()%>");
+ paramLookup.put("entityOperation","_VIEW");
+ paramLookup.put("permissionType","simple");
+ }
+ return "success";
+ }
+}*/
+ }
+ }
+/*{
+}
+
+}*/
+ }
+}