sunset.bpmn20.xml revision a60d77aaed3324cd783f4e648fedfecd54f8e551
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns:activiti="http://activiti.org/bpmn"
xsi:schemaLocation="
<process id="sunset" name="Contract termination process">
<startEvent id="start" activiti:initiator="startUserId" />
<sequenceFlow sourceRef="start" targetRef="fetchData"/>
<scriptTask id="fetchData" name="Prepare Task" scriptFormat="groovy">
<script><![CDATA[
user = openidm.read(userId)
userName = user.userName
givenName = user.givenName
familyName = user.familyName
department = user.department
endDate = user.sunset.date
employeeNumber = user.employeeNumber
]]>
</script>
</scriptTask>
<sequenceFlow sourceRef="fetchData" targetRef="decideApprovalTask"/>
<userTask id="decideApprovalTask" name="Contract Termination" activiti:assignee="${user.manager.managerId}">
<extensionElements>
<activiti:formProperty id="userName"
name="Username"
required="true"
writable="false"
type="string" />
<activiti:formProperty id="givenName"
name="First Name"
required="true"
writable="false"
type="string" />
<activiti:formProperty id="familyName"
name="Last Name"
required="true"
writable="false"
type="string" />
<activiti:formProperty id="department"
name="Department"
required="true"
writable="false"
type="string"/>
<activiti:formProperty id="endDate"
name="End Date"
type="string"
datePattern="yyyy-MM-dd"/>
<activiti:formProperty id="employeeNumber"
name="Employee number"
required="true"
writable="false"
type="string" />
<activiti:formProperty id="decision" name="Decision" type="enum" required="true">
<activiti:value id="accept" name="Accept termination"></activiti:value>
<activiti:value id="modify" name="Modify date"></activiti:value>
</activiti:formProperty>
</extensionElements>
</userTask>
<sequenceFlow sourceRef="decideApprovalTask" targetRef="decisionMadeGateway"></sequenceFlow>
<exclusiveGateway id="decisionMadeGateway" name="Decision Made"></exclusiveGateway>
<sequenceFlow sourceRef="decisionMadeGateway" targetRef="deactivateManagedUser">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[ ${decision=='accept'} ]]>
</conditionExpression>
</sequenceFlow>
<scriptTask id="deactivateManagedUser" scriptFormat="groovy">
<script>
params.put('_action', 'patch')
list = [[replace:'accountStatus',value:'inactive']]
params.put('_entity', list)
</script>
</scriptTask>
<sequenceFlow sourceRef="deactivateManagedUser" targetRef="sendAcceptNotification"/>
<scriptTask id="sendAcceptNotification" scriptFormat="groovy">
<script>
java.text.SimpleDateFormat formatUTC = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
requestDate = formatUTC.format(new Date());
def newRequesterNotification = [
"receiverId": "hradmin",
"requesterId" : "",
"requester" : "",
"createDate" : requestDate,
"notificationType" : "info",
"notificationSubtype" : "",
"message" : "The requested user " + userName + " was successfully inactivated"
];
</script>
</scriptTask>
<sequenceFlow sourceRef="sendAcceptNotification" targetRef="end"/>
<sequenceFlow sourceRef="decisionMadeGateway" targetRef="modifyDate">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[ ${decision=='modify'} ]]>
</conditionExpression>
</sequenceFlow>
<scriptTask id="modifyDate" scriptFormat="groovy">
<script>
java.text.SimpleDateFormat formatUTC = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
if (endDate != "") {
endDateISO = formatUTC.format(formatUTCDate.parse(endDate))
sunsetMap = [date:endDateISO.toString()]
params.put('_action', 'patch')
list = [[replace:'sunset',value:sunsetMap]]
params.put('_entity', list)
}
requestDate = formatUTC.format(new Date());
def newRequesterNotification = [
"receiverId": user.manager.managerId,
"requesterId" : "",
"requester" : "",
"createDate" : requestDate,
"notificationType" : "warning",
"notificationSubtype" : "",
"message" : "Contract of " + userName + " was extended"
];
</script>
</scriptTask>
<sequenceFlow sourceRef="modifyDate" targetRef="end"/>
<endEvent id="end"/>
</process>
</definitions>