You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2007/10/18 05:50:31 UTC

svn commit: r585840 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder: ByAndFinder.java ByConditionFinder.java EntityFinderUtil.java ListFinder.java PrimaryKeyFinder.java

Author: doogie
Date: Wed Oct 17 20:50:30 2007
New Revision: 585840

URL: http://svn.apache.org/viewvc?rev=585840&view=rev
Log:
Java 1.5 markup for entity finder.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByConditionFinder.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java?rev=585840&r1=585839&r2=585840&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByAndFinder.java Wed Oct 17 20:50:30 2007
@@ -18,9 +18,11 @@
  *******************************************************************************/
 package org.ofbiz.entity.finder;
 
-import java.util.HashMap;
 import java.util.Map;
 
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.condition.EntityFieldMap;
 import org.ofbiz.entity.condition.EntityOperator;
@@ -36,7 +38,7 @@
     
     public static final String module = ByAndFinder.class.getName();         
     
-    protected Map fieldMap;
+    protected Map<FlexibleMapAccessor, Object> fieldMap;
 
     public ByAndFinder(Element element) {
         super(element, "and");
@@ -45,9 +47,9 @@
         this.fieldMap = EntityFinderUtil.makeFieldMap(element);
     }
 
-    protected EntityCondition getWhereEntityCondition(Map context, ModelEntity modelEntity, GenericDelegator delegator) {
+    protected EntityCondition getWhereEntityCondition(Map<String, Object> context, ModelEntity modelEntity, GenericDelegator delegator) {
         // create the by and map
-        Map entityContext = new HashMap();
+        Map<String, Object> entityContext = FastMap.newInstance();
         EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, entityContext);
         // then convert the types...
         modelEntity.convertFieldMapInPlace(entityContext, delegator);

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByConditionFinder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByConditionFinder.java?rev=585840&r1=585839&r2=585840&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByConditionFinder.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ByConditionFinder.java Wed Oct 17 20:50:30 2007
@@ -23,6 +23,8 @@
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityConditionList;
+import org.ofbiz.entity.condition.EntityJoinOperator;
 import org.ofbiz.entity.finder.EntityFinderUtil.Condition;
 import org.ofbiz.entity.finder.EntityFinderUtil.ConditionExpr;
 import org.ofbiz.entity.finder.EntityFinderUtil.ConditionList;
@@ -57,7 +59,7 @@
         }
     }
 
-    protected EntityCondition getWhereEntityCondition(Map context, ModelEntity modelEntity, GenericDelegator delegator) {
+    protected EntityCondition getWhereEntityCondition(Map<String, Object> context, ModelEntity modelEntity, GenericDelegator delegator) {
         // create whereEntityCondition from whereCondition
         if (this.whereCondition != null) {
             return this.whereCondition.createCondition(context, modelEntity.getEntityName(), delegator);
@@ -65,7 +67,7 @@
         return null;
     }
 
-    protected EntityCondition getHavingEntityCondition(Map context, ModelEntity modelEntity, GenericDelegator delegator) {
+    protected EntityCondition getHavingEntityCondition(Map<String, Object> context, ModelEntity modelEntity, GenericDelegator delegator) {
         // create havingEntityCondition from havingCondition
         if (this.havingCondition != null) {
             return this.havingCondition.createCondition(context, modelEntity.getEntityName(), delegator);

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java?rev=585840&r1=585839&r2=585840&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java Wed Oct 17 20:50:30 2007
@@ -38,6 +38,7 @@
 import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityComparisonOperator;
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.condition.EntityConditionList;
@@ -56,14 +57,12 @@
     
     public static final String module = EntityFinderUtil.class.getName();         
     
-    public static Map makeFieldMap(Element element) {
-        Map fieldMap = null;
-        List fieldMapElementList = UtilXml.childElementList(element, "field-map");
+    public static Map<FlexibleMapAccessor, Object> makeFieldMap(Element element) {
+        Map<FlexibleMapAccessor, Object> fieldMap = null;
+        List<? extends Element> fieldMapElementList = UtilXml.childElementList(element, "field-map");
         if (fieldMapElementList.size() > 0) {
-            fieldMap = new HashMap();
-            Iterator fieldMapElementIter = fieldMapElementList.iterator();
-            while (fieldMapElementIter.hasNext()) {
-                Element fieldMapElement = (Element) fieldMapElementIter.next();
+            fieldMap = new HashMap<FlexibleMapAccessor, Object>();
+            for (Element fieldMapElement: fieldMapElementList) {
                 // set the env-name for each field-name, noting that if no field-name is specified it defaults to the env-name
                 String fieldName = fieldMapElement.getAttribute("field-name");
                 String envName = fieldMapElement.getAttribute("env-name");
@@ -89,13 +88,11 @@
         return fieldMap;
     }
 
-    public static void expandFieldMapToContext(Map fieldMap, Map context, Map outContext) {
+    public static void expandFieldMapToContext(Map<FlexibleMapAccessor, Object> fieldMap, Map<String, Object> context, Map<String, Object> outContext) {
         //Debug.logInfo("fieldMap: " + fieldMap, module);
         if (fieldMap != null) {
-            Iterator fieldMapEntryIter = fieldMap.entrySet().iterator();
-            while (fieldMapEntryIter.hasNext()) {
-                Map.Entry entry = (Map.Entry) fieldMapEntryIter.next();
-                FlexibleMapAccessor serviceContextFieldAcsr = (FlexibleMapAccessor) entry.getKey();
+            for (Map.Entry<FlexibleMapAccessor, Object> entry: fieldMap.entrySet()) {
+                FlexibleMapAccessor serviceContextFieldAcsr = entry.getKey();
                 Object valueSrc = entry.getValue();
                 if (valueSrc instanceof FlexibleMapAccessor) {
                     FlexibleMapAccessor contextEnvAcsr = (FlexibleMapAccessor) valueSrc;
@@ -110,40 +107,34 @@
         }
     }
     
-    public static List makeSelectFieldExpanderList(Element element) {
-        List selectFieldExpanderList = null;
-        List selectFieldElementList = UtilXml.childElementList(element, "select-field");
+    public static List<FlexibleStringExpander> makeSelectFieldExpanderList(Element element) {
+        List<FlexibleStringExpander> selectFieldExpanderList = null;
+        List<? extends Element> selectFieldElementList = UtilXml.childElementList(element, "select-field");
         if (selectFieldElementList.size() > 0) {
-            selectFieldExpanderList = new LinkedList();
-            Iterator selectFieldElementIter = selectFieldElementList.iterator();
-            while (selectFieldElementIter.hasNext()) {
-                Element selectFieldElement = (Element) selectFieldElementIter.next();
+            selectFieldExpanderList = new LinkedList<FlexibleStringExpander>();
+            for (Element selectFieldElement: selectFieldElementList) {
                 selectFieldExpanderList.add(new FlexibleStringExpander(selectFieldElement.getAttribute("field-name")));
             }
         }
         return selectFieldExpanderList;
     }
     
-    public static Set makeFieldsToSelect(List selectFieldExpanderList, Map context) {
-        Set fieldsToSelect = null;
+    public static Set<String> makeFieldsToSelect(List<FlexibleStringExpander> selectFieldExpanderList, Map<String, Object> context) {
+        Set<String> fieldsToSelect = null;
         if (selectFieldExpanderList != null && selectFieldExpanderList.size() > 0) {
-            fieldsToSelect = new HashSet();
-            Iterator selectFieldExpanderIter = selectFieldExpanderList.iterator();
-            while (selectFieldExpanderIter.hasNext()) {
-                FlexibleStringExpander selectFieldExpander = (FlexibleStringExpander) selectFieldExpanderIter.next();
+            fieldsToSelect = new HashSet<String>();
+            for (FlexibleStringExpander selectFieldExpander: selectFieldExpanderList) {
                 fieldsToSelect.add(selectFieldExpander.expandString(context));
             }
         }
         return fieldsToSelect;
     }
     
-    public static List makeOrderByFieldList(List orderByExpanderList, Map context) {
-        List orderByFields = null;
+    public static List<String> makeOrderByFieldList(List<FlexibleStringExpander> orderByExpanderList, Map<String, Object> context) {
+        List<String> orderByFields = null;
         if (orderByExpanderList != null && orderByExpanderList.size() > 0) {
-            orderByFields = new LinkedList();
-            Iterator orderByExpanderIter = orderByExpanderList.iterator();
-            while (orderByExpanderIter.hasNext()) {
-                FlexibleStringExpander orderByExpander = (FlexibleStringExpander) orderByExpanderIter.next();
+            orderByFields = new LinkedList<String>();
+            for (FlexibleStringExpander orderByExpander: orderByExpanderList) {
                 orderByFields.add(orderByExpander.expandString(context));
             }
         }
@@ -151,7 +142,7 @@
     }
     
     public static interface Condition extends Serializable {
-        public EntityCondition createCondition(Map context, String entityName, GenericDelegator delegator);
+        public EntityCondition createCondition(Map<String, ? extends Object> context, String entityName, GenericDelegator delegator);
     }
     public static class ConditionExpr implements Condition {
         protected FlexibleStringExpander fieldNameExdr;
@@ -177,7 +168,7 @@
             this.ignoreCase = "true".equals(conditionExprElement.getAttribute("ignore-case"));
         }
         
-        public EntityCondition createCondition(Map context, String entityName, GenericDelegator delegator) {
+        public EntityCondition createCondition(Map<String, ? extends Object> context, String entityName, GenericDelegator delegator) {
             ModelEntity modelEntity = delegator.getModelEntity(entityName);
             if (modelEntity == null) {
                 throw new IllegalArgumentException("Error in Entity Find: could not find entity with name [" + entityName + "]");
@@ -255,16 +246,14 @@
     }
     
     public static class ConditionList implements Condition {
-        List conditionList = new LinkedList();
+        List<Condition> conditionList = new LinkedList<Condition>();
         FlexibleStringExpander combineExdr;
         
         public ConditionList(Element conditionListElement) {
             this.combineExdr = new FlexibleStringExpander(conditionListElement.getAttribute("combine"));
             
-            List subElements = UtilXml.childElementList(conditionListElement);
-            Iterator subElementIter = subElements.iterator();
-            while (subElementIter.hasNext()) {
-                Element subElement = (Element) subElementIter.next();
+            List<? extends Element> subElements = UtilXml.childElementList(conditionListElement);
+            for (Element subElement: subElements) {
                 if ("condition-expr".equals(subElement.getNodeName())) {
                     conditionList.add(new ConditionExpr(subElement));
                 } else if ("condition-list".equals(subElement.getNodeName())) {
@@ -277,19 +266,17 @@
             }
         }
         
-        public EntityCondition createCondition(Map context, String entityName, GenericDelegator delegator) {
+        public EntityCondition createCondition(Map<String, ? extends Object> context, String entityName, GenericDelegator delegator) {
             if (this.conditionList.size() == 0) {
                 return null;
             }
             if (this.conditionList.size() == 1) {
-                Condition condition = (Condition) this.conditionList.get(0);
+                Condition condition = this.conditionList.get(0);
                 return condition.createCondition(context, entityName, delegator);
             }
             
-            List entityConditionList = new LinkedList();
-            Iterator conditionIter = conditionList.iterator();
-            while (conditionIter.hasNext()) {
-                Condition curCondition = (Condition) conditionIter.next();
+            List<EntityCondition> entityConditionList = new LinkedList<EntityCondition>();
+            for (Condition curCondition: conditionList) {
                 EntityCondition econd = curCondition.createCondition(context, entityName, delegator);
                 if (econd != null) {
                     entityConditionList.add(econd);
@@ -302,7 +289,7 @@
                 throw new IllegalArgumentException("Could not find an entity operator for the name: " + operatorName);
             }
             
-            return new EntityConditionList(entityConditionList, (EntityJoinOperator) operator);
+            return new EntityConditionList<EntityCondition>(entityConditionList, (EntityJoinOperator) operator);
         }
     }
     public static class ConditionObject implements Condition {
@@ -316,15 +303,15 @@
             }
         }
         
-        public EntityCondition createCondition(Map context, String entityName, GenericDelegator delegator) {
+        public EntityCondition createCondition(Map<String, ? extends Object> context, String entityName, GenericDelegator delegator) {
             EntityCondition condition = (EntityCondition) fieldNameAcsr.get(context);
             return condition;
         }
     }
     
     public static interface OutputHandler extends Serializable {
-        public void handleOutput(EntityListIterator eli, Map context, FlexibleMapAccessor listAcsr);
-        public void handleOutput(List results, Map context, FlexibleMapAccessor listAcsr);
+        public void handleOutput(EntityListIterator eli, Map<String, Object> context, FlexibleMapAccessor listAcsr);
+        public void handleOutput(List<GenericValue> results, Map<String, Object> context, FlexibleMapAccessor listAcsr);
     }
     public static class LimitRange implements OutputHandler {
         FlexibleStringExpander startExdr;
@@ -335,7 +322,7 @@
             this.sizeExdr = new FlexibleStringExpander(limitRangeElement.getAttribute("size"));
         }
         
-        int getStart(Map context) {
+        int getStart(Map<String, Object> context) {
             String startStr = this.startExdr.expandString(context);
             try {
                 return Integer.parseInt(startStr);
@@ -346,7 +333,7 @@
             }
         }
         
-        int getSize(Map context) {
+        int getSize(Map<String, Object> context) {
             String sizeStr = this.sizeExdr.expandString(context);
             try {
                 return Integer.parseInt(sizeStr);
@@ -357,7 +344,7 @@
             }
         }
         
-        public void handleOutput(EntityListIterator eli, Map context, FlexibleMapAccessor listAcsr) {
+        public void handleOutput(EntityListIterator eli, Map<String, Object> context, FlexibleMapAccessor listAcsr) {
             int start = getStart(context);
             int size = getSize(context);
             try {
@@ -370,7 +357,7 @@
             }
         }
 
-        public void handleOutput(List results, Map context, FlexibleMapAccessor listAcsr) {
+        public void handleOutput(List<GenericValue> results, Map<String, Object> context, FlexibleMapAccessor listAcsr) {
             int start = getStart(context);
             int size = getSize(context);
             
@@ -389,7 +376,7 @@
             this.viewSizeExdr = new FlexibleStringExpander(limitViewElement.getAttribute("view-size"));
         }
         
-        int getIndex(Map context) {
+        int getIndex(Map<String, Object> context) {
             String viewIndexStr = this.viewIndexExdr.expandString(context);
             try {
                 return Integer.parseInt(viewIndexStr);
@@ -400,7 +387,7 @@
             }
         }
         
-        int getSize(Map context) {
+        int getSize(Map<String, Object> context) {
             String viewSizeStr = this.viewSizeExdr.expandString(context);
             try {
                 return Integer.parseInt(viewSizeStr);
@@ -411,7 +398,7 @@
             }
         }
         
-        public void handleOutput(EntityListIterator eli, Map context, FlexibleMapAccessor listAcsr) {
+        public void handleOutput(EntityListIterator eli, Map<String, Object> context, FlexibleMapAccessor listAcsr) {
             int index = this.getIndex(context);
             int size = this.getSize(context);
             
@@ -425,7 +412,7 @@
             }
         }
 
-        public void handleOutput(List results, Map context, FlexibleMapAccessor listAcsr) {
+        public void handleOutput(List<GenericValue> results, Map<String, Object> context, FlexibleMapAccessor listAcsr) {
             int index = this.getIndex(context);
             int size = this.getSize(context);
             
@@ -441,11 +428,11 @@
             // no parameters, nothing to do
         }
         
-        public void handleOutput(EntityListIterator eli, Map context, FlexibleMapAccessor listAcsr) {
+        public void handleOutput(EntityListIterator eli, Map<String, Object> context, FlexibleMapAccessor listAcsr) {
             listAcsr.put(context, eli);
         }
 
-        public void handleOutput(List results, Map context, FlexibleMapAccessor listAcsr) {
+        public void handleOutput(List<GenericValue> results, Map<String, Object> context, FlexibleMapAccessor listAcsr) {
             throw new IllegalArgumentException("Cannot handle output with use-iterator when the query is cached, or the result in general is not an EntityListIterator");
         }
     }
@@ -454,7 +441,7 @@
             // no parameters, nothing to do
         }
         
-        public void handleOutput(EntityListIterator eli, Map context, FlexibleMapAccessor listAcsr) {
+        public void handleOutput(EntityListIterator eli, Map<String, Object> context, FlexibleMapAccessor listAcsr) {
             try {
                 listAcsr.put(context, eli.getCompleteList());
                 eli.close();
@@ -465,7 +452,7 @@
             }
         }
 
-        public void handleOutput(List results, Map context, FlexibleMapAccessor listAcsr) {
+        public void handleOutput(List<GenericValue> results, Map<String, Object> context, FlexibleMapAccessor listAcsr) {
             listAcsr.put(context, results);
         }
     }

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java?rev=585840&r1=585839&r2=585840&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java Wed Oct 17 20:50:30 2007
@@ -18,7 +18,6 @@
  *******************************************************************************/
 package org.ofbiz.entity.finder;
 
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -68,8 +67,8 @@
     protected FlexibleMapAccessor listAcsr;
     protected FlexibleStringExpander resultSetTypeExdr;
     
-    protected List selectFieldExpanderList;
-    protected List orderByExpanderList;
+    protected List<FlexibleStringExpander> selectFieldExpanderList;
+    protected List<FlexibleStringExpander> orderByExpanderList;
     protected OutputHandler outputHandler;
 
     protected ListFinder(Element element, String label) {
@@ -86,12 +85,10 @@
         selectFieldExpanderList = EntityFinderUtil.makeSelectFieldExpanderList(element);
         
         // process order-by
-        List orderByElementList = UtilXml.childElementList(element, "order-by");
+        List<? extends Element> orderByElementList = UtilXml.childElementList(element, "order-by");
         if (orderByElementList.size() > 0) {
             orderByExpanderList = FastList.newInstance();
-            Iterator orderByElementIter = orderByElementList.iterator();
-            while (orderByElementIter.hasNext()) {
-                Element orderByElement = (Element) orderByElementIter.next();
+            for (Element orderByElement: orderByElementList) {
                 orderByExpanderList.add(new FlexibleStringExpander(orderByElement.getAttribute("field-name")));
             }
         }
@@ -115,7 +112,7 @@
         }
     }
 
-    public void runFind(Map context, GenericDelegator delegator) throws GeneralException {
+    public void runFind(Map<String, Object> context, GenericDelegator delegator) throws GeneralException {
         String entityName = this.entityNameExdr.expandString(context);
         String useCacheStr = this.useCacheStrExdr.expandString(context);
         String filterByDateStr = this.filterByDateStrExdr.expandString(context);
@@ -156,7 +153,7 @@
         
         
         // get the list of fieldsToSelect from selectFieldExpanderList
-        Set fieldsToSelect = EntityFinderUtil.makeFieldsToSelect(selectFieldExpanderList, context);
+        Set<String> fieldsToSelect = EntityFinderUtil.makeFieldsToSelect(selectFieldExpanderList, context);
 
         //if fieldsToSelect != null and useCacheBool is true, throw an error
         if (fieldsToSelect != null && useCache) {
@@ -164,21 +161,21 @@
         }
 
         // get the list of orderByFields from orderByExpanderList
-        List orderByFields = EntityFinderUtil.makeOrderByFieldList(this.orderByExpanderList, context);
+        List<String> orderByFields = EntityFinderUtil.makeOrderByFieldList(this.orderByExpanderList, context);
         
         try {
             // if filterByDate, do a date filter on the results based on the now-timestamp
             if (filterByDate) {
                 EntityCondition filterByDateCondition = EntityUtil.getFilterByDateExpr();
                 if (whereEntityCondition != null) {
-                    whereEntityCondition = new EntityConditionList(UtilMisc.toList(whereEntityCondition, filterByDateCondition), EntityJoinOperator.AND);
+                    whereEntityCondition = new EntityConditionList<EntityCondition>(UtilMisc.toList(whereEntityCondition, filterByDateCondition), EntityJoinOperator.AND);
                 } else {
                     whereEntityCondition = filterByDateCondition;
                 }
             }
             
             if (useCache) {
-                List results = delegator.findByConditionCache(entityName, whereEntityCondition, fieldsToSelect, orderByFields);
+                List<GenericValue> results = delegator.findByConditionCache(entityName, whereEntityCondition, fieldsToSelect, orderByFields);
                 this.outputHandler.handleOutput(results, context, listAcsr);
             } else {
                 boolean useTransaction = true;
@@ -222,11 +219,11 @@
         }
     }
 
-    protected EntityCondition getWhereEntityCondition(Map context, ModelEntity modelEntity, GenericDelegator delegator) {
+    protected EntityCondition getWhereEntityCondition(Map<String, Object> context, ModelEntity modelEntity, GenericDelegator delegator) {
         return null;
     }
 
-    protected EntityCondition getHavingEntityCondition(Map context, ModelEntity modelEntity, GenericDelegator delegator) {
+    protected EntityCondition getHavingEntityCondition(Map<String, Object> context, ModelEntity modelEntity, GenericDelegator delegator) {
         return null;
     }
 }

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java?rev=585840&r1=585839&r2=585840&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java Wed Oct 17 20:50:30 2007
@@ -25,6 +25,7 @@
 import java.util.Set;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.collections.FlexibleMapAccessor;
@@ -45,8 +46,8 @@
     
     protected FlexibleMapAccessor valueNameAcsr;
     protected FlexibleStringExpander autoFieldMapExdr;
-    protected Map fieldMap;
-    protected List selectFieldExpanderList;
+    protected Map<FlexibleMapAccessor, Object> fieldMap;
+    protected List<FlexibleStringExpander> selectFieldExpanderList;
 
     public PrimaryKeyFinder(Element entityOneElement) {
         super(entityOneElement);
@@ -61,7 +62,7 @@
         selectFieldExpanderList = EntityFinderUtil.makeSelectFieldExpanderList(entityOneElement);
     }
 
-    public void runFind(Map context, GenericDelegator delegator) throws GeneralException {
+    public void runFind(Map<String, Object> context, GenericDelegator delegator) throws GeneralException {
         String entityName = this.entityNameExdr.expandString(context);
         ModelEntity modelEntity = delegator.getModelEntity(entityName);
         
@@ -74,14 +75,14 @@
         boolean autoFieldMapBool = !"false".equals(autoFieldMapString);
 
         // assemble the field map
-        Map entityContext = new HashMap();
+        Map<String, Object> entityContext = new HashMap<String, Object>();
         if (autoFieldMapBool) {
             GenericValue tempVal = delegator.makeValue(entityName);
 
             // try a map called "parameters", try it first so values from here are overriden by values in the main context
             Object parametersObj = context.get("parameters");
             if (parametersObj != null && parametersObj instanceof Map) {
-                tempVal.setAllFields((Map) parametersObj, true, null, Boolean.TRUE);
+                tempVal.setAllFields(UtilGenerics.checkMap(parametersObj), true, null, Boolean.TRUE);
             }
 
             // just get the primary keys, and hopefully will get all of them, if not they must be manually filled in below in the field-maps
@@ -95,7 +96,7 @@
         modelEntity.convertFieldMapInPlace(entityContext, delegator);
         
         // get the list of fieldsToSelect from selectFieldExpanderList
-        Set fieldsToSelect = EntityFinderUtil.makeFieldsToSelect(selectFieldExpanderList, context);
+        Set<String> fieldsToSelect = EntityFinderUtil.makeFieldsToSelect(selectFieldExpanderList, context);
         
         //if fieldsToSelect != null and useCacheBool is true, throw an error
         if (fieldsToSelect != null && useCacheBool) {