svn commit: r1062178 - /ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java

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

svn commit: r1062178 - /ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java

mrisaliti
Author: mrisaliti
Date: Sat Jan 22 15:43:05 2011
New Revision: 1062178

URL: http://svn.apache.org/viewvc?rev=1062178&view=rev
Log:
Remove some java compilation warnings of ContentServicesComples (OFBIZ-4102)

Modified:
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java?rev=1062178&r1=1062177&r2=1062178&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java Sat Jan 22 15:43:05 2011
@@ -30,6 +30,7 @@ import javolution.util.FastMap;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
@@ -63,10 +64,9 @@ public class ContentServicesComplex {
     * A mapKey value.
     */
     public static Map<String, Object> getAssocAndContentAndDataResource(DispatchContext dctx, Map<String, ? extends Object> context) {
-
         Delegator delegator = dctx.getDelegator();
-        List assocTypes = (List) context.get("assocTypes");
-        List contentTypes = (List)context.get("contentTypes");
+        List<String> assocTypes = UtilGenerics.checkList(context.get("assocTypes"));
+        List<String> contentTypes = UtilGenerics.checkList(context.get("contentTypes"));
         Timestamp fromDate = (Timestamp)context.get("fromDate");
         Timestamp thruDate = (Timestamp)context.get("thruDate");
         String fromDateStr = (String)context.get("fromDateStr");
@@ -74,18 +74,14 @@ public class ContentServicesComplex {
         String contentId = (String)context.get("contentId");
         String direction = (String)context.get("direction");
         String mapKey = (String)context.get("mapKey");
-        Boolean nullThruDatesOnly = (Boolean)context.get("nullThruDatesOnly");
-        Map results = getAssocAndContentAndDataResourceMethod(delegator,
-                          contentId, mapKey, direction, fromDate, thruDate,
-                          fromDateStr, thruDateStr, assocTypes, contentTypes);
+        // Boolean nullThruDatesOnly = (Boolean)context.get("nullThruDatesOnly");
+        Map<String, Object> results = getAssocAndContentAndDataResourceMethod(delegator, contentId, mapKey, direction, fromDate, thruDate, fromDateStr, thruDateStr, assocTypes, contentTypes);
         return results;
     }
 
-    public static Map getAssocAndContentAndDataResourceMethod(Delegator delegator, String contentId, String mapKey, String direction, Timestamp fromDate, Timestamp thruDate, String fromDateStr, String thruDateStr, List assocTypes, List contentTypes) {
-
+    public static Map<String, Object> getAssocAndContentAndDataResourceMethod(Delegator delegator, String contentId, String mapKey, String direction, Timestamp fromDate, Timestamp thruDate, String fromDateStr, String thruDateStr, List<String> assocTypes, List<String> contentTypes) {
         List exprList = FastList.newInstance();
         EntityExpr joinExpr = null;
-        EntityExpr expr = null;
         String viewName = null;
         if (mapKey != null) {
             EntityExpr mapKeyExpr = EntityCondition.makeCondition("caMapKey", EntityOperator.EQUALS, mapKey);
@@ -118,44 +114,37 @@ public class ContentServicesComplex {
             exprList.add(fromExpr);
         }
         if (thruDate != null) {
-            List thruList = FastList.newInstance();
+            List<EntityExpr> thruList = FastList.newInstance();
             //thruDate = UtilDateTime.getDayStart(thruDate, daysLater);
 
             EntityExpr thruExpr = EntityCondition.makeCondition("caThruDate", EntityOperator.LESS_THAN, thruDate);
             thruList.add(thruExpr);
             EntityExpr thruExpr2 = EntityCondition.makeCondition("caThruDate", EntityOperator.EQUALS, null);
             thruList.add(thruExpr2);
-            EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
+            EntityConditionList<EntityExpr> thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
             exprList.add(thruExprList);
         } else if (fromDate != null) {
-            List thruList = FastList.newInstance();
+            List<EntityExpr> thruList = FastList.newInstance();
 
             EntityExpr thruExpr = EntityCondition.makeCondition("caThruDate", EntityOperator.GREATER_THAN, fromDate);
             thruList.add(thruExpr);
             EntityExpr thruExpr2 = EntityCondition.makeCondition("caThruDate", EntityOperator.EQUALS, null);
             thruList.add(thruExpr2);
-            EntityConditionList thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
+            EntityConditionList<EntityExpr> thruExprList = EntityCondition.makeCondition(thruList, EntityOperator.OR);
             exprList.add(thruExprList);
         }
-        EntityConditionList assocExprList = EntityCondition.makeCondition(exprList, EntityOperator.AND);
-        List relatedAssocs = null;
+        EntityConditionList<EntityExpr> assocExprList = EntityCondition.makeCondition(exprList, EntityOperator.AND);
+        List<GenericValue> relatedAssocs = null;
         try {
-            //relatedAssocs = delegator.findByCondition(viewName, joinExpr,
             relatedAssocs = delegator.findList(viewName, assocExprList, null,UtilMisc.toList("caFromDate"), null, false);
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError(e.getMessage());
         }
         for (int i=0; i < relatedAssocs.size(); i++) {
             GenericValue a = (GenericValue)relatedAssocs.get(i);
-                Debug.logVerbose(" contentId:" + a.get("contentId")
-                         + " To:" + a.get("caContentIdTo")
-                         + " fromDate:" + a.get("caFromDate")
-                         + " thruDate:" + a.get("caThruDate")
-                         + " AssocTypeId:" + a.get("caContentAssocTypeId")
-                         ,null);
-
+            Debug.logVerbose(" contentId:" + a.get("contentId") + " To:" + a.get("caContentIdTo") + " fromDate:" + a.get("caFromDate") + " thruDate:" + a.get("caThruDate") + " AssocTypeId:" + a.get("caContentAssocTypeId"), null);
         }
-        Map results = FastMap.newInstance();
+        Map<String, Object> results = FastMap.newInstance();
         results.put("entityList", relatedAssocs);
         return results;
     }
@@ -169,21 +158,20 @@ public class ContentServicesComplex {
     * A mapKey value.
     */
     public static Map<String, Object> getAssocAndContentAndDataResourceCache(DispatchContext dctx, Map<String, ? extends Object> context) {
-
         Delegator delegator = dctx.getDelegator();
-        List assocTypes = (List) context.get("assocTypes");
+        List<String> assocTypes = UtilGenerics.checkList(context.get("assocTypes"));
         String assocTypesString = (String)context.get("assocTypesString");
         if (UtilValidate.isNotEmpty(assocTypesString)) {
-            List lst = StringUtil.split(assocTypesString, "|");
+            List<String> lst = StringUtil.split(assocTypesString, "|");
             if (assocTypes == null) {
                 assocTypes = FastList.newInstance();
             }
             assocTypes.addAll(lst);
         }
-        List contentTypes = (List)context.get("contentTypes");
+        List<String> contentTypes = UtilGenerics.checkList(context.get("contentTypes"));
         String contentTypesString = (String)context.get("contentTypesString");
         if (UtilValidate.isNotEmpty(contentTypesString)) {
-            List lst = StringUtil.split(contentTypesString, "|");
+            List<String> lst = StringUtil.split(contentTypesString, "|");
             if (contentTypes == null) {
                 contentTypes = FastList.newInstance();
             }
@@ -196,11 +184,9 @@ public class ContentServicesComplex {
         String mapKey = (String)context.get("mapKey");
         String contentAssocPredicateId = (String)context.get("contentAssocPredicateId");
         Boolean nullThruDatesOnly = (Boolean)context.get("nullThruDatesOnly");
-        Map results = null;
+        Map<String, Object> results = null;
         try {
-            results = getAssocAndContentAndDataResourceCacheMethod(delegator,
-                          contentId, mapKey, direction, fromDate,
-                          fromDateStr, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId);
+            results = getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId);
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError(e.getMessage());
         } catch (MiniLangException e2) {
@@ -210,16 +196,14 @@ public class ContentServicesComplex {
     }
 
 
-    public static Map getAssocAndContentAndDataResourceCacheMethod(Delegator delegator, String contentId, String mapKey, String direction,
-                          Timestamp fromDate, String fromDateStr, List assocTypes, List contentTypes, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException, MiniLangException {
-            Map results = getAssocAndContentAndDataResourceCacheMethod(delegator,
-                          contentId, mapKey, direction, fromDate, fromDateStr, assocTypes,
-                          contentTypes, nullThruDatesOnly, contentAssocPredicateId, null);
+    public static Map<String, Object> getAssocAndContentAndDataResourceCacheMethod(Delegator delegator, String contentId, String mapKey, String direction,
+                          Timestamp fromDate, String fromDateStr, List<String> assocTypes, List<String> contentTypes, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException, MiniLangException {
+            Map<String, Object> results = getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId, null);
             return results;
     }
 
-    public static Map getAssocAndContentAndDataResourceCacheMethod(Delegator delegator, String contentId, String mapKey, String direction,
-                          Timestamp fromDate, String fromDateStr, List assocTypes, List contentTypes, Boolean nullThruDatesOnly, String contentAssocPredicateId, String orderBy) throws GenericEntityException, MiniLangException {
+    public static Map<String, Object> getAssocAndContentAndDataResourceCacheMethod(Delegator delegator, String contentId, String mapKey, String direction,
+                          Timestamp fromDate, String fromDateStr, List<String> assocTypes, List<String> contentTypes, Boolean nullThruDatesOnly, String contentAssocPredicateId, String orderBy) throws GenericEntityException, MiniLangException {
 
         //List exprList = FastList.newInstance();
         //EntityExpr joinExpr = null;
@@ -237,42 +221,42 @@ public class ContentServicesComplex {
         } else {
             viewName = "ContentAssocDataResourceViewTo";
         }
-            //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, assocTypes:" + assocTypes, module);
-        Map fieldMap = UtilMisc.toMap(contentFieldName, contentId);
+        //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, assocTypes:" + assocTypes, module);
+        Map<String, Object> fieldMap = UtilMisc.<String, Object>toMap(contentFieldName, contentId);
         if (assocTypes != null && assocTypes.size() == 1) {
-            fieldMap.putAll(UtilMisc.toMap("contentAssocTypeId", assocTypes.get(0)));
+            fieldMap.putAll(UtilMisc.<String, Object>toMap("contentAssocTypeId", assocTypes.get(0)));
         }
         if (UtilValidate.isNotEmpty(mapKey)) {
             if (mapKey.equalsIgnoreCase("is null"))
-                fieldMap.putAll(UtilMisc.toMap("mapKey", null));
+                fieldMap.putAll(UtilMisc.<String, Object>toMap("mapKey", null));
             else
-                fieldMap.putAll(UtilMisc.toMap("mapKey", mapKey));
+                fieldMap.putAll(UtilMisc.<String, Object>toMap("mapKey", mapKey));
         }
         if (UtilValidate.isNotEmpty(contentAssocPredicateId)) {
             if (contentAssocPredicateId.equalsIgnoreCase("is null"))
-                fieldMap.putAll(UtilMisc.toMap("contentAssocPredicateId", null));
+                fieldMap.putAll(UtilMisc.<String, Object>toMap("contentAssocPredicateId", null));
             else
-                fieldMap.putAll(UtilMisc.toMap("contentAssocPredicateId", contentAssocPredicateId));
+                fieldMap.putAll(UtilMisc.<String, Object>toMap("contentAssocPredicateId", contentAssocPredicateId));
         }
         if (nullThruDatesOnly != null && nullThruDatesOnly.booleanValue()) {
-            fieldMap.putAll(UtilMisc.toMap("thruDate", null));
+            fieldMap.putAll(UtilMisc.<String, Object>toMap("thruDate", null));
         }
-        List contentAssocsUnfiltered = null;
+        List<GenericValue> contentAssocsUnfiltered = null;
 
-            //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, fieldMap:" + fieldMap, module);
+        //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, fieldMap:" + fieldMap, module);
         contentAssocsUnfiltered = delegator.findByAndCache("ContentAssoc", fieldMap, UtilMisc.toList("-fromDate"));
 
-            //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, contentAssocsUnfiltered:" + contentAssocsUnfiltered, module);
+        //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, contentAssocsUnfiltered:" + contentAssocsUnfiltered, module);
         if (fromDate == null && fromDateStr != null) {
             fromDate = UtilDateTime.toTimestamp(fromDateStr);
         }
-        List contentAssocsDateFiltered2 = EntityUtil.filterByDate(contentAssocsUnfiltered, fromDate);
-        List contentAssocsDateFiltered = EntityUtil.orderBy(contentAssocsDateFiltered2, UtilMisc.toList("sequenceNum", "fromDate DESC"));
+        List<GenericValue> contentAssocsDateFiltered2 = EntityUtil.filterByDate(contentAssocsUnfiltered, fromDate);
+        List<GenericValue> contentAssocsDateFiltered = EntityUtil.orderBy(contentAssocsDateFiltered2, UtilMisc.toList("sequenceNum", "fromDate DESC"));
 
         String contentAssocTypeId = null;
-        List contentAssocsTypeFiltered = FastList.newInstance();
+        List<GenericValue> contentAssocsTypeFiltered = FastList.newInstance();
         if (assocTypes != null && assocTypes.size() > 1) {
-            Iterator it = contentAssocsDateFiltered.iterator();
+            Iterator<GenericValue> it = contentAssocsDateFiltered.iterator();
             while (it.hasNext()) {
                 contentAssoc = (GenericValue)it.next();
                 contentAssocTypeId = (String)contentAssoc.get("contentAssocTypeId");
@@ -294,9 +278,9 @@ public class ContentServicesComplex {
         GenericValue contentAssocDataResourceView = null;
         GenericValue content = null;
         GenericValue dataResource = null;
-        List contentAssocDataResourceList = FastList.newInstance();
+        List<GenericValue> contentAssocDataResourceList = FastList.newInstance();
         Locale locale = Locale.getDefault(); // TODO: this needs to be passed in
-        Iterator it = contentAssocsTypeFiltered.iterator();
+        Iterator<GenericValue> it = contentAssocsTypeFiltered.iterator();
         while (it.hasNext()) {
             contentAssoc = (GenericValue)it.next();
             content = contentAssoc.getRelatedOneCache(assocRelationName);
@@ -326,12 +310,12 @@ public class ContentServicesComplex {
             contentAssocDataResourceList.add(contentAssocDataResourceView);
         }
 
-        List orderByList = null;
+        List<String> orderByList = null;
         if (UtilValidate.isNotEmpty(orderBy)) {
            orderByList = StringUtil.split(orderBy, "|");
            contentAssocDataResourceList = EntityUtil.orderBy(contentAssocDataResourceList, orderByList);
         }
-        Map results = FastMap.newInstance();
+        Map<String, Object> results = FastMap.newInstance();
         results.put("entityList", contentAssocDataResourceList);
         if (UtilValidate.isNotEmpty(contentAssocDataResourceList)) {
             results.put("view", contentAssocDataResourceList.get(0));