Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorListFtl.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorListFtl.java:1.1 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorListFtl.java:1.2 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorListFtl.java:1.1 Wed May 19 06:43:19 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorListFtl.java Fri May 28 20:45:25 2004 @@ -12,7 +12,7 @@ public String getFilenameForClass(ObjectModelClass clazz){ Map nameMap = Util.initPackageName(clazz); - return "webapp/"+((String)nameMap.get("packageName"))+"/"+((String)nameMap.get("subpackageName"))+"/List"+clazz.getName()+".ftl"; + return ((String)nameMap.get("packageName"))+"/webapp/"+((String)nameMap.get("packageName"))+"/"+((String)nameMap.get("subpackageName"))+"/List"+clazz.getName()+".ftl"; } public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { @@ -33,17 +33,17 @@ * 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. + * 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 $ + * @author Olivier.Heintz@nereide.biz + *@version $Revision: 1.2 $ *@since 3.1 * * This file has been generated, and will be re-generated, @@ -51,19 +51,6 @@ --> <#assign uiLabelMap = requestAttributes.uiLabelMap> ${pages.get(page.getProperty("subMenu"))} -}*/ - if (guiListAll){ -/*{ -<#if hasCreatePermission> -
[${uiLabelMap.<%=Util.toUpperCaseFirstLetter(packageName)%>New<%=clazz.getName()%>}]
- - -<#if hasPermission> - ${listWrapper.renderFormString()} -}*/ - } - else { // it's the list with select -/*{ <#if hasPermission> @@ -81,7 +68,7 @@
- <#if requestParameters.hideSearch?default("N") != "Y"> + <#if hideSearch?default("N") != "Y">
@@ -100,9 +87,6 @@ <#if showList?default("Y") == "Y"> ${listWrapper.renderFormString()} -}*/ - } -/*{ <#else>

${uiLabelMap.CommonPermissionError}

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.16 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.17 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java:1.16 Wed May 26 06:29:13 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFormsXml.java Fri May 28 20:45:25 2004 @@ -2,10 +2,11 @@ import java.io.IOException; import java.io.Writer; +import java.util.ArrayList; import java.util.Iterator; -import java.util.Vector; -import java.util.Collection; +import java.util.List; import java.util.Map; +import java.util.Vector; import org.codelutin.generator.ObjectModelGenerator; import org.codelutin.generator.models.object.ObjectModelAttribute; @@ -15,7 +16,8 @@ private String packageName, subpackageName; private Vector listAttLookup, listAttList, listAttListLookup, listAttShow, - listAttEdit, listAttHidden, listAttListAssoc, listAttListInAssoc, listAttPrimaryKey; + listAttEdit, listAttHidden ; + private Vector listAttListAssoc, listAttListInAssoc, listAttPrimaryKey; private String listValAtt = ""; private boolean associe( ObjectModelAttribute _att ){ @@ -23,43 +25,45 @@ return true; return false; } + + private String getIdName(ObjectModelClass clazz){ + // TODO vérifier si il ne faut pas appeler une autre méthode pour le préfix + return Util.toLowerCaseFirstLetter(clazz.getName())+ "Name"; + } + private String getDescription(ObjectModelClass clazz){ + // TODO vérifier si il ne faut pas appeler une autre méthode pour le préfix + return Util.toLowerCaseFirstLetter(clazz.getName())+ "Description"; + } private void initListAtt( ObjectModelClass clazz ){ listAttLookup = new Vector(); - listAttList = new Vector(); + listAttList = new Vector(Util.getAttributesList(clazz) ); listAttListLookup = new Vector(); listAttShow = new Vector(); listAttEdit = new Vector(); - listAttListAssoc = new Vector(); - listAttListInAssoc = new Vector(); + // TODO : replace getPrimaryKeyAttributes by new methode getListPrimaryKeyAttr listAttPrimaryKey = new Vector( Util.getPrimaryKeyAttributes( clazz )); listAttHidden = new Vector(); ObjectModelAttribute att; for ( Iterator iter = clazz.getAttributes().iterator(); iter.hasNext(); ){ att = (ObjectModelAttribute) iter.next(); - if( ! Util.hasGuiHidden( att ) ){ - - if( Util.hasGuiIndexed( att ) ) - listAttLookup.add( att ); - - if( ! Util.hasGuiCalculated( att ) ) - listAttEdit.add( att ); + if(! att.referenceClassifier()){ + if( ! Util.hasGuiHidden( att ) ){ - if( Util.hasGuiListLookup( att ) ) - listAttListLookup.add( att ); + if( Util.hasGuiIndexed( att ) ) listAttLookup.add( att ); - if( Util.hasGuiList( att ) ) - listAttList.add( att ); + if( ! Util.hasGuiCalculated( att ) ) listAttEdit.add( att ); - if( Util.hasGuiListAssoc( att ) ) - listAttListAssoc.add( att ); + if( Util.hasGuiListLookup( att ) ) listAttListLookup.add( att ); - listAttShow.add( att ); + listAttShow.add( att ); + } + else + listAttHidden.add( att ); } - else - listAttHidden.add( att ); } + if (listAttListLookup.size()<1) listAttListLookup.addAll(listAttShow); } private void initPackageName(ObjectModelClass clazz){ @@ -69,22 +73,26 @@ } public String getFilenameForClass(ObjectModelClass clazz){ - // return super.getFilenameForClass(Clazz) + "Service.java"; initPackageName(clazz); - return "webapp/" + packageName + "/" + subpackageName + "/" + return packageName+"/webapp/" + packageName + "/" + subpackageName + "/" + "Forms" + clazz.getName()+".xml"; } - private String getCallForAssociation( ObjectModelAttribute _att ){ - Collection primaryKeysAtt = Util.getPrimaryKeyAttributes( _att.getAssociationClass() ); - String stringReturn = _att.getAssociationClass().getName() + "?"; - String attName; - if( primaryKeysAtt.isEmpty() ) - return ""; - for( Iterator iter = primaryKeysAtt.iterator(); iter.hasNext(); ){ - attName = ((ObjectModelAttribute)iter.next()).getName(); - stringReturn = stringReturn + attName + "=${" + attName; - if( iter.hasNext() ) + /** + * create the parameters which is needed to be able to call the Show(_attribute.getClassifier). + * @param _attribute + * @return string to put after the begining of the URI ex: /Show<%=getCallForAssociation(clazz)%>} + */ + 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; @@ -98,9 +106,8 @@ return associe( _att ); } - private String uiLabel( ObjectModelAttribute _att ){ - String first = (_att.getName().substring(0,1)); - return "${uiLabelMap." + packageName + first.toUpperCase() + _att.getName().substring( 1 ); + private String uiLabel( ObjectModelAttribute _attribute ){ + return "${uiLabelMap." + packageName + Util.toUpperCaseFirstLetter( _attribute.getName() )+ "}"; } @@ -123,16 +130,28 @@ +
- }*/ +}*/ for ( iter = listAttLookup.iterator(); iter.hasNext(); ){ att = (ObjectModelAttribute) iter.next(); - /*{ +/*{ }*/ if( att.getType().equals( "Date" ) ){ /*{}*/ } - else { - if( putLookup( output, att ) ){ } - else{ - /*{}*/ - } + else if(! putLookup( output, att ) ); /*{}*/ /*{ - - }*/ - } +}*/ } - /*{ - +/*{
- }*/ - +}*/ + } + if( Util.hasGuiLookup( clazz ) ){ /* ================================= Generation ListLookup ================================= */ System.out.println( "ListLookup " + clazz.getName() ); - /*{ +/*{
- }*/ +}*/ for ( iter = listAttListLookup.iterator(); iter.hasNext(); ){ att = (ObjectModelAttribute) iter.next(); - /*{ + // TODO : completed by the test if classifier + System.out.println( "ListLookup Attribute=" + att.getName() ); +/*{ - }*/ +}*/ } - /*{ +/*{
- }*/ +}*/ } - /* - ============================= - Generation List - ============================= - */ + //================================== + // Generation List without any selection + //================================== if( Util.hasGuiListAll( clazz ) ){ System.out.println( "List " + clazz.getName() ); - /*{ +/*{ + - - -
}*/ for ( iter = listAttList.iterator(); iter.hasNext(); ){ att = (ObjectModelAttribute) iter.next(); - /*{ + if (att.referenceClassifier() ){ +/*{ + + + +}*/ + }else { +/*{ - }*/ +}*/ + } } - /*{ +/*{
- }*/ +}*/ } - /* - ================================= - Generation ListSelect - ================================= - */ + //==================================== + // Generation Selection for List but why + //==================================== if( Util.hasGuiList( clazz ) ){ - System.out.println( "ListSelect " + clazz.getName() ); + System.out.println( "ListSelection " + clazz.getName() ); listValAtt = ""; - /*{ +/*{ - + -
- - }*/ - +}*/ for ( iter = listAttList.iterator(); iter.hasNext(); ){ att = (ObjectModelAttribute) iter.next(); - /*{ + System.out.println( "Les attribues = " + att.getName() ); +/*{ - }*/ +}*/ listValAtt = listValAtt + att.getName() + "=${" + att.getName() + "}&"; } - /*{ +/*{
+--> +}*/ - }*/ - - /* - ================================= - Generation ListEdit - ================================= - */ - - /*{ - + //========================================= + // Generation List whith selection to be able to Edit + //========================================= + System.out.println( "Beginning ListEdit " ); +/*{ - + -
- - }*/ - listValAtt = ""; +}*/ for ( iter = listAttList.iterator(); iter.hasNext(); ){ att = (ObjectModelAttribute) iter.next(); - - /*{ - - - }*/ - if( associe( att ) ){ - if( att.getMaxMultiplicity() == 1 ){ + if (att.referenceClassifier() ){ String call = getCallForAssociation( att ); - /*{ - " title="<%=uiLabel( att )%>"> + + +}*/ + }else { +/*{ + +}*/ } - - /*{}*/ - listValAtt = listValAtt + att.getName() + "=${" + att.getName() + "}&"; } - /*{ + listValAtt = ""; + List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = new ArrayList(); + Util.getListPrimaryKeyAttr(model, clazz, listPrimaryKeyName, listPrimaryKeyType); + for(int j=0; j - }*/ +}*/ } /* @@ -337,8 +354,7 @@ if( Util.hasGuiEdit( clazz ) ){ System.out.println( "Edit " + clazz.getName() ); - /*{ - +/*{ @@ -347,46 +363,47 @@ default-title-style="tableheadtext" default-widget-style="tabletext" default-tooltip-style="tabletext"> - }*/ +}*/ listValAtt = ""; for ( iter = listAttEdit.iterator(); iter.hasNext(); ){ att = (ObjectModelAttribute) iter.next(); System.out.println( " Boucle " + att.getName() + " suivant? " + iter.hasNext() ); - /*{ +/*{ }*/ System.out.println( " Class Associée " ); ObjectModelClass associatClazz = att.getAssociationClass(); System.out.println( " associatClazz " + associatClazz.getName() ); - if( Util.hasGuiDropDown( associatClazz ) ) - /*{ + if( Util.hasGuiDropDown( associatClazz ) ){ +/*{ - }*/ +}*/ } - else{ /*{>}*/ } + } + else { /*{>}*/ } if( putLookup( output, att ) ){ } /*{ - }*/ +}*/ listValAtt = listValAtt + att.getName() + "=${" + att.getName() + "}&"; } - /*{ +/*{ - }*/ +}*/ } /* @@ -430,7 +447,9 @@ ================================ */ - if( ! listAttListAssoc.isEmpty() ){ + // TODO : to be study, how to populate the listAttListAssoc + if( false ){ + //if( ! listAttListAssoc.isEmpty() ){ System.out.println( "Listattlistassoc" + clazz.getName() ); ObjectModelClass associatClazz; ObjectModelAttribute attAssoc = null; @@ -483,11 +502,11 @@ }*/ } } - /*{ +/*{ - }*/ - +}*/ + } } } 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.14 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.15 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java:1.14 Thu May 27 06:34:33 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/Util.java Fri May 28 20:45:25 2004 @@ -28,19 +28,22 @@ * Copyright Code Lutin * Copyright Nereide * Copyright Neogia -* @version $Revision: 1.14 $ +* @version $Revision: 1.15 $ * -* Last update : $Date: 2004/05/27 06:34:33 $ +* Last update : $Date: 2004/05/28 20:45:25 $ * by : $Author: holivier $ */ package org.nereide.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; @@ -57,7 +60,7 @@ /** * Return a List with all the clazz attribute which have the tag gui - listLookup. - * This method is call by attributesListLookup and attributesList. + * This method is call by attributesList. */ public static List attributesWithGuiLookup(ObjectModelClass clazz){ List attributesWithGuiLookup = new ArrayList(); @@ -68,15 +71,6 @@ return attributesWithGuiLookup; } - /** - * Return a List with all the clazz attribute which must be list in a Lookup. - * This List is attributesWithGuiLookup if there is at least one, otherwise it's clazz.getAttribues. - */ - public static List attributesListLookup(ObjectModelClass clazz){ - List attributesListLookup = attributesWithGuiLookup(clazz); - if (attributesListLookup.size() == 0) attributesListLookup = (List) clazz.getAttributes(); - return attributesListLookup; - } /** * Re-organize the getParticipants result to be able to access by index the class and the attributeName. @@ -178,16 +172,20 @@ /** * 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 result is a collection empty it's clazz.getAttribues. + * 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(clazz.getAttributes()); + attributesList.addAll(classAttExecptHidden); } return attributesList; } @@ -309,6 +307,59 @@ } /** + * Give the class associated for the attribute, if maxMultiplicity==1, + * give the name of the field which done the relation. + * It's use for defining relation in entitymodel + * @param model + * @param attribute + * @return a Map with two key
    + *
  • "clazzAssociated" : the class associated (the reference classifier or associationClass). + *
  • "listName" : a list of map, in each map two key "fieldName" and "relFieldName". + *
+ */ + public static Map getRelationOneFieldName(ObjectModel model, ObjectModelAttribute attribute){ + List relationOneFieldNames = new ArrayList(); + List listPrimaryKeyName = new ArrayList(), listPrimaryKeyType = 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){ + Util.getListPrimaryKeyAttr(model, clazzAssociated, listPrimaryKeyName, listPrimaryKeyType); + for(int i=0; imain <%=packageName%>List<%=clazz.getName()%> /<%=subpackageName%>/Forms<%=clazz.getName()%>.xml -}*/ - if (guiList){ -/*{ find<%=clazz.getName()%> -}*/ - } -/*{ list<%=clazz.getName()%> 20 <%=subpackageName%> - /<%=subpackageName%>/SubMenuTabBar.ftl + /<%=subpackageName%>/TabBarSubMenu.ftl find <%=clazz.getName()%> }*/ if (guiList){ /*{ + N +}*/ + } else { +/*{ + Y +}*/ + } +/*{ N -}*/ - } -/*{ entityList <%=packageName.toUpperCase()%> _VIEW simple -}*/ - if (guiList){ -/*{ -}*/ - }else{ -/*{ - -}*/ - } -/*{ Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java:1.4 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java:1.5 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java:1.4 Wed May 19 06:43:19 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorControlerXml.java Fri May 28 20:45:25 2004 @@ -10,12 +10,20 @@ public class GeneratorControlerXml extends ObjectModelGenerator { - final private String packageParam = "org.neogia.manufacturing"; - final private String packageName = "manufacturing"; + private String packageParam = null; + private String packageName = null; public String getFilenameForModel(ObjectModel model){ - return "webapp/"+packageName+"/WEB-INF/controlerG.xml"; + 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 { @@ -41,7 +49,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * *@author Olivier.Heintz@nereide.biz - *@version $Revision: 1.4 $ + *@version $Revision: 1.5 $ *@since 3.1 * * This file has been generated, and will be re-generated, @@ -49,6 +57,14 @@ --> }*/ + 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(); ){ @@ -56,11 +72,17 @@ 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)){ +/*{ @@ -72,11 +94,9 @@ - }*/ - String gui = clazz.getDocumentation(); - if (gui == null) gui = ""; - if (gui.indexOf("lookup") != -1){ + } + if (Util.hasGuiLookup(clazz)){ /*{ @@ -99,22 +119,17 @@ if(Util.isEntity(clazz)){ entityName = clazz.getName(); subpackageName = Util.getLastWord(Util.getParentPackageName(clazz.getPackageName())); - String gui = clazz.getDocumentation(); - if (gui == null) gui = ""; - if (gui.indexOf("listAll") != -1){ - // if (clazz.isGui("listAll")){ -/*{ - - }*/ - } else { + if (Util.hasGuiList(clazz) || Util.hasGuiListAll(clazz)){ /*{ }*/ } + if (Util.hasGuiEdit(clazz)){ /*{ }*/ + } } } } Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java:1.6 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java:1.7 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java:1.6 Thu May 27 06:33:00 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorEntitymodelXml.java Fri May 28 20:45:25 2004 @@ -14,12 +14,20 @@ public class GeneratorEntitymodelXml extends ObjectModelGenerator { - final private String packageParam = "org.neogia.manufacturing"; - final private String packageName = "manufacturing"; + private String packageParam = null; + private String packageName = null; public String getFilenameForModel(ObjectModel model){ - return "entitydef/entitymodel.xml"; + 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 { @@ -48,7 +56,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * *@author Olivier.Heintz@nereide.biz - *@version $Revision: 1.6 $ + *@version $Revision: 1.7 $ *@since 3.1 * * This file has been generated, and will be re-generated, @@ -71,6 +79,14 @@ }*/ + 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(); @@ -208,40 +224,19 @@ attribute = (ObjectModelAttribute) iterattribute.next(); //System.out.println("XXXXXXXX5Debug attribute="+attribute.getName()); if (attribute.referenceClassifier()){ - // test if there are an association class for this atribute - String prefix=null; - boolean thereIsAssociationClass = false; - if (attribute.getAssociationClass() != null){ - clazzAssociated = attribute.getAssociationClass(); - prefix = attribute.getReverseAttribute().getName(); - if (Util.toUpperCaseFirstLetter(prefix).equals(clazz.getName())) prefix = Util.getClassShortName(clazz); - thereIsAssociationClass = true; - } else - clazzAssociated = (ObjectModelClass) attribute.getClassifier(); - String relationName = clazzAssociated.getName(); + Map relationKeyName = Util.getRelationOneFieldName(model, attribute); + String relationName = ((ObjectModelClass) relationKeyName.get("clazzAssociated")).getName(); - //participantsWithName = Util.getParticipantsWithName(clazzAssociated); - if (attribute.getMaxMultiplicity() == 1){ + if (attribute.getMaxMultiplicity() == 1){ /*{ }*/ - listPrimaryKeyName.clear(); listPrimaryKeyType.clear(); - Util.getListPrimaryKeyAttr(model, clazzAssociated, listPrimaryKeyName, listPrimaryKeyType); - for(int i=0; i -}*/ - }else if (thereIsAssociationClass) { -/*{ - -}*/ - }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 { /*{ Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java diff -u ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java:1.1 ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java:1.2 --- ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java:1.1 Thu May 20 21:33:11 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorFindBsh.java Fri May 28 20:45:25 2004 @@ -16,7 +16,7 @@ public String getFilenameForClass(ObjectModelClass clazz){ Map nameMap = Util.initPackageName(clazz); - return "webapp/"+((String)nameMap.get("packageName"))+"/WEB-INF/actions/"+((String)nameMap.get("subpackageName"))+"/Find"+clazz.getName()+".bsh"; + return ((String)nameMap.get("packageName"))+"/webapp/"+((String)nameMap.get("packageName"))+"/WEB-INF/actions/"+((String)nameMap.get("subpackageName"))+"/Find"+clazz.getName()+".bsh"; } public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { @@ -27,7 +27,7 @@ System.out.println("XXXXXXXX1Debug clazz.getName="+clazz.getName()); /*{ -// $Id: GeneratorFindBsh.java,v 1.1 2004/05/20 21:33:11 holivier Exp $ +// $Id: GeneratorFindBsh.java,v 1.2 2004/05/28 20:45:25 holivier Exp $ // Copyright (c) 2004 Olivier Heintz - olivier.heintz@nereide.biz // Copyright (c) 2004 Nereide - www.nereide.biz // Copyright (c) 2004 Neogia - www.neogia.org @@ -47,7 +47,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // @author Olivier.Heintz@nereide.biz -// @version $Revision: 1.1 $ +// @version $Revision: 1.2 $ // @since 3.1 // // Calls Find on a dynamiqueView to return an EntityListIterator of the @@ -91,7 +91,9 @@ } } 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"); @@ -111,41 +113,64 @@ ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); System.out.println("XXXXXXXX2Debug attribute.getName="+attribute.getName()); if (Util.hasGuiIndexed(attribute)){ - attributesIndexed.add(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(); System.out.println("XXXXXXXX3Debug attribute.getName="+attribute.getName()); 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(); System.out.println("XXXXXXXX4Debug attribute.getName="+attribute.getName()); - ObjectModelClass clazzAssoc = (ObjectModelClass) attribute.getClassifier(); + Map relationKeyName = Util.getRelationOneFieldName(model, attribute); + ObjectModelClass clazzAssoc = (ObjectModelClass) relationKeyName.get("clazzAssociated"); + String relationName = clazzAssoc.getName(); /*{ - // Associated entities - dynamicView.addMemberEntity("E<%=String.valueOf(nbAssoc)%>", "<%=clazzAssoc.getName()%>"); - dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(clazzAssoc.getName())%>Name","<%=Util.getAttributeName(clazzAssoc)%>",null,null,null,null); - dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(clazzAssoc.getName())%>Description","<%=Util.getAttributeDescription(clazzAssoc)%>",null,null,null,null); + // Associated entities + dynamicView.addMemberEntity("E<%=String.valueOf(nbAssoc)%>", "<%=relationName%>"); + dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(relationName)%>Name","<%=Util.getAttributeName(clazzAssoc)%>",null,null,null,null); + dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(relationName)%>Description","<%=Util.getAttributeDescription(clazzAssoc)%>",null,null,null,null); + }*/ + if (Util.hasGuiIndexed(attribute) ){ + attributesIndexed.add(Util.toLowerCaseFirstLetter(relationName)+"Name"); + attributesIndexed.add(Util.toLowerCaseFirstLetter(relationName)+"Description"); + } + + // check and add if necessary, the field relation maker + List listName = (List) relationKeyName.get("listName"); + for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){ + Map relationItem = (Map) iterList.next(); + String fieldName = (String) relationItem.get("fieldName"); + if (listAttributeName.indexOf(fieldName) == -1){ // adding the field in the dynamicView + listAttributeName.add(fieldName); +/*{ + dynamicView.addAlias("EE", "<%=fieldName%>"); +}*/ + } + } // Add the classAssoc attributes with the tag gui listInAssoc - for (Iterator iterAssoc=clazz.getAttributes().iterator(); iterAssoc.hasNext(); ){ + for (Iterator iterAssoc=clazzAssoc.getAttributes().iterator(); iterAssoc.hasNext(); ){ ObjectModelAttribute attributeAssoc = (ObjectModelAttribute) iterAssoc.next(); System.out.println("XXXXXXXX5Debug attributeAssoc.getName="+attributeAssoc.getName()); if ( Util.hasGuiListInAssoc(attributeAssoc) ){ /*{ - dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(clazzAssoc.getName())%><%=Util.toUpperCaseFirstLetter(attributeAssoc.getName())%>","<%=attributeAssoc.getName()%>",null,null,null,null); + dynamicView.addAlias("E<%=String.valueOf(nbAssoc)%>", "<%=Util.toLowerCaseFirstLetter(relationName)%><%=Util.toUpperCaseFirstLetter(attributeAssoc.getName())%>","<%=attributeAssoc.getName()%>",null,null,null,null); }*/ } } @@ -153,14 +178,13 @@ dynamicView.addViewLink("EE", "E<%=String.valueOf(nbAssoc)%>", Boolean.TRUE, ModelKeyMap.makeKeyMapList( }*/ boolean first = true; - for(Iterator iterPk=Util.getPrimaryKeyAttributes(clazzAssoc).iterator();iterPk.hasNext(); ){ - ObjectModelAttribute attrAssocPk = (ObjectModelAttribute) iterPk.next(); - System.out.println("XXXXXXXX6Debug attrAssocPk.getName="+attrAssocPk.getName()); + for(Iterator iterList=listName.iterator(); iterList.hasNext(); ){ + Map relationItem = (Map) iterList.next(); if ( ! first ){ /*{, }*/ } /*{ - "<%=Util.toLowerCaseFirstLetter(clazzAssoc.getName())%><%=Util.toUpperCaseFirstLetter(attrAssocPk.getName())%>","<%=attrAssocPk.getName()%>"}*/ + "<%=(String) relationItem.get("fieldName")%>","<%=(String) relationItem.get("relFieldName")%>"}*/ first = false; } /*{ )); @@ -178,19 +202,11 @@ List keys = new ArrayList(); }*/ for (Iterator iter=attributesIndexed.iterator(); iter.hasNext(); ){ - ObjectModelAttribute attribute = (ObjectModelAttribute) iter.next(); - System.out.println("XXXXXXXX7Debug attribute.getName="+attribute.getName()); - if (attribute.referenceClassifier()){ - ObjectModelClass clazzAssoc = (ObjectModelClass) attribute.getClassifier(); -/*{ - keys.add("<%=Util.toLowerCaseFirstLetter(clazzAssoc.getName())%>Name"); - keys.add("<%=Util.toLowerCaseFirstLetter(clazzAssoc.getName())%>Description"); -}*/ - } else { + String attributeName = (String) iter.next(); + System.out.println("XXXXXXXX7Debug attribute.getName="+attributeName); /*{ - keys.add("<%=attribute.getName()%>"); + keys.add("<%=attributeName%>"); }*/ - } } /*{ ArrayList tmpList = FindServices.createCondition(keys, normalizedFields, queryStringMap, origValueMap); Index: ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorUiLabelProperties.java diff -u /dev/null ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorUiLabelProperties.java:1.1 --- /dev/null Fri May 28 20:45:31 2004 +++ ofbiz-neogia-generators/src/java/org/nereide/ofbiz/neogia/generators/GeneratorUiLabelProperties.java Fri May 28 20:45:25 2004 @@ -0,0 +1,181 @@ +package org.nereide.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)%>List<%=entityName%>=List <%=entityName%> +#<%=Util.toUpperCaseFirstLetter(packageName)%>New<%=entityName%>=New <%=entityName%> + +}*/ + // 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