<?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.
-->

<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://ofbiz.apache.org/dtds/services.xsd">
    <description>Product Component Maintenance Services</description>
    <vendor>OFBiz</vendor>
    <version>1.0</version>

    <!-- Product Category Maintenance Services -->
    <service name="copyCategoryProductMembers" engine="groovy" transaction-timeout="600"
            location="component://product/src/main/groovy/org/apache/ofbiz/product/product/category/CategoryServicesScript.groovy" invoke="copyCategoryProductMembers" auth="true">
        <description>Copy Product Members from one Category to Another, optionally filtering by the given valid date (otherwise no date filtering done), and optionally recursing (if recurse=Y) down the from category</description>
        <attribute name="productCategoryId" type="String" mode="IN" optional="false">
	     <type-validate>
	         <fail-property resource="ProductErrorUiLabels" property="ProductRequiredFieldMissingProductCategoryId"/>
	     </type-validate>
        </attribute>
        <attribute name="productCategoryIdTo" type="String" mode="IN" optional="false">
	     <type-validate>
	         <fail-property resource="ProductErrorUiLabels" property="ProductRequiredFieldMissingProductCategoryIdTo"/>
	     </type-validate>
        </attribute>
        <attribute name="validDate" type="Timestamp" mode="IN" optional="true"/>
        <attribute name="recurse" type="String" mode="IN" optional="true"/>
    </service>
    <service name="expireAllCategoryProductMembers" engine="groovy"
            location="component://product/src/main/groovy/org/apache/ofbiz/product/product/category/CategoryServicesScript.groovy" invoke="expireAllCategoryProductMembers" auth="true">
        <description>Expire All Product Members in a Category optionally using the thruDate specified as the expire date (now timestamp used by default)</description>
        <attribute name="productCategoryId" type="String" mode="IN" optional="false">
	     <type-validate>
	         <fail-property resource="ProductErrorUiLabels" property="ProductRequiredFieldMissingProductCategoryId"/>
	     </type-validate>
        </attribute>
        <attribute name="thruDate" type="Timestamp" mode="IN" optional="true"/>
    </service>
    <service name="removeExpiredCategoryProductMembers" engine="groovy"
            location="component://product/src/main/groovy/org/apache/ofbiz/product/product/category/CategoryServicesScript.groovy" invoke="removeExpiredCategoryProductMembers" auth="true">
        <description>Remove All Expired Product Members in a Category, optionally uses the valid date instead of now to determine if the member has expired</description>
        <attribute name="productCategoryId" type="String" mode="IN" optional="false">
	     <type-validate>
                <fail-property resource="ProductErrorUiLabels" property="ProductRequiredFieldMissingProductCategoryId"/>
	     </type-validate>
        </attribute>
        <attribute name="validDate" type="Timestamp" mode="IN" optional="true"/>
    </service>

    <!-- ========================================= -->
    <!-- Some Product Maintenance Utility Services -->
    <!-- ========================================= -->
    <!-- These are generally run manually, but some can be run on a schedule as well. -->
    <service name="discVirtualsWithDiscVariants" engine="java"
            location="org.apache.ofbiz.product.product.ProductUtilServices" invoke="discVirtualsWithDiscVariants" auth="true" transaction-timeout="36000" require-new-transaction="true">
        <description>Discontinue Virtuals With Discontinued Variants</description>
    </service>
    <service name="removeCategoryMembersOfDiscProducts" engine="java"
            location="org.apache.ofbiz.product.product.ProductUtilServices" invoke="removeCategoryMembersOfDiscProducts" auth="true" transaction-timeout="36000" require-new-transaction="true">
        <description>Remove Category Members Of Discontinued Products</description>
    </service>
    <service name="removeDuplicateOpenEndedCategoryMembers" engine="java"
            location="org.apache.ofbiz.product.product.ProductUtilServices" invoke="removeDuplicateOpenEndedCategoryMembers" auth="true" transaction-timeout="36000" require-new-transaction="true">
        <description>Remove Duplicate, excluding fromDate, Category Members that have no thruDate</description>
    </service>

    <service name="makeStandAloneFromSingleVariantVirtuals" engine="java"
            location="org.apache.ofbiz.product.product.ProductUtilServices" invoke="makeStandAloneFromSingleVariantVirtuals" auth="true" transaction-timeout="36000" require-new-transaction="true">
        <description>Make Stand Alone From Single Variant Virtuals</description>
    </service>
    <service name="mergeVirtualWithSingleVariant" engine="java"
            location="org.apache.ofbiz.product.product.ProductUtilServices" invoke="mergeVirtualWithSingleVariant" auth="true" transaction-timeout="36000" require-new-transaction="true">
        <description>A service to be called by the make stand alone service to do the operation for one product.</description>
        <attribute name="productId" type="String" mode="IN" optional="false"/>
        <attribute name="removeOld" type="Boolean" mode="IN" optional="false"/>
        <attribute name="test" type="Boolean" mode="IN" optional="true"/>
    </service>

    <service name="setAllProductImageNames" engine="java"
            location="org.apache.ofbiz.product.product.ProductUtilServices" invoke="setAllProductImageNames" auth="true" transaction-timeout="36000" require-new-transaction="true">
        <description>Set All Product Image Names; pattern example: /images/products/${size}/${productId}.jpg; defaults to values in the catalog.properties file (image.url.prefix + / + image.filename.format)</description>
        <attribute name="pattern" type="String" mode="IN" optional="true"/>
    </service>
    <service name="clearAllVirtualProductImageNames" engine="java"
            location="org.apache.ofbiz.product.product.ProductUtilServices" invoke="clearAllVirtualProductImageNames" auth="true" transaction-timeout="36000" require-new-transaction="true">
        <description>Set All Product Image Names</description>
    </service>

    <service name="attachProductFeaturesToCategory" engine="java"
            location="org.apache.ofbiz.product.product.ProductUtilServices" invoke="attachProductFeaturesToCategory" auth="true" transaction-timeout="36000" require-new-transaction="true">
        <description>Attach Product Features To Category Through Groups</description>
        <attribute name="productCategoryId" type="String" mode="IN" optional="false"/>
        <attribute name="doSubCategories" type="String" mode="IN" optional="true"/>
    </service>

    <!-- Check Urls exists or not related services -->
    <service name="checkImageUrlForAllCategories" engine="groovy"
      location="component://product/src/main/groovy/org/apache/ofbiz/product/product/catalog/CatalogServices.groovy" invoke="checkImageUrlForAllCategories" transaction-timeout="36000">
        <description>check For Image Urls exists or not for all categories</description>
        <attribute name="topCategory" type="String" mode="IN" optional="true"/>
        <attribute name="excludeEmpty" type="Boolean" mode="IN" optional="true"/>
        <attribute name="categoriesMap" type="java.util.Map" mode="OUT" optional="true"/>
    </service>

    <service name="getAllCategories" engine="groovy"
      location="component://product/src/main/groovy/org/apache/ofbiz/product/product/catalog/CatalogServices.groovy" invoke="getAllCategories">
        <description>Get all categories of a category </description>
        <attribute name="topCategory" type="String" mode="IN" optional="true"/>
        <attribute name="categories" type="java.util.List" mode="OUT" optional="true"/>
    </service>

    <service name="getRelatedCategories" engine="groovy"
      location="component://product/src/main/groovy/org/apache/ofbiz/product/product/catalog/CatalogServices.groovy" invoke="getRelatedCategories">
        <description>Get all related categories of a category </description>
        <attribute name="parentProductCategoryId" type="String" mode="IN" optional="false">
	     <type-validate>
	         <fail-property resource="ProductErrorUiLabels" property="ProductRequiredFieldMissingParentProductCategoryId"/>
	     </type-validate>
        </attribute>
        <attribute name="categories" type="java.util.List" mode="INOUT" optional="true"/>
    </service>

    <service name="getCategoryTrail" engine="java"
      location="org.apache.ofbiz.product.category.CategoryWorker" invoke="getCategoryTrail">
        <description> Returns a complete category trail - can be used for exporting proper category trees.
        This is mostly useful when used in combination with breadcrumbs,  for building a facetted index tree,
        or to export a category tree for migration to another system.
        Will create the tree from root point to categoryId.

        This service is not meant to be run on every request.
        Its best use is to generate the trail every so often and store somewhere (a lucene/solr tree, entities, cache or so).
        </description>
        <attribute name="productCategoryId" type="String" mode="IN" optional="false"/>
        <attribute name="trail" type="java.util.List" mode="OUT" optional="true"/>
    </service>

    <service name="checkImageUrlForCategoryAndProduct" engine="groovy"
      location="component://product/src/main/groovy/org/apache/ofbiz/product/product/catalog/CatalogServices.groovy" invoke="checkImageUrlForCategoryAndProduct">
        <description>check For Image Urls exists or not for category</description>
        <attribute name="categoryId" type="String" mode="IN" optional="false">
	     <type-validate>
	         <fail-property resource="ProductErrorUiLabels" property="ProductRequiredFieldMissingCategoryId"/>
	     </type-validate>
        </attribute>
        <attribute name="fileNotExists" type="java.util.List" mode="OUT" optional="true"/>
        <attribute name="fileExists" type="java.util.List" mode="OUT" optional="true"/>
    </service>
    <service name="checkImageUrlForCategory" engine="groovy"
      location="component://product/src/main/groovy/org/apache/ofbiz/product/product/catalog/CatalogServices.groovy" invoke="checkImageUrlForCategory">
        <description>check For Image Urls exists or not For Product</description>
        <attribute name="categoryId" type="String" mode="IN" optional="false">
	     <type-validate>
	         <fail-property resource="ProductErrorUiLabels" property="ProductRequiredFieldMissingCategoryId"/>
	     </type-validate>
        </attribute>
        <attribute name="filesImageMap" type="java.util.Map" mode="OUT" optional="true"/>
    </service>
    <service name="checkImageUrlForProduct" engine="groovy"
      location="component://product/src/main/groovy/org/apache/ofbiz/product/product/catalog/CatalogServices.groovy" invoke="checkImageUrlForProduct">
        <description>check For Image Urls exists or not For Product</description>
        <attribute name="productId" type="String" mode="IN" optional="false">
	     <type-validate>
	         <fail-property resource="ProductErrorUiLabels" property="ProductRequiredFieldMissingProductId"/>
	     </type-validate>
        </attribute>
        <attribute name="filesImageMap" type="java.util.Map" mode="OUT" optional="true"/>
    </service>

    <service name="checkImageUrl" engine="groovy"
      location="component://product/src/main/groovy/org/apache/ofbiz/product/product/catalog/CatalogServices.groovy" invoke="checkImageUrl">
        <description>check For Image Urls exists or not</description>
        <attribute name="imageUrl" type="String" mode="IN" optional="false">
	     <type-validate>
	         <fail-property resource="ProductErrorUiLabels" property="ProductRequiredFieldMissingImageUrl"/>
	     </type-validate>
        </attribute>
        <attribute name="isExists" type="String" mode="OUT" optional="true"/>
    </service>

    <!-- ============================== -->
    <!-- Promotion Maintenance Services -->
    <!-- ============================== -->
    <service name="purgeOldStoreAutoPromos" engine="java"
            location="org.apache.ofbiz.product.promo.PromoServices" invoke="purgeOldStoreAutoPromos" auth="true">
        <description>Purge Expired ProductStorePromoAppl Records, by store or global if productStoreId is null</description>
        <attribute name="productStoreId" type="String" mode="IN" optional="true"/>
    </service>

</services>
