svn commit: r766293 - in /ofbiz/trunk: applications/content/script/org/ofbiz/content/survey/SurveyServices.xml applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java specialpurpose/ecommerce/templates/survey/genericresult.ftl

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

svn commit: r766293 - in /ofbiz/trunk: applications/content/script/org/ofbiz/content/survey/SurveyServices.xml applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java specialpurpose/ecommerce/templates/survey/genericresult.ftl

ashish-18
Author: ashish
Date: Sat Apr 18 10:40:40 2009
New Revision: 766293

URL: http://svn.apache.org/viewvc?rev=766293&view=rev
Log:
Applied patch from Jira issue OFBIZ-1901 (Class cast exception on doing survey [ take survey ] on Customer Profile).

Framework part has been committed by Jacopo and here is the code snippet changes in applications & special purpose.

Thanks to Vikas Mayur for working on framework part.

Modified:
    ofbiz/trunk/applications/content/script/org/ofbiz/content/survey/SurveyServices.xml
    ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java
    ofbiz/trunk/specialpurpose/ecommerce/templates/survey/genericresult.ftl

Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/survey/SurveyServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/script/org/ofbiz/content/survey/SurveyServices.xml?rev=766293&r1=766292&r2=766293&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/script/org/ofbiz/content/survey/SurveyServices.xml (original)
+++ ofbiz/trunk/applications/content/script/org/ofbiz/content/survey/SurveyServices.xml Sat Apr 18 10:40:40 2009
@@ -438,7 +438,6 @@
                 </if-not-empty>
             </if-not-empty>
         </if-compare>
-
         <!-- make sure we have answers to check -->
         <if-empty field="parameters.answers">
             <add-error><fail-message message="No answers were found"/></add-error>
@@ -721,14 +720,43 @@
                 <set field="responseAnswer.textResponse" from-field="answers[&quot;${currentFieldName}&quot;]"/>
             </if-compare>
             <if-compare field="surveyQuestionAndAppl.surveyQuestionTypeId" operator="equals" value="CONTENT">
-                <!-- <log level="always" message="Found CONTENT type question"/> -->
                 <if-instance-of field="answers[&quot;${currentFieldName}&quot;]" class="java.nio.ByteBuffer">
-                    <set from-field="answers._${surveyQuestionAndAppl.surveyQuestionId}_contentType" field="partyContent._uploadedFile_contentType"/>
+                    <!--set from-field="answers._${surveyQuestionAndAppl.surveyQuestionId}_contentType" field="partyContent._uploadedFile_contentType"/>
                     <set from-field="answers._${surveyQuestionAndAppl.surveyQuestionId}_fileName" field="partyContent._uploadedFile_fileName"/>
                     <set from-field="answers[&quot;${currentFieldName}&quot;]" field="partyContent.uploadedFile"/>
                     <set value="DOCUMENT" field="partyContent.contentTypeId"/>
                     <set value="PERSONAL" field="partyContent.dataCategoryId"/>
-                    <set value="CTNT_PUBLISHED" field="partyContent.statusId"/>
+                    <set value="CTNT_PUBLISHED" field="partyContent.statusId"/-->
+                    
+                    <!--  First create the Content record -->
+                    <make-value entity-name="Content" value-field="content"/>
+                    <sequenced-id field="content.contentId" sequence-name="Content"/>
+                    <set field="content.contentTypeId" value="DOCUMENT"/>
+                    <set field="content.statusId" value="CTNT_PUBLISHED" />
+                    <create-value value-field="content"/>
+                    
+                    <!-- Create the DataResource record -->
+                    <set field="dataResource.dataResourceTypeId" value="IMAGE_OBJECT"/>
+                    <set field="dataResource.mimeTypeId" from-field="answers._${surveyQuestionAndAppl.surveyQuestionId}_contentType"/>
+                    <set field="dataResource.objectInfo" from-field="answers._${surveyQuestionAndAppl.surveyQuestionId}_fileName"/>
+                    
+                    <call-service service-name="createDataResource" in-map-name="dataResource">
+                        <result-to-field result-name="dataResourceId"/>
+                    </call-service>
+                    
+                    <!-- Create the ImageDataResource record -->
+                    <set field="imageDataResource.dataResourceId" from-field="dataResourceId"/>
+                    <set field="imageDataResource.imageData" from-field="answers[&quot;${currentFieldName}&quot;]"/>
+                    <call-service service-name="createImageDataResource" in-map-name="imageDataResource"/>                    
+                    
+                    <!-- Associate the DataResource with the Content record -->
+                    <set field="content.dataResourceId" from-field="dataResourceId"/>
+                    <store-value value-field="content"/>
+                    
+                    <set field="partyContent.partyId" from-field="parameters.partyId"/>
+                    <set field="partyContent.contentId" from-field="content.contentId"/>
+                    <set field="partyContent.partyContentTypeId" value="INTERNAL"/>
+                    <set field="partyContent.fromDate" from-field="nowTimestamp"/>
                     <call-service service-name="createPartyContent" in-map-name="partyContent">
                         <result-to-field result-name="contentId" field="responseAnswer.contentId"/>
                     </call-service>

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java?rev=766293&r1=766292&r2=766293&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java Sat Apr 18 10:40:40 2009
@@ -27,6 +27,7 @@
 import java.net.URL;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javolution.util.FastList;
@@ -205,6 +206,7 @@
         templateContext.put("additionalFields", passThru);
         templateContext.put("defaultValues", defaultValues);
         templateContext.put("delegator", this.delegator);
+        templateContext.put("locale", Locale.getDefault());
 
         Template template = this.getTemplate(templateUrl);
         try {

Modified: ofbiz/trunk/specialpurpose/ecommerce/templates/survey/genericresult.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/templates/survey/genericresult.ftl?rev=766293&r1=766292&r2=766293&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/templates/survey/genericresult.ftl (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/templates/survey/genericresult.ftl Sat Apr 18 10:40:40 2009
@@ -17,6 +17,8 @@
 under the License.
 -->
 
+<#assign uiLabelMap = Static["org.ofbiz.base.util.UtilProperties"].getResourceBundleMap("CommonUiLabels", locale)>
+
 <h1>${survey.description?if_exists}</h1>
 <br/>