Files
ofbiz-framework/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml
T
Ashish Vijaywargiya d98ddff5d1 Applied patch from JIRA issue OFBIZ-1966.
Thanks Awdesh Parihar for your contribution and thanks Ratnesh for your support.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@697833 13f79535-47bb-0310-9956-ffa450edef68
2008-09-22 13:59:00 +00:00

1023 lines
59 KiB
XML

<?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"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
<simple-method method-name="createProject" short-description="Create a project">
<if-not-empty field="parameters.templateId">
<set field="parameters.projectId" from-field="parameters.templateId"/>
<call-simple-method method-name="copyProject"/>
<else>
<call-simple-method method-name="createWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
</else>
</if-not-empty>
</simple-method>
<simple-method method-name="createProjectTask" short-description="Create a project task and optionally assign">
<!-- create task -->
<if-empty field="parameters.statusId">
<set field="parameters.statusId" value="PTS_CREATED"/>
</if-empty>
<call-simple-method method-name="createWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
<set field="parameters.workEffortId" from-field="newEntity.workEffortId"/>
<!-- optionally assign to party -->
<if-not-empty field="parameters.partyId">
<call-simple-method method-name="assignPartyToWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
</if-not-empty>
<!-- optionally enter estimated time and required skill -->
<if-not-empty field="parameters.estimatedHours">
<set field="parameters.estimatedDuration" from-field="parameters.estimatedHours"/>
<if-empty field="parameters.skillTypeId">
<set field="parameters.skillTypeId" value="_NA_"/>
</if-empty>
<call-simple-method method-name="createWorkEffortSkillStandard" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
</if-not-empty>
</simple-method>
<simple-method method-name="updateTaskAssigment"
short-description="Update task to resource assignment, if required create a new one by re-assigment">
<field-to-result map-name="parameters" field-name="workEffortId"/>
<if>
<!-- check if a change in partyId Or roletypeId: need to delete and create new -->
<condition>
<or>
<and>
<not>
<if-empty field="parameters.newPartyId"/>
</not>
<if-compare-field field="parameters.partyId" to-field="parameters.newPartyId" operator="not-equals"/>
</and>
<and>
<not>
<if-empty field="parameters.newRoleTypeId"/>
</not>
<if-compare-field field="parameters.roleTypeId" to-field="parameters.newRoleTypeId" operator="not-equals"/>
</and>
</or>
</condition>
<then>
<!-- roleType and/or partyId changed: end old and create new assign-->
<entity-one entity-name="WorkEffortPartyAssignment" value-name="workEffortPartyAssignment"/>
<set field="workEffortPartyAssignment.delegateReasonEnumId" from-field="parameters.delegateReasonEnumId"/>
<set field="workEffortPartyAssignment.comments" from-field="parameters.comments"/>
<set field="workEffortPartyAssignment.assignedByUserLoginId" from-field="userLogin.userLoginId"/>
<now-date-to-env env-name="workEffortPartyAssignment.thruDate"/>
<store-value value-name="workEffortPartyAssignment"/>
<!-- create a new one -->
<make-value value-name="newAssign" entity-name="WorkEffortPartyAssignment"/>
<set field="newAssign.workEffortId" from-field="parameters.workEffortId"/>
<set field="newAssign.partyId" from-field="parameters.newPartyId"/>
<set field="newAssign.roleTypeId" from-field="parameters.newRoleTypeId"/>
<set field="newAssign.assignedByUserLoginId" from-field="userLogin.userLoginId"/>
<now-date-to-env env-name="newAssign.fromDate"/>
<set field="newAssign.statusId" value="PAS_ASSIGNED"/>
<create-value value-name="newAssign"/>
</then>
<else>
<if-not-empty field="parameters.fromDate">
<!-- status changed or assignment ended -->
<entity-one entity-name="WorkEffortPartyAssignment" value-name="assignment">
<field-map field-name="workEffortId" env-name="parameters.workEffortId"/>
<field-map field-name="partyId" env-name="parameters.partyId"/>
<field-map field-name="roleTypeId" env-name="parameters.roleTypeId"/>
<field-map field-name="fromDate" env-name="parameters.fromDate"/>
</entity-one>
<if-compare field="parameters.statusId" value="PAS_ENDED" operator="equals">
<!-- special case to indicate end of assignment -->
<now-date-to-env env-name="assignment.thruDate"/>
<clear-field field-name="parameters.statusId"/>
</if-compare>
<set-nonpk-fields value-name="assignment" map-name="parameters"/>
<store-value value-name="assignment"/>
<if-compare field="assignment.statusId" value="PAS_COMPLETED" operator="equals">
<call-simple-method method-name="updateTaskStatusToComplete"/>
</if-compare>
<else>
<!-- new assignment -->
<call-simple-method method-name="assignPartyToWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
</else>
</if-not-empty>
</else>
</if>
</simple-method>
<simple-method method-name="updateTaskStatusToComplete"
short-description="Check partyassignments on a task, if all completes set task status to completed and set actual completiondate to now">
<entity-and entity-name="WorkEffortPartyAssignment" list-name="assignments" filter-by-date="true">
<field-map field-name="workEffortId" env-name="parameters.workEffortId"/>
</entity-and>
<!-- check if all open assignments were completed -->
<if-not-empty field="assignments">
<iterate entry-name="assignment" list-name="assignments">
<if-compare field="assignment.statusId" value="PAS_COMPLETED" operator="not-equals">
<set field="status" value="notcomplete"/>
</if-compare>
</iterate>
</if-not-empty>
<if-empty field="status">
<now-timestamp-to-env env-name="parameters.actualCompletionDate"/>
<set field="parameters.currentStatusId" value="PTS_COMPLETED"/>
<call-simple-method method-name="updateWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
<!-- check for related customer request, set these too to completed -->
<entity-and list-name="custRequests" entity-name="CustRequestWorkEffort">
<field-map field-name="workEffortId" env-name="parameters.workEffortId"/>
</entity-and>
<if-not-empty field="custRequests">
<iterate entry-name="custReq" list-name="custRequests">
<set field="updStat.custRequestId" from-field="custReq.custRequestId"/>
<set field="updStat.statusId" value="CRQ_COMPLETED"/>
<call-service service-name="updateCustRequest" in-map-name="updStat"/>
</iterate>
</if-not-empty>
</if-empty>
</simple-method>
<simple-method method-name="scheduleProject" short-description="Project Scheduler sets the planningdates according task requirements and available resources">
<!--
theory behind the program
- - - - - - - - - - - - -
(program under development)
Assumptions for tasks and resources
1. a workday has 8 hours.
2. a workweek has 40 hours and 5 days.
3. The order of the execution of the tasks is set by the workeffortassociation.
4. The default start of the project is today
5. default length of a task is 3 day if not planned hours entered
The steps of the program are:
1. read all tasks and check if there are predesessors, when not set he estimated dates
for critical path processing:
* ES - Earliest Start time
* EF - Earliest Finish time
* LS - Latest Start time
* LF - Latest Finish time
EF = LF task is on the critical path
2. call a recursive java function to set all the dependant tasks.
-->
<field-to-result map-name="parameters" field-name="projectId"/>
<!-- create the tasklist -->
<entity-one entity-name="WorkEffort" value-name="project">
<field-map field-name="workEffortId" env-name="parameters.projectId"/>
</entity-one>
<get-related value-name="project" relation-name="ChildWorkEffort" list-name="phases"/>
<if-not-empty field="phases">
<iterate entry-name="phase" list-name="phases">
<get-related value-name="phase" relation-name="ChildWorkEffort" list-name="tasks"/>
<if-not-empty field="tasks">
<iterate entry-name="task" list-name="tasks">
<get-related value-name="task" relation-name="ToWorkEffortAssoc" list-name="t.prevTasks"/>
<if-empty field="t.prevTasks">
<!-- no predecessors so i can set the dates -->
<now-timestamp-to-env env-name="upd.estimatedStartDate"/>
<now-timestamp-to-env env-name="currentDate"/>
<call-class-method class-name="org.ofbiz.project.Various" method-name="calculateCompletionDate" ret-field-name="upd.estimatedCompletionDate">
<field field-name="task" type="org.ofbiz.entity.GenericValue"/>
<field field-name="currentDate" type="java.sql.Timestamp"/>
</call-class-method>
<set field="upd.workEffortId" from-field="task.workEffortId"/>
<call-service service-name="updateWorkEffort" in-map-name="upd"/>
<entity-one entity-name="WorkEffort" value-name="newTask">
<field-map field-name="workEffortId" env-name="task.workEffortId"/>
</entity-one>
<call-class-method class-name="org.ofbiz.project.Various" method-name="setDatesFollowingTasks">
<field field-name="newTask" type="org.ofbiz.entity.GenericValue"/>
</call-class-method>
</if-empty>
</iterate>
</if-not-empty>
</iterate>
</if-not-empty>
</simple-method>
<simple-method method-name="updateTimeEntryByWorkeffort" short-description="Update workeffort by workeffortId and timesheetId ">
<field-to-result field-name="parameters.timesheetId" result-name="timesheetId"/>
<if-empty field="parameters.workEffortId">
<return/>
</if-empty>
<if-compare field="parameters.workEffortId" operator="equals" value="Totals">
<return/>
</if-compare>
<entity-one entity-name="Timesheet" value-name="timesheet"/>
<!-- check if party assigned to task, when not add with roletype of project, if assigned check status -->
<entity-and entity-name="WorkEffortPartyAssignment" list-name="assigns" filter-by-date="true">
<field-map field-name="workEffortId" env-name="parameters.workEffortId"/>
<field-map field-name="partyId" env-name="timesheet.partyId"/>
</entity-and>
<if-empty field="assigns">
<set field="getpr.taskId" from-field="parameters.workEffortId"/>
<call-service service-name="getProjectIdAndNameFromTask" in-map-name="getpr">
<result-to-field result-name="projectId"/>
</call-service>
<entity-and entity-name="WorkEffortPartyAssignment" list-name="projectAssigns" filter-by-date="true">
<field-map field-name="workEffortId" env-name="projectId"/>
<field-map field-name="partyId" env-name="timesheet.partyId"/>
</entity-and>
<first-from-list entry-name="projectAssign" list-name="projectAssigns"/>
<set field="parameters.partyId" from-field="timesheet.partyId"/>
<set field="parameters.roleTypeId" from-field="projectAssign.roleTypeId"/>
<set field="parameters.statusId" value="PAS_ASSIGNED"/>
<call-simple-method method-name="assignPartyToWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
<set field="parameters.fromDate" from-field="newEntity.fromDate"/><!-- need to be able to update status later -->
</if-empty>
<check-errors/>
<!-- check if the actual start date is set, when not set it to todays date -->
<if-empty field="project.actualStartDate">
<entity-one entity-name="WorkEffort" value-name="workEffort"/>
<now-timestamp-to-env env-name="workEffort.actualStartDate"/>
<store-value value-name="workEffort"/>
</if-empty>
<get-related value-name="timesheet" relation-name="TimeEntry" list-name="timeEntries"/>
<!-- update existing entries -->
<set field="hours" value="0" type="Double"/>
<if-not-empty field="timeEntries">
<iterate entry-name="timeEntry" list-name="timeEntries">
<if-compare-field field="timeEntry.workEffortId" to-field="parameters.workEffortId" operator="equals">
<if-compare-field field="timeEntry.rateTypeId" to-field="parameters.rateTypeId" operator="equals">
<!-- check if the entry does not contain any hours, then delete -->
<if-empty field="timeEntry.hours">
<remove-value value-name="timeEntry"/>
<else>
<!-- translate the date into the daynumber -->
<call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="getIntervalInDays" ret-field-name="dayNumber">
<field field-name="timesheet.fromDate" type="java.sql.Timestamp"/>
<field field-name="timeEntry.fromDate" type="java.sql.Timestamp"/>
</call-class-method>
<!-- get the related field -->
<if-not-empty field="parameters.hoursDay${dayNumber}">
<set field="hours" from-field="parameters.hoursDay${dayNumber}"/>
<else>
<set field="hours" value="0"/>
</else>
</if-not-empty>
<call-simple-method method-name="updateTimeEntry"/>
<set field="parameters.hoursDay${dayNumber}" value="-999999"/>
</else>
</if-empty>
</if-compare-field>
</if-compare-field>
</iterate>
</if-not-empty>
<!-- process not yet done fields -->
<loop count="7" field="dayNr">
<if-not-empty field="parameters.hoursDay${dayNr}">
<if-compare field="parameters.hoursDay${dayNr}" value="-999999" operator="not-equals">
<set field="hours" from-field="parameters.hoursDay${dayNr}"/>
<call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="addDaysToTimestamp" ret-field-name="fromDate">
<field field-name="timesheet.fromDate" type="java.sql.Timestamp"/>
<field field-name="dayNr" type="int"/>
</call-class-method>
<call-simple-method method-name="updateTimeEntry"/>
</if-compare>
</if-not-empty>
</loop>
<!-- update the assignment status -->
<if-compare field="parameters.checkComplete" value="Y" operator="equals">
<entity-one entity-name="WorkEffortPartyAssignment" value-name="alreadyAssign"/>
<if-compare field="alreadyAssign.statusId" value="PAS_COMPLETED" operator="not-equals">
<set field="parameters.partyId" from-field="timesheet.partyId"/>
<set field="parameters.statusId" value="PAS_COMPLETED"/>
<call-simple-method method-name="updateTaskAssigment"/>
</if-compare>
</if-compare>
</simple-method>
<simple-method method-name="getProjectIdAndNameFromTask" short-description="Get the projectId when a phase or task is provided." login-required="true">
<if-empty field="parameters.taskId">
<if-empty field="parameters.phaseId">
<return/>
</if-empty>
</if-empty>
<if-not-empty field="parameters.taskId">
<entity-one entity-name="WorkEffort" value-name="task">
<field-map field-name="workEffortId" env-name="parameters.taskId"/>
</entity-one>
<if-not-empty field="task">
<get-related-one value-name="task" relation-name="ParentWorkEffort" to-value-name="phase"/>
<else>
<return/>
</else>
</if-not-empty>
<else>
<entity-one entity-name="WorkEffort" value-name="phase">
<field-map field-name="workEffortId" env-name="parameters.phaseId"/>
</entity-one>
</else>
</if-not-empty>
<get-related-one value-name="phase" relation-name="ParentWorkEffort" to-value-name="project"/>
<field-to-result field-name="project.workEffortId" result-name="projectId"/>
<field-to-result field-name="project.workEffortName" result-name="projectName"/>
<field-to-result field-name="phase.workEffortId" result-name="phaseId"/>
<field-to-result field-name="phase.workEffortName" result-name="phaseName"/>
</simple-method>
<simple-method method-name="copyProjectToTemplate" short-description="copy a project to a workeffortType starting with 'template'">
<set field="toTemplate" value="dummy"/>
<call-simple-method method-name="copyProject"/>
</simple-method>
<simple-method method-name="copyProject" short-description="copy a project with related phases and tasks however no actual data">
<entity-one entity-name="WorkEffort" value-name="project">
<field-map field-name="workEffortId" env-name="parameters.projectId"/>
</entity-one>
<if-empty field="project">
<field-to-result map-name="parameters" field-name="projectId"/>
<add-error error-list-name="error_list"><fail-message message="Project: ${parameters.projectId} not found"/></add-error>
</if-empty>
<if-not-empty field="parameters.workEffortName">
<set field="newProject.workEffortName" from-field="parameters.workEffortName"/>
<else>
<set field="newProject.workEffortName" from-field="project.workEffortName"/>
</else>
</if-not-empty>
<if-not-empty field="toTemplate">
<set field="parameters.workEffortTypeId" value="PROJECT_TEMPLATE"/>
<else>
<set field="parameters.workEffortTypeId" value="PROJECT"/>
</else>
</if-not-empty>
<set field="parameters.currentStatusId" value="_NA_"/>
<clear-field field-name="parameters.workEffortId"/>
<set field="parameters.workEffortName" from-field="project.workEffortName"/>
<set field="parameters.currentStatusId" value="_NA_"/>
<call-simple-method method-name="createWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
<set field="newProjectId" from-field="newEntity.workEffortId"/>
<!-- copy assigned parties -->
<get-related value-name="project" relation-name="WorkEffortPartyAssignment" list-name="partiesAll"/>
<filter-list-by-date list-name="partiesAll" to-list-name="parties"/>
<if-not-empty field="parties">
<iterate entry-name="party" list-name="parties">
<set field="parameters.workEffortId" from-field="newProjectId"/>
<set field="parameters.partyId" from-field="party.partyId"/>
<set field="parameters.roleTypeId" from-field="party.roleTypeId"/>
<set field="parameters.statusId" value="PAS_ASSIGNED"/>
<call-simple-method method-name="assignPartyToWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
</iterate>
</if-not-empty>
<get-related value-name="project" relation-name="ChildWorkEffort" list-name="phases"/>
<if-not-empty field="phases">
<iterate entry-name="phase" list-name="phases">
<clear-field field-name="newPhase"/>
<if-not-empty field="toTemplate">
<set field="parameters.workEffortTypeId" value="PHASE_TEMPLATE"/>
<else>
<set field="parameters.workEffortTypeId" value="PHASE"/>
</else>
</if-not-empty>
<set field="parameters.workEffortName" from-field="phase.workEffortName"/>
<set field="parameters.workEffortParentId" from-field="newProjectId"/>
<set field="parameters.currentStatusId" value="_NA_"/>
<clear-field field-name="parameters.workEffortId"/>
<call-simple-method method-name="createWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
<set field="newPhaseId" from-field="newEntity.workEffortId"/>
<get-related value-name="phase" relation-name="ChildWorkEffort" list-name="tasks"/>
<if-not-empty field="tasks">
<iterate entry-name="task" list-name="tasks">
<clear-field field-name="newTask"/>
<if-not-empty field="toTemplate">
<set field="newTask.workEffortTypeId" value="TASK_TEMPLATE"/>
<else>
<set field="newTask.workEffortTypeId" value="TASK"/>
</else>
</if-not-empty>
<set field="parameters.workEffortName" from-field="task.workEffortName"/>
<set field="parameters.priority" from-field="task.priority"/>
<set field="parameters.workEffortParentId" from-field="newPhaseId"/>
<set field="parameters.currentStatusId" value="PTS_CREATED"/>
<clear-field field-name="parameters.workEffortId"/>
<call-simple-method method-name="createWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
</iterate>
</if-not-empty>
</iterate>
</if-not-empty>
<field-to-result field-name="newProjectId" result-name="projectId"/>
</simple-method>
<simple-method method-name="getProject" short-description="get Project information" login-required="true">
<if-empty field="parameters.projectId">
<return/>
</if-empty>
<entity-one entity-name="WorkEffort" value-name="project">
<field-map field-name="workEffortId" env-name="parameters.projectId"/>
</entity-one>
<set field="highInfo.projectId" from-field="project.workEffortId"/>
<set field="highInfo.projectName" from-field="project.workEffortName"/>
<set field="highInfo.projectDescription" from-field="project.description"/>
<set field="highInfo.scopeEnumId" from-field="project.scopeEnumId"/>
<set field="highInfo.createdStamp" from-field="project.createdStamp"/>
<entity-one entity-name="StatusItem" value-name="highSeq">
<field-map field-name="statusId" env-name="project.currentStatusId"/>
</entity-one>
<set field="highInfo.createdDate" from-field="project.createdDate"/>
<set field="highInfo.parentProjectId" from-field="parentProject.workEffortId"/>
<!-- loop through the related phases and tasks -->
<get-related value-name="project" relation-name="ChildWorkEffort" list-name="phases"/>
<if-not-empty field="phases">
<iterate entry-name="phase" list-name="phases">
<get-related value-name="phase" relation-name="ChildWorkEffort" list-name="tasks"/>
<if-not-empty field="tasks">
<iterate entry-name="lowInfo" list-name="tasks">
<if-compare field="lowInfo.currentStatusId" value="PTS_COMPLETED" operator="not-equals">
<if-compare field="lowInfo.currentStatusId" value="PTS_CANCELLED" operator="not-equals">
<set field="allTaskStatus" value="notComplete"/>
</if-compare>
</if-compare>
<call-simple-method method-name="combineInfo"/>
<call-simple-method method-name="getHours"/>
</iterate>
</if-not-empty>
</iterate>
</if-not-empty>
<!-- translate squenceId back into statusId -->
<entity-and entity-name="StatusItem" list-name="statusses">
<field-map field-name="sequenceId" env-name="highInfo.sequenceId"/>
<field-map field-name="statusTypeId" value="PROJECT_TASK_STATUS"/>
</entity-and>
<first-from-list entry-name="status" list-name="statusses"/>
<set field="highInfo.currentStatusId" from-field="status.statusId"/>
<if>
<condition>
<and>
<or>
<if-compare field="highInfo.currentStatusId" value="PTS_COMPLETED" operator="equals"/>
<if-compare field="highInfo.currentStatusId" value="PTS_ON_HOLD" operator="equals"/>
</or>
<not>
<if-empty field="allTaskStatus"/>
</not>
</and>
</condition>
<then>
<set field="highInfo.currentStatusId" value="PTS_CREATED_IP"/>
</then>
</if>
<call-simple-method method-name="createDates"/>
<!-- results -->
<field-to-result field-name="highInfo" result-name="projectInfo"/>
<field-to-result field-name="parameters.projectId" result-name="projectId"/>
</simple-method>
<simple-method method-name="getProjectPhaseList" short-description="get Project Phase information" login-required="true">
<if-empty field="parameters.projectId">
<return/>
</if-empty>
<entity-and entity-name="WorkEffort" list-name="phases">
<field-map field-name="workEffortParentId" env-name="parameters.projectId"/>
</entity-and>
<if-not-empty field="phases">
<iterate entry-name="phase" list-name="phases">
<!-- get the phase seq id -->
<entity-one entity-name="StatusItem" value-name="highSeq">
<field-map field-name="statusId" env-name="phase.currentStatusId"/>
</entity-one>
<clear-field field-name="highInfo"/>
<set field="highInfo.sequenceId" from-field="highSeq.sequenceId"/>
<set field="highInfo.phaseId" from-field="phase.workEffortId"/>
<set field="highInfo.phaseName" from-field="phase.workEffortName"/>
<set field="highInfo.phaseDescription" from-field="phase.description"/>
<set field="highInfo.scopeEnumId" from-field="phase.scopeEnumId"/>
<!-- loop through the related tasks and combine information -->
<get-related value-name="phase" relation-name="ChildWorkEffort" list-name="tasks"/>
<if-not-empty field="tasks">
<iterate entry-name="lowInfo" list-name="tasks">
<if-compare field="lowInfo.currentStatusId" value="PTS_COMPLETED" operator="not-equals">
<if-compare field="lowInfo.currentStatusId" value="PTS_CANCELLED" operator="not-equals">
<set field="allTaskStatus" value="notComplete"/>
</if-compare>
</if-compare>
<call-simple-method method-name="combineInfo"/>
<call-simple-method method-name="getHours"/>
</iterate>
</if-not-empty>
<!-- merge estimated and actual dates -->
<call-simple-method method-name="createDates"/>
<!-- translate squenceId back into statusId -->
<entity-and entity-name="StatusItem" list-name="statusses">
<field-map field-name="sequenceId" env-name="highInfo.sequenceId"/>
<field-map field-name="statusTypeId" value="PROJECT_TASK_STATUS"/>
</entity-and>
<first-from-list entry-name="status" list-name="statusses"/>
<clear-field field-name="highInfo.sequenceId"/>
<set field="highInfo.currentStatusId" from-field="status.statusId"/>
<!-- however the status 'completed' can only be 'completed' when all related tasks are completed -->
<if>
<condition>
<and>
<or>
<if-compare field="highInfo.currentStatusId" value="PTS_COMPLETED" operator="equals"/>
<if-compare field="highInfo.currentStatusId" value="PTS_ON_HOLD" operator="equals"/>
</or>
<not>
<if-empty field="allTaskStatus"/>
</not>
</and>
</condition>
<then>
<set field="highInfo.currentStatusId" value="PTS_CREATED_IP"/>
</then>
</if>
<field-to-list field-name="highInfo" list-name="phaseList"/>
</iterate>
</if-not-empty>
<!-- results -->
<field-to-result field-name="phaseList"/>
<field-to-result field-name="parameters.projectId" result-name="projectId"/>
</simple-method>
<simple-method method-name="getProjectTaskList" short-description="get Project Phase/task information" login-required="true">
<if-empty field="parameters.projectId">
<return/>
</if-empty>
<entity-and entity-name="ProjectAndPhaseAndTask" list-name="tasks">
<field-map field-name="projectId" env-name="parameters.projectId"/>
</entity-and>
<if-not-empty field="tasks">
<iterate entry-name="lowInfo" list-name="tasks">
<set field="highInfo.phaseName" from-field="lowInfo.phaseName"/>
<call-simple-method method-name="combineInfo"/>
<clear-field field-name="highInfo.sequenceId"/>
<set field="highInfo.currentStatusId" from-field="lowInfo.currentStatusId"/>
<call-simple-method method-name="createDates"/>
<call-simple-method method-name="getHours"/>
<set field="highInfo.workEffortId" from-field="lowInfo.workEffortId"/>
<set field="highInfo.workEffortName" from-field="lowInfo.workEffortName"/>
<field-to-list field-name="highInfo" list-name="taskList"/>
<clear-field field-name="highInfo"/>
</iterate>
</if-not-empty>
<!-- results -->
<field-to-result field-name="taskList"/>
<field-to-result field-name="parameters.projectId" result-name="projectId"/>
</simple-method>
<simple-method method-name="getProjectTask" short-description="get Project task information" login-required="true">
<entity-one entity-name="WorkEffort" value-name="lowInfo">
<field-map field-name="workEffortId" env-name="parameters.taskId"/>
</entity-one>
<set field="highInfo.taskId" from-field="lowInfo.workEffortId"/>
<set field="highInfo.taskName" from-field="lowInfo.workEffortName"/>
<set field="highInfo.taskDescription" from-field="lowInfo.description"/>
<set field="highInfo.scopeEnumId" from-field="lowInfo.scopeEnumId"/>
<set field="highInfo.workEffortParentId" from-field="lowInfo.workEffortParentId"/>
<call-simple-method method-name="combineInfo"/>
<call-simple-method method-name="getHours"/>
<set field="highInfo.currentStatusId" from-field="lowInfo.currentStatusId"/>
<field-to-result field-name="highInfo" result-name="taskInfo"/>
</simple-method>
<simple-method method-name="getProjectsByParties" short-description="get Project information by party member" login-required="true">
<entity-condition entity-name="ProjectAndPhaseAndTaskParty" list-name="tasks">
<condition-list combine="and">
<condition-expr field-name="projectId" operator="equals" env-name="parameters.projectId" ignore-if-empty="true"/>
<condition-expr field-name="partyId" operator="equals" env-name="parameters.partyId" ignore-if-empty="true"/>
</condition-list>
<order-by field-name="projectId"/>
<order-by field-name="partyId"/>
</entity-condition>
<if-not-empty field="tasks">
<iterate entry-name="task" list-name="tasks">
<if>
<condition>
<and>
<not><if-empty field="projectParty"/></not>
<if-compare-field field="task.partyId" to-field="projectParty.partyId" operator="not-equals"/>
</and>
</condition>
<then>
<field-to-list field-name="projectParty" list-name="projectParties"/>
<clear-field field-name="projectParty"/>
<clear-field field-name="highInfo"/>
</then>
</if>
<if-empty field="projectParty">
<set field="projectParty.partyId" from-field="task.partyId"/>
<entity-one entity-name="PartyNameView" value-name="partyNameView">
<field-map field-name="partyId" env-name="task.partyId"/>
</entity-one>
<if-not-empty field="partyNameView">
<set field="projectParty.partyName" value="${partyNameView.lastName},${partyNameView.firstName}${partyNameView.groupName}"/>
</if-not-empty>
<set field="projectParty.roleTypeId" from-field="task.roleTypeId"/>
<set field="projectParty.fromDate" from-field="task.fromDate"/>
<set field="projectParty.thruDate" from-field="task.thruDate"/>
</if-empty>
<!-- get the planned/actual hours -->
<set field="lowInfo" from-field="task"/>
<set field="parameters.hoursPartyId" from-field="task.partyId"/>
<call-simple-method method-name="getHours"/>
<set field="projectParty.plannedHours" from-field="highInfo.plannedHours"/>
<set field="projectParty.actualHours" from-field="highInfo.actualHours"/>
</iterate>
<if-not-empty field="projectParty">
<field-to-list field-name="projectParty" list-name="projectParties"/>
</if-not-empty>
<if-not-empty field="projectParties">
<field-to-result field-name="projectParties"/>
</if-not-empty>
</if-not-empty>
</simple-method>
<simple-method method-name="getTasksByParties" short-description="get task information by party member" login-required="true">
<!-- get the list of tasks optionaly selected for a party -->
<if-empty field="parameters.partyId">
<set field="parameters.partyId" value="%"/>
</if-empty>
<if-empty field="parameters.workEffortId">
<set field="parameters.workEffortId" value="%"/>
</if-empty>
<entity-condition entity-name="WorkEffortPartyAssignment" list-name="tasks" filter-by-date="true">
<condition-list combine="and">
<condition-expr field-name="partyId" operator="like" env-name="parameters.partyId"/>
<condition-expr field-name="workEffortId" operator="like" env-name="parameters.workEffortId"/>
</condition-list>
<order-by field-name="workEffortId"/>
<order-by field-name="partyId"/>
</entity-condition>
<if-not-empty field="tasks">
<iterate entry-name="task" list-name="tasks">
<if>
<condition >
<and>
<not>
<if-empty field="taskParty"/>
</not>
<if-compare-field field="task.partyId" to-field="taskParty.partyId" operator="not-equals"/>
</and>
</condition>
<then>
<field-to-list field-name="taskParty" list-name="taskParties"/>
<clear-field field-name="taskParty"/>
</then>
</if>
<if-empty field="taskParty">
<set field="taskParty.partyId" from-field="task.partyId"/>
<entity-one entity-name="PartyNameView" value-name="partyNameView">
<field-map field-name="partyId" env-name="task.partyId"/>
</entity-one>
<if-not-empty field="partyNameView">
<set field="taskParty.partyName" value="${partyNameView.lastName},${partyNameView.firstName}${partyNameView.groupName}"/>
</if-not-empty>
<set field="taskParty.roleTypeId" from-field="task.roleTypeId"/>
<set field="taskParty.statusId" from-field="task.statusId"/>
<set field="taskParty.fromDate" from-field="task.fromDate"/>
<set field="taskParty.thruDate" from-field="task.thruDate"/>
</if-empty>
<!-- get the planned hours -->
<set field="lowInfo" from-field="task"/>
<set field="hoursPartyId" from-field="task.partyId"/>
<get-related-one value-name="task" relation-name="WorkEffort" to-value-name="lowInfo"/>
<call-simple-method method-name="getHours"/>
<set field="taskParty.plannedHours" from-field="highInfo.plannedHours"/>
<set field="taskParty.actualHours" from-field="highInfo.actualHours"/>
</iterate>
<if-not-empty field="taskParty">
<field-to-list field-name="taskParty" list-name="taskParties"/>
</if-not-empty>
<if-not-empty field="taskParties">
<field-to-result field-name="taskParties"/>
</if-not-empty>
</if-not-empty>
</simple-method>
<!-- Internal functions -->
<simple-method method-name="combineInfo" short-description="combine lower level status, dates of tasks.">
<!-- in/output highInfo infoMap -->
<!-- input lowInfo info map -->
<!-- set the dates from the lower level tasks -->
<if-not-empty field="lowInfo.estimatedStartDate">
<if-empty field="highInfo.estimatedStartDate">
<set field="highInfo.estimatedStartDate" from-field="lowInfo.estimatedStartDate" />
<else>
<if-compare-field to-field="lowInfo.estimatedStartDate" field="highInfo.estimatedStartDate" operator="greater">
<set field="highInfo.estimatedStartDate" from-field="lowInfo.estimatedStartDate" />
</if-compare-field>
</else>
</if-empty>
</if-not-empty>
<if-not-empty field="lowInfo.estimatedCompletionDate">
<if-empty field="highInfo.estimatedCompletionDate">
<set field="highInfo.estimatedCompletionDate" from-field="lowInfo.estimatedCompletionDate" />
<else>
<if-compare-field to-field="lowInfo.estimatedCompletionDate" field="highInfo.estimatedCompletionDate" operator="less">
<set field="highInfo.estimatedCompletionDate" from-field="lowInfo.estimatedCompletionDate" />
</if-compare-field>
</else>
</if-empty>
</if-not-empty>
<if-not-empty field="lowInfo.actualStartDate">
<if-empty field="highInfo.actualStartDate">
<set field="highInfo.actualStartDate" from-field="lowInfo.actualStartDate" />
<else>
<if-compare-field to-field="lowInfo.actualStartDate" field="highInfo.actualStartDate" operator="greater">
<set field="highInfo.actualStartDate" from-field="lowInfo.actualStartDate" />
</if-compare-field>
</else>
</if-empty>
</if-not-empty>
<if-not-empty field="lowInfo.actualCompletionDate">
<if-empty field="highInfo.actualCompletionDate">
<set field="highInfo.actualCompletionDate" from-field="lowInfo.actualCompletionDate" />
<else>
<if-compare-field to-field="lowInfo.actualCompletionDate" field="highInfo.actualCompletionDate" operator="less">
<set field="highInfo.actualCompletionDate" from-field="lowInfo.actualCompletionDate" />
</if-compare-field>
</else>
</if-empty>
</if-not-empty>
<!-- combine the priorities -->
<if-not-empty field="lowInfo.priority">
<if-empty field="highInfo.priority">
<set field="highInfo.priority" from-field="lowInfo.priority" />
<else>
<if-compare-field to-field="lowInfo.priority" field="highInfo.priority" operator="greater">
<set field="highInfo.priority" from-field="lowInfo.priority" />
</if-compare-field>
</else>
</if-empty>
</if-not-empty>
<!-- if lowlevel type equals TASK then get create the status first -->
<if-compare field="lowInfo.workEffortTypeId" value="TASK" operator="equals">
<if-compare field="lowInfo.currentStatusId" value="PTS_CREATED" operator="equals">
<get-related value-name="lowInfo" relation-name="WorkEffortPartyAssignment" list-name="assignsAll"/>
<filter-list-by-date list-name="assignsAll" to-list-name="assigns"/>
<if-not-empty field="assigns">
<set field="lowInfo.currentStatusId" value="PTS_CREATED_AS"/><!-- task is assigned -->
</if-not-empty>
<get-related value-name="lowInfo" relation-name="TimeEntry" list-name="entries"/>
<if-not-empty field="entries">
<set field="lowInfo.currentStatusId" value="PTS_CREATED_IP"/><!-- task is in progress -->
</if-not-empty>
</if-compare>
</if-compare>
<entity-one entity-name="StatusItem" value-name="status">
<field-map field-name="statusId" env-name="lowInfo.currentStatusId"/>
</entity-one>
<if-empty field="highInfo.sequenceId">
<set field="highInfo.sequenceId" from-field="status.sequenceId"/>
<else>
<if-compare-field field="highInfo.sequenceId" to-field="status.sequenceId" operator="less">
<set field="highInfo.sequenceId" from-field="status.sequenceId"/>
</if-compare-field>
</else>
</if-empty>
</simple-method>
<simple-method method-name="getHours"
short-description="get the planned and estimated hours for a task and add to the highInfo map">
<!-- input is 'lowInfo' map output is 'highInfo map -->
<!-- hoursPartyId: if provided only the hours of that party -->
<!-- add the planned hours together -->
<get-related value-name="lowInfo" relation-name="WorkEffortSkillStandard" list-name="estimates"/>
<if-not-empty field="estimates">
<iterate entry-name="estimate" list-name="estimates">
<if-not-empty field="estimate.estimatedDuration">
<if-not-empty field="highInfo.plannedHours">
<calculate field-name="highInfo.plannedHours">
<calcop operator="get" field-name="highInfo.plannedHours"></calcop>
<calcop operator="add" field-name="estimate.estimatedDuration"/>
</calculate>
<else>
<set field="highInfo.plannedHours" from-field="estimate.estimatedDuration"/>
</else>
</if-not-empty>
</if-not-empty>
</iterate>
</if-not-empty>
<!-- get the actual hours -->
<get-related value-name="lowInfo" relation-name="TimeEntry" list-name="actuals"/>
<if-not-empty field="actuals">
<iterate entry-name="actual" list-name="actuals">
<if-not-empty field="actual.hours">
<get-related-one value-name="actual" relation-name="Timesheet" to-value-name="timesheet"/>
<if>
<condition>
<or>
<if-empty field="parameters.hoursPartyId"/>
<and>
<not><if-empty field="parameters.hoursPartyId"/></not>
<if-compare-field field="timesheet.partyId" to-field="parameters.hoursPartyId" operator="equals"/>
</and>
</or>
</condition>
<then>
<if-not-empty field="highInfo.actualHours">
<calculate field-name="highInfo.actualHours">
<calcop operator="get" field-name="highInfo.actualHours"/>
<calcop operator="add" field-name="actual.hours"></calcop>
</calculate>
<else>
<set field="highInfo.actualHours" from-field="actual.hours"/>
</else>
</if-not-empty>
</then>
</if>
<!-- keep also a general total for the actual hours of all participants -->
<if-not-empty field="highInfo.actualTotalHours">
<calculate field-name="highInfo.actualTotalHours">
<calcop operator="get" field-name="highInfo.actualTotalHours"/>
<calcop operator="add" field-name="actual.hours"></calcop>
</calculate>
<else>
<set field="highInfo.actualTotalHours" from-field="actual.hours"/>
</else>
</if-not-empty>
</if-not-empty>
</iterate>
</if-not-empty>
</simple-method>
<simple-method method-name="createDates" short-description="merge the estimated and actual dates">
<!-- input/output is 'highInfo map -->
<!-- create dates taking the last known one to save space on the list -->
<if-not-empty field="highInfo.actualStartDate">
<set field="highInfo.startDate" from-field="highInfo.actualStartDate"/>
<else>
<set field="highInfo.startDate" from-field="highInfo.estimatedStartDate"/>
</else>
</if-not-empty>
<if-not-empty field="highInfo.actualCompletionDate">
<set field="highInfo.completionDate" from-field="highInfo.actualCompletionDate"/>
<else>
<set field="highInfo.completionDate" from-field="highInfo.estimatedCompletionDate"/>
</else>
</if-not-empty>
</simple-method>
<simple-method method-name="updateTimeEntry" short-description="">
<if-compare field="hours" value="-1" operator="equals">
<return/>
</if-compare>
<if-not-empty field="timeEntry.timeEntryId">
<if-compare field="hours" operator="equals" value="0">
<set field="teDelMap.timeEntryId" from-field="timeEntry.timeEntryId"/>
<call-service service-name="deleteTimeEntry" in-map-name="teDelMap"/>
<else>
<clear-field field-name="teUpdMap"/>
<set field="teUpdMap.hours" from-field="hours"/>
<set field="teUpdMap.timeEntryId" from-field="timeEntry.timeEntryId"/>
<set field="teUpdMap.rateTypeId" from-field="parameters.rateTypeId"/>
<call-service service-name="updateTimeEntry" in-map-name="teUpdMap"/>
</else>
</if-compare>
<else>
<if-compare field="hours" operator="not-equals" value="0">
<set-service-fields service-name="createTimeEntry" map-name="parameters" to-map-name="teCreMap"/>
<set field="teCreMap.hours" from-field="hours"/>
<set field="teCreMap.fromDate" from-field="fromDate"/>
<call-service service-name="createTimeEntry" in-map-name="teCreMap"/>
</if-compare>
</else>
</if-not-empty>
</simple-method>
<simple-method method-name="createTimeEntryInTimesheet" short-description="Creates TimeEntry and searches for a timesheetId if not provided">
<if-not-empty field="parameters.fromDate">
<if-empty field="parameters.timesheetId">
<entity-condition entity-name="Timesheet" list-name="timesheets">
<condition-list combine="and">
<condition-expr field-name="fromDate" operator="less-equals" env-name="parameters.fromDate"/>
<condition-expr field-name="thruDate" operator="greater-equals" env-name="parameters.fromDate"/>
<condition-expr field-name="partyId" operator="equals" env-name="parameters.partyId"/>
</condition-list>
</entity-condition>
<if-not-empty field="timesheets">
<!-- use existing timesheet -->
<first-from-list entry-name="timesheet" list-name="timesheets"/>
<if-compare field="timesheet.statusId" value="TIMESHEET_IN_PROCESS" operator="equals">
<set field="parameters.timesheetId" from-field="timesheet.timesheetId"/>
<else>
<add-error>
<fail-message message="Cannot add to timesheet ${timesheet.timesheetId} because the status does not allow additions or modifications."/>
</add-error>
<check-errors/>
</else>
</if-compare>
<else>
<!-- create new timesheet -->
<set field="parameters.requiredDate" from-field="parameters.fromDate"/>
<call-simple-method method-name="createTimesheetForThisWeek" xml-resource="component://workeffort/script/org/ofbiz/workeffort/timesheet/TimesheetServices.xml"/>
<set field="parameters.timesheetId" from-field="newEntity.timesheetId"/>
</else>
</if-not-empty>
</if-empty>
</if-not-empty>
<!-- get role for this party in this project -->
<entity-and entity-name="ProjectPartyAndPhaseAndTask" list-name="taskRoles" filter-by-date="true">
<field-map field-name="partyId" env-name="parameters.partyId"/>
<field-map field-name="workEffortId" env-name="parameters.workEffortId"/>
</entity-and>
<first-from-list entry-name="taskRole" list-name="taskRoles"/>
<set field="parameters.roleTypeId" from-field="taskRole.roleTypeId"/>
<set field="parameters.statusId" value="PAS_ASSIGNED"/>
<call-simple-method method-name="assignPartyToWorkEffort" xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"/>
<call-simple-method method-name="createTimeEntry" xml-resource="component://workeffort/script/org/ofbiz/workeffort/timesheet/TimesheetServices.xml"/>
</simple-method>
<simple-method method-name="addProjectTimeToNewInvoice" short-description="add all reported time on all completed timesheets from all workefforts for a project">
<!-- recreate the invoice if still in preparation in order to correct errors. -->
<if-compare operator="equals" value="Y" field="parameters.reCreate">
<entity-one entity-name="Invoice" value-name="invoice"/>
<if-empty field="invoice">
<add-error><fail-message message="Could not find invoice with ID [${parameters.invoiceId}], not adding Timesheet Entries to it."/></add-error>
<check-errors/>
</if-empty>
<if-compare field="invoice.statusId" operator="not-equals" value="INVOICE_IN_PROCESS">
<add-error><fail-message message="Could not find invoice with ID [${parameters.invoiceId}], not adding Timesheet Entries to it."/></add-error>
<check-errors/>
</if-compare>
<entity-and list-name="entries" entity-name="TimeEntry">
<field-map field-name="invoiceId" env-name="parameters.invoiceId"/>
</entity-and>
<iterate list-name="entries" entry-name="timeEntry">
<clear-field field-name="timeEntry.invoiceId"/>
<clear-field field-name="timeEntry.invoiceItemSeqId"/>
<store-value value-name="timeEntry"/>
</iterate>
<set field="removeItems.invoiceId" from-field="parameters.invoiceId"/>
<remove-by-and entity-name="InvoiceItem" map-name="removeItems"/>
<set field="notFirst" value="Y"/><!-- do not create, only add -->
</if-compare>
<log level="always" message="==============invoice items deleted"/>
<entity-and entity-name="ProjectAndPhaseAndTask" list-name="tasks">
<field-map field-name="projectId" env-name="parameters.projectId"/>
</entity-and>
<iterate entry-name="task" list-name="tasks">
<if-empty field="notFirst">
<!-- first time so create invoice -->
<set-service-fields service-name="addWorkEffortTimeToNewInvoice" map-name="parameters" to-map-name="addTaskToNewInvoice"/>
<set field="addTaskToNewInvoice.workEffortId" from-field="task.workEffortId"/>
<set field="addTaskToNewInvoice.combineInvoiceItem" value="Y"/>
<call-service service-name="addWorkEffortTimeToNewInvoice" in-map-name="addTaskToNewInvoice">
<result-to-field result-name="invoiceId" field-name="parameters.invoiceId"/>
</call-service>
<set field="addTaskToInvoice.combineInvoiceItem" value="Y"/>
<set field="notFirst" value="Y"/>
<field-to-result field-name="parameters.invoiceId" result-name="invoiceId"/>
<else>
<!-- add to created invoice -->
<set field="addTaskToInvoice.combineInvoiceItem" value="Y"/>
<set field="addTaskToInvoice.invoiceId" from-field="parameters.invoiceId"/>
<set field="addTaskToInvoice.workEffortId" from-field="task.workEffortId"/>
<log level="always" message="==============add workeffort iwth data ${addTaskToInvoice}"/>
<call-service service-name="addWorkEffortTimeToInvoice" in-map-name="addTaskToInvoice"/>
</else>
</if-empty>
</iterate>
</simple-method>
</simple-methods>