svn commit: r1292661 - in /ofbiz/trunk/applications: party/data/ product/config/ product/data/ product/script/org/ofbiz/product/imagemanagement/ product/src/org/ofbiz/product/imagemanagement/ product/widget/catalog/

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

svn commit: r1292661 - in /ofbiz/trunk/applications: party/data/ product/config/ product/data/ product/script/org/ofbiz/product/imagemanagement/ product/src/org/ofbiz/product/imagemanagement/ product/widget/catalog/

hansbak-2
Author: hansbak
Date: Thu Feb 23 06:38:38 2012
New Revision: 1292661

URL: http://svn.apache.org/viewvc?rev=1292661&view=rev
Log:
auto approve image function in catalog image management

Modified:
    ofbiz/trunk/applications/party/data/PartyDemoData.xml
    ofbiz/trunk/applications/product/config/catalog.properties
    ofbiz/trunk/applications/product/data/ProductDemoData.xml
    ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
    ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml

Modified: ofbiz/trunk/applications/party/data/PartyDemoData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/data/PartyDemoData.xml?rev=1292661&r1=1292660&r2=1292661&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/data/PartyDemoData.xml (original)
+++ ofbiz/trunk/applications/party/data/PartyDemoData.xml Thu Feb 23 06:38:38 2012
@@ -24,7 +24,6 @@
     <Party partyId="Company"/>
     <Party partyId="DemoEmployee"/>
     <PartyRole partyId="admin" roleTypeId="EMAIL_ADMIN"/>
-    <PartyRole partyId="admin" roleTypeId="IMAGEAPPROVER"/>
     <PartyRole partyId="Company" roleTypeId="_NA_"/>
     <PartyRelationship partyIdFrom="admin" roleTypeIdFrom="EMAIL_ADMIN" partyIdTo="Company" roleTypeIdTo="_NA_" fromDate="2000-01-01 00:00:00"/>
     <PartyRole partyId="DemoEmployee" roleTypeId="EMAIL_ADMIN"/>

Modified: ofbiz/trunk/applications/product/config/catalog.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/catalog.properties?rev=1292661&r1=1292660&r2=1292661&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/catalog.properties (original)
+++ ofbiz/trunk/applications/product/config/catalog.properties Thu Feb 23 06:38:38 2012
@@ -39,3 +39,5 @@ reactivate.product.from.receipt=Y
 image.management.path=${sys:getProperty('ofbiz.home')}/framework/images/webapp/images/products/management
 image.management.url=/images/products/management
 image.management.nameofthumbnail=-100
+image.management.autoApproveImage=Y
+image.management.multipleApproval=N

Modified: ofbiz/trunk/applications/product/data/ProductDemoData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductDemoData.xml?rev=1292661&r1=1292660&r2=1292661&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/data/ProductDemoData.xml (original)
+++ ofbiz/trunk/applications/product/data/ProductDemoData.xml Thu Feb 23 06:38:38 2012
@@ -42,4 +42,5 @@ under the License.
     <UserLoginSecurityGroup userLoginId="imageUpload" groupId="CATALOGADMIN" fromDate="2010-01-01 12:00:00.0"/>
     <UserLoginSecurityGroup userLoginId="imageUpload" groupId="IMAGEUPLOAD" fromDate="2010-01-01 12:00:00.0"/>
     
+    <PartyRole partyId="admin" roleTypeId="IMAGEAPPROVER"/>
 </entity-engine-xml>

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml?rev=1292661&r1=1292660&r2=1292661&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml Thu Feb 23 06:38:38 2012
@@ -245,16 +245,29 @@ under the License.
         statusId = StringUtil.split(checkStatusVal, &quot;/&quot;);
         if (statusId) return statusId[0];
         }"/>
-        <entity-and entity-name="ContentApproval" list="contentApprovals">
-            <field-map field-name="partyId" from-field="userLogin.partyId"/>
-            <field-map field-name="contentId" from-field="parameters.contentId"/>
-            <field-map field-name="roleTypeId" value="IMAGEAPPROVER"/>
-        </entity-and>
-        <first-from-list entry="contentApproval" list="contentApprovals"/>
-        <if-not-empty field="parameters.checkStatusId">
+        
+        <property-to-field resource="catalog.properties" property="image.management.autoApproveImage" field="autoApproveImage"/>
+        <property-to-field resource="catalog.properties" property="image.management.multipleApproval" field="multipleApproval"/>
+        <if-compare field="autoApproveImage" operator="equals" value="Y">
+            <entity-and entity-name="ContentApproval" list="contentApprovals">
+                <field-map field-name="contentId" from-field="parameters.contentId"/>
+                <field-map field-name="roleTypeId" value="IMAGEAPPROVER"/>
+            </entity-and>
+            <iterate entry="contentApproval" list="contentApprovals">
+                <set field="contentApproval.approvalStatusId" from-field="parameters.checkStatusId"/>
+                <store-value value-field="contentApproval"/>
+            </iterate>
+        <else>
+            <entity-and entity-name="ContentApproval" list="contentApprovals">
+                <field-map field-name="partyId" from-field="userLogin.partyId"/>
+                <field-map field-name="contentId" from-field="parameters.contentId"/>
+                <field-map field-name="roleTypeId" value="IMAGEAPPROVER"/>
+            </entity-and>
+            <first-from-list entry="contentApproval" list="contentApprovals"/>
             <set field="contentApproval.approvalStatusId" from-field="parameters.checkStatusId"/>
-        </if-not-empty>
-        <store-value value-field="contentApproval"/>
+            <store-value value-field="contentApproval"/>
+        </else>
+        </if-compare>
         
         <if-compare field="parameters.checkStatusId" operator="equals" value="IM_REJECTED">
             <entity-condition entity-name="ContentApproval" list="checkRejects">
@@ -271,8 +284,9 @@ under the License.
             <set field="content.statusId" value="IM_REJECTED"/>
             <set field="content.createdByUserLogin" from-field="userLogin.userLoginId"/>
             <store-value value-field="content"/>
-            <else>
-                <if-compare field="parameters.checkStatusId" operator="equals" value="IM_APPROVED">
+        <else>
+            <if-compare field="parameters.checkStatusId" operator="equals" value="IM_APPROVED">
+                <if-compare field="multipleApproval" operator="equals" value="Y">
                     <entity-count entity-name="ContentApproval" count-field="countParty">
                         <condition-list combine="and">
                             <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
@@ -291,42 +305,67 @@ under the License.
                         <first-from-list entry="productContent" list="productContents"/>
                         <set field="productContent.purchaseFromDate" from-field="nowTimestamp"/>
                         <store-value value-field="productContent"/>
-                        <else>
-                            <entity-count entity-name="ContentApproval" count-field="countApprove">
-                                 <condition-list combine="and">
+                    <else>
+                        <entity-count entity-name="ContentApproval" count-field="countApprove">
+                             <condition-list combine="and">
+                                <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
+                                <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
+                                <condition-expr field-name="approvalStatusId" operator="equals" value="IM_APPROVED"/>
+                            </condition-list>
+                        </entity-count>
+                        <if-compare field="countApprove" operator="greater-equals" value="2">
+                            <entity-one entity-name="Content" value-field="content"/>
+                            <set field="content.statusId" value="IM_APPROVED"/>
+                            <store-value value-field="content"/>
+                            
+                            <entity-and entity-name="ProductContent" list="productContents">
+                                <field-map field-name="contentId" from-field="parameters.contentId"/>
+                                <field-map field-name="productContentTypeId" value="IMAGE"/>
+                            </entity-and>
+                            <first-from-list entry="productContent" list="productContents"/>
+                            <set field="productContent.purchaseFromDate" from-field="nowTimestamp"/>
+                            <store-value value-field="productContent"/>
+                            
+                            <entity-condition entity-name="ContentApproval" list="checkApproveList">
+                                <condition-list combine="and">
                                     <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
                                     <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
-                                    <condition-expr field-name="approvalStatusId" operator="equals" value="IM_APPROVED"/>
                                 </condition-list>
-                            </entity-count>
-                            <if-compare field="countApprove" operator="greater-equals" value="2">
-                                <entity-one entity-name="Content" value-field="content"/>
-                                <set field="content.statusId" value="IM_APPROVED"/>
-                                <store-value value-field="content"/>
-                                
-                                <entity-and entity-name="ProductContent" list="productContents">
-                                    <field-map field-name="contentId" from-field="parameters.contentId"/>
-                                    <field-map field-name="productContentTypeId" value="IMAGE"/>
-                                </entity-and>
-                                <first-from-list entry="productContent" list="productContents"/>
-                                <set field="productContent.purchaseFromDate" from-field="nowTimestamp"/>
-                                <store-value value-field="productContent"/>
-                                
-                                <entity-condition entity-name="ContentApproval" list="checkApproveList">
-                                    <condition-list combine="and">
-                                        <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
-                                        <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
-                                    </condition-list>
-                                </entity-condition>
-                                <iterate entry="checkApprove" list="checkApproveList">
-                                    <set field="checkApprove.approvalStatusId" value="IM_APPROVED"/>
-                                    <store-value value-field="checkApprove"/>
-                                </iterate>
-                            </if-compare>
-                        </else>
+                            </entity-condition>
+                            <iterate entry="checkApprove" list="checkApproveList">
+                                <set field="checkApprove.approvalStatusId" value="IM_APPROVED"/>
+                                <store-value value-field="checkApprove"/>
+                            </iterate>
+                        </if-compare>
+                    </else>
                     </if-compare>
+                <else>
+                    <entity-one entity-name="Content" value-field="content"/>
+                    <set field="content.statusId" value="IM_APPROVED"/>
+                    <store-value value-field="content"/>
+                    
+                    <entity-and entity-name="ProductContent" list="productContents">
+                        <field-map field-name="contentId" from-field="parameters.contentId"/>
+                        <field-map field-name="productContentTypeId" value="IMAGE"/>
+                    </entity-and>
+                    <first-from-list entry="productContent" list="productContents"/>
+                    <set field="productContent.purchaseFromDate" from-field="nowTimestamp"/>
+                    <store-value value-field="productContent"/>
+                    
+                    <entity-condition entity-name="ContentApproval" list="checkApproveList">
+                        <condition-list combine="and">
+                            <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
+                            <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
+                        </condition-list>
+                    </entity-condition>
+                    <iterate entry="checkApprove" list="checkApproveList">
+                        <set field="checkApprove.approvalStatusId" value="IM_APPROVED"/>
+                        <store-value value-field="checkApprove"/>
+                    </iterate>
+                </else>
                 </if-compare>
-            </else>
+            </if-compare>
+        </else>
         </if-compare>
     </simple-method>
     

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java?rev=1292661&r1=1292660&r2=1292661&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java Thu Feb 23 06:38:38 2012
@@ -276,6 +276,20 @@ public class ImageManagementServices {
                 Debug.logError(e, module);
                 return ServiceUtil.returnError(e.getMessage());
             }
+            
+            String autoApproveImage = UtilProperties.getPropertyValue("catalog", "image.management.autoApproveImage");
+            if (autoApproveImage.equals("Y")) {
+                Map<String, Object> autoApproveCtx = FastMap.newInstance();
+                autoApproveCtx.put("contentId", contentId);
+                autoApproveCtx.put("userLogin", userLogin);
+                autoApproveCtx.put("checkStatusId", "IM_APPROVED");
+                try {
+                    dispatcher.runSync("updateStatusImageManagement", autoApproveCtx);
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                }
+            }
         }
         return result;
     }

Modified: ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml?rev=1292661&r1=1292660&r2=1292661&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml Thu Feb 23 06:38:38 2012
@@ -605,7 +605,6 @@ under the License.
             <entity-condition entity-name="ProductContentAndInfo">
                 <condition-list combine="and">
                     <condition-expr field-name="productId" from-field="parameters.productId"/>
-                       <condition-expr field-name="statusId" value="IM_PENDING"/>
                        <condition-expr field-name="productContentTypeId" value="IMAGE"/>
                        <condition-expr field-name="fromDate" operator="greater-equals" from-field="dateNow" />
                 </condition-list>