svn commit: r628700 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/model/ModelEntity.java entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java webtools/build.xml webtools/src/org/ofbiz/webtools/WebToolsServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r628700 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/model/ModelEntity.java entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java webtools/build.xml webtools/src/org/ofbiz/webtools/WebToolsServices.java

jonesde
Author: jonesde
Date: Mon Feb 18 04:21:13 2008
New Revision: 628700

URL: http://svn.apache.org/viewvc?rev=628700&view=rev
Log:
A few misc cleanups/improvements; some generics stuff, use FastMap/List, convenience methods for meta data

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
    ofbiz/trunk/framework/webtools/build.xml
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=628700&r1=628699&r2=628700&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java Mon Feb 18 04:21:13 2008
@@ -648,6 +648,30 @@
         return this.relations.iterator();
     }
 
+    public List<ModelRelation> getRelationsList(boolean includeOne, boolean includeOneNoFk, boolean includeMany) {
+     List<ModelRelation> relationsList = FastList.newInstance();
+     Iterator<ModelRelation> allIter = this.getRelationsIterator();
+        while (allIter.hasNext()) {
+            ModelRelation modelRelation = allIter.next();
+            if (includeOne && "one".equals(modelRelation.getType())) {
+             relationsList.add(modelRelation);
+            } else if (includeOneNoFk && "one-nofk".equals(modelRelation.getType())) {
+             relationsList.add(modelRelation);
+            } else if (includeMany && "many".equals(modelRelation.getType())) {
+             relationsList.add(modelRelation);
+            }
+        }
+        return relationsList;
+    }
+
+    public List<ModelRelation> getRelationsOneList() {
+        return getRelationsList(true, true, false);
+    }
+
+    public List<ModelRelation> getRelationsManyList() {
+        return getRelationsList(false, false, true);
+    }
+
     public ModelRelation getRelation(String relationName) {
         if (relationName == null) return null;
         for (ModelRelation relation: relations) {

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java?rev=628700&r1=628699&r2=628700&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java Mon Feb 18 04:21:13 2008
@@ -25,6 +25,9 @@
 import java.util.Map;
 import java.util.Collection;
 
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
 import org.ofbiz.base.component.ComponentConfig;
 import org.ofbiz.base.config.GenericConfigException;
 import org.ofbiz.base.config.MainResourceHandler;
@@ -47,13 +50,13 @@
 
     public static UtilCache entityEcaReaders = new UtilCache("entity.EcaReaders", 0, 0, false);
 
-    public static Map getEntityEcaCache(String entityEcaReaderName) {
-        Map ecaCache = (Map) entityEcaReaders.get(entityEcaReaderName);
+    public static Map<String, Map<String, List<EntityEcaRule>>> getEntityEcaCache(String entityEcaReaderName) {
+     Map<String, Map<String, List<EntityEcaRule>>> ecaCache = (Map) entityEcaReaders.get(entityEcaReaderName);
         if (ecaCache == null) {
             synchronized (EntityEcaUtil.class) {
                 ecaCache = (Map) entityEcaReaders.get(entityEcaReaderName);
                 if (ecaCache == null) {
-                    ecaCache = new HashMap();
+                    ecaCache = FastMap.newInstance();
                     readConfig(entityEcaReaderName, ecaCache);
                     entityEcaReaders.put(entityEcaReaderName, ecaCache);
                 }
@@ -115,14 +118,14 @@
             Map eventMap = (Map) ecaCache.get(entityName);
             List rules = null;
             if (eventMap == null) {
-                eventMap = new HashMap();
-                rules = new LinkedList();
+                eventMap = FastMap.newInstance();
+                rules = FastList.newInstance();
                 ecaCache.put(entityName, eventMap);
                 eventMap.put(eventName, rules);
             } else {
                 rules = (List) eventMap.get(eventName);
                 if (rules == null) {
-                    rules = new LinkedList();
+                    rules = FastList.newInstance();
                     eventMap.put(eventName, rules);
                 }
             }

Modified: ofbiz/trunk/framework/webtools/build.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/build.xml?rev=628700&r1=628699&r2=628700&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/build.xml (original)
+++ ofbiz/trunk/framework/webtools/build.xml Mon Feb 18 04:21:13 2008
@@ -44,6 +44,7 @@
             <fileset dir="../base/build/lib" includes="*.jar"/>
             <fileset dir="../entity/lib" includes="*.jar"/>
             <fileset dir="../entity/build/lib" includes="*.jar"/>
+            <fileset dir="../entityext/build/lib" includes="*.jar"/>
             <fileset dir="../security/build/lib" includes="*.jar"/>
             <fileset dir="../service/lib" includes="*.jar"/>
             <fileset dir="../service/build/lib" includes="*.jar"/>

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java?rev=628700&r1=628699&r2=628700&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Mon Feb 18 04:21:13 2008
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *******************************************************************************/
+ */
 package org.ofbiz.webtools;
 
 import java.text.NumberFormat;
@@ -46,6 +46,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import javolution.util.FastList;
+import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.StringUtil;
@@ -618,7 +619,7 @@
         Map<String, Object> resultMap = ServiceUtil.returnSuccess();
         
         ModelReader reader = delegator.getModelReader();
-        Map<String, Object> packages = new HashMap<String, Object>();
+        Map<String, Object> packages = FastMap.newInstance();
         TreeSet<String> packageNames = new TreeSet<String>();
         TreeSet<String> tableNames = new TreeSet<String>();
         
@@ -647,17 +648,17 @@
         }
         
         String search = (String) context.get("search");
-        List<Map<String, Object>> packagesList = new ArrayList<Map<String, Object>>();
+        List<Map<String, Object>> packagesList = FastList.newInstance();
         Iterator piter = packageNames.iterator();
         try {
             while (piter.hasNext()) {
-                Map<String, Object> packageMap = new HashMap<String, Object>();
+                Map<String, Object> packageMap = FastMap.newInstance();
                 String pName = (String) piter.next();
                 TreeSet entities = (TreeSet) packages.get(pName);
-                List<Map<String, Object>> entitiesList = new ArrayList<Map<String, Object>>();
+                List<Map<String, Object>> entitiesList = FastList.newInstance();
                 Iterator e = entities.iterator();
                 while (e.hasNext()) {
-                    Map<String, Object> entityMap = new HashMap<String, Object>();
+                    Map<String, Object> entityMap = FastMap.newInstance();
                     String entityName = (String) e.next();
                     String helperName = delegator.getEntityHelperName(entityName);
                     String groupName = delegator.getEntityGroupName(entityName);
@@ -673,9 +674,9 @@
                         }
 
                         // fields list
-                        List<Map<String, Object>> javaNameList = new ArrayList<Map<String, Object>>();
+                        List<Map<String, Object>> javaNameList = FastList.newInstance();
                         for (Iterator f = entity.getFieldsIterator(); f.hasNext();) {
-                            Map<String, Object> javaNameMap = new HashMap<String, Object>();
+                            Map<String, Object> javaNameMap = FastMap.newInstance();
                             ModelField field = (ModelField) f.next();
                             ModelFieldType type = delegator.getEntityFieldType(entity, field.getType());
                             javaNameMap.put("isPk", field.getIsPk());
@@ -684,7 +685,7 @@
                             String fieldDescription = null;
                             if (bundle != null) {
                                 try {
-                                fieldDescription = bundle.getString("FieldDescription." + entity.getEntityName() + "." + field.getName());
+                                    fieldDescription = bundle.getString("FieldDescription." + entity.getEntityName() + "." + field.getName());
                                 } catch (Exception exception) {}
                             }
                             if (UtilValidate.isEmpty(fieldDescription)) {
@@ -707,13 +708,13 @@
                         }
 
                         // relations list
-                        List<Map<String, Object>> relationsList = new ArrayList<Map<String, Object>>();
+                        List<Map<String, Object>> relationsList = FastList.newInstance();
                         for (int r = 0; r < entity.getRelationsSize(); r++) {
-                            Map<String, Object> relationMap = new HashMap<String, Object>();
+                            Map<String, Object> relationMap = FastMap.newInstance();
                             ModelRelation relation = entity.getRelation(r);
-                            List<Map<String, Object>> keysList = new ArrayList<Map<String, Object>>();
+                            List<Map<String, Object>> keysList = FastList.newInstance();
                             for (int km = 0; km < relation.getKeyMapsSize(); km++) {
-                                Map<String, Object> keysMap = new HashMap<String, Object>();
+                                Map<String, Object> keysMap = FastMap.newInstance();
                                 ModelKeyMap keyMap = relation.getKeyMap(km);
                                 String fieldName = null;
                                 String relFieldName = null;
@@ -740,16 +741,16 @@
                         }
 
                         // index list
-                        List<Map<String, Object>> indexList = new ArrayList<Map<String, Object>>();
+                        List<Map<String, Object>> indexList = FastList.newInstance();
                         for (int r = 0; r < entity.getIndexesSize(); r++) {
-                            List<String> fieldNameList = new ArrayList<String>();
+                            List<String> fieldNameList = FastList.newInstance();
                             
                             ModelIndex index = entity.getIndex(r);
                             for (Iterator fieldIterator = index.getIndexFieldsIterator(); fieldIterator.hasNext();) {
                                 fieldNameList.add((String) fieldIterator.next());
                             }
                             
-                            Map<String, Object> indexMap = new HashMap<String, Object>();
+                            Map<String, Object> indexMap = FastMap.newInstance();
                             indexMap.put("name", index.getName());
                             indexMap.put("description", index.getDescription());
                             indexMap.put("fieldNameList", fieldNameList);