Author: jaz
Date: Tue Feb 27 16:06:26 2007 New Revision: 512510 URL: http://svn.apache.org/viewvc?view=rev&rev=512510 Log: now have update uploaded content working; updates all necessary entities; added a few text based ecas for text content; handles many different text based data resource types now Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml ofbiz/trunk/applications/content/servicedef/secas.xml ofbiz/trunk/applications/content/servicedef/services_content.xml 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?view=diff&rev=512510&r1=512509&r2=512510 ============================================================================== --- ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml (original) +++ ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml Tue Feb 27 16:06:26 2007 @@ -516,9 +516,9 @@ <log level="always" message="result:${result}"/> <log level="always" message="parameters:${parameters}"/> </simple-method> - - <!-- Determines which type of uploaded file this is and calls the proper method --> + <simple-method method-name="attachUploadToDataResource" short-description="Attach an uploaded file to a data resource"> + <set field="isUpdate" value="false"/> <if-empty field-name="parameters.dataResourceTypeId"> <!-- create default behavior --> <if> @@ -568,21 +568,45 @@ </if-compare> <if-compare field-name="parameters.dataResourceTypeId" value="IMAGE_OBJECT" operator="equals"> + <entity-one entity-name="ImageDataResource" value-name="dataResObj"> + <field-map field-name="dataResourceId" env-name="parameters.dataResourceId"/> + </entity-one> + <if-not-empty field-name="dataResObj"> + <set field="isUpdate" value="true"/> + </if-not-empty> <call-simple-method method-name="saveImageObjectDateResource"/> <return/> </if-compare> <if-compare field-name="parameters.dataResourceTypeId" value="VIDEO_OBJECT" operator="equals"> - <call-simple-method method-name="saveImageObjectDateResource"/> + <entity-one entity-name="VideoDataResource" value-name="dataResObj"> + <field-map field-name="dataResourceId" env-name="parameters.dataResourceId"/> + </entity-one> + <if-not-empty field-name="dataResObj"> + <set field="isUpdate" value="true"/> + </if-not-empty> + <call-simple-method method-name="saveVideoObjectDateResource"/> <return/> </if-compare> <if-compare field-name="parameters.dataResourceTypeId" value="AUDIO_OBJECT" operator="equals"> - <call-simple-method method-name="saveImageObjectDateResource"/> + <entity-one entity-name="AudioDataResource" value-name="dataResObj"> + <field-map field-name="dataResourceId" env-name="parameters.dataResourceId"/> + </entity-one> + <if-not-empty field-name="dataResObj"> + <set field="isUpdate" value="true"/> + </if-not-empty> + <call-simple-method method-name="saveAudioObjectDateResource"/> <return/> </if-compare> <if-compare field-name="parameters.dataResourceTypeId" value="OTHER_OBJECT" operator="equals"> + <entity-one entity-name="OtherDataResource" value-name="dataResObj"> + <field-map field-name="dataResourceId" env-name="parameters.dataResourceId"/> + </entity-one> + <if-not-empty field-name="dataResObj"> + <set field="isUpdate" value="true"/> + </if-not-empty> <call-simple-method method-name="saveOtherObjectDateResource"/> <return/> </if-compare> @@ -649,8 +673,14 @@ <!-- fields serviceName and fileField are required to be set by calling method --> <set-service-fields service-name="createOtherDataResource" map-name="dataResource" to-map-name="serviceContext"/> - <set from-field="parameters.uploadedFile" field="serviceContext.dataResourceContent"/> - <call-service service-name="createOtherDataResource" in-map-name="serviceContext"/> + <set from-field="parameters.uploadedFile" field="serviceContext.dataResourceContent"/> + + <if-compare field-name="isUpdate" value="true" operator="equals"> + <call-service service-name="updateOtherDataResource" in-map-name="serviceContext"/> + <else> + <call-service service-name="createOtherDataResource" in-map-name="serviceContext"/> + </else> + </if-compare> <field-to-result field-name="dataResourceId" map-name="dataResource"/> </simple-method> @@ -676,8 +706,14 @@ <!-- fields serviceName and fileField are required to be set by calling method --> <set-service-fields service-name="createImageDataResource" map-name="dataResource" to-map-name="serviceContext"/> - <set from-field="parameters.uploadedFile" field="serviceContext.imageData"/> - <call-service service-name="createImageDataResource" in-map-name="serviceContext"/> + <set from-field="parameters.uploadedFile" field="serviceContext.imageData"/> + + <if-compare field-name="isUpdate" value="true" operator="equals"> + <call-service service-name="updateImageDataResource" in-map-name="serviceContext"/> + <else> + <call-service service-name="createImageDataResource" in-map-name="serviceContext"/> + </else> + </if-compare> <field-to-result field-name="dataResourceId" map-name="dataResource"/> </simple-method> @@ -704,7 +740,13 @@ <!-- fields serviceName and fileField are required to be set by calling method --> <set-service-fields service-name="createVideoDataResource" map-name="dataResource" to-map-name="serviceContext"/> <set from-field="parameters.uploadedFile" field="serviceContext.videoData"/> - <call-service service-name="createVideoDataResource" in-map-name="serviceContext"/> + + <if-compare field-name="isUpdate" value="true" operator="equals"> + <call-service service-name="updateVideoDataResource" in-map-name="serviceContext"/> + <else> + <call-service service-name="createVideoDataResource" in-map-name="serviceContext"/> + </else> + </if-compare> <field-to-result field-name="dataResourceId" map-name="dataResource"/> </simple-method> @@ -731,7 +773,13 @@ <!-- fields serviceName and fileField are required to be set by calling method --> <set-service-fields service-name="createAudioDataResource" map-name="dataResource" to-map-name="serviceContext"/> <set from-field="parameters.uploadedFile" field="serviceContext.audioData"/> - <call-service service-name="createAudioDataResource" in-map-name="serviceContext"/> + + <if-compare field-name="isUpdate" value="true" operator="equals"> + <call-service service-name="updateAudioDataResource" in-map-name="serviceContext"/> + <else> + <call-service service-name="createAudioDataResource" in-map-name="serviceContext"/> + </else> + </if-compare> <field-to-result field-name="dataResourceId" map-name="dataResource"/> </simple-method> Modified: ofbiz/trunk/applications/content/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/secas.xml?view=diff&rev=512510&r1=512509&r2=512510 ============================================================================== --- ofbiz/trunk/applications/content/servicedef/secas.xml (original) +++ ofbiz/trunk/applications/content/servicedef/secas.xml Tue Feb 27 16:06:26 2007 @@ -77,8 +77,21 @@ <action service="createElectronicText" mode="sync" result-to-context="true"/> </eca> <eca service="createDataText" event="invoke"> - <condition field-name="dataResourceTypeId" operator="not-equals" value="ELECTRONIC_TEXT"/> + <condition field-name="dataResourceTypeId" operator="is-empty"/> + <condition field-name="textData" operator="is-not-empty"/> + <set field-name="dataResourceTypeId" value="ELECTRONIC_TEXT"/> + <action service="createElectronicText" mode="sync" result-to-context="true"/> + </eca> + <eca service="createDataText" event="invoke"> + <condition field-name="dataResourceTypeId" operator="is-empty"/> + <condition field-name="textData" operator="is-empty"/> <set field-name="dataResourceTypeId" value="SHORT_TEXT"/> + <action service="createDataResource" mode="sync" result-to-context="true"/> + </eca> + <eca service="createDataText" event="invoke"> + <condition field-name="dataResourceTypeId" operator="not-equals" value="ELECTRONIC_TEXT"/> + <condition field-name="dataResourceTypeId" operator="is-not-empty"/> + <condition field-name="textData" operator="is-empty"/> <action service="createDataResource" mode="sync" result-to-context="true"/> </eca> <eca service="updateDataText" event="invoke"> Modified: ofbiz/trunk/applications/content/servicedef/services_content.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services_content.xml?view=diff&rev=512510&r1=512509&r2=512510 ============================================================================== --- ofbiz/trunk/applications/content/servicedef/services_content.xml (original) +++ ofbiz/trunk/applications/content/servicedef/services_content.xml Tue Feb 27 16:06:26 2007 @@ -66,7 +66,7 @@ <attribute name="contentId" type="String" mode="OUT" optional="false"/> </service> - <service name="uploadFileToDataResource" engine="simple" transaction-timeout="300" + <service name="attachUploadToDataResource" engine="simple" transaction-timeout="300" location="org/ofbiz/content/data/DataServices.xml" invoke="attachUploadToDataResource"> <description>Accepts uploaded content and attaches to an existing data resource</description> <!-- uses createContent internally; additonal permission(s) not necessary --> @@ -79,8 +79,17 @@ <!-- uses createContent internally; additonal permission(s) not necessary --> <group> <invoke name="createDataResource" parameters="preserve" result-to-context="true"/> - <invoke name="uploadFileToDataResource" parameters="preserve" result-to-context="true"/> + <invoke name="attachUploadToDataResource" parameters="preserve" result-to-context="true"/> <invoke name="createContentFromDataResource"/> + </group> + </service> + + <service name="updateContentAndUploadedFile" engine="group" transaction-timeout="300"> + <description>Accepts file upload, updates DataResource and Content records.</description> + <group> + <invoke name="updateDataResource" parameters="preserve" result-to-context="true"/> + <invoke name="attachUploadToDataResource" parameters="preserve" result-to-context="true"/> + <invoke name="updateContent"/> </group> </service> |
Free forum by Nabble | Edit this page |