svn commit: r685951 - in /ofbiz/trunk/applications/content/src/org/ofbiz/content: ContentManagementServices.java ContentManagementWorker.java 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: r685951 - in /ofbiz/trunk/applications/content/src/org/ofbiz/content: ContentManagementServices.java ContentManagementWorker.java content/ContentServicesComplex.java

doogie-3
Author: doogie
Date: Thu Aug 14 09:24:56 2008
New Revision: 685951

URL: http://svn.apache.org/viewvc?rev=685951&view=rev
Log:
Another anti-pattern discovery.

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

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java?rev=685951&r1=685950&r2=685951&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java Thu Aug 14 09:24:56 2008
@@ -908,14 +908,7 @@
         String contentAssocTypeId = (String)context.get("contentAssocTypeId");
         if (UtilValidate.isNotEmpty(contentAssocTypeId)) typeList.add(contentAssocTypeId);
         if (UtilValidate.isEmpty(typeList)) typeList = UtilMisc.toList("PUBLISH_LINK", "SUB_CONTENT");
-        List condList = FastList.newInstance();
-        Iterator iterType = typeList.iterator();
-        while (iterType.hasNext()) {
-            String type = (String)iterType.next();
-            condList.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.EQUALS, type));
-        }
-        
-        EntityCondition conditionType = EntityCondition.makeCondition(condList, EntityOperator.OR);
+        EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList);
         EntityCondition conditionMain = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentIdTo), conditionType), EntityOperator.AND);
          try {
              List listAll = delegator.findList("ContentAssoc", conditionMain, null, UtilMisc.toList("sequenceNum", "fromDate", "createdDate"), null, false);
@@ -1086,14 +1079,7 @@
                 //subLeafCount = subLeafCount;
             }
             
-           List condList = FastList.newInstance();
-           Iterator iterType = typeList.iterator();
-           while (iterType.hasNext()) {
-               String type = (String)iterType.next();
-               condList.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.EQUALS, type));
-           }
-          
-           EntityCondition conditionType = EntityCondition.makeCondition(condList, EntityOperator.OR);
+           EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList);
            EntityCondition conditionMain = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, thisContentId), conditionType), EntityOperator.AND);
             List listAll = delegator.findByConditionCache("ContentAssoc", conditionMain, null, null);
             List listFiltered = EntityUtil.filterByDate(listAll);

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java?rev=685951&r1=685950&r2=685951&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementWorker.java Thu Aug 14 09:24:56 2008
@@ -741,16 +741,9 @@
         if (thisContent == null)
             throw new RuntimeException("No entity found for id=" + contentId);
         
-       List condList = FastList.newInstance();
-       Iterator iterType = typeList.iterator();
-       while (iterType.hasNext()) {
-           String type = (String)iterType.next();
-           condList.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.EQUALS, type));
-       }
-      
        EntityCondition conditionMain = null;
-       if (condList.size() > 0 ) {
-           EntityCondition conditionType = EntityCondition.makeCondition(condList, EntityOperator.OR);
+       if (typeList.size() > 0 ) {
+           EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList);
            conditionMain = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentId), conditionType), EntityOperator.AND);
        } else {
            conditionMain = EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentId);
@@ -779,14 +772,7 @@
         if (thisContent == null)
             throw new RuntimeException("No entity found for id=" + contentId);
         
-       List condList = FastList.newInstance();
-       Iterator iterType = typeList.iterator();
-       while (iterType.hasNext()) {
-           String type = (String)iterType.next();
-           condList.add(EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.EQUALS, type));
-       }
-      
-       EntityCondition conditionType = EntityCondition.makeCondition(condList, EntityOperator.OR);
+       EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList);
        EntityCondition conditionMain = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId), conditionType), EntityOperator.AND);
             List listAll = delegator.findList("ContentAssoc", conditionMain, null, null, null, true);
             List listFiltered = EntityUtil.filterByDate(listAll);

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=685951&r1=685950&r2=685951&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 Thu Aug 14 09:24:56 2008
@@ -100,28 +100,10 @@
         }
         exprList.add(joinExpr);
         if (assocTypes != null && assocTypes.size() > 0) {
-            List exprListOr = FastList.newInstance();
-            Iterator it = assocTypes.iterator();
-            while (it.hasNext()) {
-                String assocType = (String)it.next();
-                expr = EntityCondition.makeCondition("caContentAssocTypeId", EntityOperator.EQUALS, assocType);
-                exprListOr.add(expr);
-            }
-            EntityConditionList assocExprList = EntityCondition.makeCondition(exprListOr, EntityOperator.OR);
-
-            exprList.add(assocExprList);
+            exprList.add(EntityCondition.makeCondition("caContentAssocTypeId", EntityOperator.IN, assocTypes));
         }
         if (contentTypes != null && contentTypes.size() > 0) {
-            List exprListOr = FastList.newInstance();
-            Iterator it = contentTypes.iterator();
-            while (it.hasNext()) {
-                String contentType = (String)it.next();
-                expr = EntityCondition.makeCondition("contentTypeId",
-                                  EntityOperator.EQUALS, contentType);
-                exprListOr.add(expr);
-            }
-            EntityConditionList contentExprList = EntityCondition.makeCondition(exprListOr, EntityOperator.OR);
-            exprList.add(contentExprList);
+            exprList.add(EntityCondition.makeCondition("contentTypeId", EntityOperator.IN, contentTypes));
         }
 
         if (fromDate == null && fromDateStr != null) {