blob: 950fba39ee7d83640262f0c4f69a09c56ab722c3 [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="createSprint" short-description="Create Sprint">
<!-- Permission Check -->
<call-simple-method method-name="getWebSiteId"/>
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_SPRINT" action="_CREATE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<entity-one entity-name="UserLogin" value-field="sysUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<!-- Error Filtering -->
<if-compare operator="less-equals" value="0" field="parameters.maxNum">
<add-error error-list-name="_error_message_list_">
<fail-message message="There is no product backlogs in the system. Please create the product backlogs before perform this action."/>
</add-error>
</if-compare>
<if-compare-field field="parameters.sprintBacklogs" operator="greater" to-field="parameters.maxNum" type="Integer">
<add-error error-list-name="_error_message_list_">
<fail-message message="Number of sprint backlogs are too much. Please enter the number equal or less than ${parameters.maxNum}."/>
</add-error>
</if-compare-field>
<if-compare operator="less-equals" value="0" field="parameters.sprintBacklogs" type="Integer">
<add-error error-list-name="_error_message_list_">
<fail-message message="Number of sprint backlogs must greater than 0 (zero)"/>
</add-error>
</if-compare>
<if-empty field="parameters.sprintEstimatedStart">
<add-error error-list-name="_error_message_list_">
<fail-message message="Start Date is missing"/>
</add-error>
</if-empty>
<if-not-empty field="_error_message_list_">
<return response-code="error"/>
</if-not-empty>
<!-- calculate estimatedMilliSeconds -->
<set field="sprintDuration" from-field="parameters.sprintDuration" type="Integer"/>
<set field="actualStartDate" from-field="parameters.sprintEstimatedStart" type="Date"/>
<set field="actualCompletionDate"/>
<set field="groovy" value="${groovy: import groovy.time.*;
context.actualCompletionDate = (context.actualStartDate-1) + (context.sprintDuration*7);
}"/>
<set field="actualStartDateT" from-field="actualStartDate" type="Timestamp"/>
<set field="actualCompletionDateT" from-field="actualCompletionDate" type="Timestamp"/>
<set field="input.estimatedMilliSeconds" type="Long" value="${groovy: import groovy.time.*;
def estimatedMilliSeconds = context.sprintDuration*5*8*60*60*1000;
return (estimatedMilliSeconds);
}"/>
<set field="input.workEffortName" from-field="parameters.sprintName"/>
<set field="input.description" from-field="parameters.sprintDescription"/>
<set field="input.actualStartDate" from-field="actualStartDate"/>
<set field="input.actualCompletionDate" from-field="actualCompletionDate"/>
<set field="input.workEffortTypeId" value="SCRUM_SPRINT"/>
<set field="input.currentStatusId" value="SPRINT_ACTIVE"/>
<set field="input.workEffortParentId" from-field="parameters.projectId"/>
<set field="input.webSiteId" from-field="parameters.webSiteId"/>
<set field="input.userLogin" from-field="sysUserLogin"/>
<!-- Create Sprint -->
<call-service service-name="createWorkEffort" in-map-name="input">
<result-to-field result-name="workEffortId" field="parameters.sprintId"/>
</call-service>
<!-- Add sprint backlog to sprint -->
<call-simple-method method-name="createSprintBacklog"></call-simple-method>
<!-- Add default backlog and task to sprint -->
<call-simple-method method-name="createBacklogMeeting"/>
<entity-one entity-name="WorkEffort" value-field="workEffort">
<field-map field-name="workEffortId" from-field="parameters.projectId"/>
</entity-one>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="createBacklogMeeting" short-description="Create Backlog for meeting to sprint">
<if>
<condition>
<or>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
<if-has-permission permission="SCRUM_SPRINT" action="_CREATE"/>
</or>
</condition>
<then>
<entity-and entity-name="WorkEffortAndProduct" list="workEffortList">
<field-map field-name="workEffortId" from-field="parameters.projectId"/>
</entity-and>
<first-from-list list="workEffortList" entry="workEffortMap"/>
<make-value value-field="backlogMeeting" entity-name="CustRequest"/>
<sequenced-id sequence-name="CustRequest" field="custRequestId"/>
<set field="backlogMeeting.custRequestId" from-field="custRequestId"/>
<set field="backlogMeeting.custRequestTypeId" value="RF_SCRUM_MEETINGS"/>
<set field="backlogMeeting.statusId" value="CRQ_REVIEWED"/>
<set field="backlogMeeting.custRequestName" value="Scrum Meeting"/>
<set field="backlogMeeting.description" value="Scrum Meeting"/>
<set field="backlogMeeting.fromPartyId" from-field="userLogin.partyId"/>
<create-value value-field="backlogMeeting"/>
<set-service-fields service-name="createCustRequestItem" map="parameters" to-map="createItem"/>
<set field="createItem.custRequestId" from-field="custRequestId"/>
<set field="createItem.productId" from-field="workEffortMap.productId"/>
<call-service service-name="createCustRequestItem" in-map-name="createItem"/>
<!-- add default backlog to sprint -->
<set field="createBL.custRequestId" from-field="custRequestId"/>
<set field="createBL.workEffortId" from-field="parameters.sprintId"/>
<set field="createBL.userLogin" from-field="userLogin"/>
<call-service service-name="createWorkEffortRequest" in-map-name="createBL"/>
<!-- add default task to backlog -->
<set field="newDefaultTask.workEffortName" value="Scrum Planning"/>
<set field="newDefaultTask.currentStatusId" value="STS_CREATED"/>
<set field="newDefaultTask.workEffortTypeId" value="SCRUM_TASK_IMPL"/>
<set field="newDefaultTask.workEffortPurposeTypeId" value="SCRUM_DEFAULT_TASK"/>
<set field="newDefaultTask.workEffortParentId" from-field="parameters.sprintId"/>
<call-service service-name="createWorkEffort" in-map-name="newDefaultTask">
<result-to-field result-name="workEffortId"/>
</call-service>
<set field="parameters.custRequestId" from-field="custRequestId"/>
<set field="parameters.workEffortId" from-field="workEffortId"/>
<set-service-fields service-name="createWorkEffortRequest" map="parameters" to-map="createWorkEffortRequest"/>
<call-service service-name="createWorkEffortRequest" in-map-name="createWorkEffortRequest">
<result-to-field result-name="workEffortId" field="workEffort"/>
</call-service>
<set field="newDefaultTask.workEffortName" value="Sprint Evaluation and Sprint Retrospective"/>
<set field="newDefaultTask.currentStatusId" value="STS_CREATED"/>
<set field="newDefaultTask.workEffortTypeId" value="SCRUM_TASK_IMPL"/>
<set field="newDefaultTask.workEffortPurposeTypeId" value="SCRUM_DEFAULT_TASK"/>
<set field="newDefaultTask.workEffortParentId" from-field="parameters.sprintId"/>
<call-service service-name="createWorkEffort" in-map-name="newDefaultTask">
<result-to-field result-name="workEffortId"/>
</call-service>
<set field="parameters.custRequestId" from-field="custRequestId"/>
<set field="parameters.workEffortId" from-field="workEffortId"/>
<set-service-fields service-name="createWorkEffortRequest" map="parameters" to-map="createWorkEffortRequest"/>
<call-service service-name="createWorkEffortRequest" in-map-name="createWorkEffortRequest">
<result-to-field result-name="workEffortId" field="workEffortId"/>
</call-service>
<set field="newDefaultTask.workEffortName" value="Daily Scrum"/>
<set field="newDefaultTask.currentStatusId" value="STS_CREATED"/>
<set field="newDefaultTask.workEffortTypeId" value="SCRUM_TASK_IMPL"/>
<set field="newDefaultTask.workEffortPurposeTypeId" value="SCRUM_DEFAULT_TASK"/>
<set field="newDefaultTask.workEffortParentId" from-field="parameters.sprintId"/>
<call-service service-name="createWorkEffort" in-map-name="newDefaultTask">
<result-to-field result-name="workEffortId"/>
</call-service>
<set field="parameters.custRequestId" from-field="custRequestId"/>
<set field="parameters.workEffortId" from-field="workEffortId"/>
<set-service-fields service-name="createWorkEffortRequest" map="parameters" to-map="createWorkEffortRequest"/>
<call-service service-name="createWorkEffortRequest" in-map-name="createWorkEffortRequest">
<result-to-field result-name="workEffortId" field="workEffortId"/>
</call-service>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="updateSprintInfo" short-description="Update Sprint Infomation">
<!-- Permission Check -->
<call-simple-method method-name="getWebSiteId"/>
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_SPRINT" action="_UPDATE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<if>
<condition>
<if-compare field="parameters.statusId" value="SPRINT_CLOSED" operator="equals"/>
</condition>
<then>
<!-- close sprint and take out incomplete backlog(s) -->
<call-simple-method method-name="closeSprint"/>
</then>
<else>
<!-- Error Filltering -->
<if-empty field="parameters.workEffortName">
<add-error error-list-name="_error_message_list_">
<fail-message message="Sprint Name is missing."/>
</add-error>
</if-empty>
<if-empty field="parameters.actualStartDate">
<add-error error-list-name="_error_message_list_">
<fail-message message="Start Date is missing."/>
</add-error>
</if-empty>
<if-not-empty field="_error_message_list_">
<return response-code="error"/>
</if-not-empty>
<!-- calculate estimatedMilliSeconds -->
<set field="sprintDuration" from-field="parameters.sprintDuration" type="Integer"/>
<set field="actualStartDate" from-field="parameters.actualStartDate" type="Date"/>
<set field="actualCompletionDate"/>
<set field="groovy" value="${groovy: import groovy.time.*;
context.actualCompletionDate = (context.actualStartDate-1) +(context.sprintDuration*7);}"/>
<set field="actualStartDateT" from-field="actualStartDate" type="Timestamp"/>
<set field="actualCompletionDateT" from-field="actualCompletionDate" type="Timestamp"/>
<set field="parameters.estimatedMilliSeconds" type="Long" value="${groovy: import groovy.time.*;
def estimatedMilliSeconds = context.sprintDuration*5*8*60*60*1000;
return (estimatedMilliSeconds);}"/>
<set field="parameters.actualStartDate" from-field="actualStartDateT"/>
<set field="parameters.actualCompletionDate" from-field="actualCompletionDateT"/>
<set field="parameters.currentStatusId" from-field="parameters.statusId"/>
<set field="parameters.webSiteId" from-field="parameters.webSiteId"/>
<call-service service-name="updateWorkEffort" in-map-name="parameters">
</call-service>
</else>
</if>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="deleteSprintBacklog" short-description="Delete relation of sprint and customer request">
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_SPRINT" action="_UPDATE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<call-simple-method method-name="getWebSiteId"/>
<entity-condition entity-name="CustRequestAndWorkEffort" list="taskInSprintBacklogs">
<condition-list combine="and">
<condition-expr field-name="custRequestId" from-field="parameters.custRequestId"/>
<condition-expr field-name="workEffortTypeId" value="SCRUM_SPRINT" operator="not-equals"/>
</condition-list>
</entity-condition>
<!-- Grouping Sprint and Customer Request -->
<set field="input.custRequestId" from-field="parameters.custRequestId"/>
<set field="input.workEffortId" from-field="parameters.sprintId"/>
<if-not-empty field="input.workEffortId">
<call-service service-name="deleteWorkEffortRequest" in-map-name="input"/>
</if-not-empty>
<!-- Change CustRequest status back to Accepted an d reorder backlog Item-->
<entity-one entity-name="WorkEffort" value-field="sprintMap">
<field-map field-name="workEffortId" from-field="parameters.sprintId"/>
</entity-one>
<entity-and entity-name="WorkEffortAndProduct" list="projectList">
<field-map field-name="workEffortId" from-field="sprintMap.workEffortParentId"/>
</entity-and>
<set field="productId" from-field="projectList[0].productId"/>
<if-empty field="productId">
<set field="productId" from-field="parameters.productId"/>
</if-empty>
<entity-one entity-name="CustRequest" value-field="custRequest"/>
<if-compare field="custRequest.custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG">
<entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="productId"/>
<condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
<condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
</condition-list>
</entity-count>
<else>
<entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="productId"/>
<condition-expr field-name="custRequestTypeId" operator="not-equals" value="RF_UNPLAN_BACKLOG"/>
<condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
</condition-list>
</entity-count>
</else>
</if-compare>
<set field="sequenceNumIn" value="1" type="Long"/>
<set field="custRequestResultMap.custRequestId" from-field="parameters.custRequestId"/>
<!-- the first sequence number -->
<if-compare field="getNum" operator="equals" value="0">
<set field="custRequestResultMap.custSequenceNum" from-field="sequenceNumIn"/>
<else>
<if-compare field="custRequest.custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG">
<entity-condition entity-name="CustRequestAndCustRequestItem" list="custRequestList">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="productId"/>
<condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
<condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
</condition-list>
<order-by field-name="custSequenceNum"/>
</entity-condition>
<else>
<entity-condition entity-name="CustRequestAndCustRequestItem" list="custRequestList">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="productId"/>
<condition-expr field-name="custRequestTypeId" operator="not-equals" value="RF_UNPLAN_BACKLOG"/>
<condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
</condition-list>
<order-by field-name="custSequenceNum"/>
</entity-condition>
</else>
</if-compare>
<set field="sequenceNumkey" from-field="sequenceNumIn" type="Integer"/>
<set field="productMap" from-field="custRequestList[sequenceNumkey-1]"/>
<set field="externalSeq" from-field="productMap.custSequenceNum" type="Long"/>
<!-- Insert new transaction to CustRequest -->
<loop count="${getNum}" field="i">
<set field="internalSeq" from-field="custRequestList[i].custSequenceNum" type="Long" />
<set field="ready" value="${groovy:internalSeq&gt;=externalSeq}" type="Boolean"/>
<if-compare field="ready" operator="equals" value="true" type="Boolean">
<set field="custRequestIdIn" from-field="custRequestList[i].custRequestId"/>
<entity-one entity-name="CustRequest" value-field="custRequestMap">
<field-map field-name="custRequestId" from-field="custRequestIdIn"/>
</entity-one>
<set field="custSequenceNum" from-field="custRequestMap.custSequenceNum"/>
<set field="nextSeqNum" value="${custSequenceNum+1}" type="Long"/>
<set field="custRequestMap.custSequenceNum" from-field="nextSeqNum"/>
<store-value value-field="custRequestMap"/>
</if-compare>
</loop>
<set field="custRequestResultMap.custSequenceNum" from-field="externalSeq"/>
</else>
</if-compare>
<!-- update Cust Request -->
<set field="oldStatusId" from-field="custRequest.statusId"/><!-- use in confirmation email (current status is CRQ_REVIEWED) -->
<set field="custRequestResultMap.webSiteId" from-field="parameters.webSiteId"/>
<call-service service-name="updateCustRequest" in-map-name="custRequestResultMap"/>
<set field="setCustRequestStatusCtx.custRequestId" from-field="parameters.custRequestId"/>
<set field="setCustRequestStatusCtx.statusId" value="CRQ_ACCEPTED"/>
<set field="setCustRequestStatusCtx.webSiteId" from-field="parameters.webSiteId"/>
<call-service service-name="setCustRequestStatus" in-map-name="setCustRequestStatusCtx"/>
<entity-condition entity-name="ProductBacklog" list="listTaskInBacklog">
<condition-list combine="and">
<condition-expr field-name="custRequestId" from-field="parameters.custRequestId"/>
<condition-list combine="or">
<condition-expr field-name="workEffortTypeId" value="SCRUM_TASK_IMPL"/>
<condition-expr field-name="workEffortTypeId" value="SCRUM_TASK_ERROR"/>
<condition-expr field-name="workEffortTypeId" value="SCRUM_TASK_INST"/>
<condition-expr field-name="workEffortTypeId" value="SCRUM_TASK_TEST"/>
</condition-list>
</condition-list>
</entity-condition>
<if-not-empty field="listTaskInBacklog">
<loop count="${groovy: listTaskInBacklog.size()}" field="i">
<set field="updateProject.workEffortId" from-field="listTaskInBacklog[i].workEffortId"/>
<clear-field field="updateProject.workEffortParentId"/>
<call-service service-name="updateWorkEffort" in-map-name="updateProject"/>
</loop>
</if-not-empty>
<set field="_event_message_" value="The Sprint backlog has been deleted."/>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="DeleteSprint" short-description="Delete Sprint">
<!-- Permission Check -->
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_SPRINT" action="_DELETE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<set field="parameters.sprintId" from-field="parameters.workEffortId"/>
<entity-and entity-name="CustRequestWorkEffort" list="custRequestWorkEfforts">
<field-map field-name="workEffortId" from-field="parameters.sprintId"/>
</entity-and>
<if-not-empty field="custRequestWorkEfforts">
<!-- Delete Bound Sprint and Customer Request -->
<remove-list list="custRequestWorkEfforts"/>
</if-not-empty>
<!-- Delete Sprint -->
<set field="delSprintInput.workEffortId" from-field="parameters.sprintId"/>
<call-service service-name="deleteWorkEffort" in-map-name="delSprintInput">
</call-service>
<!-- Delete Sprint Member -->
<entity-and entity-name="WorkEffortPartyAssignView" list="membersPartyId">
<field-map field-name="workEffortId" from-field="parameters.sprintId"/>
</entity-and>
<if-not-empty field="membersPartyId">
<iterate list="membersPartyId" entry="memberPartyId">
<call-service service-name="unassignPartyFromWorkEffort" in-map-name="memberPartyId"></call-service>
</iterate>
</if-not-empty>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="createScrumProject" short-description="Create Scrum Project and Product Owner">
<!-- Permission Check -->
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_PROJECT" action="_CREATE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
<if-has-permission permission="SCRUM_PROJECT_ROLE" action="_ADMIN"/>
<if-has-permission permission="SCRUM_PROJECT" action="_ADMIN"/>
<if-has-permission permission="SCRUM_PROJECT" action="_UPDATE"/>
</or>
</condition>
<then>
<now-timestamp field="now"/>
<entity-one entity-name="UserLogin" value-field="sysUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<set-service-fields service-name="createWorkEffort" map="parameters" to-map="createProject"/>
<set field="createProject.workEffortTypeId" value="SCRUM_PROJECT"/>
<set field="createProject.currentStatusId" value="SPJ_ACTIVE"/>
<set field="createProject.userLogin" from-field="sysUserLogin"/>
<call-service service-name="createWorkEffort" in-map-name="createProject" >
<result-to-field result-name="workEffortId" field="workEffortId"/>
</call-service>
<field-to-request field="workEffortId" request-name="projectId"/>
<log level="info" message="Creating new project, projectId=${workEffortId}"/>
<!-- Create workeffort associate with product -->
<make-value value-field="goodStandardMap" entity-name="WorkEffortGoodStandard"/>
<set field="goodStandardMap.workEffortId" from-field="workEffortId"/>
<set field="goodStandardMap.productId" from-field="parameters.productId"/>
<set field="goodStandardMap.workEffortGoodStdTypeId" value="SCRUM_PRO_WORKEFF"/>
<set field="goodStandardMap.fromDate" from-field="now"/>
<set field="goodStandardMap.statusId" value="WEGS_CREATED"/>
<create-value value-field="goodStandardMap"/>
<!-- Create project billed options -->
<if-not-empty field="parameters.billed">
<make-value value-field="workEffortAttMap" entity-name="WorkEffortAttribute"/>
<set field="workEffortAttMap.workEffortId" from-field="workEffortId"/>
<set field="workEffortAttMap.attrName" value="PROJECT_BILLED"/>
<set field="workEffortAttMap.attrValue" from-field="parameters.billed"/>
<create-value value-field="workEffortAttMap"/>
</if-not-empty>
<set-service-fields service-name="assignPartyToWorkEffort" map="parameters" to-map="assign"/>
<set field="assign.workEffortId" from-field="workEffortId"/>
<set field="assign.partyId" from-field="productRole[0].partyId"/>
<set field="assign.roleTypeId" value="PRODUCT_OWNER"/>
<set field="assign.statusId" value="PRTYASGN_ASSIGNED"/>
<set field="assign.userLogin" from-field="sysUserLogin"/>
<log level="info" message="Assign partyId ${assign.partyId} to projectId=${workEffortId}"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="assign"/>
<entity-and entity-name="PartyRole" list="listPartyRoleScrumMaster">
<field-map field-name="partyId" from-field="userLogin.partyId"/>
<field-map field-name="roleTypeId" value="SCRUM_MASTER"/>
</entity-and>
<if-not-empty field="listPartyRoleScrumMaster">
<set-service-fields service-name="assignPartyToWorkEffort" map="parameters" to-map="assignScrumMaster"/>
<set field="assignScrumMaster.workEffortId" from-field="workEffortId"/>
<set field="assignScrumMaster.partyId" from-field="userLogin.partyId"/>
<set field="assignScrumMaster.roleTypeId" value="SCRUM_MASTER"/>
<set field="assignScrumMaster.statusId" value="PRTYASGN_ASSIGNED"/>
<set field="assignScrumMaster.userLogin" from-field="sysUserLogin"/>
<log level="info" message="Assign partyId ${assignScrumMaster.partyId} to projectId=${workEffortId}"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="assignScrumMaster"/>
</if-not-empty>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<log level="error" message="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="updateScrumProject" short-description="Update Scrum Project and Product Owner">
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_PROJECT" action="_UPDATE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
<if-has-permission permission="SCRUM_PROJECT_ROLE" action="_ADMIN"/>
</or>
</condition>
<then>
<now-timestamp field="now"/>
<set-service-fields service-name="updateWorkEffort" map="parameters" to-map="updateProject"/>
<call-service service-name="updateWorkEffort" in-map-name="updateProject"/>
<!-- remove old workeffort associate with product -->
<entity-and entity-name="WorkEffortGoodStandard" list="workEffGSDList">
<field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
<field-map field-name="workEffortGoodStdTypeId" value="SCRUM_PRO_WORKEFF"/>
</entity-and>
<if-not-empty field="workEffGSDList">
<remove-list list="workEffGSDList"/>
</if-not-empty>
<!-- create old workeffort associate with product -->
<make-value value-field="goodStandardMap" entity-name="WorkEffortGoodStandard"/>
<set field="goodStandardMap.workEffortId" from-field="parameters.workEffortId"/>
<set field="goodStandardMap.productId" from-field="parameters.productId"/>
<set field="goodStandardMap.workEffortGoodStdTypeId" value="SCRUM_PRO_WORKEFF"/>
<set field="goodStandardMap.fromDate" from-field="now"/>
<set field="goodStandardMap.statusId" value="WEGS_CREATED"/>
<create-value value-field="goodStandardMap"/>
<!-- update project billed options -->
<entity-one entity-name="WorkEffortAttribute" value-field="workEffortAttMap">
<field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
<field-map field-name="attrName" value="PROJECT_BILLED"/>
</entity-one>
<if-not-empty field="workEffortAttMap">
<set field="workEffortAttMap.attrValue" from-field="parameters.billed"/>
<store-value value-field="workEffortAttMap"/>
<else>
<make-value value-field="workEffortAttMap" entity-name="WorkEffortAttribute"/>
<set field="workEffortAttMap.workEffortId" from-field="parameters.workEffortId"/>
<set field="workEffortAttMap.attrName" value="PROJECT_BILLED"/>
<set field="workEffortAttMap.attrValue" from-field="parameters.billed"/>
<create-value value-field="workEffortAttMap"/>
</else>
</if-not-empty>
<!-- update project current status to closed -->
<if-compare field="parameters.currentStatusId" operator="equals" value="SPJ_CLOSED">
<!-- <entity-and entity-name="ProjectSprintBacklogAndTask" list="sprintList">-->
<!-- <field-map field-name="projectId" from-field="parameters.projectId"/>-->
<!-- <field-map field-name="sprintTypeId" value="SCRUM_SPRINT"/>-->
<!-- </entity-and>-->
<entity-and entity-name="ProjectSprint" list="sprintList">
<field-map field-name="projectId" from-field="parameters.projectId"/>
<field-map field-name="projectTypeId" value="SCRUM_PROJECT"/>
</entity-and>
<if-not-empty field="sprintList"></if-not-empty>
<iterate list="sprintList" entry="sprint">
<!-- Check current status -->
<entity-one entity-name="WorkEffort" value-field="sprintEntry">
<field-map field-name="workEffortId" from-field="sprint.sprintId"/>
</entity-one>
<if-not-empty field="sprintEntry">
<if-compare operator="not-equals" value="SPRINT_CLOSED" field="sprintEntry.currentStatusId">
<set field="updateStatus.currentStatusId" value="SPRINT_CLOSED"/>
<set field="updateStatus.workEffortId" from-field="sprint.sprintId"/>
<call-service service-name="updateWorkEffort" in-map-name="updateStatus"/>
<!-- clear unneccessay parameters -->
<clear-field field="parameters.currentStatusId"/>
<set field="parameters.projectId" from-field="parameters.projectId"/>
<set field="parameters.sprintId" from-field="sprint.sprintId"/>
<call-simple-method method-name="closeSprint"/>
</if-compare>
</if-not-empty>
</iterate>
</if-compare>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="deleteCustRequestItem" short-description="Delete Cust Request Item" login-required="false">
<set field="custRequestItemCtx.custRequestItemSeqId" from-field="parameters.custRequestItemSeqId"/>
<remove-by-and entity-name="CustRequestItemNote" map="custRequestItemCtx"/>
<remove-by-and entity-name="CustRequestItemWorkEffort" map="custRequestItemCtx"/>
<make-value value-field="deleteCustRequestItem" entity-name="CustRequestItem"/>
<set-pk-fields value-field="deleteCustRequestItem" map="parameters"/>
<set-nonpk-fields map="parameters" value-field="deleteCustRequestItem"/>
<remove-value value-field="deleteCustRequestItem"/>
</simple-method>
<simple-method method-name="deleteCustRequest" short-description="Delete a draft Customer Request with no relations yet">
<call-simple-method method-name="getWebSiteId"/>
<!-- Permission Check -->
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_PRODUCT_BACKLOG" action="_DELETE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<entity-one entity-name="CustRequest" value-field="custRequest"/>
<!-- set default custRequestName -->
<if-empty field="custRequest.custRequestName">
<set field="custRequest.custRequestName" value="product backlog[${custRequest.custRequestId}]"/>
<store-value value-field="custRequest"/>
</if-empty>
<set field="custRequest.reason" from-field="parameters.reason"/>
<if-not-empty field="custRequest">
<set field="input.custRequestId" from-field="custRequest.custRequestId"/>
<set field="input.reason" from-field="custRequest.reason"/>
<set field="input.statusId" value="CRQ_CANCELLED"/>
<set field="input.webSiteId" from-field="parameters.webSiteId"/>
<call-service service-name="setCustRequestStatus" in-map-name="input"/>
</if-not-empty>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="updateProductBacklogItemRows" short-description="Update product backlog item rows in multi form">
<!-- Permission Check -->
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_PRODUCT_BACKLOG" action="_DELETE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<call-class-method method-name="getParameterMap" class-name="org.apache.ofbiz.base.util.UtilHttp" ret-field="paramMap">
<field field="request" type="javax.servlet.http.HttpServletRequest"/>
</call-class-method>
<call-class-method method-name="getMultiFormRowCount" class-name="org.apache.ofbiz.base.util.UtilHttp" ret-field="rowCount">
<field field="paramMap" type="java.util.Map"/>
</call-class-method>
<!-- get all data to list -->
<set field="custRequestIndexList" type="List"/>
<set field="custRequestList" type="List"/>
<loop count="${rowCount}" field="j">
<set field="custRequestMap" type="NewMap"/>
<set field="custRequestMap.custRequestId" from-field="paramMap[&quot;custRequestId_o_${j}&quot;]"/>
<set field="custRequestMap.custSequenceNum" from-field="paramMap[&quot;realSequenceNum_o_${j}&quot;]"/>
<field-to-list list="custRequestList" field="custRequestMap"/>
<field-to-list list="custRequestIndexList" field="paramMap[&quot;realSequenceNum_o_${j}&quot;]"/>
</loop>
<set field="newCustRequestList" type="List"/>
<set field="custRequestListWithNewSeq" type="List"/>
<loop count="${rowCount}" field="k">
<set field="custRequestMap" type="NewMap"/>
<set field="custRequestMap.custRequestId" from-field="paramMap[&quot;custRequestId_o_${k}&quot;]"/>
<set field="oldSequenceNum" from-field="paramMap[&quot;realSequenceNum_o_${k}&quot;]"/>
<set field="newSequenceNum" from-field="paramMap[&quot;newSequenceNum_o_${k}&quot;]"/>
<if-not-empty field="newSequenceNum">
<set field="custRequestMap.custSequenceNum" from-field="newSequenceNum"/>
<field-to-list list="custRequestListWithNewSeq" field="custRequestMap"/>
<else>
<set field="custRequestMap.custSequenceNum" from-field="oldSequenceNum"/>
<field-to-list list="newCustRequestList" field="custRequestMap"/>
</else>
</if-not-empty>
</loop>
<!-- get size -->
<set field="custRequestListSize" value="${groovy: custRequestList.size();}" type="Double"/>
<!-- Check if there are duplicate value will reorder and change it -->
<set field="custRequestIndex" type="List"/>
<set field="custRequestIndexToSet" value="${groovy: import java.util.Set; new HashSet(custRequestIndexList);}"/>
<iterate list="custRequestIndexToSet" entry="custRequestIndexMap">
<set field="count" value="0" type="Integer"/>
<loop count="${custRequestListSize}" field="l">
<if-compare-field field="custRequestList[l].custSequenceNum" operator="equals" to-field="custRequestIndexMap" type="Integer">
<set field="count" value="${count + 1}"/>
</if-compare-field>
</loop>
<if-compare field="count" operator="greater" value="1" type="Integer">
<set field="custRequestIndexMap" from-field="custRequestIndexMap" type="Integer"/>
<field-to-list list="custRequestIndex" field="custRequestIndexMap"/>
</if-compare>
</iterate>
<if-not-empty field="custRequestIndex">
<script>groovy:
List indexList = custRequestIndex;
Collections.sort(indexList);
Collections.reverse(indexList);
List uniqueCustRequestIndexList = indexList;
return org.apache.ofbiz.base.util.UtilMisc.toMap("uniqueCustRequestIndexList", uniqueCustRequestIndexList);
</script>
</if-not-empty>
<if-not-empty field="uniqueCustRequestIndexList">
<iterate list="uniqueCustRequestIndexList" entry="custRequestIndexMap">
<set field="count" value="0" type="Integer"/>
<loop count="${custRequestListSize}" field="m">
<if>
<condition>
<if-compare-field field="custRequestList[m].custSequenceNum" operator="equals" to-field="custRequestIndexMap" type="Integer"/>
</condition>
<then>
<set field="sequenceNumIndex" value="${custRequestList[m].custSequenceNum + count}" type="Integer"/>
<set field="custRequestList[m].custSequenceNum" from-field="sequenceNumIndex" type="String"/>
<entity-one entity-name="CustRequest" value-field="newCustRequestMap">
<field-map field-name="custRequestId" from-field="custRequestList[m].custRequestId"/>
</entity-one>
<set field="nextSeqNum" value="${custRequestList[m].custSequenceNum}" type="Long"/>
<set field="newCustRequestMap.custSequenceNum" from-field="nextSeqNum"/>
<store-value value-field="newCustRequestMap"/>
<set field="count" value="${count + 1}"/>
</then>
<else>
<if-compare-field field="custRequestList[m].custSequenceNum" operator="greater" to-field="custRequestIndexMap" type="Integer">
<set field="sequenceNumIndex" value="${custRequestIndexMap + count}" type="Integer"/>
<set field="custRequestList[m].custSequenceNum" from-field="sequenceNumIndex" type="String"/>
<entity-one entity-name="CustRequest" value-field="newCustRequestMaps">
<field-map field-name="custRequestId" from-field="custRequestList[m].custRequestId"/>
</entity-one>
<set field="nextSeqNum" value="${custRequestList[m].custSequenceNum}" type="Long"/>
<set field="newCustRequestMaps.custSequenceNum" from-field="nextSeqNum"/>
<store-value value-field="newCustRequestMaps"/>
<set field="count" value="${count + 1}"/>
</if-compare-field>
</else>
</if>
</loop>
</iterate>
</if-not-empty>
<!-- if new sequence not empty -->
<if-not-empty field="custRequestListWithNewSeq">
<if-empty field="newCustRequestList">
<!-- use when all field in new sequence not empty -->
<loop count="${rowCount}" field="l">
<set field="newSeq" from-field="custRequestListWithNewSeq[l].custSequenceNum" type="Integer"/>
<set field="oldSeq" from-field="custRequestList[newSeq-1].custSequenceNum" type="Long"/>
<set field="custRequestId" from-field="custRequestListWithNewSeq[l].custRequestId"/>
<entity-one entity-name="CustRequest" value-field="newCustRequestMap">
<field-map field-name="custRequestId" from-field="custRequestId"/>
</entity-one>
<set field="newCustRequestMap.custSequenceNum" from-field="oldSeq"/>
<store-value value-field="newCustRequestMap"/>
</loop>
<else>
<!-- get size -->
<script>groovy:
List custRequestSeq = custRequestListWithNewSeq;
List custRequestSeqList = org.apache.ofbiz.base.util.UtilMisc.sortMaps(custRequestSeq, org.apache.ofbiz.base.util.UtilMisc.toList("custSequenceNum"));
return org.apache.ofbiz.base.util.UtilMisc.toMap("custRequestSeqList", custRequestSeqList);
</script>
<set field="custRequestListWithNewSeq" from-field="custRequestSeqList"/>
<call-object-method method-name="size" obj-field="custRequestListWithNewSeq" ret-field="newCustCount"/>
<!-- start sort transaction -->
<loop count="${newCustCount}" field="l">
<set field="custRequestId" from-field="custRequestListWithNewSeq[l].custRequestId"/>
<entity-one entity-name="CustRequest" value-field="newCustRequestMap">
<field-map field-name="custRequestId" from-field="custRequestId"/>
</entity-one>
<if-compare field="newCustRequestMap.custRequestTypeId" operator="equals" value="RF_PROD_BACKLOG" >
<entity-and entity-name="CustRequestAndCustRequestItem" list="custRequestItemList">
<field-map field-name="productId" from-field="parameters.productId"/>
<field-map field-name="custRequestTypeId" value="RF_PROD_BACKLOG"/>
<field-map field-name="statusId" value="CRQ_ACCEPTED"/>
<select-field field-name="custRequestId"/>
<select-field field-name="custSequenceNum"/>
<order-by field-name="custSequenceNum"/>
</entity-and>
<set field="custRequestList" from-field="custRequestItemList"/>
<call-object-method method-name="size" obj-field="custRequestList" ret-field="custCount"/>
<else>
<entity-and entity-name="CustRequestAndCustRequestItem" list="custRequestItemList">
<field-map field-name="productId" from-field="parameters.productId"/>
<field-map field-name="custRequestTypeId" value="RF_UNPLAN_BACKLOG"/>
<field-map field-name="statusId" value="CRQ_ACCEPTED"/>
<select-field field-name="custRequestId"/>
<select-field field-name="custSequenceNum"/>
<order-by field-name="custSequenceNum"/>
</entity-and>
<set field="custRequestList" from-field="custRequestItemList"/>
<call-object-method method-name="size" obj-field="custRequestList" ret-field="custCount"/>
</else>
</if-compare>
<set field="newOfOldSeq" from-field="newCustRequestMap.custSequenceNum" type="Long"/>
<set field="newSeq" from-field="custRequestListWithNewSeq[l].custSequenceNum" type="Long"/>
<set field="oldSeq" from-field="custRequestList[newSeq-1].custSequenceNum" type="Long" />
<loop count="${custCount}" field="m">
<set field="newcustRequestId" from-field="custRequestList[m].custRequestId"/>
<entity-one entity-name="CustRequest" value-field="custRequestMap">
<field-map field-name="custRequestId" from-field="newcustRequestId"/>
</entity-one>
<set field="custSequenceNum" from-field="custRequestMap.custSequenceNum" type="Long"/>
<if-compare-field field="custRequestId" operator="not-equals" to-field="newcustRequestId">
<if-compare-field field="newOfOldSeq" operator="not-equals" to-field="oldSeq" type="Long">
<set field="readyDown" value="${groovy:(newOfOldSeq&lt;oldSeq)&amp;&amp;(custSequenceNum&lt;=oldSeq)&amp;&amp;(custSequenceNum&gt;newOfOldSeq)}" type="Boolean"/>
<set field="readyUp" value="${groovy:(newOfOldSeq&gt;oldSeq)&amp;&amp;(custSequenceNum&gt;=oldSeq)&amp;&amp;(custSequenceNum&lt;newOfOldSeq)}" type="Boolean"/>
<!-- use when number move down -->
<if>
<condition>
<if-compare field="readyDown" operator="equals" value="true" type="Boolean"/>
</condition>
<then>
<set field="nextSeqNum" value="${custSequenceNum-1}" type="Long"/>
<set field="custRequestMap.custSequenceNum" from-field="nextSeqNum"/>
<store-value value-field="custRequestMap"/>
</then>
</if>
<!-- use when number move up -->
<if>
<condition>
<and>
<if-compare field="readyUp" operator="equals" value="true" type="Boolean"/>
</and>
</condition>
<then>
<set field="nextSeqNum" value="${custSequenceNum+1}" type="Long"/>
<set field="custRequestMap.custSequenceNum" from-field="nextSeqNum"/>
<store-value value-field="custRequestMap"/>
</then>
</if>
</if-compare-field>
</if-compare-field>
</loop>
<set field="newCustRequestMap.custSequenceNum" from-field="oldSeq" type="Long"/>
<store-value value-field="newCustRequestMap"/>
</loop>
</else>
</if-empty>
</if-not-empty>
<set field="beDeleted" value="false" type="Boolean"/>
<loop count="${rowCount}" field="i">
<set field="deleteFlag" from-field="paramMap[&quot;deleteFlag_o_${i}&quot;]" default-value="N"/>
<set field="custRequestId" from-field="paramMap[&quot;custRequestId_o_${i}&quot;]"/>
<set field="statusId" from-field="paramMap[&quot;statusId_o_${i}&quot;]"/>
<!-- check CRQ_COMPLETED status -->
<if-compare field="statusId" operator="not-equals" value="CRQ_COMPLETED">
<if-compare field="deleteFlag" operator="equals" value="Y">
<!-- delete product backlog -->
<call-simple-method method-name="deleteCustRequest"/>
<set field="beDeleted" value="true" type="Boolean"/>
<else>
<!-- update category and plan hour -->
<entity-condition entity-name="CustRequestAndWorkEffort" list="existTasks">
<condition-list combine="and">
<condition-expr field-name="custRequestId" from-field="custRequestId"/>
<condition-expr field-name="workEffortTypeId" operator="not-equals" value="SCRUM_SPRINT"/>
</condition-list>
</entity-condition>
<set field="parentCustRequestId" from-field="paramMap[&quot;parentCustRequestId_o_${i}&quot;]"/>
<set field="estimatedHours" from-field="paramMap[&quot;estimatedHours_o_${i}&quot;]" type="Double"/>
<set field="updateCustRequestInMap.custRequestId" from-field="custRequestId"/>
<set field="updateCustRequestInMap.parentCustRequestId" from-field="parentCustRequestId"/>
<set field="custEstimatedMilliSeconds" value="${estimatedHours*1000*60*60}" default-value="0" type="Double"/>
<set field="updateCustRequestInMap.custEstimatedMilliSeconds" from-field="custEstimatedMilliSeconds" type="Double"/>
<if-not-empty field="existTasks">
<log level="info" message="warningMessage====================Cannot update plan hour of backlog item[${custRequestId}] because there is existing task for that already."></log>
</if-not-empty>
<call-service service-name="updateCustRequest" in-map-name="updateCustRequestInMap"/>
</else>
</if-compare>
</if-compare>
</loop>
<!-- if some backlog item be deleted then re arrange custSequenceNum field -->
<if-compare field="beDeleted" operator="equals" value="true" type="Boolean">
<set field="reOrderProductBacklogItemSequenceNumberInMap.productId" from-field="parameters.productId"/>
<call-service service-name="reOrderProductBacklogItemSequenceNumber" in-map-name="reOrderProductBacklogItemSequenceNumberInMap"/>
</if-compare>
<!-- check warning message list -->
<if-not-empty field="warningMessageList">
<set field="_event_message_" value="Warning ${warningMessageList}"/>
</if-not-empty>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
<field-to-request field="parameters.sequence" request-name="sequence"/>
<field-to-request field="parameters.UnplannedSequence" request-name="UnplannedSequence"/>
<field-to-request field="parameters.VIEW_SIZE_1" request-name="VIEW_SIZE_1"/>
<field-to-request field="parameters.VIEW_INDEX_1" request-name="VIEW_INDEX_1"/>
</simple-method>
<simple-method method-name="createProductBacklog" short-description="">
<!-- Permission Check -->
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_PRODUCT_BACKLOG" action="_CREATE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<call-simple-method method-name="getWebSiteId"/>
<if-compare operator="equals" value="Y" field="parameters.unplannedFlag">
<set field="custRequestTypeId" value="RF_UNPLAN_BACKLOG"/>
<else>
<set field="custRequestTypeId" value="RF_PROD_BACKLOG"/>
</else>
</if-compare>
<if-empty field="parameters.description">
<add-error >
<fail-message message="There Product Backlog Item is missing, Please add."/>
</add-error>
<check-errors/>
</if-empty>
<if-empty field="parameters.custSequenceNum">
<set field="sequenceNumIn" value="1" type="Long"/>
<entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="parameters.productId"/>
<condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
</condition-list>
</entity-count>
<if-compare operator="equals" value="0" field="getNum">
<set field="createCustRequestInMap.custSequenceNum" from-field="sequenceNumIn"/>
<else>
<entity-condition entity-name="CustRequestAndCustRequestItem" list="custRequestList">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="parameters.productId"/>
<condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
</condition-list>
<order-by field-name="custSequenceNum"/>
</entity-condition>
<set field="productMap" from-field="custRequestList[getNum-1]"/>
<set field="nextSeq" from-field="productMap.custSequenceNum" type="Integer"/>
<set field="newSequenceNum" value="${nextSeq+1}" type="Long"/>
<set field="createCustRequestInMap.custSequenceNum" from-field="newSequenceNum" />
</else>
</if-compare>
<else>
<!-- check duplicate data -->
<entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="parameters.productId"/>
<condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
</condition-list>
</entity-count>
<!-- the first sequence number -->
<if-compare field="getNum" operator="equals" value="0">
<set field="createCustRequestInMap.custSequenceNum" from-field="parameters.custSequenceNum"/>
<else>
<entity-condition entity-name="CustRequestAndCustRequestItem" list="custRequestList">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="parameters.productId"/>
<condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
</condition-list>
<order-by field-name="custSequenceNum"/>
</entity-condition>
<set field="sequenceNumkey" from-field="parameters.custSequenceNum" type="Integer"/>
<set field="productMap" from-field="custRequestList[sequenceNumkey-1]"/>
<set field="externalSeq" from-field="productMap.custSequenceNum" type="Long"/>
<!-- Insert new transaction to CustRequest -->
<loop count="${getNum}" field="j">
<set field="internalSeq" from-field="custRequestList[j].custSequenceNum" type="Long" />
<set field="ready" value="${groovy:internalSeq&gt;=externalSeq}" type="Boolean"/>
<if-compare field="ready" operator="equals" value="true" type="Boolean">
<set field="custRequestId" from-field="custRequestList[j].custRequestId"/>
<entity-one entity-name="CustRequest" value-field="custRequestMap">
<field-map field-name="custRequestId" from-field="custRequestId"/>
</entity-one>
<set field="custSequenceNum" from-field="custRequestMap.custSequenceNum"/>
<set field="nextSeqNum" value="${custSequenceNum+1}" type="Long"/>
<set field="custRequestMap.custSequenceNum" from-field="nextSeqNum"/>
<store-value value-field="custRequestMap"/>
</if-compare>
</loop>
<set field="createCustRequestInMap.custSequenceNum" from-field="externalSeq"/>
</else>
</if-compare>
</else>
</if-empty>
<if-empty field="parameters.fromPartyId">
<set field="createCustRequestInMap.fromPartyId" from-field="userLogin.partyId"/>
</if-empty>
<set field="changeToMilliSec" value="${parameters.custEstimatedMilliSeconds*1000*60*60}"/>
<set field="createCustRequestInMap.custEstimatedMilliSeconds" from-field="changeToMilliSec" type="Double"/>
<set field="createCustRequestInMap.billed" from-field="parameters.billed"/>
<set field="createCustRequestInMap.custRequestTypeId" from-field="custRequestTypeId"/>
<set field="createCustRequestInMap.statusId" value="CRQ_ACCEPTED"/>
<set field="createCustRequestInMap.custRequestName" value="Product Backlog"/>
<set field="createCustRequestInMap.description" from-field="parameters.description"/>
<set field="createCustRequestInMap.openDateTime" from-field="parameters.openDateTime"/>
<set field="createCustRequestInMap.closedDateTime" from-field="parameters.closedDateTime"/>
<set field="createCustRequestInMap.parentCustRequestId" from-field="parameters.parentCustRequestId"/>
<set field="createCustRequestInMap.webSiteId" from-field="parameters.webSiteId"/>
<sequenced-id sequence-name="CustRequestItem" field="custRequestItemSeqId"/>
<set field="createCustRequestInMap.custRequestItemSeqId" from-field="custRequestItemSeqId"/>
<set field="createCustRequestInMap.story" from-field="parameters.story"/>
<set field="createCustRequestInMap.productId" from-field="parameters.productId"/>
<call-service service-name="createCustRequest" in-map-name="createCustRequestInMap">
<result-to-field result-name="custRequestId"/>
</call-service>
<!-- create CustRequestNote -->
<if-not-empty field="parameters.noteInfo">
<set field="newNoteMap.note" from-field="parameters.noteInfo"/>
<set field="newNoteMap.noteName" value="How to test"/>
<call-service service-name="createNote" in-map-name="newNoteMap">
<result-to-field result-name="noteId" field="noteId"/>
</call-service>
<make-value value-field="newEntity" entity-name="CustRequestNote"/>
<set from-field="custRequestId" field="newEntity.custRequestId"/>
<set from-field="noteId" field="newEntity.noteId"/>
<create-value value-field="newEntity"/>
</if-not-empty>
<request-to-field field="parameters.productId" request-name="productId"/>
<request-to-field field="parameters.sequence" request-name="sequence"/>
<request-to-field field="parameters.UnplannedSequence" request-name="UnplannedSequence"/>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="updateSprintBacklog" short-description="Update Sprint Backlog">
<call-simple-method method-name="getWebSiteId"/>
<set field="parameters.custEstimatedMilliSeconds" from-field="parameters.estimatedHours" type="Float"/>
<calculate field="parameters.custEstimatedMilliSeconds" type="Float">
<calcop operator="multiply" field="parameters.custEstimatedMilliSeconds">
<number value="3600000"/>
</calcop>
</calculate>
<set-service-fields service-name="updateCustRequest" map="parameters" to-map="inMap"/>
<call-service service-name="updateCustRequest" in-map-name="inMap"/>
</simple-method>
<simple-method method-name="createSprintBacklog" short-description="Create Sprint Backlog">
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_SPRINT" action="_UPDATE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<call-simple-method method-name="getWebSiteId"/>
<set field="parameters.sprintBacklogs" value="${parameters.sprintBacklogs}-1" type="Integer"/>
<entity-and entity-name="WorkEffortAndProduct" list="projectList">
<field-map field-name="workEffortId" from-field="parameters.projectId"/>
</entity-and>
<first-from-list entry="project" list="projectList"/>
<entity-one entity-name="WorkEffortAttribute" value-field="workEffortAttMap">
<field-map field-name="workEffortId" from-field="parameters.projectId"/>
<field-map field-name="attrName" value="PROJECT_BILLED"/>
</entity-one>
<entity-condition entity-name="CustRequestAndCustRequestItem" list="custRequestList">
<condition-list combine="and">
<condition-expr field-name="custRequestTypeId" value="RF_PROD_BACKLOG" />
<condition-expr field-name="statusId" value="CRQ_ACCEPTED" />
<condition-expr field-name="productId" from-field="project.productId"/>
</condition-list>
<order-by field-name="custSequenceNum"/>
</entity-condition>
<loop count="${parameters.sprintBacklogs}" field="i">
<set field="sequenceNumx" value="${i+1}"/>
<set field="sprintBL.custRequestId" from-field="custRequestList[i].custRequestId"/>
<set field="sprintBL.workEffortId" from-field="parameters.sprintId"/>
<set field="sprintBL.userLogin" from-field="userLogin"/>
<call-service service-name="createWorkEffortRequest" in-map-name="sprintBL"/>
<set field="inMap.custRequestId" from-field="custRequestList[i].custRequestId"/>
<set field="inMap.statusId" value="CRQ_REVIEWED"/>
<set field="inMap.custRequestName" value=" "/>
<set field="inMap.webSiteId" from-field="parameters.webSiteId"/>
<!-- if the Billed field of the project was set. -->
<if-not-empty field="workEffortAttMap">
<set field="inMap.billed" from-field="workEffortAttMap.attrValue"/>
</if-not-empty>
<set field="inMap.webSiteId" from-field="parameters.webSiteId"/>
<call-service service-name="updateCustRequest" in-map-name="inMap"/>
<!-- Check If there are tasks already in a backlog -->
<entity-condition entity-name="WorkEffortCustRequestView" list="backlogItemTaskList">
<condition-list combine="and">
<condition-expr field-name="custRequestId" from-field="custRequestList[i].custRequestId"/>
<condition-list combine="or">
<condition-expr field-name="workEffortTypeId" value="SCRUM_TASK_ERROR"/>
<condition-expr field-name="workEffortTypeId" value="SCRUM_TASK_IMPL"/>
<condition-expr field-name="workEffortTypeId" value="SCRUM_TASK_INST"/>
<condition-expr field-name="workEffortTypeId" value="SCRUM_TASK_TEST"/>
</condition-list>
</condition-list>
</entity-condition>
<if-empty field="backlogItemTaskList">
<entity-and entity-name="WorkEffortAndProduct" list="defaultTaskList">
<field-map field-name="workEffortPurposeTypeId" value="SCRUM_DEFAULT_TASK"/>
<field-map field-name="productId" from-field="project.productId"/>
</entity-and>
<if-not-empty field="defaultTaskList">
<iterate list="defaultTaskList" entry="defaultTask">
<set field="newDefaultTask.workEffortName" from-field="defaultTask.workEffortName"/>
<set field="newDefaultTask.estimatedMilliSeconds" from-field="defaultTask.estimatedMilliSeconds"/>
<set field="newDefaultTask.currentStatusId" from-field="defaultTask.currentStatusId"/>
<set field="newDefaultTask.workEffortTypeId" from-field="defaultTask.workEffortTypeId"/>
<set field="newDefaultTask.workEffortParentId" from-field="parameters.sprintId"/>
<call-service service-name="createWorkEffort" in-map-name="newDefaultTask">
<result-to-field result-name="workEffortId"/>
</call-service>
<set field="newBacklogItemTask.custRequestId" from-field="custRequestList[i].custRequestId"/>
<set field="newBacklogItemTask.workEffortId" from-field="workEffortId"/>
<set field="newBacklogItemTask.userLogin" from-field="userLogin"/>
<call-service service-name="createWorkEffortRequest" in-map-name="newBacklogItemTask"/>
<!-- Assigned party for default task-->
<entity-condition entity-name="WorkEffortPartyAssignment" list="assigneds">
<condition-list combine="and">
<condition-expr field-name="statusId" value="PRTYASGN_ASSIGNED"/>
<condition-expr field-name="workEffortId" from-field="defaultTask.workEffortId"/>
</condition-list>
</entity-condition>
<if-not-empty field="assigneds">
<first-from-list list="assigneds" entry="assignedMap"/>
<set field="newInput.partyId" from-field="assignedMap.partyId"></set>
<set field="newInput.workEffortId" from-field="workEffortId"></set>
<set field="newInput.roleTypeId" from-field="assignedMap.roleTypeId"></set>
<set field="newInput.statusId" value="SCAS_ASSIGNED"></set>
<set field="newInput.userLogin" from-field="userLogin"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="newInput"/>
<!-- Assigned party for sprint -->
<entity-condition entity-name="WorkEffortPartyAssignment" list="sprintAssigneds">
<condition-list combine="and">
<condition-expr field-name="partyId" from-field="assignedMap.partyId"/>
<condition-expr field-name="statusId" value="PRTYASGN_ASSIGNED"/>
<condition-expr field-name="workEffortId" from-field="parameters.sprintId"/>
</condition-list>
</entity-condition>
<if-empty field="sprintAssigneds">
<set field="sprintInput.partyId" from-field="assignedMap.partyId"></set>
<set field="sprintInput.workEffortId" from-field="parameters.sprintId"></set>
<set field="sprintInput.roleTypeId" from-field="assignedMap.roleTypeId"></set>
<set field="sprintInput.statusId" value="PRTYASGN_ASSIGNED"></set>
<set field="sprintInput.userLogin" from-field="userLogin"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="sprintInput"/>
</if-empty>
</if-not-empty>
</iterate>
<else>
<!-- If not have default task in product level -->
<entity-and entity-name="WorkEffort" list="defaultTaskScrum">
<field-map field-name="workEffortPurposeTypeId" value="SYSTEM_DEFAULT_TASK"/>
</entity-and>
<if-not-empty field="defaultTaskScrum">
<iterate list="defaultTaskScrum" entry="defaultScrum">
<set field="newDefaultTaskScrum.workEffortName" from-field="defaultScrum.workEffortName"/>
<set field="newDefaultTaskScrum.estimatedMilliSeconds" from-field="defaultScrum.estimatedMilliSeconds"/>
<set field="newDefaultTaskScrum.currentStatusId" from-field="defaultScrum.currentStatusId"/>
<set field="newDefaultTaskScrum.workEffortTypeId" from-field="defaultScrum.workEffortTypeId"/>
<set field="newDefaultTaskScrum.workEffortParentId" from-field="parameters.sprintId"/>
<call-service service-name="createWorkEffort" in-map-name="newDefaultTaskScrum">
<result-to-field result-name="workEffortId"/>
</call-service>
<set field="newBacklogItemTaskScrum.custRequestId" from-field="custRequestList[i].custRequestId"/>
<set field="newBacklogItemTaskScrum.workEffortId" from-field="workEffortId"/>
<set field="newBacklogItemTaskScrum.userLogin" from-field="userLogin"/>
<call-service service-name="createWorkEffortRequest" in-map-name="newBacklogItemTaskScrum"/>
<!-- Assigned party for default task-->
<entity-condition entity-name="WorkEffortPartyAssignment" list="assigneds">
<condition-list combine="and">
<condition-expr field-name="statusId" value="PRTYASGN_ASSIGNED"/>
<condition-expr field-name="workEffortId" from-field="defaultScrum.workEffortId"/>
</condition-list>
</entity-condition>
<if-not-empty field="assigneds">
<first-from-list list="assigneds" entry="assignedMap"/>
<set field="newInput.partyId" from-field="assignedMap.partyId"></set>
<set field="newInput.workEffortId" from-field="workEffortId"></set>
<set field="newInput.roleTypeId" from-field="assignedMap.roleTypeId"></set>
<set field="newInput.statusId" value="SCAS_ASSIGNED"></set>
<set field="newInput.userLogin" from-field="userLogin"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="newInput"/>
<!-- Assigned party for sprint -->
<entity-condition entity-name="WorkEffortPartyAssignment" list="sprintAssigneds">
<condition-list combine="and">
<condition-expr field-name="partyId" from-field="assignedMap.partyId"/>
<condition-expr field-name="statusId" value="PRTYASGN_ASSIGNED"/>
<condition-expr field-name="workEffortId" from-field="parameters.sprintId"/>
</condition-list>
</entity-condition>
<if-empty field="sprintAssigneds">
<set field="sprintInput.partyId" from-field="assignedMap.partyId"></set>
<set field="sprintInput.workEffortId" from-field="parameters.sprintId"></set>
<set field="sprintInput.roleTypeId" from-field="assignedMap.roleTypeId"></set>
<set field="sprintInput.statusId" value="PRTYASGN_ASSIGNED"></set>
<set field="sprintInput.userLogin" from-field="userLogin"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="sprintInput"/>
</if-empty>
</if-not-empty>
</iterate>
</if-not-empty>
</else>
</if-not-empty>
<else>
<loop count="${groovy: backlogItemTaskList.size()}" field="j">
<set field="updateWorkEffort.workEffortId" from-field="backlogItemTaskList[j].workEffortId"/>
<set field="updateWorkEffort.workEffortParentId" from-field="parameters.sprintId"/>
<call-service service-name="updateWorkEffort" in-map-name="updateWorkEffort"/>
</loop>
</else>
</if-empty>
</loop>
<if-not-empty field="parameters.sprintId">
<field-to-request field="parameters.sprintId" request-name="sprintId"/>
</if-not-empty>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="addScrumResource" short-description="make parties available in the Scrum.">
<set field="userLoginIdDesc" from-field="parameters.userLoginIdDesc"/>
<set field="userLoginId" value="${groovy:userLoginIdDesc.substring(userLoginIdDesc.indexOf(&quot;|&quot;)+1)}"/>
<entity-and entity-name="UserLogin" list="userLogins">
<field-map field-name="partyId" from-field="parameters.partyId"/>
</entity-and>
<entity-one entity-name="PartyNameView" value-field="partyNameView"/>
<if-empty field="userLogins">
<set field="_error_message_" value="${partyNameView.lastName}, ${partyNameView.firstName} [${parameters.partyId}] does not have UserLogin."/>
<return response-code="error"/>
</if-empty>
<if-compare operator="equals" value="SCRUM_PRODUCT_OWNER" field="parameters.groupId">
<set field="parameters.roleTypeId" value="PRODUCT_OWNER"/>
</if-compare>
<if-compare operator="equals" value="SCRUM_MASTER" field="parameters.groupId">
<set field="parameters.roleTypeId" value="SCRUM_MASTER"/>
</if-compare>
<if-compare operator="equals" value="SCRUM_TEAM" field="parameters.groupId">
<set field="parameters.roleTypeId" value="SCRUM_TEAM"/>
</if-compare>
<!-- For special role -->
<if-compare operator="equals" value="SCRUM_STAKEHOLDER" field="parameters.groupId">
<set field="parameters.roleTypeId" value="STAKEHOLDER"/>
</if-compare>
<set-service-fields service-name="ensurePartyRole" map="parameters" to-map="ensurePartyRole"/>
<set field="ensurePartyRole.userLogin" from-field="sysUserLogin"/>
<call-service service-name="ensurePartyRole" in-map-name="ensurePartyRole"/>
<entity-one entity-name="UserLogin" value-field="sysUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<entity-and entity-name="UserLoginSecurityGroup" list="listGroupId">
<field-map field-name="userLoginId" from-field="userLoginId"/>
<field-map field-name="groupId" from-field="parameters.groupId"/>
</entity-and>
<if-empty field="listGroupId">
<set field="parameters.userLoginId" from-field="userLoginId"/>
<set-service-fields service-name="addUserLoginToSecurityGroup" map="parameters" to-map="inMap"/>
<set field="inMap.userLogin" from-field="sysUserLogin"/>
<call-service service-name="addUserLoginToSecurityGroup" in-map-name="inMap"/>
<else>
<entity-one entity-name="RoleType" value-field="roleTypeMap">
<field-map field-name="roleTypeId" from-field="parameters.roleTypeId"/>
</entity-one>
<add-error>
<fail-message message="There are partyId : ${parameters.partyId} , userLoginId : ${userLoginId} and roleTypeId : ${roleTypeMap.description} already exist."/>
</add-error>
<check-errors/>
</else>
</if-empty>
<set field="roleData.partyId" from-field="parameters.partyId"/>
<set field="roleData.roleTypeId" value="SCRUM_MEMBER"/>
<set field="roleData.userLogin" from-field="sysUserLogin"/>
<call-service service-name="ensurePartyRole" in-map-name="roleData">
<default-message resource="CommonUiLabels" property="CommonSuccessfullyCreated"/>
</call-service>
</simple-method>
<simple-method method-name="createSprintBacklogTask" short-description="Create Sprint Backlog Task">
<call-class-method class-name="org.apache.ofbiz.content.layout.LayoutWorker" method-name="uploadImageAndParameters" ret-field="formInput">
<field field="request" type="javax.servlet.http.HttpServletRequest"/>
<string value="uploadedFile"/>
</call-class-method>
<entity-one entity-name="UserLogin" value-field="systemUser">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<entity-one entity-name="CustRequest" value-field="custRequestMap">
<field-map field-name="custRequestId" from-field="formInput.formInput.custRequestId"/>
</entity-one>
<if-empty field="formInput.formInput.sprintId">
<entity-and entity-name="CustRequestAndWorkEffort" list="custRequestWorkEfforts">
<field-map field-name="custRequestId" from-field="formInput.formInput.custRequestId"/>
<field-map field-name="currentStatusId" value="SPRINT_ACTIVE"/>
</entity-and>
<if-not-empty field="custRequestWorkEfforts">
<first-from-list list="custRequestWorkEfforts" entry="custRequestWorkEffort"/>
<set field="formInput.formInput.sprintId" from-field="custRequestWorkEffort.workEffortId"/>
</if-not-empty>
</if-empty>
<if>
<condition>
<not><if-empty field="formInput.formInput.actualStartDate"/></not>
</condition>
<then>
<entity-one entity-name="WorkEffort" value-field="sprint">
<field-map field-name="workEffortId" from-field="formInput.formInput.sprintId"/>
</entity-one>
<set field="formInput.formInput.actualStartDate" from-field="sprint.actualStartDate"/>
<if>
<condition>
<or>
<if-compare-field operator="less" field="formInput.formInput.actualStartDate" to-field="sprint.actualStartDate" type="Timestamp"/>
<if-compare-field operator="greater" field="formInput.formInput.actualStartDate" to-field="sprint.actualCompletionDate" type="Timestamp"/>
</or>
</condition>
<then>
<add-error>
<fail-message message="Start Date isn't in Sprint Duration."/>
</add-error>
</then>
</if>
</then>
</if>
<check-errors/>
<if-empty field="formInput.formInput.workEffortName">
<add-error >
<fail-message message="Task name is empty, please enter task name."/>
</add-error>
</if-empty>
<check-errors/>
<if-not-empty field="formInput.formInput.planHours">
<set field="formInput.formInput.estimatedMilliSeconds" from-field="formInput.formInput.planHours" type="Float"/>
<calculate field="formInput.formInput.estimatedMilliSeconds" type="Float">
<calcop operator="multiply" field="formInput.formInput.estimatedMilliSeconds">
<number value="3600000"/>
</calcop>
</calculate>
</if-not-empty>
<if-compare field="custRequestMap.custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG">
<if-empty field="formInput.formInput.actualStartDate">
<now-timestamp field="nowTimesamp"/>
<set field="formInput.formInput.actualStartDate" from-field="nowTimesamp"/>
</if-empty>
</if-compare>
<set field="custRequestId" from-field="formInput.formInput.custRequestId"/>
<clear-field field="formInput.formInput.custRequestId"/>
<if-compare field="custRequestMap.custRequestTypeId" operator="not-equals" value="RF_UNPLAN_BACKLOG">
<set field="formInput.formInput.workEffortParentId" from-field="formInput.formInput.sprintId"/>
</if-compare>
<set field="formInput.formInput.currentStatusId" value="STS_CREATED"/>
<if-compare field="formInput.formInput.workEffortTypeId" operator="equals" value="SCRUM_TASK_ERROR">
<set field="formInput.formInput.priority" value="1"/>
</if-compare>
<if-compare field="formInput.formInput.workEffortTypeId" operator="equals" value="SCRUM_TASK_TEST">
<set field="formInput.formInput.priority" value="2"/>
</if-compare>
<if-compare field="formInput.formInput.workEffortTypeId" operator="equals" value="SCRUM_TASK_IMPL">
<set field="formInput.formInput.priority" value="3"/>
</if-compare>
<if-compare field="formInput.formInput.workEffortTypeId" operator="equals" value="SCRUM_TASK_INST">
<set field="formInput.formInput.priority" value="4"/>
</if-compare>
<set-service-fields service-name="createWorkEffort" map="formInput.formInput" to-map="createWorkEffort"/>
<entity-one entity-name="UserLogin" value-field="sysUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<if-has-permission permission="SCRUM" action="_ADMIN">
<set field="createWorkEffort.userLogin" from-field="sysUserLogin"/>
</if-has-permission>
<call-service service-name="createWorkEffort" in-map-name="createWorkEffort">
<result-to-field result-name="workEffortId" field="formInput.formInput.workEffortId"/>
</call-service>
<set field="formInput.formInput.custRequestId" from-field="custRequestId"/>
<set-service-fields service-name="createWorkEffortRequest" map="formInput.formInput" to-map="createWorkEffortRequest"/>
<call-service service-name="createWorkEffortRequest" in-map-name="createWorkEffortRequest"/>
<!--if plan hours(from task) more than first plan hours -->
<set field="backlogPlanMap.custRequestId" from-field="formInput.formInput.custRequestId" />
<set field="taskPlanMap.custRequestId" from-field="formInput.formInput.custRequestId" />
<call-service service-name="getScrumPlanHour" in-map-name="backlogPlanMap">
<result-to-field result-name="planHours" />
</call-service>
<call-service service-name="getScrumPlanHour" in-map-name="taskPlanMap">
<result-to-field result-name="initPlanHours"/>
</call-service>
<if-compare-field field="planHours" operator="greater" to-field="initPlanHours" type="Double">
<entity-one entity-name="CustRequest" value-field="custRequestMap">
<field-map field-name="custRequestId" from-field="formInput.formInput.custRequestId"/>
</entity-one>
<set field="planHoursIn" from-field="planHours" type="Double"/>
<set field="custRequestMap.custEstimatedMilliSeconds" value="${groovy:planHoursIn*1000*60*60}" type="Double"/>
<store-value value-field="custRequestMap"/>
<else>
<if-compare-field field="initPlanHours" operator="greater" to-field="planHours" type="Double">
<entity-one entity-name="CustRequest" value-field="custRequestMap">
<field-map field-name="custRequestId" from-field="formInput.formInput.custRequestId"/>
</entity-one>
<set field="planHoursIn" from-field="planHours" type="Double"/>
<set field="custRequestMap.custEstimatedMilliSeconds" value="${groovy:planHoursIn*1000*60*60}" type="Double"/>
<store-value value-field="custRequestMap"/>
</if-compare-field>
</else>
</if-compare-field>
<if-not-empty field="formInput.formInput.partyId">
<!-- Assigned -->
<entity-condition entity-name="WorkEffortPartyAssignment" list="assigneds">
<condition-list combine="and">
<condition-expr field-name="partyId" from-field="formInput.formInput.partyId"/>
<condition-expr field-name="statusId" value="SCAS_ASSIGNED"/>
<condition-expr field-name="workEffortId" from-field="formInput.formInput.workEffortId"/>
</condition-list>
</entity-condition>
<if-empty field="assigneds">
<entity-and entity-name="WorkEffortPartyAssignment" list="assigneds">
<field-map field-name="workEffortId" from-field="formInput.formInput.workEffortId"/>
</entity-and>
<entity-and entity-name="PartyRole" list="taskOwnerRoles">
<field-map field-name="partyId" from-field="formInput.formInput.partyId"/>
<field-map field-name="roleTypeId" value="SCRUM_TEAM"/>
</entity-and>
<entity-one entity-name="UserLogin" value-field="systemUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<iterate list="assigneds" entry="assigned">
<remove-value value-field="assigned"/>
</iterate>
<set field="newInput.partyId" from-field="formInput.formInput.partyId"></set>
<set field="newInput.workEffortId" from-field="formInput.formInput.workEffortId"></set>
<set field="newInput.roleTypeId" from-field="taskOwnerRoles[0].roleTypeId"></set>
<set field="newInput.statusId" value="SCAS_ASSIGNED"></set>
<call-service service-name="assignPartyToWorkEffort" in-map-name="newInput"/>
</if-empty>
</if-not-empty>
<!-- for contents -->
<if-not-empty field="formInput.imageFileName">
<add-error><fail-message message="Upload file is missing..."/></add-error>
<set field="parameters.imageFileName" from-field="formInput.imageFileName"/>
<!-- Create Data Resource -->
<set-service-fields service-name="createContentFromUploadedFile"
map="formInput.formInput" to-map="data"/>
<set field="data.dataResourceTypeId" value="LOCAL_FILE"/>
<set field="data.dataTemplateTypeId" value="NONE"/>
<set field="data.dataCategoryId" from-field="formInput.formInput.dataCategoryId"/>
<set field="data.userLogin" from-field="systemUser"/>
<set field="data.statusId" from-field="formInput.formInput.resourceStatusId"/>
<set field="data.dataResourceName" from-field="formInput.imageFileName"/>
<set field="data.mimeTypeId" from-field="mimeType.mimeTypeId"/>
<set field="data.uploadedFile" from-field="formInput.imageData"/>
<set field="data._uploadedFile_fileName" from-field="formInput.imageFileName"/>
<set field="data._uploadedFile_contentType" from-field="formInput.formInput.mimeTypeId"/>
<call-service service-name="createDataResource" in-map-name="data">
<result-to-field result-name="dataResourceId" field="parameters.dataResourceId"/>
</call-service>
<!-- Create attach upload to data resource -->
<set-service-fields service-name="attachUploadToDataResource" map="formInput.formInput"
to-map="attachMap"/>
<set field="attachMap.uploadedFile" from-field="formInput.imageData"/>
<set field="attachMap._uploadedFile_fileName" from-field="formInput.imageFileName"/>
<set field="attachMap._uploadedFile_contentType" from-field="formInput.formInput.mimeTypeId"/>
<set field="attachMap.dataResourceId" from-field="parameters.dataResourceId"/>
<set field="attachMap.mimeTypeId" from-field="mimeType.mimeTypeId"/>
<call-service service-name="attachUploadToDataResource" in-map-name="attachMap"/>
<!-- Create content from dataResource -->
<set-service-fields service-name="createContentFromDataResource"
map="formInput.formInput" to-map="contentMap"/>
<set field="contentMap.roleTypeId" from-field="formInput.formInput.roleTypeId"/>
<set field="contentMap.partyId" from-field="formInput.formInput.partyId"/>
<set field="contentMap.contentTypeId" from-field="formInput.formInput.contentTypeId"/>
<set field="contentMap.dataResourceId" from-field="parameters.dataResourceId"/>
<set field="contentMap.userLogin" from-field="systemUser"/>
<call-service service-name="createContentFromDataResource" in-map-name="contentMap">
<result-to-field result-name="contentId" field="formInput.formInput.contentId"/>
</call-service>
<!-- Create WorkEffort Content -->
<set-service-fields service-name="createWorkEffortContent" map="formInput.formInput" to-map="workEffortContent"/>
<set field="workEffortContent.userLogin" from-field="systemUser"/>
<set field="workEffortContent.workEffortContentTypeId" from-field="formInput.formInput.workEffortContentTypeId"/>
<call-service service-name="createWorkEffortContent" in-map-name="workEffortContent"/>
</if-not-empty>
<field-to-request field="formInput.formInput.workEffortId" request-name="taskId"/>
</simple-method>
<simple-method method-name="addProjectMember" short-description="Add Project Member">
<set field="groupIdDesc" from-field="parameters.groupIdDesc"/>
<set field="groupName" value="${groovy:groupIdDesc.substring(0, groupIdDesc.indexOf(&quot;--&quot;))}"/>
<set field="fullName" value="${groovy:groupIdDesc.substring(groupIdDesc.indexOf(&quot;--&quot;)+2, groupIdDesc.indexOf(&quot;|&quot;))}"/>
<set field="groupId" value="${groovy:groupIdDesc.substring(groupIdDesc.indexOf(&quot;|&quot;)+1)}"/>
<entity-condition entity-name="WorkEffortPartyAssignment" list="project">
<condition-list>
<condition-expr field-name="workEffortId" from-field="parameters.projectId"/>
<condition-expr field-name="roleTypeId" value="PRODUCT_OWNER"/>
</condition-list>
</entity-condition>
<entity-and entity-name="UserLogin" list="userLogins">
<field-map field-name="partyId" from-field="parameters.partyId"/>
</entity-and>
<entity-one entity-name="PartyNameView" value-field="partyNameView"/>
<if-not-empty field="project">
<if-compare operator="equals" value="PRODUCT_OWNER" field="roleTypeId">
<set field="_error_message_" value="The system can add only one product owner!"/>
<return response-code="error"/>
</if-compare>
</if-not-empty>
<if-compare operator="equals" value="SCRUM_PRODUCT_OWNER" field="groupId">
<set field="parameters.roleTypeId" value="PRODUCT_OWNER"/>
</if-compare>
<if-compare operator="equals" value="SCRUM_MASTER" field="groupId">
<set field="parameters.roleTypeId" value="SCRUM_MASTER"/>
</if-compare>
<if-compare operator="equals" value="SCRUM_TEAM" field="groupId">
<set field="parameters.roleTypeId" value="SCRUM_TEAM"/>
</if-compare>
<if-compare operator="equals" value="SCRUM_STAKEHOLDER" field="groupId">
<set field="parameters.roleTypeId" value="STAKEHOLDER"/>
</if-compare>
<entity-one entity-name="UserLogin" value-field="sysUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<set-service-fields service-name="ensurePartyRole" map="parameters" to-map="ensurePartyRole"/>
<set field="ensurePartyRole.userLogin" from-field="sysUserLogin"/>
<set field="ensurePartyRole.roleTypeId" from-field="parameters.roleTypeId"/>
<call-service service-name="ensurePartyRole" in-map-name="ensurePartyRole"/>
<set-service-fields service-name="assignPartyToWorkEffort" map="parameters" to-map="assignPartyToWorkEffort"/>
<set field="assignPartyToWorkEffort.userLogin" from-field="sysUserLogin"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="assignPartyToWorkEffort"/>
</simple-method>
<simple-method method-name="addMemberTask" short-description="Assign member to Tasks">
<if>
<condition>
<or>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
<if-has-permission permission="SCRUM_TASK" action="_CREATE"/>
</or>
</condition>
<then>
<set field="taskId" from-field="parameters.taskId" default-value="${parameters.workEffortId}"/>
<!-- get backlog from task -->
<entity-and entity-name="ProductBacklog" list="scrumMeetingBacklogs">
<field-map field-name="workEffortId" from-field="taskId"/>
<field-map field-name="custRequestTypeId" value="RF_SCRUM_MEETINGS"/>
</entity-and>
<if-not-empty field="scrumMeetingBacklogs">
<!-- be able to assign more than one person in this task -->
<set field="member.partyId" from-field="parameters.partyId"/>
<set field="member.roleTypeId" from-field="parameters.roleTypeId"/>
<set field="member.statusId" value="SCAS_ASSIGNED"/>
<set field="member.workEffortId" from-field="taskId"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="member"/>
<else>
<!-- check if this task assign to member, and they also enter actual hour. return error -->
<entity-and entity-name="WorkEffortPartyAssignment" list="workEffortPartyAssignments">
<field-map field-name="workEffortId" from-field="taskId"/>
</entity-and>
<if-not-empty field="workEffortPartyAssignments">
<!-- remove existing party and add new party -->
<iterate list="workEffortPartyAssignments" entry="workEffortPartyAssignment">
<remove-value value-field="workEffortPartyAssignment"/>
</iterate>
</if-not-empty>
<!-- assign new party to task -->
<set field="newInput.partyId" from-field="parameters.partyId"/>
<set field="newInput.workEffortId" from-field="taskId"/>
<set field="newInput.fromDate" from-field="parameters.fromDate"/>
<set field="newInput.thruDate" from-field="parameters.thruDate"/>
<if-empty field="taskOwnerRoles">
<set field="newInput.roleTypeId" from-field="parameters.roleTypeId"/>
</if-empty>
<set field="newInput.roleTypeId" from-field="taskOwnerRoles[0].roleTypeId"/>
<set field="newInput.statusId" value="SCAS_ASSIGNED"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="newInput"/>
</else>
</if-not-empty>
<field-to-request field="taskId" request-name="workEffortId"/>
<field-to-request field="taskId" request-name="taskId"/>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="deleteProduct" short-description="">
<if>
<condition>
<or>
<!-- Permission Check -->
<if-has-permission permission="SCRUM_PRODUCT" action="_DELETE"/>
<if-has-permission permission="SCRUM_PRODUCT" action="_ADMIN"/>
<if-has-permission permission="SCRUM" action="_DELETE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<entity-one entity-name="Product" value-field="product"/>
<make-value value-field="product" entity-name="Product"/>
<set field="product.productId" from-field="parameters.productId"/>
<set field="product.productTypeId" value="SCRUM_ITEM"/>
<!--<remove-related relation-name="CustRequestItem" value-field="product"/>-->
<remove-related relation-name="ProductRole" value-field="product"/>
<remove-related relation-name="ProductKeyword" value-field="product"/>
<remove-related relation-name="CustRequestItem" value-field="product"/>
<remove-value value-field="product"/>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="updateProductBacklog" short-description="">
<!-- Permission Check -->
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_PRODUCT_BACKLOG" action="_UPDATE"/>
<if-has-permission permission="SCRUM_PRODUCT_BACKLOG" action="_ADMIN"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<call-simple-method method-name="getWebSiteId"/>
<entity-one entity-name="CustRequest" value-field="custRequest">
<field-map field-name="custRequestId" from-field="parameters.custRequestId"/>
</entity-one>
<set field="update.custRequestId" from-field="parameters.custRequestId"/>
<if-empty field="parameters.description">
<add-error >
<fail-message message="There Product Backlog Item is missing, Please add."/>
</add-error>
<check-errors/>
</if-empty>
<set field="update.description" from-field="parameters.description"/>
<set field="update.parentCustRequestId" from-field="parameters.parentCustRequestId"/>
<set-service-fields service-name="updateCustRequest" map="parameters" to-map="update"/>
<set field="changeToMilliSec" value="${parameters.custEstimatedMilliSeconds *1000*60*60}"></set>
<set field="update.custEstimatedMilliSeconds" from-field="changeToMilliSec" type="Double"/>
<set field="update.fromPartyId" from-field="parameters.partyIdTo" default-value="${custRequest.fromPartyId}"/>
<set field="update.custRequestTypeId" from-field="parameters.custRequestTypeId"/>
<call-service service-name="updateCustRequest" in-map-name="update"/>
<!-- Update CustRequestItem -->
<entity-and entity-name="CustRequestItem" list="custRequestItemList">
<field-map field-name="custRequestId" from-field="parameters.custRequestId"/>
</entity-and>
<first-from-list list="custRequestItemList" entry="custRequestItemMap"/>
<if-compare-field field="custRequestItemMap.productId" operator="not-equals" to-field="parameters.productId" type="String">
<set field="nullField" type="String"/>
<set field="custRequest.parentCustRequestId" from-field="nullField"/>
<store-value value-field="custRequest"/>
<set field="custRequestItemMap.productId" from-field="parameters.productId"/>
<store-value value-field="custRequestItemMap"/>
</if-compare-field>
<entity-and entity-name="CustRequestNoteView" list="custRequestNoteViews">
<field-map field-name="custRequestId" from-field="parameters.custRequestId"/>
<field-map field-name="noteName" value="How to test"/>
</entity-and>
<if-empty field="custRequestNoteViews">
<!-- create CustRequestNote -->
<if-not-empty field="parameters.noteInfo">
<make-value value-field="newEntity" entity-name="CustRequestNote"/>
<set from-field="parameters.custRequestId" field="newEntity.custRequestId"/>
<set field="newNoteMap.note" from-field="parameters.noteInfo"/>
<set field="newNoteMap.noteName" value="How to test"/>
<call-service service-name="createNote" in-map-name="newNoteMap" >
<result-to-field result-name="noteId" field="newEntity.noteId" />
</call-service>
<create-value value-field="newEntity"/>
</if-not-empty>
<else>
<!-- update noteData -->
<set-service-fields service-name="updateNote" map="parameters" to-map="updateNoteCtx"/>
<call-service service-name="updateNote" in-map-name="updateNoteCtx"/>
</else>
</if-empty>
<set field="productId" from-field="custRequestItem[0].productId"/>
<field-to-request field="custRequestItem[0].productId" request-name="productId"/>
<field-to-request field="parameters.sequence" request-name="sequence"/>
<field-to-request field="parameters.UnplannedSequence" request-name="UnplannedSequence"/>
</then>
<else>
<set field="_error_message_" value="You has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="createProductAndRole" short-description="">
<if>
<condition>
<or>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
<if-has-permission permission="SCRUM_PRODUCT" action="_CREATE"/>
</or>
</condition>
<then>
<now-timestamp field="nowTimestamp"/>
<entity-one entity-name="UserLogin" value-field="sysUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<if-not-empty field="parameters.internalName">
<set field="product.internalName" from-field="parameters.internalName"/>
<set field="product.longDescription" from-field="parameters.longDescription"/>
<set field="product.productTypeId" value="SCRUM_ITEM"/>
<set field="product.introductionDate" from-field="nowTimestamp"/>
<set field="product.userLogin" from-field="sysUserLogin"/>
<call-service service-name="createProduct" in-map-name="product">
<result-to-field result-name="productId"/>
</call-service>
<!-- create ProductRole -->
<set field="partyId" from-field="parameters.partyId"/>
<set field="parameters.partyIdTo" from-field="partyId"/>
<set field="parameters.productId" from-field="productId"/>
<call-simple-method method-name="createProductRole"/>
<else>
<set field="_error_message_" value="There is no product name."/>
<return response-code="error"/>
</else>
</if-not-empty>
<field-to-request field="productId"/>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="createProductRole"
short-description="Create Product Role" login-required="true">
<now-timestamp field="nowTimestamp" />
<set field="partyCompany" from-field="parameters.partyCompany"/>
<set field="companyId" value="${groovy:partyCompany.substring(partyCompany.indexOf('[')+1,partyCompany.indexOf(']'))}"/>
<!-- Create partyPreson -->
<entity-one entity-name="PartyRole" value-field="partyRoles">
<field-map field-name="partyId" value="${parameters.partyId}"/>
<field-map field-name="roleTypeId" value="PRODUCT_OWNER"/>
</entity-one>
<if-empty field="partyRoles">
<make-value value-field="partyRole" entity-name="PartyRole"/>
<set field="partyRole.partyId" value="${parameters.partyId}"/>
<set field="partyRole.roleTypeId" value="PRODUCT_OWNER"/>
<create-value value-field="partyRole"/>
</if-empty>
<make-value value-field="productRole" entity-name="ProductRole" />
<set field="productRole.productId" from-field="parameters.productId" />
<set field="productRole.partyId" value="${parameters.partyId}"/>
<set field="productRole.roleTypeId" value="PRODUCT_OWNER"/>
<set field="productRole.fromDate" from-field="nowTimestamp" />
<create-value value-field="productRole"/>
<!-- Create partyCompany -->
<entity-one entity-name="PartyRole" value-field="partyRoles">
<field-map field-name="partyId" value="${companyId}"/>
<field-map field-name="roleTypeId" value="PRODUCT_OWNER_COMP"/>
</entity-one>
<if-empty field="partyRoles">
<make-value value-field="partyRole" entity-name="PartyRole"/>
<set field="partyRole.partyId" value="${companyId}"/>
<set field="partyRole.roleTypeId" value="PRODUCT_OWNER_COMP"/>
<create-value value-field="partyRole"/>
</if-empty>
<make-value value-field="productRole" entity-name="ProductRole" />
<set field="productRole.productId" from-field="parameters.productId" />
<set field="productRole.partyId" value="${companyId}"/>
<set field="productRole.roleTypeId" value="PRODUCT_OWNER_COMP"/>
<set field="productRole.fromDate" from-field="nowTimestamp" />
<create-value value-field="productRole"/>
</simple-method>
<simple-method method-name="updateProduct" short-description="">
<!-- CHECK PERMISSION -->
<if>
<condition>
<or>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
<if-has-permission permission="SCRUM" action="_UPDATE"/>
<if-has-permission permission="SCRUM_PRODUCT" action="_ADMIN"/>
<if-has-permission permission="SCRUM_PRODUCT" action="_UPDATE"/>
</or>
</condition>
<then>
<entity-one entity-name="UserLogin" value-field="systemUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<if-empty field="parameters.partyCompany">
<if-not-empty field="parameters.partyId">
<set field="partyCompany" value="${parameters.partyId}"/>
<if-compare operator="equals" value="Y" field="parameters.isCloseBtn">
<set field="companyId" from-field="parameters.companyId"/>
<entity-and entity-name="PartyRelationship" list="owner">
<field-map field-name="partyIdFrom" from-field="companyId"/>
</entity-and>
<!--<set field="partyOwnerId" from-field="userLogin.partyId"/>-->
<set field="partyOwnerId" from-field="owner[0].partyIdTo"/>
<else>
<set field="companyId" value="${groovy:partyCompany.substring(partyCompany.indexOf('[')+1,partyCompany.indexOf(']'))}"/>
<set field="partyOwnerId" value="${groovy:partyCompany.substring(partyCompany.indexOf('(')+1,partyCompany.indexOf(')'))}"/>
</else>
</if-compare>
</if-not-empty>
<else>
<set field="partyCompany" from-field="parameters.partyCompany"/>
<set field="companyId" value="${groovy:partyCompany.substring(partyCompany.indexOf('[')+1,partyCompany.indexOf(']'))}"/>
<set field="partyOwnerId" from-field="parameters.partyId"/>
</else>
</if-empty>
<if-not-empty field="companyId" >
<now-timestamp field="nowTimestamp"/>
<entity-and entity-name="ProductRole" list="productRoleList">
<field-map field-name="productId" from-field="parameters.productId"/>
<field-map field-name="roleTypeId" value="PRODUCT_OWNER_COMP"/>
</entity-and>
<if-empty field="productRoleList">
<entity-and entity-name="PartyRole" list="partyRoleList">
<field-map field-name="partyId" value="${companyId}"/>
<field-map field-name="roleTypeId" value="PRODUCT_OWNER_COMP"/>
</entity-and>
<if-empty field="partyRoleList">
<make-value value-field="partyRole" entity-name="PartyRole"/>
<set field="partyRole.partyId" value="${companyId}"/>
<set field="partyRole.roleTypeId" value="PRODUCT_OWNER_COMP"/>
<create-value value-field="partyRole"/>
</if-empty>
<call-class-method class-name="org.apache.ofbiz.base.util.UtilDateTime" method-name="getDayStart" ret-field="formDate">
<field field="nowTimestamp" type="java.sql.Timestamp"/>
</call-class-method>
<make-value value-field="productRole" entity-name="ProductRole" />
<set field="productRole.productId" from-field="parameters.productId" />
<set field="productRole.partyId" value="${companyId}"/>
<set field="productRole.roleTypeId" value="PRODUCT_OWNER_COMP"/>
<set field="productRole.fromDate" from-field="nowTimestamp" type="Timestamp"/>
<create-value value-field="productRole"/>
</if-empty>
<log level="info" message="${productRoleList[0].partyId}"/>
<if-compare operator="not-equals" value="${companyId}" field="productRoleList[0].partyId">
<entity-and entity-name="ProductRole" list="ownerProductRoles" filter-by-date="true">
<field-map field-name="productId" from-field="parameters.productId"/>
<field-map field-name="roleTypeId" value="PRODUCT_OWNER"/>
</entity-and>
<if-not-empty field="ownerProductRoles">
<first-from-list list="ownerProductRoles" entry="ownerProductRole"/>
<set-service-fields service-name="removePartyFromProduct" to-map="removeProductOwnerRole" map="ownerProductRole"/>
<set field="removeProductOwnerRole.userLogin" from-field="systemUserLogin"/>
<call-service service-name="removePartyFromProduct" in-map-name="removeProductOwnerRole"/>
</if-not-empty>
<entity-and entity-name="ProductRole" list="companyRoles" filter-by-date="true">
<field-map field-name="productId" from-field="parameters.productId"/>
<field-map field-name="roleTypeId" value="PRODUCT_OWNER_COMP"/>
<field-map field-name="partyId" from-field="productRoleList[0].partyId"/>
</entity-and>
<if-not-empty field="companyRoles">
<first-from-list list="companyRoles" entry="companyRole"/>
<set-service-fields service-name="removePartyFromProduct" to-map="removeCompanyRole" map="companyRole"/>
<set field="removeCompanyRole.userLogin" from-field="systemUserLogin"/>
<call-service service-name="removePartyFromProduct" in-map-name="removeCompanyRole"/>
</if-not-empty>
<set field="updateProdOwner.partyId" from-field="partyOwnerId"/>
<set field="updateProdOwner.roleTypeId" value="PRODUCT_OWNER"/>
<set field="updateProdOwner.productId" from-field="parameters.productId"/>
<set field="updateProdOwner.fromDate" from-field="productRole.fromDate"/>
<set field="updateProdOwner.userLogin" from-field="systemUserLogin"/>
<call-service service-name="addPartyToProduct" in-map-name="updateProdOwner"/>
<entity-and entity-name="ProductRole" list="productCompList">
<field-map field-name="productId" from-field="parameters.productId"/>
<field-map field-name="partyId" from-field="companyId"/>
<field-map field-name="roleTypeId" value="PRODUCT_OWNER_COMP"/>
</entity-and>
<if-empty field="productCompList">
<make-value value-field="productComp" entity-name="ProductRole" />
<set field="productComp.productId" from-field="parameters.productId" />
<set field="productComp.partyId" value="${companyId}"/>
<set field="productComp.roleTypeId" value="PRODUCT_OWNER_COMP"/>
<set field="productComp.fromDate" from-field="nowTimestamp"/>
<create-value value-field="productComp"/>
</if-empty>
</if-compare>
<entity-one entity-name="UserLogin" value-field="sysUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<set field="update.productId" from-field="parameters.productId"/>
<set field="update.internalName" from-field="parameters.internalName"/>
<if-compare field="parameters.statusId" operator="equals" value="PRODUCT_CLOSED">
<set field="update.supportDiscontinuationDate" from-field="nowTimestamp"/>
</if-compare>
<set field="update.longDescription" from-field="parameters.longDescription"/>
<set field="update.userLogin" from-field="sysUserLogin"/>
<call-service service-name="updateProduct" in-map-name="update"/>
<if-compare operator="equals" value="PRODUCT_CLOSED" field="parameters.statusId">
<!-- Commplete Default Tasks -->
<entity-and entity-name="WorkEffortAndProduct" list="defaultTaskList">
<field-map field-name="productId" from-field="parameters.productId"/>
<field-map field-name="workEffortPurposeTypeId" value="SCRUM_DEFAULT_TASK"/>
</entity-and>
<if-not-empty field="defaultTaskList">
<iterate list="defaultTaskList" entry="defaultTaskMap">
<set field="defaultTaskMap.currentStatusId" value="STS_COMPLETED"/>
<store-value value-field="defaultTaskMap"/>
</iterate>
</if-not-empty>
<!-- Close The Project -->
<entity-and entity-name="WorkEffortAndProduct" list="projects">
<field-map field-name="productId" from-field="parameters.productId"/>
<field-map field-name="workEffortTypeId" value="SCRUM_PROJECT"/>
</entity-and>
<if-not-empty field="projects">
<iterate list="projects" entry="project">
<set field="workEffortId" from-field="project.workEffortId"/>
<set field="projectId" from-field="project.workEffortId"/>
<set field="parameters.workEffortId" from-field="workEffortId"/>
<set field="parameters.projectId" from-field="projectId"/>
<set field="parameters.currentStatusId" value="SPJ_CLOSED"/>
<call-simple-method method-name="updateScrumProject"/>
</iterate>
</if-not-empty>
</if-compare>
<else>
<set field="_error_message_" value="Please Select the Product Owner and Company"/>
<return response-code="error"/>
</else>
</if-not-empty>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="createDailyNote" short-description="Create Daily Meeting Minute Note">
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_DAILY" action="_CREATE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<now-timestamp field="nowTimestamp"/>
<call-class-method class-name="org.apache.ofbiz.base.util.UtilDateTime" method-name="getDayStart" ret-field="noteDateTime">
<field field="nowTimestamp" type="java.sql.Timestamp"/>
</call-class-method>
<if-not-empty field="parameters.noteInfo1">
<make-value value-field="noteData" entity-name="NoteData"/>
<sequenced-id sequence-name="NoteData" field="noteId"/>
<set field="noteData.noteId" from-field="noteId"/>
<set field="noteData.noteName" from-field="parameters.noteName1"/>
<set field="noteData.noteInfo" from-field="parameters.noteInfo1"/>
<set field="noteData.noteParty" from-field="userLogin.partyId"/>
<set field="noteData.noteDateTime" from-field="noteDateTime" type="Timestamp"/>
<create-value value-field="noteData"/>
<make-value value-field="newWorkEffortNote" entity-name="WorkEffortNote"/>
<set from-field="noteId" field="newWorkEffortNote.noteId"/>
<set from-field="parameters.workEffortId" field="newWorkEffortNote.workEffortId"/>
<create-value value-field="newWorkEffortNote"/>
<make-value value-field="noteData" entity-name="NoteData"/>
</if-not-empty>
<if-not-empty field="parameters.noteInfo2">
<make-value value-field="noteData" entity-name="NoteData"/>
<sequenced-id sequence-name="NoteData" field="noteId"/>
<set field="noteData.noteId" from-field="noteId"/>
<set field="noteData.noteName" from-field="parameters.noteName2"/>
<set field="noteData.noteInfo" from-field="parameters.noteInfo2"/>
<set field="noteData.noteParty" from-field="userLogin.partyId"/>
<set field="noteData.noteDateTime" from-field="noteDateTime" type="Timestamp"/>
<create-value value-field="noteData"/>
<make-value value-field="newWorkEffortNote" entity-name="WorkEffortNote"/>
<set from-field="noteId" field="newWorkEffortNote.noteId"/>
<set from-field="parameters.workEffortId" field="newWorkEffortNote.workEffortId"/>
<create-value value-field="newWorkEffortNote"/>
<make-value value-field="noteData" entity-name="NoteData"/>
</if-not-empty>
<if-not-empty field="parameters.noteInfo3">
<make-value value-field="noteData" entity-name="NoteData"/>
<sequenced-id sequence-name="NoteData" field="noteId"/>
<set field="noteData.noteId" from-field="noteId"/>
<set field="noteData.noteName" from-field="parameters.noteName3"/>
<set field="noteData.noteInfo" from-field="parameters.noteInfo3"/>
<set field="noteData.noteParty" from-field="userLogin.partyId"/>
<set field="noteData.noteDateTime" from-field="noteDateTime" type="Timestamp"/>
<create-value value-field="noteData"/>
<make-value value-field="newWorkEffortNote" entity-name="WorkEffortNote"/>
<set from-field="noteId" field="newWorkEffortNote.noteId"/>
<set from-field="parameters.workEffortId" field="newWorkEffortNote.workEffortId"/>
<create-value value-field="newWorkEffortNote"/>
<make-value value-field="noteData" entity-name="NoteData"/>
</if-not-empty>
<field-to-request field="parameters.workEffortId" request-name="projectId"/>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="updateDailyNote" short-description="Update Daily Meeting Minute Note">
<if>
<condition>
<or>
<if-has-permission permission="SCRUM_DAILY" action="_UPDATE"/>
<if-has-permission permission="SCRUM" action="_ADMIN"/>
</or>
</condition>
<then>
<set field="update.workEffortId" from-field="parameters.workEffortId"/>
<set field="update.noteId" from-field="parameters.noteId"/>
<set field="update.internalNote" value="N"/>
<call-service service-name="updateWorkEffortNote" in-map-name="update"/>
<set field="_event_message_" value="Daily Meeting Minutes has been updated."/>
</then>
<else>
<set field="_error_message_" value="You are has no permission to perform this action."/>
<return response-code="error"/>
</else>
</if>
</simple-method>
<simple-method method-name="updateTask" short-description="Update Task">
<!-- Update planned hours -->
<!-- If a task have time entry, planned hours will update last time entry of task and always update in estimatedMilliSeconds field of task -->
<calculate field="parameters.estimatedMilliSeconds" type="Float">
<calcop operator="multiply" field="parameters.planHours">
<number value="3600000"/>
</calcop>
</calculate>
<!-- update if task has TimeEntry -->
<entity-condition entity-name="TimeEntry" list="lastTimeEntrys">
<condition-list combine="and">
<condition-expr field-name="workEffortId" from-field="parameters.workEffortId"/>
</condition-list>
<order-by field-name="-fromDate"/>
</entity-condition>
<entity-and entity-name="ProjectSprintBacklogAndTask" list="meetingTasks">
<field-map field-name="taskId" from-field="parameters.taskId"/>
<field-map field-name="sprintTypeId" value="SCRUM_SPRINT"/>
<field-map field-name="custRequestTypeId" value="RF_SCRUM_MEETINGS"/>
</entity-and>
<if-empty field="meetingTasks">
<first-from-list list="lastTimeEntrys" entry="lastTimeEntry"/>
<if-not-empty field="lastTimeEntry">
<set field="lastTimeEntry.planHours" from-field="parameters.planHours" type="Double"/>
<set field="parameters.timeEntryId" from-field="lastTimeEntry.timeEntryId"/>
<set field="parameters.timesheetId" from-field="lastTimeEntry.timesheetId"/>
<set field="parameters.planHours" from-field="lastTimeEntry.planHours"/>
<call-simple-method method-name="updateScrumTimeEntry"/>
</if-not-empty>
</if-empty>
<set-service-fields service-name="updateWorkEffort" map="parameters" to-map="inMap"/>
<call-service service-name="updateWorkEffort" in-map-name="inMap"/>
<if-not-empty field="parameters.partyId">
<!-- Assigned -->
<entity-condition entity-name="WorkEffortPartyAssignment" list="assigneds">
<condition-list combine="and">
<condition-expr field-name="partyId" from-field="parameters.partyId"/>
<condition-expr field-name="statusId" value="SCAS_ASSIGNED"/>
<condition-expr field-name="workEffortId" from-field="parameters.workEffortId"/>
</condition-list>
</entity-condition>
<if-empty field="assigneds">
<!-- get roletype from sprint member -->
<entity-condition entity-name="ProjectSprintBacklogAndTask" list="sprintList">
<condition-list combine="and">
<condition-expr field-name="sprintTypeId" value="SCRUM_SPRINT"/>
<condition-expr field-name="taskId" from-field="parameters.workEffortId"/>
</condition-list>
</entity-condition>
<first-from-list list="sprintList" entry="sprint"/>
<entity-condition entity-name="WorkEffortPartyAssignment" list="sprintRoles">
<condition-list combine="and">
<condition-expr field-name="partyId" from-field="parameters.partyId"/>
<condition-expr field-name="workEffortId" from-field="sprint.sprintId"/>
<condition-expr field-name="roleTypeId" value="SCRUM_TEAM"/>
</condition-list>
</entity-condition>
<!-- Use when role type id still empty -->
<entity-and entity-name="ScrumPersonAndCompanyAndSecurityGroup" list="roleList">
<field-map field-name="partyId" from-field="parameters.partyId"/>
<field-map field-name="groupId" value="SCRUM_TEAM"/>
</entity-and>
<entity-and entity-name="WorkEffortPartyAssignment" list="assigneds">
<field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
</entity-and>
<entity-one entity-name="UserLogin" value-field="systemUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<iterate list="assigneds" entry="assigned">
<remove-value value-field="assigned"/>
</iterate>
<set field="newInput.partyId" from-field="parameters.partyId"/>
<set field="newInput.workEffortId" from-field="parameters.workEffortId"/>
<if-not-empty field="sprintRoles[0].roleTypeId">
<set field="newInput.roleTypeId" from-field="sprintRoles[0].roleTypeId"/>
<else>
<set field="newInput.roleTypeId" from-field="roleList[0].groupId"/>
</else>
</if-not-empty>
<set field="newInput.statusId" value="SCAS_ASSIGNED"/>
<call-service service-name="assignPartyToWorkEffort" in-map-name="newInput"/>
</if-empty>
</if-not-empty>
<!--if plan hours(from task) more than first plan hours -->
<entity-and entity-name="CustRequestWorkEffort" list="custRequestWorkEffortList">
<field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
</entity-and>
<first-from-list list="custRequestWorkEffortList" entry="custRequestWorkEffortMap"/>
<set field="backlogPlanMap.custRequestId" from-field="custRequestWorkEffortMap.custRequestId" />
<set field="taskPlanMap.custRequestId" from-field="custRequestWorkEffortMap.custRequestId" />
<call-service service-name="getScrumPlanHour" in-map-name="backlogPlanMap">
<result-to-field result-name="planHours" />
</call-service>
<call-service service-name="getScrumPlanHour" in-map-name="taskPlanMap">
<result-to-field result-name="initPlanHours"/>
</call-service>
<if-compare-field field="planHours" operator="greater" to-field="initPlanHours" type="Double">
<entity-one entity-name="CustRequest" value-field="custRequestMap">
<field-map field-name="custRequestId" from-field="custRequestWorkEffortMap.custRequestId"/>
</entity-one>
<set field="planHoursIn" from-field="planHours" type="Double"/>
<set field="custRequestMap.custEstimatedMilliSeconds" value="${groovy:planHoursIn*1000*60*60}" type="Double"/>
<store-value value-field="custRequestMap"/>
<else>
<if-compare-field field="initPlanHours" operator="greater" to-field="planHours" type="Double">
<entity-one entity-name="CustRequest" value-field="custRequestMap">
<field-map field-name="custRequestId" from-field="custRequestWorkEffortMap.custRequestId"/>
</entity-one>
<set field="planHoursIn" from-field="planHours" type="Double"/>
<set field="custRequestMap.custEstimatedMilliSeconds" value="${groovy:planHoursIn*1000*60*60}" type="Double"/>
<store-value value-field="custRequestMap"/>
</if-compare-field>
</else>
</if-compare-field>
</simple-method>
<!-- Task Note -->
<simple-method method-name="createTaskNote" short-description="Create Task Note">
<if-empty field="parameters.noteName">
<set field="newNoteMap.noteName" value="Task Note"/>
<else>
<set field="newNoteMap.noteName" from-field="parameters.noteName"/>
</else>
</if-empty>
<if-empty field="parameters.noteInfo">
<add-error>
<fail-message message="Can not empty noteInfo"/>
</add-error>
<check-errors/>
<else>
<set field="newNoteMap.note" from-field="parameters.noteInfo"/>
</else>
</if-empty>
<if-not-empty field="parameters.workEffortId">
<call-service service-name="createNote" in-map-name="newNoteMap">
<result-to-field result-name="noteId" field="noteId"/>
</call-service>
<make-value value-field="newEntity" entity-name="WorkEffortNote"/>
<set field="newEntity.workEffortId" from-field="parameters.workEffortId" />
<set field="newEntity.noteId" from-field="noteId" />
<set field="newEntity.internalNote" value="Y"/>
<create-value value-field="newEntity"/>
</if-not-empty>
</simple-method>
<simple-method method-name="deleteTaskNote" short-description="Delete Task Note">
<entity-one entity-name="WorkEffortNote" value-field="workNoteMap" auto-field-map="true"/>
<remove-value value-field="workNoteMap"/>
<remove-related relation-name="NoteData" value-field="workNoteMap"/>
</simple-method>
<simple-method method-name="DeleteTaskFromSprintOverview" short-description="Delete Task From Sprint Overview Screen">
<entity-one entity-name="CustRequestWorkEffort" value-field="taskWorkEffort">
<field-map field-name="workEffortId" from-field="parameters.workEffort"/>
<field-map field-name="custRequestId" from-field="parameters.custRequestId"/>
</entity-one>
<remove-value value-field="taskWorkEffort"/>
</simple-method>
<simple-method method-name="deleteScrumResource" short-description="remove scrum resource">
<entity-one entity-name="UserLogin" value-field="sysUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<if-compare operator="equals" value="SCRUM_PRODUCT_OWNER" field="parameters.groupId">
<set field="parameters.roleTypeId" value="PRODUCT_OWNER"/>
</if-compare>
<if-compare operator="equals" value="SCRUM_MASTER" field="parameters.groupId">
<set field="parameters.roleTypeId" value="SCRUM_MASTER"/>
</if-compare>
<if-compare operator="equals" value="SCRUM_TEAM" field="parameters.groupId">
<set field="parameters.roleTypeId" value="SCRUM_TEAM"/>
</if-compare>
<!-- For special role -->
<if-compare operator="equals" value="SCRUM_STAKEHOLDER" field="parameters.groupId">
<set field="parameters.roleTypeId" value="STAKEHOLDER"/>
</if-compare>
<entity-and entity-name="PartyRole" list="partyRoles">
<field-map field-name="partyId" from-field="parameters.partyId"/>
<field-map field-name="roleTypeId" from-field="parameters.roleTypeId"/>
</entity-and>
<if-not-empty field="partyRoles">
<set-service-fields service-name="deletePartyRole" map="parameters" to-map="deletePartyRoleMap"/>
<set field="deletePartyRoleMap.userLogin" from-field="sysUserLogin"/>
<call-service service-name="deletePartyRole" in-map-name="deletePartyRoleMap"/>
</if-not-empty>
<now-timestamp field="nowTimestamp" />
<entity-and entity-name="UserLoginSecurityGroup" list="userLoginSecurityGroups">
<field-map field-name="userLoginId" from-field="parameters.userLoginId"/>
<field-map field-name="groupId" from-field="parameters.groupId"/>
</entity-and>
<if-not-empty field="userLoginSecurityGroups">
<iterate list="userLoginSecurityGroups" entry="userLoginSecurityGroup">
<remove-value value-field="userLoginSecurityGroup"/>
</iterate>
</if-not-empty>
</simple-method>
<simple-method method-name="assignPartyToWorkEffort" short-description="Assign Party To WorkEffort">
<entity-one entity-name="UserLogin" value-field="sysUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<set-service-fields service-name="assignPartyToWorkEffort" map="parameters" to-map="assignPartyToWorkEffortCtx"/>
<set field="assignPartyToWorkEffortCtx.userLogin" from-field="sysUserLogin"/>
<entity-condition entity-name="PartyRole" list="partyRoleList">
<condition-expr field-name="partyId" from-field="assignPartyToWorkEffortCtx.partyId"/>
<select-field field-name="roleTypeId"/>
</entity-condition>
<if-not-empty field="partyRoleList">
<iterate list="partyRoleList" entry="partyRoleMap">
<if>
<condition>
<and>
<or>
<if-compare field="partyRoleMap.roleTypeId" operator="equals" value="SCRUM_MASTER"/>
<if-compare field="partyRoleMap.roleTypeId" operator="equals" value="SCRUM_TEAM"/>
</or>
<if-compare field="assignPartyToWorkEffortCtx.roleTypeId" operator="equals" value="PRODUCT_OWNER" ></if-compare>
</and>
</condition>
<then>
<add-error>
<fail-property resource="scrumUiLabels" property="ScrumPartyAssignmentError"/>
</add-error>
<check-errors/>
</then>
</if>
</iterate>
</if-not-empty>
<call-service service-name="assignPartyToWorkEffort" in-map-name="assignPartyToWorkEffortCtx"/>
</simple-method>
<simple-method method-name="createTestTask" short-description="Create A test task">
<call-class-method class-name="org.apache.ofbiz.content.layout.LayoutWorker" method-name="uploadImageAndParameters" ret-field="formInput">
<field field="request" type="javax.servlet.http.HttpServletRequest"/>
<string value="uploadedFile"/>
</call-class-method>
<entity-one entity-name="UserLogin" value-field="systemUser">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<!--<log level="info" message="=========================parameters:${formInput.formInput}"></log>-->
<if-not-empty field="formInput.formInput.workEffortName">
<set-service-fields service-name="createWorkEffortAndPartyAssign" map="formInput.formInput" to-map="assignPartyToWorkEffortCtx"/>
<set field="assignPartyToWorkEffortCtx.userLogin" from-field="systemUser"/>
<call-service service-name="createWorkEffortAndPartyAssign" in-map-name="assignPartyToWorkEffortCtx" include-user-login="false" >
<result-to-field result-name="workEffortId" field="workEffortId"/>
</call-service>
<field-to-request field="workEffortId"/>
<set field="formInput.formInput.workEffortId" from-field="workEffortId"/>