Why can't we use both? What happens to users who are using the serviceName field? Is there a migration service?

-Adrian

On 8/31/2012 10:55 AM, jler...@apache.org wrote:
Author: jleroux
Date: Fri Aug 31 09:55:34 2012
New Revision: 1379389

URL: http://svn.apache.org/viewvc?rev=1379389&view=rev
Log:
A 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 renamed to oldServiceName field for backward compatibility


Modified:
     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

Modified: ofbiz/trunk/applications/content/entitydef/entitymodel.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/entitydef/entitymodel.xml?rev=1379389&r1=1379388&r2=1379389&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/content/entitydef/entitymodel.xml Fri Aug 31 
09:55:34 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="oldServiceName" type="long-varchar" col-name="service_name">
+          <description>Deprecated : use customMethod pattern instead of. Keep 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=1379389&r1=1379388&r2=1379389&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/content/script/org/ofbiz/content/ContentManagementMapProcessors.xml
 (original)
+++ 
ofbiz/trunk/applications/content/script/org/ofbiz/content/ContentManagementMapProcessors.xml
 Fri Aug 31 09:55:34 2012
@@ -27,7 +27,8 @@ 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="serviceName"><copy to-field="serviceName" replace="true" 
set-if-null="false"/></process>
+      <process field="customMethodId"><copy to-field="customMethodId" replace="true" 
set-if-null="false"/></process>
+      <process field="oldServiceName"><copy to-field="oldServiceName" 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>
        <process field="localeString"><copy to-field="localeString" replace="true" 
set-if-null="false"/></process>
@@ -112,7 +113,8 @@ 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="serviceName"><copy to-field="serviceName" replace="true" 
set-if-null="false"/></process>
+      <process field="customMethodId"><copy to-field="customMethodId" replace="true" 
set-if-null="false"/></process>
+      <process field="oldServiceName"><copy to-field="oldServiceName" 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>
        <process field="localeString"><copy to-field="localeString" 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=1379389&r1=1379388&r2=1379389&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
 Fri Aug 31 09:55:34 2012
@@ -177,7 +177,10 @@ 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");
+        //search serviceName to call on associate customMethod and if empty 
get value from old serviceName  field
+        String serviceName = content.getString("oldServiceName");
+        GenericValue custMethod = content.getRelatedOne("CustomMethod", true);
+        if (custMethod != null) serviceName = 
custMethod.getString("customMethodName");
          if (dispatcher != null && UtilValidate.isNotEmpty(serviceName)) {
              DispatchContext dctx = dispatcher.getDispatchContext();
              ModelService service = dctx.getModelService(serviceName);



Reply via email to