Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java:1.1 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java:1.2 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java:1.1 Wed Jun 2 00:09:26 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditBsh.java Sun Jun 6 22:25:40 2004 @@ -21,14 +21,14 @@ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { if(! Util.isEntity(clazz)) return; - if (! Util.hasGuiList(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/06/02 00:09:26 holivier Exp $ +// $Id: GeneratorEditBsh.java,v 1.2 2004/06/06 22:25:40 holivier Exp $ // Copyright (c) 2004 Olivier Heintz - olivier.heintz@nereide.biz // Copyright (c) 2004 Nereide - www.nereide.biz // Copyright (c) 2004 Neogia - www.neogia.org @@ -48,7 +48,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // @author Olivier.Heintz@nereide.biz -// @version $Revision: 1.1 $ +// @version $Revision: 1.2 $ // @since 3.1 // // Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.1 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.2 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.1 Wed Jun 2 00:09:26 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java Sun Jun 6 22:25:40 2004 @@ -48,7 +48,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // @author Olivier.Heintz@nereide.biz -// @version $Revision: 1.1 $ +// @version $Revision: 1.2 $ // @since 3.1 // // This file has been generated, and will be re-generated, @@ -145,7 +145,7 @@ } public GenericValue getGenericValue(){ - return techDataCalendar; + return <%=Util.toLowerCaseFirstLetter(entityName)%>; } }*/ for(int j=0; j(){ - if (exist() ) return <%=Util.toLowerCaseFirstLetter(entityName)%>.getRelatedOne("<%=classAssociated.getName()%>"); + if (exist() ) + try { + return <%=Util.toLowerCaseFirstLetter(entityName)%>.getRelatedOne("<%=classAssociated.getName()%>"); + } + catch (GenericEntityException e) { + Debug.logError("Error getRelatedOne in <%=entityName%>:" + e.getMessage(), module); + } return null; } @@ -218,7 +224,7 @@ }*/ } } - } + } // TODO : add some controle or actions in the remove method when there are association /*{ public boolean store(){ if (exist() ){ @@ -232,6 +238,18 @@ } 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/nereide/ofbiz/neogia/generators/GeneratorEditFtl.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditFtl.java:1.1 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditFtl.java:1.2 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditFtl.java:1.1 Wed Jun 2 00:09:26 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEditFtl.java Sun Jun 6 22:25:40 2004 @@ -20,7 +20,7 @@ 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; + 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(); @@ -52,7 +52,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * @author Olivier.Heintz@nereide.biz - *@version $Revision: 1.1 $ + *@version $Revision: 1.2 $ *@since 3.1 * * This file has been generated, and will be re-generated, Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.18 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.19 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.18 Wed Jun 2 00:09:26 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java Sun Jun 6 22:25:40 2004 @@ -154,7 +154,7 @@ * *@author Olivier.Heintz@nereide.biz *@author malin.nicolas@nereide.biz -*@version $Revision: 1.18 $ +*@version $Revision: 1.19 $ *@since 3.1 * * This file has been generated, and will be re-generated, @@ -270,43 +270,12 @@ }*/ } - //==================================== - // Generation Selection for List but why - //==================================== - - if( Util.hasGuiList( clazz ) ){ - System.out.println( "ListSelection " + clazz.getName() ); - listValAtt = ""; -/*{ - - - - -}*/ //========================================= // Generation List whith selection to be able to Edit //========================================= - System.out.println( "Beginning ListEdit " ); + if (Util.hasGuiList( clazz ) || Util.hasGuiSubList( clazz ) ){ + System.out.println( "Beginning ListEdit " ); /*{ @@ -317,6 +286,24 @@ default-title-style="tableheadtext" default-widget-style="tabletext" default-tooltip-style="tabletext"> }*/ + // add field for link with getMaxMultiplicity = 1 and not navigable for this class + List classAssocWithoutNav = Util.getClassAssocWithoutNav(model, clazz); + if (classAssocWithoutNav.size() > 0 ){ + for (Iterator iterClass=classAssocWithoutNav.iterator(); iterClass.hasNext(); ){ + ObjectModelAttribute attrAssociated = (ObjectModelAttribute) iterClass.next(); + ObjectModelClass classAssociated = (ObjectModelClass) attrAssociated.getDeclaringElement(); + String relationName = (attrAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName())) ) ? + Util.toLowerCaseFirstLetter(classAssociated.getName()) : + attrAssociated.getName(); + ListPkAttribute listPrimaryKey = new ListPkAttribute(model, classAssociated, false); + for(int i=0; i +}*/ + } + } + } for ( iter = listAttList.iterator(); iter.hasNext(); ){ att = (ObjectModelAttribute) iter.next(); if (att.referenceClassifier() ){ @@ -357,7 +344,7 @@ ================================= */ - if( Util.hasGuiEdit( clazz ) ){ + if( Util.hasGuiEdit( clazz ) || Util.hasGuiSubEdit( clazz ) ){ System.out.println( "Edit " + clazz.getName() ); /*{ @@ -369,6 +356,30 @@ }*/ + // add field for link with getMaxMultiplicity = 1 and not navigable for this class + List classAssocWithoutNav = Util.getClassAssocWithoutNav(model, clazz); + if (classAssocWithoutNav.size() > 0 ){ + for (Iterator iterClass=classAssocWithoutNav.iterator(); iterClass.hasNext(); ){ + ObjectModelAttribute attrAssociated = (ObjectModelAttribute) iterClass.next(); + ObjectModelClass classAssociated = (ObjectModelClass) attrAssociated.getDeclaringElement(); + String relationName = (attrAssociated.getName().equals(Util.toLowerCaseFirstLetter(clazz.getName())) ) ? + Util.toLowerCaseFirstLetter(classAssociated.getName()) : + attrAssociated.getName(); + ListPkAttribute listPrimaryKey = new ListPkAttribute(model, classAssociated, true); + for(int i=0; i}*/ + if ("date-time".equals(listPrimaryKey.getType().get(i) ) ) { /*{}*/ } + else { /*{}*/ } + /*{ + +}*/ + } + } + } for ( iter = clazz.getAttributes().iterator(); iter.hasNext(); ){ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); System.out.println( " Boucle " + attribute.getName() + " suivant? " + iter.hasNext() ); @@ -450,33 +461,48 @@ ============================= */ - if( Util.hasGuiShow( clazz ) ){ + if( Util.hasGuiShow( clazz ) ){ // TODO : add test if there is, at least, one association with guiEditAssoc System.out.println( "Show " + clazz.getName() ); - /*{ - +/*{ - +
- }*/ - - for ( iter = listAttShow.iterator(); iter.hasNext(); ){ - att = (ObjectModelAttribute) iter.next(); - - /*{ - " title="<%=uiLabel( 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); +/*{ + + + +}*/ + } + } else { // a standard edit attribute +/*{ + +}*/ + } + } + } +/*{ +
- } +}*/ } /* Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.16 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.17 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.16 Wed Jun 2 00:09:26 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java Sun Jun 6 22:25:40 2004 @@ -28,9 +28,9 @@ * Copyright Code Lutin * Copyright Nereide * Copyright Neogia -* @version $Revision: 1.16 $ +* @version $Revision: 1.17 $ * -* Last update : $Date: 2004/06/02 00:09:26 $ +* Last update : $Date: 2004/06/06 22:25:40 $ * by : $Author: holivier $ */ package org.nereide.ofbiz.neogia.generators; @@ -57,6 +57,7 @@ */ public class Util extends org.codelutin.topia.Util { + static private final String tagSeparator = ", "; /** * Return a List with all the clazz attribute which have the tag gui - listLookup. @@ -120,7 +121,8 @@ for (Iterator iterAttr=classAssociated.getAttributes().iterator(); iterAttr.hasNext(); ){ ObjectModelAttribute attribute = (ObjectModelAttribute) iterAttr.next(); if (clazz.equals(attribute.getClassifier())){ - if (attribute.getReverseAttribute() == null && ! attribute.hasAssociationClass() ){ + if (attribute.getReverseAttribute() == null && ! attribute.hasAssociationClass() + && attribute.getMaxMultiplicity() > 1 ){ System.out.println("XXXXXXX-getClassAssocWithoutNav1-Debug one found classAsso="+ classAssociated.getName()+" attribute.getName="+attribute.getName()+ " "); @@ -219,14 +221,15 @@ } /** - * return the name and type of all the primaryKey. + * Depreciated, now use class ListPkAttribute. + * 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 * @param model to be able to search in all class the association no navigable * @param clazz * @param listPrimaryKeyName return list, (List of String) * @param listPrimaryKeyType return list, (List of String) - * @param entity to say if the ofbizType is an entity OfbizType (true) or java OfbizType (false) + * @param boolean to say if the ofbizType is an entity OfbizType (true) or java OfbizType (false) * @return */ public static void getListPrimaryKeyAttr(ObjectModel model, ObjectModelClass clazz, List listPrimaryKeyName, List listPrimaryKeyType, boolean entity){ @@ -243,7 +246,7 @@ Util.getClassShortName(classAssociated) : Util.toUpperCaseFirstLetter(attrAssociated.getName()); List listCompositePrimaryKeyName=new ArrayList(), listCompositePrimaryKeyType=new ArrayList(); - Util.getListPrimaryKeyAttr(model, classAssociated, listCompositePrimaryKeyName, listCompositePrimaryKeyType); + Util.getListPrimaryKeyAttr(model, classAssociated, listCompositePrimaryKeyName, listCompositePrimaryKeyType, entity); for(int i=0; i *
  • "clazzAssociated" : the class associated (the reference classifier or associationClass). - *
  • "listName" : a list of map, in each map two key "fieldName" and "relFieldName". + *
  • "listName" : a list of map, in each map three key "fieldName", "relFieldName" and "fieldType" (OfbizJavaType). * */ public static Map getRelationOneFieldName(ObjectModel model, ObjectModelAttribute attribute){ @@ -347,10 +350,11 @@ clazzAssociated = (ObjectModelClass) attribute.getClassifier(); if (attribute.getMaxMultiplicity() == 1){ - Util.getListPrimaryKeyAttr(model, clazzAssociated, listPrimaryKeyName, listPrimaryKeyType); + Util.getListPrimaryKeyAttr(model, clazzAssociated, listPrimaryKeyName, listPrimaryKeyType, false); for(int i=0; i - + - + @@ -111,6 +111,15 @@ }*/ } + if (Util.hasGuiShow(clazz)){ +/*{ + + + + + +}*/ + } } } /*{ @@ -125,13 +134,20 @@ entityName = clazz.getName(); subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName())); if (Util.hasGuiList(clazz) || Util.hasGuiListAll(clazz)){ -/*{ - +/*{ + + }*/ } if (Util.hasGuiEdit(clazz)){ /*{ - + + + }*/ + } + if (Util.hasGuiShow(clazz)){ +/*{ + }*/ } Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorUiLabelProperties.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorUiLabelProperties.java:1.2 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorUiLabelProperties.java:1.3 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorUiLabelProperties.java:1.2 Wed Jun 2 00:09:26 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorUiLabelProperties.java Sun Jun 6 22:25:40 2004 @@ -76,7 +76,7 @@ #* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #* # *@author Olivier.Heintz@nereide.biz -# *@version $Revision: 1.2 $ +# *@version $Revision: 1.3 $ # *@since 3.1 # * # * This file has been generated, and will be re-generated, @@ -102,11 +102,26 @@ subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName())); /*{ -# <%=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.hasGuiShow(clazz)){ +/*{ +#<%=Util.toUpperCaseFirstLetter(packageName)%>Show<%=entityName%>=Show <%=entityName%> +}*/ + } +/*{ #<%=Util.toUpperCaseFirstLetter(packageName)%><%=entityName%>Id=<%=entityName%> Id }*/ @@ -146,7 +161,12 @@ entityField.add(fieldName); } } - } + } + else { + // TODO : uiLabel related to association + // ManufacturingListOfTechDataCalendarCalendarException=List of TechDataCalendar exception + // ManufacturingAddCalendarException=Add a Calendar Exception + } } } // add field for link with getMaxMultiplicity = 1 and not navigable for this class Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java diff -u /dev/null ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java:1.1 --- /dev/null Sun Jun 6 22:25:45 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityServicesJava.java Sun Jun 6 22:25:40 2004 @@ -0,0 +1,232 @@ +package org.nereide.ofbiz.neogia.generators; + +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelClass; + +public class GeneratorEntityServicesJava 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"))+"/"+clazz.getName()+"Services.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(); + +/*{ +// +// 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%>; + +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; + + +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); +}*/ + // initialisation of the primaryKeyList + String primaryKeyAsParam="", primaryKeyAsMap="", primaryKeyNotNull=""; + List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = new ArrayList(); + Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType, false); + for(int j=0; j <%=attributeKeyName%> = (<%=attributeKeyType%>) context.get("<%=attributeKeyName%>"); +}*/ + if (j ){ + <%=entityName%> <%=Util.toLowerCaseFirstLetter(entityName)%> = new <%=entityName%>(delegator, <%=primaryKeyAsParam%>); + + if (actionForm.equals("add") ){ + if (<%=Util.toLowerCaseFirstLetter(entityName)%>.isAlreadyPersistant() ){ + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonIdAlreadyExist", locale)); + } + } +}*/ + 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); + List listName = (List) relationKeyName.get("listName"); + ObjectModelClass classAssociated = (ObjectModelClass) ((Map) relationKeyName ).get("clazzAssociated"); + 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"); +}*/ + // initialisation of the primaryKeyList + primaryKeyAsParam=""; primaryKeyAsMap=""; primaryKeyNotNull=""; + listPrimaryKeyName.clear(); listPrimaryKeyType.clear(); + Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType, false); + for(int j=0; j <%=attributeKeyName%> = (<%=attributeKeyType%>) context.get("<%=attributeKeyName%>"); +}*/ + if (j ){ + <%=entityName%> <%=Util.toLowerCaseFirstLetter(entityName)%> = new <%=entityName%>(delegator, <%=primaryKeyAsParam%>); + if (! <%=Util.toLowerCaseFirstLetter(entityName)%>.isAlreadyPersistant() ){ + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonIdDoesNotExist", locale)); + } + 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/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java diff -u /dev/null ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java:1.1 --- /dev/null Sun Jun 6 22:25:45 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java Sun Jun 6 22:25:40 2004 @@ -0,0 +1,49 @@ +package org.nereide.ofbiz.neogia.generators; + +import java.io.IOException; +import java.io.Writer; +import java.util.Map; +import java.util.StringTokenizer; + +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"))+"/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"); + + +/*{ + + + + <%=packageName%>Show<%=clazz.getName()%> + /<%=subpackageName%>/Forms<%=clazz.getName()%>.xml + show<%=clazz.getName()%> + <%=subpackageName%> + /<%=subpackageName%>/TabBarSubMenu.ftl + show + <%=clazz.getName()%> + <%=packageName.toUpperCase()%> + _VIEW + simple + + + + +}*/ + } +} + + Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorServicesXml.java diff -u /dev/null ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorServicesXml.java:1.1 --- /dev/null Sun Jun 6 22:25:45 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorServicesXml.java Sun Jun 6 22:25:40 2004 @@ -0,0 +1,95 @@ +package org.nereide.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) ){ +/*{ + + Create or Update a <%=entityName%> + + + + + Remove a <%=entityName%> + + +}*/ + } + } + } + } +} + + Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/ListPkAttribute.java diff -u /dev/null ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/ListPkAttribute.java:1.1 --- /dev/null Sun Jun 6 22:25:45 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/ListPkAttribute.java Sun Jun 6 22:25:40 2004 @@ -0,0 +1,140 @@ +/* *##% + * 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.nereide.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) + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2004/06/06 22:25:40 $ + * by : $Author: holivier $ + */ +public class ListPkAttribute { + protected List name = new ArrayList(), type = new ArrayList(); + + public ListPkAttribute(ObjectModel model, ObjectModelClass clazz, boolean entity){ + System.out.println("XXXXXXX-getMapPrimaryKeyAttr1-Debug clazz="+clazz.getName()); + // 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(); + 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 +<#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()} +
    + +<#else> +

    ${uiLabelMap.CommonPermissionError}

    + + + }*/ + } +} + +