Author: hansbak
Date: Tue Oct 26 03:04:48 2010
New Revision: 1027347

URL: http://svn.apache.org/viewvc?rev=1027347&view=rev
Log:
make more use of the cache in order to speed up the ecommerce frontend

Modified:
    
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
    
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java
    
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java

Modified: 
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java?rev=1027347&r1=1027346&r2=1027347&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
 (original)
+++ 
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
 Tue Oct 26 03:04:48 2010
@@ -124,7 +124,7 @@ public class ContentWorker implements or
 
         // if the content is a PUBLISH_POINT and the data resource is not 
defined; get the related content
         if ("WEB_SITE_PUB_PT".equals(content.get("contentTypeId")) && 
content.get("dataResourceId") == null) {
-            List<GenericValue> relContentIds = 
delegator.findByAnd("ContentAssocDataResourceViewTo",
+            List<GenericValue> relContentIds = 
delegator.findByAndCache("ContentAssocDataResourceViewTo",
                     UtilMisc.toMap("contentIdStart", 
content.get("contentId"),"statusId","CTNT_PUBLISHED",
                     "caContentAssocTypeId", "PUBLISH_LINK"), 
UtilMisc.toList("caFromDate"));
 
@@ -165,10 +165,10 @@ public class ContentWorker implements or
             Iterator<GenericValue> alternateViewIter = 
alternateViews.iterator();
             while (alternateViewIter.hasNext()) {
                 GenericValue thisView = alternateViewIter.next();
-                GenericValue altContentRole = 
EntityUtil.getFirst(EntityUtil.filterByDate(thisView.getRelatedByAnd("ContentRole",
 UtilMisc.toMap("partyId", partyId, "roleTypeId", roleTypeId))));
+                GenericValue altContentRole = 
EntityUtil.getFirst(EntityUtil.filterByDate(thisView.getRelatedByAndCache("ContentRole",
 UtilMisc.toMap("partyId", partyId, "roleTypeId", roleTypeId))));
                 GenericValue altContent = null;
                 if (UtilValidate.isNotEmpty(altContentRole)) {
-                    altContent = altContentRole.getRelatedOne("Content");
+                    altContent = altContentRole.getRelatedOneCache("Content");
                     if (altContent != null) {
                         content = altContent;
                     }
@@ -288,8 +288,8 @@ public class ContentWorker implements or
                 // This part is using an xml file as the input data and an ftl 
or xsl file to present it.
                 if (UtilValidate.isNotEmpty(mimeType)) {
                     if (mimeType.toLowerCase().indexOf("xml") >= 0) {
-                        GenericValue dataResource = 
delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", 
dataResourceId));
-                        GenericValue templateDataResource = 
delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", 
templateDataResourceId));
+                        GenericValue dataResource = 
delegator.findByPrimaryKeyCache("DataResource", 
UtilMisc.toMap("dataResourceId", dataResourceId));
+                        GenericValue templateDataResource = 
delegator.findByPrimaryKeyCache("DataResource", 
UtilMisc.toMap("dataResourceId", templateDataResourceId));
                         if 
("FTL".equals(templateDataResource.getString("dataTemplateTypeId"))) {
                             StringReader sr = new StringReader(textData);
                             try {
@@ -373,7 +373,7 @@ public class ContentWorker implements or
 
         List<GenericValue> alternateViews = null;
         try {
-            alternateViews = view.getRelated("ContentAssocDataResourceViewTo", 
UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), 
UtilMisc.toList("-caFromDate"));
+            alternateViews = 
view.getRelatedCache("ContentAssocDataResourceViewTo", 
UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), 
UtilMisc.toList("-caFromDate"));
         } catch (GenericEntityException e) {
             Debug.logError(e, "Error finding alternate locale content: " + 
e.toString(), module);
             return contentAssocDataResourceViewFrom;

Modified: 
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java?rev=1027347&r1=1027346&r2=1027347&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java
 (original)
+++ 
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java
 Tue Oct 26 03:04:48 2010
@@ -184,7 +184,7 @@ public class ProductContentWrapper imple
             Map<String, Object> inContext = FastMap.newInstance();
             inContext.put("product", product);
             inContext.put("productContent", productContent);
-            ContentWorker.renderContentAsText(dispatcher, delegator, 
productContent.getString("contentId"), outWriter, inContext, locale, 
mimeTypeId, partyId, roleTypeId, false);
+            ContentWorker.renderContentAsText(dispatcher, delegator, 
productContent.getString("contentId"), outWriter, inContext, locale, 
mimeTypeId, partyId, roleTypeId, true);
         }
     }
 }

Modified: 
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java?rev=1027347&r1=1027346&r2=1027347&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java
 (original)
+++ 
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java
 Tue Oct 26 03:04:48 2010
@@ -175,7 +175,7 @@ public class ProductPromoContentWrapper 
         exprs.add(EntityCondition.makeCondition("productPromoContentTypeId", 
EntityOperator.EQUALS, productPromoContentTypeId));
         List<String> orderBy = UtilMisc.toList("-fromDate");
 
-        List<GenericValue> productPromoContentList = 
delegator.findList("ProductPromoContent", EntityCondition.makeCondition(exprs, 
EntityOperator.AND), null, orderBy, null, false);
+        List<GenericValue> productPromoContentList = 
delegator.findList("ProductPromoContent", EntityCondition.makeCondition(exprs, 
EntityOperator.AND), null, orderBy, null, true);
         GenericValue productPromoContent = null;
         if (UtilValidate.isNotEmpty(productPromoContentList)) {
             productPromoContent = 
EntityUtil.getFirst(EntityUtil.filterByDate(productPromoContentList));
@@ -186,7 +186,7 @@ public class ProductPromoContentWrapper 
             Map<String, Object> inContext = FastMap.newInstance();
             inContext.put("productPromo", productPromo);
             inContext.put("productPromoContent", productPromoContent);
-            ContentWorker.renderContentAsText(dispatcher, delegator, 
productPromoContent.getString("contentId"), outWriter, inContext, locale, 
mimeTypeId, partyId, roleTypeId, false);
+            ContentWorker.renderContentAsText(dispatcher, delegator, 
productPromoContent.getString("contentId"), outWriter, inContext, locale, 
mimeTypeId, partyId, roleTypeId, true);
         }
     }
 }


Reply via email to