svn commit: r993395 - in /ofbiz/trunk/applications/content: config/ script/org/ofbiz/content/data/ servicedef/ webapp/content/WEB-INF/ widget/content/

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

svn commit: r993395 - in /ofbiz/trunk/applications/content: config/ script/org/ofbiz/content/data/ servicedef/ webapp/content/WEB-INF/ widget/content/

erwan
Author: erwan
Date: Tue Sep  7 15:30:21 2010
New Revision: 993395

URL: http://svn.apache.org/viewvc?rev=993395&view=rev
Log:
OFBIZ-3647 Create dataResource from content -- A patch from Nicolas Malin -- https://issues.apache.org/jira/browse/OFBIZ-3647

Modified:
    ofbiz/trunk/applications/content/config/ContentUiLabels.xml
    ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml
    ofbiz/trunk/applications/content/servicedef/services_data.xml
    ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml
    ofbiz/trunk/applications/content/widget/content/ContentForms.xml
    ofbiz/trunk/applications/content/widget/content/DataResourceForms.xml
    ofbiz/trunk/applications/content/widget/content/DataResourceScreens.xml

Modified: ofbiz/trunk/applications/content/config/ContentUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/config/ContentUiLabels.xml?rev=993395&r1=993394&r2=993395&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/config/ContentUiLabels.xml (original)
+++ ofbiz/trunk/applications/content/config/ContentUiLabels.xml Tue Sep  7 15:30:21 2010
@@ -3724,6 +3724,10 @@
         <value xml:lang="th">เพิ่มแหล่งที่มาของข้อมูล</value>
         <value xml:lang="zh">新建数据资源</value>
     </property>
+    <property key="PageTitleAddDataResourceFromContent">
+        <value xml:lang="en">Add DataResource From Content</value>
+        <value xml:lang="fr">Ajouter une ressource de données pour un contenu</value>
+    </property>
     <property key="PageTitleAddDataResourceText">
         <value xml:lang="ar">إضافة نص مورد معلومات</value>
         <value xml:lang="da">Tilføj dataressource tekst</value>

Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml?rev=993395&r1=993394&r2=993395&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml (original)
+++ ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml Tue Sep  7 15:30:21 2010
@@ -75,6 +75,29 @@ under the License.
         <entity-one entity-name="DataResource" value-field="lookedUpValue"/>
         <remove-value value-field="lookedUpValue"/>
     </simple-method>
+    
+    <simple-method method-name="createDataResourceAndAssocToContent" short-description="Create a Data Resource and return the data resource type">
+       <entity-one value-field="content" entity-name="Content"/>
+       <if-empty field="content"><add-error><fail-message message="${layoutEvents.content_empty}"/></add-error><check-errors/></if-empty>
+  
+       <set-service-fields service-name="createDataResource" to-map="dataResourceCtx" map="parameters"/>
+       <call-service service-name="createDataResource" in-map-name="dataResourceCtx">
+           <result-to-field result-name="dataResource"/>
+       </call-service>
+
+       <if-compare field="parameters.templateDataResource" operator="equals" value="Y">
+           <set field="contentCtx.templateDataResourceId" from-field="parameters.dataResourceId" />
+           <else>
+               <set field="contentCtx.dataResourceId" from-field="parameters.dataResourceId" />
+           </else>
+       </if-compare>
+       <set field="contentCtx.contentId" from-field="parameters.contentId"/>
+       <call-service service-name="updateContent" in-map-name="contentCtx"/>
+      
+       <field-to-result field="parameters.contentId" result-name="contentId"/>      
+       <if-compare field="dataResource.dataResourceTypeId" operator="equals" value="ELECTRONIC_TEXT"><return response-code="${dataResource.dataResourceTypeId}"/></if-compare>
+       <if-compare field="dataResource.dataResourceTypeId" operator="equals" value="IMAGE_OBJECT"><return response-code="${dataResource.dataResourceTypeId}"/></if-compare>      
+    </simple-method>
 
   <!-- Methods for DataCategory -->
     <simple-method method-name="createDataCategory" short-description="Create a Data Category">

Modified: ofbiz/trunk/applications/content/servicedef/services_data.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services_data.xml?rev=993395&r1=993394&r2=993395&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services_data.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services_data.xml Tue Sep  7 15:30:21 2010
@@ -38,6 +38,14 @@
         <attribute name="dataResource" type="org.ofbiz.entity.GenericValue" mode="OUT" optional="true"/>
         <override name="objectInfo" allow-html="safe"/>
     </service>
+    <service name="createDataResourceAndAssocToContent" default-entity-name="DataResource" engine="simple"
+            location="component://content/script/org/ofbiz/content/data/DataServices.xml" invoke="createDataResourceAndAssocToContent" auth="true">
+        <description>Create a DataResource and link this data to the content present</description>
+        <permission-service service-name="genericDataResourcePermission" main-action="CREATE"/>
+        <implements service="createDataResource" optional="true"/>
+        <attribute name="contentId" type="String" mode="INOUT" optional="false"/>
+        <attribute name="templateDataResource" type="String" mode="IN" optional="true"/>
+    </service>
     <service name="updateDataResource" engine="simple" default-entity-name="DataResource" auth="true"
             location="component://content/script/org/ofbiz/content/data/DataServices.xml" invoke="updateDataResource">
         <description>Update a DataResource</description>

Modified: ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml?rev=993395&r1=993394&r2=993395&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml Tue Sep  7 15:30:21 2010
@@ -942,6 +942,7 @@ under the License.
     <request-map uri="AddDataResourceText"><security auth="true" https="true"/><response name="success" type="view" value="AddDataResourceText"/></request-map>
     <request-map uri="AddDataResourceUrl"><security auth="true" https="true"/><response name="success" type="view" value="EditDataResourceUrl"/></request-map>
     <request-map uri="AddDataResourceUpload"><security auth="true" https="true"/><response name="success" type="view" value="AddDataResourceUpload"/></request-map>
+    <request-map uri="AddDataResourceFromContent"><security auth="true" https="true"/><response name="success" type="view" value="AddDataResourceFromContent"/></request-map>
     <request-map uri="updateDataResourceText">
         <security auth="true" https="true"/>
         <event invoke="updateDataResource" path="" type="service"/>
@@ -962,6 +963,14 @@ under the License.
         <response name="IMAGE_OBJECT" type="view" value="UploadImage"/>
         <response name="error" type="view" value="AddDataResource"/>
     </request-map>
+    <request-map uri="createDataResourceAndAssocToContent">
+        <security auth="true" https="true"/>
+        <event invoke="createDataResourceAndAssocToContent" path="" type="service"/>
+        <response name="success" type="view" value="EditContent"/>
+        <response name="ELECTRONIC_TEXT" type="view" value="EditElectronicText"/>
+        <response name="IMAGE_OBJECT" type="view" value="UploadImage"/>
+        <response name="error" type="view" value="AddDataResourceFromContent"/>
+    </request-map>
     <request-map uri="createDataResourceUpload">
         <security auth="true" https="true"/>
         <event invoke="createDataResource" path="" type="service"/>
@@ -1882,6 +1891,7 @@ under the License.
     <view-map name="AddDataResourceText"  page="component://content/widget/content/DataResourceScreens.xml#AddDataResourceText" type="screen"/>
     <view-map name="AddDataResourceUrl"  page="component://content/widget/content/DataResourceScreens.xml#AddDataResourceUrl" type="screen"/>
     <view-map name="AddDataResourceUpload"  page="component://content/widget/content/DataResourceScreens.xml#AddDataResourceUpload" type="screen"/>
+    <view-map name="AddDataResourceFromContent"  page="component://content/widget/content/DataResourceScreens.xml#AddDataResourceFromContent" type="screen"/>
     <view-map name="EditDataResourceText"  page="component://content/widget/content/DataResourceScreens.xml#EditDataResourceText" type="screen"/>
     <view-map name="EditDataResourceUrl"  page="component://content/widget/content/DataResourceScreens.xml#EditDataResourceUrl" type="screen"/>
     <view-map name="EditDataResourceUpload"  page="component://content/widget/content/DataResourceScreens.xml#EditDataResourceUpload" type="screen"/>

Modified: ofbiz/trunk/applications/content/widget/content/ContentForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/widget/content/ContentForms.xml?rev=993395&r1=993394&r2=993395&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/widget/content/ContentForms.xml (original)
+++ ofbiz/trunk/applications/content/widget/content/ContentForms.xml Tue Sep  7 15:30:21 2010
@@ -137,6 +137,8 @@ under the License.
             <entity-one entity-name="StatusItem" value-field="currentStatus" auto-field-map="false">
                 <field-map field-name="statusId" from-field="currentValue.statusId"/>
             </entity-one>
+            <set field="dataResourceId" from-field="currentValue.dataResourceId"/>
+            <set field="templateDataResourceId" from-field="currentValue.templateDataResourceId"/>
         </actions>
         <alt-target use-when="currentValue==null" target="createContent"/>
         <auto-fields-entity entity-name="Content"/>
@@ -150,20 +152,36 @@ under the License.
                 </entity-options>
             </drop-down>
         </field>
-        <field name="dataResourceId">
+        <field name="dataResourceId" use-when="dataResourceId != null">
             <lookup target-form-name="LookupDataResource">
                 <sub-hyperlink link-style="buttontext" target="EditDataResource" description="${uiLabelMap.ContentGoToDataResource}">
                     <parameter param-name="dataResourceId" from-field="currentValue.dataResourceId"/>
                 </sub-hyperlink>
             </lookup>
         </field>
-        <field name="templateDataResourceId">
+        <field name="dataResourceId" use-when="dataResourceId == null ">
+            <lookup target-form-name="LookupDataResource">
+                <sub-hyperlink link-style="buttontext" target="AddDataResourceFromContent" description="${uiLabelMap.FormFieldTitle_newDataResourceId}">
+                    <parameter param-name="contentId" from-field="currentValue.contentId"/>
+                    <parameter param-name="template" value="N"/>
+                </sub-hyperlink>
+            </lookup>
+        </field>
+        <field name="templateDataResourceId" use-when="templateDataResourceId != null">
             <lookup target-form-name="LookupDataResource">
                 <sub-hyperlink link-style="buttontext" target="EditDataResource" description="${uiLabelMap.ContentGoToDataResource}">
                     <parameter param-name="dataResourceId" from-field="currentValue.templateDataResourceId"/>
                 </sub-hyperlink>
             </lookup>
         </field>
+        <field name="templateDataResourceId"  use-when="templateDataResourceId == null">
+            <lookup target-form-name="LookupDataResource">
+                <sub-hyperlink link-style="buttontext" target="AddDataResourceFromContent"  description="${uiLabelMap.FormFieldTitle_newDataResourceId}">
+                    <parameter param-name="contentId" from-field="currentValue.contentId"/>
+                    <parameter param-name="templateDataResource" value="Y"/>
+                </sub-hyperlink>
+            </lookup>
+        </field>
         <field name="ownerContentId"><lookup target-form-name="LookupContent"/></field>
         <field name="decoratorContentId">
             <lookup target-form-name="LookupContent">

Modified: ofbiz/trunk/applications/content/widget/content/DataResourceForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/widget/content/DataResourceForms.xml?rev=993395&r1=993394&r2=993395&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/widget/content/DataResourceForms.xml (original)
+++ ofbiz/trunk/applications/content/widget/content/DataResourceForms.xml Tue Sep  7 15:30:21 2010
@@ -206,6 +206,12 @@ under the License.
         <field name="createButton" title="${uiLabelMap.CommonCreate}" use-when="currentValue==null" widget-style="smallSubmit"><submit button-type="button"/></field>
         <field name="updateButton" title="${uiLabelMap.CommonUpdate}" use-when="currentValue!=null" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
+
+    <form name="AddDataResourceFromContent" extends="AddDataResource" target="createDataResourceAndAssocToContent" >
+        <field name="contentId"><hidden value="${parameters.contentId}"/></field>
+        <field name="templateDataResource"><hidden value="${parameters.templateDataResource}"/></field>
+    </form>
+    
     <form name="ListContentsAssociatedToDataResource" type="list" list-name="contentRecords" default-widget-style="display"
         odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
         <actions>

Modified: ofbiz/trunk/applications/content/widget/content/DataResourceScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/widget/content/DataResourceScreens.xml?rev=993395&r1=993394&r2=993395&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/widget/content/DataResourceScreens.xml (original)
+++ ofbiz/trunk/applications/content/widget/content/DataResourceScreens.xml Tue Sep  7 15:30:21 2010
@@ -288,6 +288,23 @@ under the License.
             </widgets>
         </section>
     </screen>
+    <screen name="AddDataResourceFromContent">
+        <section>
+            <actions>
+                <set field="titleProperty" value="PageTitleAddDataResourceFromContent"/>
+                <set field="labelTitleProperty" value="PageTitleAddDataResourceFromContent"/>
+                <set field="headerItem" value="DataResource"/>
+                <set field="tabButtonItem" value="adddataresource"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="commonDataResourceDecorator" location="${parameters.mainDecoratorLocation}">
+                    <decorator-section name="body">
+                        <include-form name="AddDataResourceFromContent" location="component://content/widget/content/DataResourceForms.xml"/>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
     <screen name="EditDataResourceText">
         <section>
             <actions>