svn commit: r1379937 - in /ofbiz/trunk: applications/accounting/data/ applications/content/entitydef/ applications/content/script/org/ofbiz/content/ applications/content/src/org/ofbiz/content/content/ applications/order/src/org/ofbiz/order/order/ speci...

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

svn commit: r1379937 - in /ofbiz/trunk: applications/accounting/data/ applications/content/entitydef/ applications/content/script/org/ofbiz/content/ applications/content/src/org/ofbiz/content/content/ applications/order/src/org/ofbiz/order/order/ speci...

jleroux@apache.org
Author: jleroux
Date: Sun Sep  2 09:46:20 2012
New Revision: 1379937

URL: http://svn.apache.org/viewvc?rev=1379937&view=rev
Log:
A slightly modified patch from Nicolas Malin "change serviceName by customMethod on Content " https://issues.apache.org/jira/browse/OFBIZ-5020

When you used a content as template, the content.serviceName value used to call the context populate service before rendering.
I propose to replace serviceName field by customMethodId and use customMethod pattern for more flexibility.
serviceName field is kept for backward compatibility

Thanks to Scott and Adrian for support

Modified:
    ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
    ofbiz/trunk/applications/content/entitydef/entitymodel.xml
    ofbiz/trunk/applications/content/script/org/ofbiz/content/ContentManagementMapProcessors.xml
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
    ofbiz/trunk/specialpurpose/ecommerce/data/DemoFinAccount.xml
    ofbiz/trunk/specialpurpose/ecommerce/data/DemoStoreGiftCertificateSettings.xml

Modified: ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml?rev=1379937&r1=1379936&r2=1379937&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Sun Sep  2 09:46:20 2012
@@ -728,11 +728,13 @@ under the License.
     <CustomMethodType customMethodTypeId="FIN_CAPTURE" parentTypeId="" hasTable="N" description="FIN account capture methods"/>
     <CustomMethodType customMethodTypeId="FIN_REFUND" parentTypeId="" hasTable="N" description="FIN account refund methods"/>
     <CustomMethodType customMethodTypeId="FIN_RELEASE" parentTypeId="" hasTable="N" description="FIN account release methods"/>
+    <CustomMethodType customMethodTypeId="FIN_PURCHASE" parentTypeId="" hasTable="N" description="FIN account purchase methods"/>
 
     <CustomMethodType customMethodTypeId="GIFT_AUTH" parentTypeId="" hasTable="N" description="GIFT card authorize methods"/>
     <CustomMethodType customMethodTypeId="GIFT_CAPTURE" parentTypeId="" hasTable="N" description="GIFT card capture methods"/>
     <CustomMethodType customMethodTypeId="GIFT_REFUND" parentTypeId="" hasTable="N" description="GIFT card refund methods"/>
     <CustomMethodType customMethodTypeId="GIFT_RELEASE" parentTypeId="" hasTable="N" description="GIFT card release methods"/>
+    <CustomMethodType customMethodTypeId="GIFT_PURCHASE" parentTypeId="" hasTable="N" description="GIFT card purchase methods"/>
 
     <CustomMethodType customMethodTypeId="PAYPAL_AUTH" parentTypeId="" hasTable="N" description="PayPal authorize methods"/>
     <CustomMethodType customMethodTypeId="PAYPAL_CAPTURE" parentTypeId="" hasTable="N" description="PayPal capture methods"/>
@@ -809,6 +811,7 @@ under the License.
     <CustomMethod customMethodId="FIN_CAPTURE_OFBIZ" customMethodTypeId="FIN_CAPTURE" customMethodName="ofbFaCapture" description="FIN account capture"/>
     <CustomMethod customMethodId="FIN_REFUND_OFBIZ" customMethodTypeId="FIN_REFUND" customMethodName="ofbFaRefund" description="FIN account refund"/>
     <CustomMethod customMethodId="FIN_RELEASE_OFBIZ" customMethodTypeId="FIN_RELEASE" customMethodName="ofbFaRelease" description="FIN account release"/>
+    <CustomMethod customMethodId="FIN_PURCH_OFBIZ" customMethodTypeId="FIN_PURCHASE" customMethodName="createPartyFinAccountFromPurchase" description="FIN account purchase"/>
 
     <CustomMethod customMethodId="GIFT_AUTH_OFBIZ" customMethodTypeId="GIFT_AUTH" customMethodName="ofbGcAuthorize" description="GIFT card authorize"/>
     <CustomMethod customMethodId="GIFT_AUTH_ALWAYSAPPR" customMethodTypeId="GIFT_AUTH" customMethodName="alwaysApproveGCProcessor" description="GIFT card always authorize"/>
@@ -820,6 +823,7 @@ under the License.
     <CustomMethod customMethodId="GIFT_RELEASE_OFBIZ" customMethodTypeId="GIFT_RELEASE" customMethodName="ofbGcRelease" description="GIFT card release"/>
     <CustomMethod customMethodId="GIFT_RELEASE_TEST" customMethodTypeId="GIFT_RELEASE" customMethodName="testGCRelease" description="GIFT card test release"/>
     <CustomMethod customMethodId="GIFT_RELEASE_VALUEL" customMethodTypeId="GIFT_RELEASE" customMethodName="valueLinkRelease" description="GIFT card ValueLink release"/>
+    <CustomMethod customMethodId="GIFT_PURCH_OFBIZ" customMethodTypeId="GIFT_PURCHASE" customMethodName="ofbGcPurchase" description="GIFT card Purchase Fulfillment Service"/>
 
     <CustomMethod customMethodId="PAYPAL_AUTH_PFP" customMethodTypeId="PAYPAL_AUTH" customMethodName="payflowPayPalProcessor" description="Payflow PayPal payment authorize"/>
     <CustomMethod customMethodId="PAYPAL_AUTH" customMethodTypeId="PAYPAL_AUTH" customMethodName="payPalProcessor" description="PayPal payment authorize"/>

Modified: ofbiz/trunk/applications/content/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/entitydef/entitymodel.xml?rev=1379937&r1=1379936&r2=1379937&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/content/entitydef/entitymodel.xml Sun Sep  2 09:46:20 2012
@@ -159,7 +159,10 @@ under the License.
       <field name="dataSourceId" type="id"></field>
       <field name="statusId" type="id"></field>
       <field name="privilegeEnumId" type="id"></field>
-      <field name="serviceName" type="long-varchar"></field>
+      <field name="serviceName" type="long-varchar">
+          <description>Deprecated : use customMethod pattern instead of. Kept for backward compatibility</description>
+      </field>
+      <field name="customMethodId" type="id"></field>
       <field name="contentName" type="name"></field>
       <field name="description" type="description"></field>
       <field name="localeString" type="very-short"></field>
@@ -187,6 +190,9 @@ under the License.
       <relation type="one" fk-name="CONTENT_PRIVENM" title="Privilege" rel-entity-name="Enumeration">
         <key-map field-name="privilegeEnumId" rel-field-name="enumId"/>
       </relation>
+      <relation type="one" fk-name="CONTENT_CUSTMET" rel-entity-name="CustomMethod">
+        <key-map field-name="customMethodId"/>
+      </relation>
       <!-- the relationship to MimeType is one-nofk so that you can still do a lookup on MimeType but a new
       and unexpected mime type would not cause a foreign key constraint violation, so MimeType can store the
       most common mime types instead of an exhaustive list of all possible mime types -->

Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/ContentManagementMapProcessors.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/script/org/ofbiz/content/ContentManagementMapProcessors.xml?rev=1379937&r1=1379936&r2=1379937&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/script/org/ofbiz/content/ContentManagementMapProcessors.xml (original)
+++ ofbiz/trunk/applications/content/script/org/ofbiz/content/ContentManagementMapProcessors.xml Sun Sep  2 09:46:20 2012
@@ -27,6 +27,7 @@ under the License.
       <process field="dataResourceId"><copy to-field="dataResourceId" replace="true" set-if-null="false"/></process>
       <process field="dataSourceId"><copy to-field="dataSourceId" replace="true" set-if-null="false"/></process>
       <process field="statusId"><copy to-field="statusId" replace="true" set-if-null="false"/></process>
+      <process field="customMethodId"><copy to-field="customMethodId" replace="true" set-if-null="false"/></process>
       <process field="serviceName"><copy to-field="serviceName" replace="true" set-if-null="false"/></process>
       <process field="contentName"><copy to-field="contentName" replace="true" set-if-null="false"/></process>
       <process field="description"><copy to-field="description" replace="true" set-if-null="false"/></process>
@@ -112,6 +113,7 @@ under the License.
       <process field="dataResourceId"><copy to-field="dataResourceId" replace="true" set-if-null="false"/></process>
       <process field="dataSourceId"><copy to-field="dataSourceId" replace="true" set-if-null="false"/></process>
       <process field="statusId"><copy to-field="statusId" replace="true" set-if-null="false"/></process>
+      <process field="customMethodId"><copy to-field="customMethodId" replace="true" set-if-null="false"/></process>
       <process field="serviceName"><copy to-field="serviceName" replace="true" set-if-null="false"/></process>
       <process field="contentName"><copy to-field="contentName" replace="true" set-if-null="false"/></process>
       <process field="description"><copy to-field="description" replace="true" set-if-null="false"/></process>

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=1379937&r1=1379936&r2=1379937&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 Sun Sep  2 09:46:20 2012
@@ -177,7 +177,12 @@ public class ContentWorker implements or
             Map<String,Object>templateContext, Locale locale, String mimeTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
         // if the content has a service attached run the service
 
-        String serviceName = content.getString("serviceName");
+        String serviceName = content.getString("serviceName"); //Kept for backward compatibility
+        GenericValue custMethod = null;
+        if (UtilValidate.isNotEmpty(content.getString("customMethodId"))) {
+            custMethod = delegator.findOne("CustomMethod", UtilMisc.toMap("customMethodId", content.get("customMethodId")), true);
+        }
+        if (custMethod != null) serviceName = custMethod.getString("customMethodName");
         if (dispatcher != null && UtilValidate.isNotEmpty(serviceName)) {
             DispatchContext dctx = dispatcher.getDispatchContext();
             ModelService service = dctx.getModelService(serviceName);

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1379937&r1=1379936&r2=1379937&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Sun Sep  2 09:46:20 2012
@@ -3337,8 +3337,18 @@ public class OrderServices {
 
                         String fulfillmentType = productContentItem.getString("productContentTypeId");
                         if ("FULFILLMENT_EXTASYNC".equals(fulfillmentType) || "FULFILLMENT_EXTSYNC".equals(fulfillmentType)) {
-                            // enternal service fulfillment
-                            String fulfillmentService = (String) content.get("serviceName");
+                            // external service fulfillment
+                            String fulfillmentService = (String) content.get("serviceName"); // Kept for backward compatibility
+                            GenericValue custMethod = null;
+                            if (UtilValidate.isNotEmpty(content.getString("customMethodId"))) {
+                                try {
+                                    custMethod = delegator.findOne("CustomMethod", UtilMisc.toMap("customMethodId", content.get("customMethodId")), true);
+                                } catch (GenericEntityException e) {
+                                    Debug.logError(e,"ERROR: Cannot get CustomMethod associate to Content entity: " + e.getMessage(),module);
+                                    continue;
+                                }
+                            }
+                            if (custMethod != null) fulfillmentService = custMethod.getString("customMethodName");
                             if (fulfillmentService == null) {
                                 Debug.logError("ProductContent of type FULFILLMENT_EXTERNAL had Content with empty serviceName, can not run fulfillment", module);
                             }

Modified: ofbiz/trunk/specialpurpose/ecommerce/data/DemoFinAccount.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/data/DemoFinAccount.xml?rev=1379937&r1=1379936&r2=1379937&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/data/DemoFinAccount.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/data/DemoFinAccount.xml Sun Sep  2 09:46:20 2012
@@ -83,7 +83,7 @@
     <ProductStoreSurveyAppl productStoreSurveyId="1100" productStoreId="9000" surveyApplTypeId="CART_ADD" surveyId="1100" productId="FA-001" fromDate="2003-11-24 16:00:02.467" surveyTemplate="/applications/content/template/survey/genericsurvey.ftl" lastUpdatedStamp="2003-12-04 21:40:23.27" lastUpdatedTxStamp="2003-12-04 21:40:20.607"/>
 
     <!-- fulfillment service -->
-    <Content contentId="FA_ACTIVATION" serviceName="createPartyFinAccountFromPurchase"/>
+    <Content contentId="FA_ACTIVATION" customMethodId="FIN_PURCH_OFBIZ"/>
 
     <!-- associate the fulfillment service with the products -->
     <ProductContent productId="FA-001" contentId="FA_ACTIVATION" productContentTypeId="FULFILLMENT_EXTASYNC" fromDate="2000-01-01 00:00:00"/>

Modified: ofbiz/trunk/specialpurpose/ecommerce/data/DemoStoreGiftCertificateSettings.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/data/DemoStoreGiftCertificateSettings.xml?rev=1379937&r1=1379936&r2=1379937&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/data/DemoStoreGiftCertificateSettings.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/data/DemoStoreGiftCertificateSettings.xml Sun Sep  2 09:46:20 2012
@@ -25,7 +25,7 @@ under the License.
         purchaseSurveyId="1000" purchSurveySendTo="recipientEmail" purchSurveyCopyMe="copyMe" accountCodeLength="12" pinCodeLength="4" accountValidDays="365" authValidDays="30"/>
 
     <!-- service for purchasing gift certificate configured as a Content and to be associated with products -->
-    <Content contentId="GC_PURCHASE" serviceName="ofbGcPurchase"/>
+    <Content contentId="GC_PURCHASE" customMethodId="GIFT_PURCH_OFBIZ"/>
 
     <!-- associate gift certificate purchase fulfillment services with products.  virtual products ok.  MUST be async fulfillment -
         synchronous fulfillment can cause database lock problems -->