Le 03/09/2012 08:27, Jacques Le Roux a écrit :
Also I wanted to remove these sentences in this section
https://cwiki.apache.org/confluence/display/OFBTECH/General+Entity+Overview#GeneralEntityOverview-DeprecatedEntities

<<change the original first letter to upper case, and specify the column-name for the field so it is the same as the original field name. For example if you are changing the "uomId" field to a new name then change the field name to "oldUomId" and specify a column-name of "UOM_ID".

In other words from
<<When changing the name of a field, or deprecating and replacing a field that does not require deprecation of the entire entity, then follow the same pattern leaving the old field there: a "old" prefix added to the field name, change the original first letter to upper case, and specify the column-name for the field so it is the same as the original field name. For example if you are changing the "uomId" field to a new name then change the field name to "oldUomId" and specify a column-name of "UOM_ID". Just as when replacing and entity, make sure to write a service to move the data from the old field to the new one.>>
to
<<When changing the name of a field, or deprecating and replacing a field that does not require deprecation of the entire entity, then follow the same pattern leaving the old field there: a "old" prefix added to the field name, change the original first letter to upper case. For example if you are changing the "uomId" field to a new name then change the field name to "oldUomId". Just as when replacing and entity, make sure to write a service to move the data from the old field to the new one.>>
Just to create the service. With col-name attribut all migration works with simple service since entity-engine link the old column. Without this deprecated method, it would be interesting to give the Best Pratice of "How move a data not connect on entity-engine by a service". If is only by sql sentence "make sure to write a service to move the data from the old field to the new one." sounds wrong.

Nicolas


It seems that this way of doing has not been used since the Apache era. But I'd like to be sure we are not missing something.

Opinions?

Jacques

From: "Adrian Crum" <[email protected]>
This looks better, but I don't like the deprecation note in serviceName field description. There is no need to deprecate the
field - some developers might PREFER to use a service.

-Adrian

On 9/2/2012 10:46 AM, [email protected] wrote:
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 -->




Reply via email to