/[Apache-SVN]
ViewVC logotype

Revision 1831783


Jump to revision: Previous Next
Author: nmalin
Date: Thu May 17 14:03:46 2018 UTC (5 years, 11 months ago)
Changed paths: 17
Log Message:
Improved: Migrate product promotion condition and action rule on SOA
(OFBIZ-10370)

Currently promotion rule engine works with :
    entities ProductPromoCond et ProductPromoAction
    java linear function ProductPromoWorker.checkCondition() (ProductPromoWorker:910) and ProductPromoWorker.performAction (ProductPromoWorker:1423)
    Enumeration list to indicate on java function what piece of code to activate the control or action

The problem with this structure is when you want to create a new case of condition or action, you need to modify the framework code base.

We convert the 2 big java leaner function to service representation with one service by case. To realize it we introduce a relation with CustomMethod :
  ProductPromoRule --> ProductPromoCond   -> CustomMethod
                    -> ProductPromoAction -> CustomMethod
Each functions's case are converted to service with a related CustomMethod.
With this pattern now you can write your own condition rule and action rule on your plugin and link it on the promo engine

For backward compatibility purpose, current "PPIP" enumeration entries receive in enumCode data the new corresponding customMethodId reference, to ensure that old data works fine with the new engine
on EntityData
 <CustomMethod customMethodId="PPC_PRODUCT_AMOUNT" customMethodTypeId="PRODUCT_PROMO_COND" customMethodName="productPromoCondProductAmount" description="Product amount"/>
 <Enumeration enumId="PPIP_PRODUCT_AMOUNT" enumCode="PPC_PRODUCT_AMOUNT"/><!--link enumeration with customMethod for backward compatibility-->
on Java
 //for backward compatibility resolve customMethodId from enumCode
 GenericValue condEnum = EntityQuery.use(delegator).from("Enumeration").where("enumId", inputParamEnumId).cache().queryOne();
 if (condEnum != null) {
     customMethod = EntityQuery.use(delegator).from("CustomMethod").where("customMethodId", condEnum.get("enumCode")).cache().queryOne();
     if (customMethod == null) {
         Debug.logWarning("The oldest enumeration " + inputParamEnumId + " for promo " + productPromoCond.getPkShortValueString() + " haven't the new customMethod to use, please check your data or load seed data", module);
         return false;
     }
     serviceName = customMethod.getString("customMethodName");
 }

Many thanks to Ziri Khalifa and Leila Mekika for their helping work

Changed paths

Path Details
Directoryofbiz/ofbiz-framework/trunk/applications/datamodel/entitydef/product-entitymodel.xml modified , text changed
Directoryofbiz/ofbiz-framework/trunk/applications/order/servicedef/services_cart.xml modified , text changed
Directoryofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartItem.java modified , text changed
Directoryofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartServices.java modified , text changed
Directoryofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/product/ProductPromoWorker.java modified , text changed
Directoryofbiz/ofbiz-framework/trunk/applications/product/data/PromoCustomMethodData.xml added
Directoryofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/promo/ added
Directoryofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/promo/ProductPromoActionServices.groovy added
Directoryofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/promo/ProductPromoCondServices.groovy added
Directoryofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ added
Directoryofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ProductPromoActionTests.groovy added
Directoryofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/test/ProductPromoCondTests.groovy added
Directoryofbiz/ofbiz-framework/trunk/applications/product/ofbiz-component.xml modified , text changed
Directoryofbiz/ofbiz-framework/trunk/applications/product/servicedef/services_pricepromo.xml modified , text changed
Directoryofbiz/ofbiz-framework/trunk/applications/product/template/promo/EditProductPromoRules.ftl modified , text changed
Directoryofbiz/ofbiz-framework/trunk/applications/product/testdef/ProductPromoTests.xml added
Directoryofbiz/ofbiz-framework/trunk/applications/product/widget/catalog/PromoScreens.xml modified , text changed

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26