blob: 0b67c758cd8e9f64bb4ad90a21963ecf6869e02e [file] [log] [blame]
<?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="getProductRouting" short-description="Get the product's routing and routing tasks">
<set from-field="parameters.productId" field="lookupRouting.productId"/>
<set value="ROU_PROD_TEMPLATE" field="lookupRouting.workEffortGoodStdTypeId"/>
<!-- If applicableDate has been passed use the value with all filter-by-date calls-->
<if-not-empty field="parameters.applicableDate">
<set from-field="parameters.applicableDate" field="filterDate"/>
<else>
<now-timestamp field="filterDate"/>
</else>
</if-not-empty>
<!-- If a workEffortId has been passed, use it to look up the desired routing-->
<if-not-empty field="parameters.workEffortId">
<set from-field="parameters.workEffortId" field="lookupRouting.workEffortId"/>
<find-by-and entity-name="WorkEffortGoodStandard" list="routings" map="lookupRouting"/>
<filter-list-by-date list="routings" valid-date="filterDate"/>
<first-from-list list="routings" entry="routingGS"/>
<!-- If the routing is not associated with our product and it's a variant, then
check to see if it's virtual product has the routing -->
<if-empty field="routingGS">
<entity-condition entity-name="ProductAssoc" list="virtualProductAssocList" filter-by-date="true">
<condition-list combine="and">
<condition-expr field-name="productIdTo" from-field="parameters.productId"/>
<condition-expr field-name="productAssocTypeId" value="PRODUCT_VARIANT"/>
</condition-list>
</entity-condition>
<first-from-list list="virtualProductAssocList" entry="virtualProductAssoc"/>
<if-not-empty field="virtualProductAssoc">
<set from-field="virtualProductAssoc.productId" field="lookupRouting.productId"/>
<find-by-and entity-name="WorkEffortGoodStandard" list="routings" map="lookupRouting"/>
<!-- Consider the validity against a date passed as (optional) parameter -->
<filter-list-by-date list="routings" valid-date="filterDate"/>
<first-from-list list="routings" entry="routingGS"/>
</if-not-empty>
</if-empty>
<!-- No workEffortId has been passed, so retrieve the first routing found for this product-->
<else>
<find-by-and entity-name="WorkEffortGoodStandard" list="routings" map="lookupRouting"/>
<!-- Consider the validity against a date passed as (optional) parameter -->
<filter-list-by-date list="routings" valid-date="filterDate"/>
<!-- TODO: we should consider the quantity to select the best routing -->
<first-from-list list="routings" entry="routingGS"/>
<!-- If there are no routings associated with our product and it's a variant, then
check to see if it's virtual product has a routing -->
<if-empty field="routingGS">
<entity-condition entity-name="ProductAssoc" list="virtualProductAssocList">
<condition-list combine="and">
<condition-expr field-name="productIdTo" from-field="parameters.productId"/>
<condition-expr field-name="productAssocTypeId" value="PRODUCT_VARIANT"/>
</condition-list>
</entity-condition>
<filter-list-by-date list="virtualProductAssocList" valid-date="filterDate"/>
<first-from-list list="virtualProductAssocList" entry="virtualProductAssoc"/>
<if-not-empty field="virtualProductAssoc">
<set from-field="virtualProductAssoc.productId" field="lookupRouting.productId"/>
<set value="ROU_PROD_TEMPLATE" field="lookupRouting.workEffortGoodStdTypeId"/>
<find-by-and entity-name="WorkEffortGoodStandard" list="routings" map="lookupRouting"/>
<!-- Consider the validity against a date passed as (optional) parameter -->
<filter-list-by-date list="routings" valid-date="filterDate"/>
<!-- TODO: we should consider the quantity to select the best routing -->
<first-from-list list="routings" entry="routingGS"/>
</if-not-empty>
</if-empty>
</else>
</if-not-empty>
<if-not-empty field="routingGS">
<clear-field field="lookupRouting"/>
<set from-field="routingGS.workEffortId" field="lookupRouting.workEffortId"/>
<find-by-primary-key entity-name="WorkEffort" value-field="routing" map="lookupRouting"/>
<else>
<!-- The default routing is used when no explicit routing is associated to the product
and the ignoreDefaultRouting is not equals to Y -->
<if>
<condition>
<or>
<if-empty field="parameters.ignoreDefaultRouting"/>
<if-compare field="parameters.ignoreDefaultRouting" operator="equals" value="N"/>
</or>
</condition>
<then>
<clear-field field="lookupRouting"/>
<set value="DEFAULT_ROUTING" field="lookupRouting.workEffortId"/>
<find-by-primary-key entity-name="WorkEffort" value-field="routing" map="lookupRouting"/>
</then>
</if>
</else>
</if-not-empty>
<if-not-empty field="routing">
<set from-field="routing.workEffortId" field="lookupTasks.workEffortIdFrom"/>
<string-to-list string="sequenceNum" list="tasksOrder"/>
<set value="ROUTING_COMPONENT" field="lookupTasks.workEffortAssocTypeId"/>
<find-by-and entity-name="WorkEffortAssoc" list="tasks" map="lookupTasks" order-by-list="tasksOrder"/>
<filter-list-by-date list="tasks"/>
</if-not-empty>
<field-to-result field="routing"/>
<field-to-result field="tasks"/>
</simple-method>
<simple-method method-name="getRoutingTaskAssocs" short-description="Get the routing task assocs of a given routing">
<set from-field="parameters.workEffortId" field="lookupTasks.workEffortIdFrom"/>
<string-to-list string="sequenceNum" list="tasksOrder"/>
<set value="ROUTING_COMPONENT" field="lookupTasks.workEffortAssocTypeId"/>
<find-by-and entity-name="WorkEffortAssoc" list="routingTaskAssocs" map="lookupTasks" order-by-list="tasksOrder"/>
<filter-list-by-date list="routingTaskAssocs"/>
<field-to-result field="routingTaskAssocs"/>
</simple-method>
</simple-methods>