<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
    
    <simple-method method-name="UploadProductImages" short-description="Method to upload multiple images for product">
        <set-service-fields service-name="addMultipleuploadForProduct" map="parameters" to-map="addAdditionalViewForProductMap"/>
        <if-not-empty field="parameters._additionalImageOne_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageOne"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageOne_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageOne_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <if-not-empty field="parameters._additionalImageTwo_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageTwo"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageTwo_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageTwo_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <if-not-empty field="parameters._additionalImageThree_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageThree"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageThree_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageThree_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <if-not-empty field="parameters._additionalImageFour_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageFour"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageFour_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageFour_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <if-not-empty field="parameters._additionalImageFive_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageFive"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageFive_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageFive_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <if-not-empty field="parameters._additionalImageSix_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageSix"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageSix_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageSix_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <if-not-empty field="parameters._additionalImageSeven_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageSeven"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
           <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageSeven_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageSeven_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <if-not-empty field="parameters._additionalImageEight_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageEight"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageEight_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageEight_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <if-not-empty field="parameters._additionalImageNine_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageNine"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageNine_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageNine_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <if-not-empty field="parameters._additionalImageTen_fileName">
            <set field="addAdditionalViewForProductMap.productId" from-field="parameters.productId"/>
            <set field="addAdditionalViewForProductMap.imageResize" from-field="parameters.imageResize"/>
            <set field="addAdditionalViewForProductMap.uploadedFile" from-field="parameters.additionalImageTen"/>
            <set field="addAdditionalViewForProductMap.productContentTypeId" value="IMAGE"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_fileName" from-field="parameters._additionalImageTen_fileName"/>
            <set field="addAdditionalViewForProductMap._uploadedFile_contentType" from-field="parameters._additionalImageTen_contentType"/>
            <call-service service-name="addMultipleuploadForProduct" in-map-name="addAdditionalViewForProductMap"/>
            <clear-field field="addAdditionalViewForProductMap"/>
        </if-not-empty>
        <field-to-result field="parameters.productId" result-name="productId"/>
    </simple-method>
   
    <simple-method method-name="removeProductContentAndImageFile" short-description="Remove Content From Product and Image File">
        <entity-and entity-name="ProductContent" list="checkDefaultImage">
            <field-map field-name="productId" from-field="parameters.productId"/>
            <field-map field-name="contentId" from-field="parameters.contentId"/>
            <field-map field-name="productContentTypeId" value="DEFAULT_IMAGE"/>
        </entity-and>
        <if-empty field="checkDefaultImage">
            <entity-and entity-name="ContentAssoc" list="contentAssocs">
                <field-map field-name="contentId" from-field="parameters.contentId"/>
                <field-map field-name="contentAssocTypeId" value="IMAGE_THUMBNAIL"/>
            </entity-and>
            <if-not-empty field="contentAssocs">
                <iterate list="contentAssocs" entry="contentAssoc">
                    <remove-value value-field="contentAssoc"/>
                    
                    <set field="removeContent.contentId" from-field="contentAssoc.contentIdTo"/>
                    <set field="removeContent.productId" from-field="parameters.productId"/>
                    <call-service service-name="removeProductContentForImageManagement" in-map-name="removeContent"/>
                </iterate>
            </if-not-empty>
            
            <make-value entity-name="ProductContent" value-field="lookupPKMap"/>
            <set-pk-fields map="parameters" value-field="lookupPKMap"/>
            <find-by-primary-key map="lookupPKMap" value-field="lookedUpValue"/>
            <remove-value value-field="lookedUpValue"/>
            <set field="removeContent.contentId" from-field="parameters.contentId"/>
            <set field="removeContent.productId" from-field="parameters.productId"/>
            <call-service service-name="removeProductContentForImageManagement" in-map-name="removeContent"/>
        <else>
            <add-error>
                <fail-property resource="ProductErrorUiLabels" property="ImageManagementErrorRmoveDefaultImage"/>
            </add-error>
            <log level="error" message="Cannot remove image contentId ${parameters.contentId}"/>
            <check-errors/>
        </else>
        </if-empty>
    </simple-method>
    
    <simple-method method-name="removeProductContentForImageManagement" short-description="Remove Content From Product">
        <entity-and entity-name="ContentRole" list="contentRoles" >
           <field-map field-name="contentId" from-field="parameters.contentId"/>
        </entity-and>
        <if-not-empty field="contentRoles">
            <remove-value value-field="contentRoles[0]"/>
        </if-not-empty>
        
        <entity-condition entity-name="ContentApproval" list="contentApprovals">
            <condition-list combine="and">
                <condition-expr field-name="contentId" from-field="parameters.contentId"/>
                <condition-expr field-name="roleTypeId" value="IMAGEAPPROVER"/>
            </condition-list>
        </entity-condition>
        <iterate list="contentApprovals" entry="contentApproval">
            <remove-value value-field="contentApproval"/>
        </iterate>
        
        <entity-and entity-name="ContentKeyword" list="contentKeywords">
            <field-map field-name="contentId" from-field="parameters.contentId"/>
        </entity-and>
        <iterate list="contentKeywords" entry="contentKeyword">
            <remove-value value-field="contentKeyword"/>
        </iterate>
        
        <entity-one entity-name="Content" value-field="content">
            <field-map field-name="contentId" from-field="parameters.contentId"/>
        </entity-one>
        <set field="removeContentPKMap.contentId" from-field="parameters.contentId"/>
        <set-service-fields service-name="removeContent" map="removeContentPKMap" to-map="removeContentMap"/>
        <call-service service-name="removeContent" in-map-name="removeContentMap"/>
        
        <set field="dataResourceId" from-field="content.dataResourceId"/>
        <entity-and entity-name="DataResourceRole" list="dataResourceRoles" >
            <field-map field-name="dataResourceId" from-field="dataResourceId"/>
        </entity-and>
        <if-not-empty field="dataResourceRoles">
            <remove-value value-field="dataResourceRoles[0]"/>
        </if-not-empty>
        
        <entity-one entity-name="DataResource" value-field="dataResource">
            <field-map field-name="dataResourceId" from-field="dataResourceId"/>
        </entity-one>
        <set field="removeImageFile.productId" from-field="parameters.productId"/>
        <set field="removeImageFile.contentId" from-field="parameters.contentId"/>
        <set field="removeImageFile.objectInfo" from-field="dataResource.objectInfo"/>
        <set field="removeImageFile.dataResourceName" from-field="dataResource.dataResourceName"/>
        <set-service-fields service-name="removeImageFileForImageManagement" map="removeImageFile" to-map="removeImageFileMap"/>
        <call-service service-name="removeImageFileForImageManagement" in-map-name="removeImageFileMap"/>
        
        <set field="removeDataResourcePKMap.dataResourceId" from-field="dataResourceId"/>
        <set-service-fields service-name="removeDataResource" map="removeDataResourcePKMap" to-map="removeDataResourceMap"/>
        <call-service service-name="removeDataResource" in-map-name="removeDataResourceMap"/>
    </simple-method>
    
    <simple-method method-name="setImageDetail" short-description="Set Image Detail">
        <entity-one entity-name="ProductContent" value-field="productContent"/>
        <set field="productContent.sequenceNum" from-field="parameters.sequenceNum" type="Long"/>
        <store-value value-field="productContent"/>
        <if-not-empty field="parameters.sequenceNum">
            <script location="component://product/groovyScripts/catalog/imagemanagement/SortSequenceNum.groovy"/>
            <set field="productContent.sequenceNum" from-field="parameters.sequenceNum" type="Long"/>
            <store-value value-field="productContent"/>
        </if-not-empty>
        
        <!-- set caption -->
        <entity-one entity-name="Content" value-field="content"/>
        <set field="content.description" from-field="parameters.description"/>
        <store-value value-field="content"/>
        
        <if-compare field="content.statusId" operator="equals" value="IM_APPROVED">
            <entity-one entity-name="DataResource" value-field="dataResource">
                <field-map field-name="dataResourceId" from-field="content.dataResourceId"/>
            </entity-one>
            <set field="dataResource.isPublic" from-field="parameters.drIsPublic"/>
            <store-value value-field="dataResource"/>
        </if-compare>
    </simple-method>
    
    <simple-method method-name="updateStatusImageManagement" short-description="Update Status Image Management">
        <now-timestamp field="nowTimestamp"/>
        <set field="parameters.checkStatusId" value="${groovy: import org.apache.ofbiz.base.util.StringUtil;
        checkStatusVal = parameters.checkStatusId; 
        statusId = StringUtil.split(checkStatusVal, &quot;/&quot;);
        if (statusId) return statusId[0];
        }"/>
        
        <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 list="contentApprovals" entry="contentApproval">
                <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 list="contentApprovals" entry="contentApproval"/>
            <set field="contentApproval.approvalStatusId" from-field="parameters.checkStatusId"/>
            <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">
                <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 list="checkRejects" entry="checkReject">
                <set field="checkReject.statusId" value="IM_REJECTED"/>
                <store-value value-field="checkReject"/>
            </iterate>
            <entity-one entity-name="Content" value-field="content"/>
            <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">
                <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"/>
                            <condition-expr field-name="roleTypeId" operator="equals" value="IMAGEAPPROVER"/>
                        </condition-list>
                    </entity-count>
                    <if-compare field="countParty" operator="equals" value="1">
                        <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 list="productContents" entry="productContent"/>
                        <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">
                                <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 list="productContents" entry="productContent"/>
                            <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 list="checkApproveList" entry="checkApprove">
                                <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 list="productContents" entry="productContent"/>
                    <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 list="checkApproveList" entry="checkApprove">
                        <set field="checkApprove.approvalStatusId" value="IM_APPROVED"/>
                        <store-value value-field="checkApprove"/>
                    </iterate>
                </else>
                </if-compare>
            </if-compare>
        </else>
        </if-compare>
    </simple-method>
    
    <simple-method method-name="addRejectedReasonImageManagement" short-description="Add Rejected Reason Image Management">
        <now-timestamp field="nowTimestam"/>
        <entity-one entity-name="Content" value-field="content"/>
        <if-not-empty field="parameters.description">
            <if-compare field="parameters.description" value="RETAKE_PHOTO" operator="equals">
                <set field="content.description" value="Re-take Photo"/>
            </if-compare>
            <if-compare field="parameters.description" value="REMOVE_LOGO" operator="equals">
                <set field="content.description" value="Remove Logo"/>
            </if-compare>
            <if-compare field="parameters.description" value="OTHER" operator="equals">
                <set field="content.description" value="Other"/>
            </if-compare>
            <else>
                <set field="content.description" value="Other"/>
            </else>
        </if-not-empty>
        <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 list="productContents" entry="productContent"/>
        <set field="productContent.thruDate" from-field="nowTimestam"/>
        <store-value value-field="productContent"/>
    </simple-method>
    
    <simple-method method-name="createImageContentApproval" short-description="Create Content Approval of Image">
        <now-timestamp field="nowTimestam"/>
        <entity-and entity-name="PartyRole" list="partyRoles">
            <field-map field-name="roleTypeId" value="IMAGEAPPROVER"/>
        </entity-and>
        <iterate list="partyRoles" entry="partyRole">
            <set field="contentApproval.partyId" from-field="partyRole.partyId"/>
            <set field="contentApproval.contentId" from-field="parameters.contentId"/>
            <set field="contentApproval.roleTypeId" value="IMAGEAPPROVER"/>
            <set field="contentApproval.approvalDate" from-field="nowTimestam"/>
            <set field="contentApproval.approvalStatusId" value="IM_PENDING"/>
            <call-service service-name="createContentApproval" in-map-name="contentApproval"/>
        </iterate>
    </simple-method>
    
    <simple-method method-name="removeImageContentApproval" short-description="Remove Content Approval of Image">
        <entity-and entity-name="ContentApproval" list="contentApprovals">
            <field-map field-name="partyId" from-field="parameters.partyId"/>
            <field-map field-name="roleTypeId" value="IMAGEAPPROVER"/>
        </entity-and>
        <iterate list="contentApprovals" entry="contentApproval">
            <remove-value value-field="contentApproval"/>
        </iterate>
    </simple-method>
    
    <simple-method method-name="resizeImages" short-description="Resize Images">
        <if-compare field="parameters.resizeOption" operator="equals" value="resizeAllImages">
            <entity-and entity-name="ProductContentAndInfo" list="productContentAndInfos">
                <field-map field-name="productId" from-field="parameters.productId"/>
                <field-map field-name="productContentTypeId" value="IMAGE"/>
                <!--<field-map field-name="statusId" value="IM_APPROVED"/>-->
            </entity-and>
            <iterate list="productContentAndInfos" entry="productContentAndInfo">
                <set field="resizeImageMap.productId" from-field="productContentAndInfo.productId"/>
                <set field="resizeImageMap.dataResourceName" from-field="productContentAndInfo.drDataResourceName"/>
                <set field="resizeImageMap.resizeWidth" from-field="parameters.size"/>
                <call-service service-name="resizeImageOfProduct" in-map-name="resizeImageMap"/>
            </iterate>
        </if-compare>
        <if-compare field="parameters.resizeOption" operator="equals" value="createNewThumbnail">
            <set field="removeImageBySizeMap.productId" from-field="parameters.productId"/>
            <set field="removeImageBySizeMap.mapKey" from-field="parameters.size"/>
            <call-service service-name="removeImageBySize" in-map-name="removeImageBySizeMap"/>
            
            <entity-and entity-name="ProductContentAndInfo" list="productContentAndInfos">
                <field-map field-name="productId" from-field="parameters.productId"/>
                <field-map field-name="productContentTypeId" value="IMAGE"/>
                <!--<field-map field-name="statusId" value="IM_APPROVED"/>-->
            </entity-and>
            <iterate list="productContentAndInfos" entry="productContentAndInfo">
                <set field="createNewImageThumbnailMap.productId" from-field="productContentAndInfo.productId"/>
                <set field="createNewImageThumbnailMap.contentId" from-field="productContentAndInfo.contentId"/>
                <set field="createNewImageThumbnailMap.dataResourceName" from-field="productContentAndInfo.drDataResourceName"/>
                <set field="createNewImageThumbnailMap.drObjectInfo" from-field="productContentAndInfo.drObjectInfo"/>
                <set field="createNewImageThumbnailMap.sizeWidth" from-field="parameters.size"/>
                <call-service service-name="createNewImageThumbnail" in-map-name="createNewImageThumbnailMap"/>
            </iterate>
        </if-compare>
    </simple-method>
    
    <simple-method method-name="removeImageBySize" short-description="Remove Image By Size">
        <entity-condition entity-name="ProductContentAndInfo" list="productContentAndInfos">
            <condition-list combine="and">
                <condition-expr field-name="productId" from-field="parameters.productId"/>
                <condition-expr field-name="productContentTypeId" value="IMAGE"/>
                <!--<field-map field-name="statusId" value="IM_APPROVED"/>-->
            </condition-list>
        </entity-condition>
        <iterate list="productContentAndInfos" entry="productContentAndInfo">
            <entity-and list="contentAssocs" entity-name="ContentAssoc">
                <field-map field-name="contentId" from-field="productContentAndInfo.contentId"/>
                <field-map field-name="contentAssocTypeId" value="IMAGE_THUMBNAIL"/>
                <field-map field-name="mapKey" from-field="parameters.mapKey"/>
            </entity-and>
            <if-not-empty field="contentAssocs">
                <iterate list="contentAssocs" entry="contentAssoc">
                    <remove-value value-field="contentAssoc"/>
                    
                    <set field="removeContent.contentId" from-field="contentAssoc.contentIdTo"/>
                    <set field="removeContent.productId" from-field="parameters.productId"/>
                    <call-service service-name="removeProductContentForImageManagement" in-map-name="removeContent"/>
                </iterate>
            </if-not-empty>
        </iterate>
    </simple-method>
</simple-methods>
