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.9 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.10 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java:1.9 Thu Jul 1 08:46:51 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectJava.java Thu Jul 1 22:37:27 2004 @@ -3,12 +3,13 @@ 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.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 { @@ -16,7 +17,7 @@ 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()+".java"; + return packageName+"/src/org/ofbiz/"+packageName+"/"+((String)nameMap.get("subpackageName"))+"/developed/"+clazz.getName()+"G.java"; } public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { @@ -26,9 +27,31 @@ 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%>.generated; +package org.ofbiz.<%=packageName%>.<%=subpackageName%>.developed; import java.sql.Timestamp; import java.util.Date; @@ -70,245 +91,40 @@ import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -}*/ - 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"); - if (! clazz.getPackageName().equals(classAssociated.getPackageName() ) ){ - nameMap = Util.initPackageName(classAssociated); -/*{import org.ofbiz.<%=(String) nameMap.get("packageName")%>.<%=(String)nameMap.get("subpackageName")%>.generated.<%=classAssociated.getName()%>; -}*/ - } - } - } - } - } -/*{ -public class <%=entityName%> { +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"; - protected GenericValue <%=Util.toLowerCaseFirstLetter(entityName)%>; -}*/ - ObjectModelAttribute AttrComposite = Util.isComposition(model, clazz); - ObjectModelClass classComposite = null; - if (AttrComposite != null){ - classComposite = (ObjectModelClass) AttrComposite.getDeclaringElement(); - String classCompositeName = classComposite.getName(); -/*{ protected <%=classCompositeName%> <%=Util.toLowerCaseFirstLetter(classCompositeName)%>; -}*/ - } - - // initialisation of the primaryKeyList - String primaryKeyAsParam="", primaryKeyAsMap="", 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 (j(GenericValue <%=varEntityName%>){ - if (<%=varEntityName%> != null ){ - this.<%=varEntityName%> = <%=varEntityName%>; - alreadyPersistant = true; - } + super(<%=varEntityName%>); } public <%=entityName%>(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)%>; - } -}*/ - for(int j=0; j get<%=Util.toUpperCaseFirstLetter((String) listPrimaryKey.getName().get(j) )%>(){ - if (exist() ) return <%=(String) listPrimaryKey.getName().get(j)%>; - return null; + super(delegator, <%=primaryKeyAsParamCall%>); } }*/ - } - 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 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 <%=classAssociated.getName()%> 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 <%=operation.getReturnType()%> <%=operation.getName()%>(<%=operationParam%>){ + <%=operation.getReturnType()%> result = null; + return result; } - - 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/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java:1.4 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java:1.5 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java:1.4 Mon Jun 28 23:04:22 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditAssocXml.java Thu Jul 1 22:37:27 2004 @@ -32,7 +32,7 @@ <%=packageName%>EditAssoc<%=clazz.getName()%> <%=subpackageName%> - /<%=subpackageName%>/developped/TabBarSubMenu.ftl + /<%=subpackageName%>/developed/TabBarSubMenu.ftl }*/ if (associationList.size() == 1){ String associationName = ((ObjectModelAttribute) associationList.get(0) ).getName(); Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java:1.3 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java:1.4 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java:1.3 Mon Jun 28 23:04:22 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsShowXml.java Thu Jul 1 22:37:27 2004 @@ -30,7 +30,7 @@ /<%=subpackageName%>/generated/Forms<%=clazz.getName()%>.xml show<%=clazz.getName()%> <%=subpackageName%> - /<%=subpackageName%>/developped/TabBarSubMenu.ftl + /<%=subpackageName%>/developed/TabBarSubMenu.ftl show <%=clazz.getName()%> <%=packageName.toUpperCase()%> Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsListXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsListXml.java:1.7 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsListXml.java:1.8 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsListXml.java:1.7 Mon Jun 28 23:04:22 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsListXml.java Thu Jul 1 22:37:27 2004 @@ -32,7 +32,7 @@ list<%=clazz.getName()%> 20 <%=subpackageName%> - /<%=subpackageName%>/developped/TabBarSubMenu.ftl + /<%=subpackageName%>/developed/TabBarSubMenu.ftl find <%=clazz.getName()%> }*/ Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java:1.3 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java:1.4 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java:1.3 Mon Jun 28 23:04:22 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorPagedefsEditXml.java Thu Jul 1 22:37:27 2004 @@ -29,7 +29,7 @@ /<%=subpackageName%>/generated/Forms<%=clazz.getName()%>.xml edit<%=clazz.getName()%> <%=subpackageName%> - /<%=subpackageName%>/developped/TabBarSubMenu.ftl + /<%=subpackageName%>/developed/TabBarSubMenu.ftl edit <%=clazz.getName()%> <%=packageName.toUpperCase()%> Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectBaseJava.java diff -u /dev/null ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectBaseJava.java:1.1 --- /dev/null Thu Jul 1 22:37:32 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntityObjectBaseJava.java Thu Jul 1 22:37:27 2004 @@ -0,0 +1,346 @@ +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() ) 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; + } +} +}*/ + } +}