Author: arunpatidar
Date: Mon Jun 6 14:47:24 2016 New Revision: 1747024 URL: http://svn.apache.org/viewvc?rev=1747024&view=rev Log: [OFBIZ-7169] Applied patch from jira issue ================================================= ContentWrapper classes owner the entity fields instead should owner the contents ================================================= Thanks Rishi Solanki and Amit Gadaley for your contribution. Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java?rev=1747024&r1=1747023&r2=1747024&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java Mon Jun 6 14:47:24 2016 @@ -199,6 +199,22 @@ public class PartyContentWrapper impleme throw new GeneralRuntimeException("Unable to find a delegator to use!"); } + // Honor party content over Party entity fields. + GenericValue partyContent; + if (contentId != null) { + partyContent = EntityQuery.use(delegator).from("PartyContent").where("partyId", partyId, "contentId", contentId).cache(cache).queryOne(); + } else { + partyContent = getFirstPartyContentByType(partyId, party, partyContentTypeId, delegator); + } + if (partyContent != null) { + // when rendering the product content, always include the Product and ProductContent records that this comes from + Map<String, Object> inContext = new HashMap<String, Object>(); + inContext.put("party", party); + inContext.put("partyContent", partyContent); + ContentWorker.renderContentAsText(dispatcher, delegator, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache); + return; + } + if (partyContentTypeId != null) { String candidateFieldName = ModelUtil.dbNameToVarName(partyContentTypeId); @@ -232,21 +248,6 @@ public class PartyContentWrapper impleme } } } - - // otherwise a content field - GenericValue partyContent; - if (contentId != null) { - partyContent = EntityQuery.use(delegator).from("PartyContent").where("partyId", partyId, "contentId", contentId).cache(cache).queryOne(); - } else { - partyContent = getFirstPartyContentByType(partyId, party, partyContentTypeId, delegator); - } - if (partyContent != null) { - // when rendering the product content, always include the Product and ProductContent records that this comes from - Map<String, Object> inContext = new HashMap<String, Object>(); - inContext.put("party", party); - inContext.put("partyContent", partyContent); - ContentWorker.renderContentAsText(dispatcher, delegator, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache); - } } public static List<String> getPartyContentTextList(GenericValue party, String partyContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java?rev=1747024&r1=1747023&r2=1747024&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java Mon Jun 6 14:47:24 2016 @@ -145,21 +145,6 @@ public class CategoryContentWrapper impl throw new GeneralRuntimeException("Unable to find a delegator to use!"); } - String candidateFieldName = ModelUtil.dbNameToVarName(prodCatContentTypeId); - ModelEntity categoryModel = delegator.getModelEntity("ProductCategory"); - if (categoryModel.isField(candidateFieldName)) { - if (productCategory == null) { - productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).cache().queryOne(); - } - if (productCategory != null) { - String candidateValue = productCategory.getString(candidateFieldName); - if (UtilValidate.isNotEmpty(candidateValue)) { - outWriter.write(candidateValue); - return; - } - } - } - List<GenericValue> categoryContentList = EntityQuery.use(delegator).from("ProductCategoryContent").where("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId).orderBy("-fromDate").cache(cache).queryList(); categoryContentList = EntityUtil.filterByDate(categoryContentList); @@ -185,6 +170,22 @@ public class CategoryContentWrapper impl inContext.put("productCategory", productCategory); inContext.put("categoryContent", categoryContent); ContentWorker.renderContentAsText(dispatcher, delegator, categoryContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache); + return; + } + + String candidateFieldName = ModelUtil.dbNameToVarName(prodCatContentTypeId); + ModelEntity categoryModel = delegator.getModelEntity("ProductCategory"); + if (categoryModel.isField(candidateFieldName)) { + if (productCategory == null) { + productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).cache().queryOne(); + } + if (productCategory != null) { + String candidateValue = productCategory.getString(candidateFieldName); + if (UtilValidate.isNotEmpty(candidateValue)) { + outWriter.write(candidateValue); + return; + } + } } } } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java?rev=1747024&r1=1747023&r2=1747024&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java Mon Jun 6 14:47:24 2016 @@ -166,6 +166,21 @@ public class ProductConfigItemContentWra mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", delegator); } + GenericValue productConfigItemContent = EntityQuery.use(delegator).from("ProdConfItemContent") + .where("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId) + .orderBy("-fromDate") + .cache(cache) + .filterByDate() + .queryFirst(); + if (productConfigItemContent != null) { + // when rendering the product config item content, always include the ProductConfigItem and ProdConfItemContent records that this comes from + Map<String, Object> inContext = new HashMap<String, Object>(); + inContext.put("productConfigItem", productConfigItem); + inContext.put("productConfigItemContent", productConfigItemContent); + ContentWorker.renderContentAsText(dispatcher, delegator, productConfigItemContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache); + return; + } + String candidateFieldName = ModelUtil.dbNameToVarName(confItemContentTypeId); //Debug.logInfo("candidateFieldName=" + candidateFieldName, module); ModelEntity productConfigItemModel = delegator.getModelEntity("ProductConfigItem"); @@ -181,20 +196,6 @@ public class ProductConfigItemContentWra } } } - - GenericValue productConfigItemContent = EntityQuery.use(delegator).from("ProdConfItemContent") - .where("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId) - .orderBy("-fromDate") - .cache(cache) - .filterByDate() - .queryFirst(); - if (productConfigItemContent != null) { - // when rendering the product config item content, always include the ProductConfigItem and ProdConfItemContent records that this comes from - Map<String, Object> inContext = new HashMap<String, Object>(); - inContext.put("productConfigItem", productConfigItem); - inContext.put("productConfigItemContent", productConfigItemContent); - ContentWorker.renderContentAsText(dispatcher, delegator, productConfigItemContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, cache); - } } } 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=1747024&r1=1747023&r2=1747024&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 Mon Jun 6 14:47:24 2016 @@ -165,21 +165,6 @@ public class ProductPromoContentWrapper throw new GeneralRuntimeException("Unable to find a delegator to use!"); } - String candidateFieldName = ModelUtil.dbNameToVarName(productPromoContentTypeId); - ModelEntity productModel = delegator.getModelEntity("ProductPromo"); - if (productModel.isField(candidateFieldName)) { - if (UtilValidate.isEmpty(productPromo)) { - productPromo = EntityQuery.use(delegator).from("ProductPromo").where("productPromoId", productPromoId).cache().queryOne(); - } - if (UtilValidate.isNotEmpty(productPromo)) { - String candidateValue = productPromo.getString(candidateFieldName); - if (UtilValidate.isNotEmpty(candidateValue)) { - outWriter.write(candidateValue); - return; - } - } - } - List<EntityExpr> exprs = new ArrayList<EntityExpr>(); exprs.add(EntityCondition.makeCondition("productPromoId", EntityOperator.EQUALS, productPromoId)); exprs.add(EntityCondition.makeCondition("productPromoContentTypeId", EntityOperator.EQUALS, productPromoContentTypeId)); @@ -196,6 +181,22 @@ public class ProductPromoContentWrapper inContext.put("productPromo", productPromo); inContext.put("productPromoContent", productPromoContent); ContentWorker.renderContentAsText(dispatcher, delegator, productPromoContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, partyId, roleTypeId, cache); + return; + } + + String candidateFieldName = ModelUtil.dbNameToVarName(productPromoContentTypeId); + ModelEntity productModel = delegator.getModelEntity("ProductPromo"); + if (productModel.isField(candidateFieldName)) { + if (UtilValidate.isEmpty(productPromo)) { + productPromo = EntityQuery.use(delegator).from("ProductPromo").where("productPromoId", productPromoId).cache().queryOne(); + } + if (UtilValidate.isNotEmpty(productPromo)) { + String candidateValue = productPromo.getString(candidateFieldName); + if (UtilValidate.isNotEmpty(candidateValue)) { + outWriter.write(candidateValue); + return; + } + } } } } Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java?rev=1747024&r1=1747023&r2=1747024&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java Mon Jun 6 14:47:24 2016 @@ -293,6 +293,22 @@ public class WorkEffortContentWrapper im throw new GeneralRuntimeException("Unable to find a delegator to use!"); } + // Honor work effort content over WorkEffort entity fields. + GenericValue workEffortContent; + if (contentId != null) { + workEffortContent = EntityQuery.use(delegator).from("WorkEffortContent").where("workEffortId", workEffortId, "contentId", contentId).cache(cache).queryOne(); + } else { + workEffortContent = getFirstWorkEffortContentByType(workEffortId, workEffort, workEffortContentTypeId, delegator, cache); + } + if (workEffortContent != null) { + // when rendering the product content, always include the Product and ProductContent records that this comes from + Map<String, Object> inContext = new HashMap<String, Object>(); + inContext.put("workEffort", workEffort); + inContext.put("workEffortContent", workEffortContent); + ContentWorker.renderContentAsText(dispatcher, delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false); + return; + } + // check for workeffort field String candidateFieldName = ModelUtil.dbNameToVarName(workEffortContentTypeId); ModelEntity workEffortModel = delegator.getModelEntity("WorkEffort"); @@ -308,21 +324,6 @@ public class WorkEffortContentWrapper im } } } - - // otherwise check content record - GenericValue workEffortContent; - if (contentId != null) { - workEffortContent = EntityQuery.use(delegator).from("WorkEffortContent").where("workEffortId", workEffortId, "contentId", contentId).cache(cache).queryOne(); - } else { - workEffortContent = getFirstWorkEffortContentByType(workEffortId, workEffort, workEffortContentTypeId, delegator, cache); - } - if (workEffortContent != null) { - // when rendering the product content, always include the Product and ProductContent records that this comes from - Map<String, Object> inContext = new HashMap<String, Object>(); - inContext.put("workEffort", workEffort); - inContext.put("workEffortContent", workEffortContent); - ContentWorker.renderContentAsText(dispatcher, delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, null, null, false); - } } public static List<String> getWorkEffortContentTextList(GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { |
Free forum by Nabble | Edit this page |