| <?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="findCustomTimePeriods" short-description="Find a CustomTimePeriod"> |
| <if-not-empty field="parameters.organizationPartyId"> |
| <!-- walk up the tree and find all party groups that this is a member of, and include the periods for all of them --> |
| <set from-field="parameters.organizationPartyId" field="getParentOrganizationsCallMap.organizationPartyId"/> |
| <call-service service-name="getParentOrganizations" in-map-name="getParentOrganizationsCallMap"> |
| <result-to-field result-name="parentOrganizationPartyIdList"/> |
| </call-service> |
| |
| <iterate list="parentOrganizationPartyIdList" entry="curOrganizationPartyId"> |
| <clear-field field="orgTimePeriodList"/> |
| <entity-condition entity-name="CustomTimePeriod" list="orgTimePeriodList" use-cache="true"> |
| <condition-list combine="and"> |
| <condition-list combine="or"> |
| <condition-expr field-name="organizationPartyId" operator="equals" from-field="curOrganizationPartyId"/> |
| </condition-list> |
| <condition-expr field-name="fromDate" operator="less-equals" from-field="parameters.findDate"/> |
| <condition-list combine="or"> |
| <condition-expr field-name="thruDate" operator="greater-equals" from-field="parameters.findDate"/> |
| <condition-expr field-name="thruDate" operator="equals" from-field="nullField"/> |
| </condition-list> |
| <condition-expr field-name="periodTypeId" operator="in" from-field="parameters.onlyIncludePeriodTypeIdList" ignore-if-empty="true"/> |
| </condition-list> |
| </entity-condition> |
| <list-to-list list="orgTimePeriodList" to-list="listSoFar"/> |
| </iterate> |
| </if-not-empty> |
| |
| <if-compare field="parameters.excludeNoOrganizationPeriods" operator="not-equals" value="Y"> |
| <entity-condition entity-name="CustomTimePeriod" list="generalCustomTimePeriodList" use-cache="true"> |
| <condition-list combine="and"> |
| <condition-list combine="or"> |
| <condition-expr field-name="organizationPartyId" operator="equals" from-field="nullField"/> |
| <condition-expr field-name="organizationPartyId" operator="equals" value="_NA_"/> |
| </condition-list> |
| <condition-expr field-name="fromDate" operator="less-equals" from-field="parameters.findDate"/> |
| <condition-list combine="or"> |
| <condition-expr field-name="thruDate" operator="greater" from-field="parameters.findDate"/> |
| <condition-expr field-name="thruDate" operator="equals" from-field="nullField"/> |
| </condition-list> |
| <condition-expr field-name="periodTypeId" operator="in" from-field="parameters.onlyIncludePeriodTypeIdList" ignore-if-empty="true"/> |
| </condition-list> |
| </entity-condition> |
| <list-to-list list="generalCustomTimePeriodList" to-list="listSoFar"/> |
| </if-compare> |
| |
| <!-- |
| * We might want to implement this sometime in the future, but for now is not needed |
| * go through the list and check each one to see if it has a child in the list, if so don't copy it |
| <if-compare field="parameters.excludeParentPeriods" operator="equals" value="Y"></if-compare> |
| --> |
| |
| <field-to-result field="listSoFar" result-name="customTimePeriodList"/> |
| </simple-method> |
| |
| <!-- Return previous year with respect to the given year and if none found then return current year as previous. --> |
| <simple-method method-name="getPreviousTimePeriod" short-description="Return previous time period"> |
| |
| <entity-one entity-name="CustomTimePeriod" value-field="currentTimePeriod"/> |
| |
| <set field="periodNum" value="${currentTimePeriod.periodNum - 1}" type="Integer"/> |
| <if-compare field="periodNum" operator="greater" value="-1"> |
| <entity-and entity-name="CustomTimePeriod" list="customTimePeriodList" filter-by-date="false" use-cache="true"> |
| <field-map field-name="organizationPartyId" from-field="currentTimePeriod.organizationPartyId"/> |
| <field-map field-name="periodTypeId" from-field="currentTimePeriod.periodTypeId"/> |
| <field-map field-name="periodNum"/> |
| </entity-and> |
| <first-from-list list="customTimePeriodList" entry="previousTimePeriod"/> |
| <field-to-result field="previousTimePeriod"/> |
| </if-compare> |
| </simple-method> |
| </simple-methods> |