newUserCreate.bpmn20.xml revision a60d77aaed3324cd783f4e648fedfecd54f8e551
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns:activiti="http://activiti.org/bpmn"
xsi:schemaLocation="
<process id="newUserCreate" name="User onboarding process">
<startEvent id="start" activiti:initiator="startUserId" >
<extensionElements>
<activiti:formProperty id="_formGenerationTemplate" type="string" default="
<style>
#processDetails fieldset {
margin-top: 0;
}
#processDetails .group-field {
float: left !important;
width: 100%;
}
#processDetails .field label {
text-align: left;
}
#processDetails .field input,#processDetails .field select {
clear: both;
}
#processDetails .field .validation-message {
clear: none !important;
margin-left: 20px !important;
float: left !important;
}
</style>
<h2 class="header">User Details</h2>
<fieldset>
<div class="fields">
<div class="field">
<label>{{t "common.user.username"}}</label>
<input type="text" name="userName" data-validation-dependents="password"/>
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>{{t "common.user.givenName"}}</label>
<input type="text" name="givenName" data-validation-dependents="password"/>
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>{{t "common.user.familyName"}}</label>
<input type="text" name="familyName" data-validation-dependents="password"/>
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>{{t "common.user.emailAddress"}}</label>
<input type="text" name="email" />
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>Country</label>
<input type="text" name="country" />
</div>
<div class="field">
<label>City</label>
<input type="text" name="city" />
</div>
<div class="field">
<label>State</label>
<input type="text" name="stateProvince" />
</div>
<div class="field">
<label>Postal Code</label>
<input type="text" name="postalCode" />
</div>
<div class="field">
<label>Address</label>
<input type="text" name="address1" />
</div>
<div class="field">
<label>{{t "common.user.phoneNumber"}}</label>
<input type="text" name="phoneNumber" />
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>Department</label>
<select name="department">
<option value="Human Resources">Human Resources</option>
<option value="Production Planning">Production Planning</option>
<option value="Sales & Distribution">Sales & Distribution</option>
<option value="Treasury & Payments">Treasury & Payments</option>
</select>
</div>
<div class="field">
<label>Employee Number</label>
<input type="text" name="employeeNumber" />
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>Display Name</label>
<input type="text" name="displayName" />
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>User Type</label>
<select name="userType">
<option value="employee">Employee</option>
<option value="contractor">Contractor</option>
</select>
</div>
</div>
</fieldset>
<script>
v.bindValidators($('#processDetails form'), "managed/user/");
});
</script>
"/>
<activiti:formProperty id="userName"
name="Username"
required="true"
type="string" />
<activiti:formProperty id="givenName"
name="First Name"
required="true"
type="string" />
<activiti:formProperty id="familyName"
name="Last Name"
required="true"
type="string" />
<activiti:formProperty id="email"
name="Email"
required="true"
type="string" />
<activiti:formProperty id="country"
name="Country"
type="string" />
<activiti:formProperty id="city"
name="City"
type="string" />
<activiti:formProperty id="stateProvince"
name="State"
type="string" />
<activiti:formProperty id="postalCode"
name="Postal Code"
type="string" />
<activiti:formProperty id="address1"
name="Address"
type="string" />
<activiti:formProperty id="phoneNumber"
name="Phone Number"
required="true"
type="string" />
<activiti:formProperty id="department"
name="Department"
required="true"
type="enum">
<activiti:value id="Human Resources" name="Human Resources"/>
<activiti:value id="Production Planning" name="Production Planning"/>
<activiti:value id="Sales & Distribution" name="Sales & Distribution"/>
<activiti:value id="Treasury & Payments" name="Treasury & Payments"/>
</activiti:formProperty>
<activiti:formProperty id="employeeNumber"
name="Employee number"
required="true"
type="string" />
<activiti:formProperty id="displayName"
name="Display Name"
required="true"
type="string" />
<activiti:formProperty id="userType"
name="User Type"
required="true"
type="enum" >
<activiti:value id="employee" name="Employee"/>
<activiti:value id="contractor" name="Contractor"/>
</activiti:formProperty>
</extensionElements>
</startEvent>
<sequenceFlow sourceRef="start" targetRef="decisionPrep"/>
<scriptTask id="decisionPrep" name="Prepare Task" scriptFormat="groovy">
<script><![CDATA[
params = [_queryExpression:"select * from managed_user where title='manager' and department='"+department+"'"];
manager = openidm.query("managed/user", params)
StringBuilder builder = new StringBuilder();
for (String string : manager.result._id) {
if (builder.length() > 0) {
builder.append(",");
}
builder.append(string);
}
candidateUsers = builder.toString();
]]>
</script>
</scriptTask>
<sequenceFlow sourceRef="decisionPrep" targetRef="decideApprovalTask"/>
<userTask id="decideApprovalTask" name="Onboarding Approval" activiti:candidateUsers="${candidateUsers}">
<extensionElements>
<activiti:formProperty id="_formGenerationTemplate" type="string" default="
<style>
#taskDetails fieldset {
margin-top: 0;
}
#taskDetails .group-field {
float: left !important;
width: 100%;
}
#taskDetails .field label {
text-align: left;
}
#taskDetails .field input,#taskDetails .field select {
clear: both;
}
#taskDetails .field .validation-message {
clear: none !important;
margin-left: 20px !important;
float: left !important;
}
</style>
<h2 class="header">User Approval</h2>
<fieldset>
<div class="fields">
<div class="field">
<label>{{t "common.user.username"}}</label>
<input type="text" name="userName" value="{{variables.userName}}" data-validation-dependents="password"/>
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>{{t "common.user.givenName"}}</label>
<input type="text" name="givenName" value="{{variables.givenName}}" data-validation-dependents="password"/>
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>{{t "common.user.familyName"}}</label>
<input type="text" name="familyName" value="{{variables.familyName}}" data-validation-dependents="password"/>
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>{{t "common.user.emailAddress"}}</label>
<input type="text" name="email" value="{{variables.email}}" />
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>Country</label>
<input type="text" name="country" value="{{variables.country}}" />
</div>
<div class="field">
<label>City</label>
<input type="text" name="city" value="{{variables.city}}"/>
</div>
<div class="field">
<label>State</label>
<input type="text" name="stateProvince" value="{{variables.stateProvince}}" />
</div>
<div class="field">
<label>Postal Code</label>
<input type="text" name="postalCode" value="{{variables.postalCode}}"/>
</div>
<div class="field">
<label>Address</label>
<input type="text" name="address1" value="{{variables.address1}}"/>
</div>
<div class="field">
<label>{{t "common.user.phoneNumber"}}</label>
<input type="text" name="phoneNumber" value="{{variables.phoneNumber}}"/>
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>Department</label>
<select name="department">
<option value="Human Resources">Human Resources</option>
<option value="Production Planning">Production Planning</option>
<option value="Sales & Distribution">Sales & Distribution</option>
<option value="Treasury & Payments">Treasury & Payments</option>
</select>
</div>
<div class="field">
<label>Start Date (yyyy-MM-dd)</label>
<input type="text" name="startDate" />
</div>
<div class="field">
<label>End Date (yyyy-MM-dd)</label>
<input type="text" name="endDate" />
</div>
<div class="field">
<label>Employee Number</label>
<input type="text" name="employeeNumber" value="{{variables.employeeNumber}}" />
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>Display Name</label>
<input type="text" name="displayName" value="{{{variables.displayName}}}"/>
<span class="error">x</span>
<div class="validation-message"></div>
</div>
<div class="field">
<label>User Type</label>
<select name="userType">
<option value="employee">Employee</option>
<option value="contractor">Contractor</option>
</select>
</div>
<div class="field">
<label>Manager</label>
<select name="title">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
</div>
<div class="field">
<label class="light">{{t "common.form.decision"}}</label>
<select name="decision" " data-validator='required' " >
<option value="accept">Accept</option>
<option value="reject">Reject</option>
</select>
<span class="ok" style="">✔</span>
<div class="validation-message"></div>
</div>
</div>
</fieldset>
<script>
$('#taskDetails form select[name=department]').val("{{{variables.department}}}");
$('#taskDetails form select[name=userType]').val("{{variables.userType}}");
{{#if assignee}}
v.bindValidators($('#taskDetails form'), "managed/user/", function () {
v.validateAllFields($('#taskDetails form'));
});
});
{{/if}}
</script>
"/>
<activiti:formProperty id="userName"
name="Username"
required="true"
type="string" />
<activiti:formProperty id="givenName"
name="First Name"
required="true"
type="string" />
<activiti:formProperty id="familyName"
name="Last Name"
required="true"
type="string" />
<activiti:formProperty id="email"
name="Email"
required="true"
type="string" />
<activiti:formProperty id="country"
name="Country"
type="string" />
<activiti:formProperty id="city"
name="City"
required="true"
type="string" />
<activiti:formProperty id="stateProvince"
name="State"
type="string" />
<activiti:formProperty id="postalCode"
name="Postal Code"
required="true"
type="string" />
<activiti:formProperty id="address1"
name="Address"
required="true"
type="string" />
<activiti:formProperty id="phoneNumber"
name="Phone Number"
required="true"
type="string" />
<activiti:formProperty id="department"
name="Department"
required="true"
type="enum">
<activiti:value id="Human Resources" name="Human Resources"/>
<activiti:value id="Production Planning" name="Production Planning"/>
<activiti:value id="Sales & Distribution" name="Sales & Distribution"/>
<activiti:value id="Treasury & Payments" name="Treasury & Payments"/>
</activiti:formProperty>
<activiti:formProperty id="startDate"
name="Start Date (yyyy-MM-dd)"
type="string"/>
<activiti:formProperty id="endDate"
name="End Date (yyyy-MM-dd)"
type="string" />
<activiti:formProperty id="employeeNumber"
name="Employee number"
required="true"
type="string" />
<activiti:formProperty id="displayName"
name="Display Name"
required="true"
type="string" />
<activiti:formProperty id="userType"
name="User Type"
required="true"
type="enum" >
<activiti:value id="employee" name="Employee"/>
<activiti:value id="contractor" name="Contractor"/>
</activiti:formProperty>
<activiti:formProperty id="title"
name="Manager"
required="true"
type="enum" >
<activiti:value id="yes" name="Yes"/>
<activiti:value id="no" name="No"/>
</activiti:formProperty>
<activiti:formProperty id="decision" name="Decision" type="enum" required="true">
<activiti:value id="accept" name="Accept"></activiti:value>
<activiti:value id="reject" name="Reject"></activiti:value>
</activiti:formProperty>
</extensionElements>
</userTask>
<sequenceFlow sourceRef="decideApprovalTask" targetRef="decisionMadeGateway"></sequenceFlow>
<exclusiveGateway id="decisionMadeGateway" name="Decision Made"></exclusiveGateway>
<sequenceFlow sourceRef="decisionMadeGateway" targetRef="createManagedUser">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[ ${decision=='accept'} ]]>
</conditionExpression>
</sequenceFlow>
<scriptTask id="createManagedUser" scriptFormat="groovy">
<script>
<![CDATA[
user = [_id:userName, userName:userName, givenName:givenName, familyName:familyName,
email:email, country:country, city:city, stateProvince:stateProvince,
postalCode:postalCode, address1:address1, phoneNumber:phoneNumber,
department:department, employeeNumber:employeeNumber, displayName:displayName,
userType:userType, password:"Passw0rd"]
if (title == 'yes') {
userTitle = 'manager'
user.put("title", userTitle)
}
if (userType=='employee') {
accountsList = ["Business"]
user.put("accounts", accountsList)
}
java.text.SimpleDateFormat formatUTCDate = new java.text.SimpleDateFormat("yyyy-MM-dd");
java.text.SimpleDateFormat formatUTC = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
if (startDate != "") {
startDateISO = formatUTC.format(formatUTCDate.parse(startDate))
sunriseMap = [date:startDateISO.toString()]
user.put("sunrise", sunriseMap)
user.put("accountStatus", "inactive")
}
if (endDate != "") {
endDateISO = formatUTC.format(formatUTCDate.parse(endDate))
sunsetMap = [date:endDateISO.toString()]
user.put("sunset", sunsetMap)
}
assignedManager = manager.result[0]
managerMap = [displayName:assignedManager.displayName, managerId:assignedManager._id]
managerMap.put('$ref', "managed/user/"+assignedManager._id)
user.put("manager", managerMap)
openidm.create('managed/user', user)
readNewUserFromRepoParams = [_queryId:'for-userName',uid:userName]
]]>
</script>
</scriptTask>
<sequenceFlow sourceRef="createManagedUser" targetRef="serviceTask"/>
<serviceTask id="serviceTask" activiti:expression="${openidm.query('managed/user', readNewUserFromRepoParams)}"
activiti:resultVariableName="newUserFromRepo"/>
<sequenceFlow sourceRef="serviceTask" 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 created"
];
def newContractorNotification = [
"receiverId": newUserFromRepo.result[0]._id,
"requesterId" : "",
"requester" : "",
"createDate" : requestDate,
"notificationType" : "info",
"notificationSubtype" : "",
"message" : "Welcome! Your work days are from " + startDate + " to " + endDate
];
</script>
</scriptTask>
<sequenceFlow sourceRef="sendAcceptNotification" targetRef="end"/>
<sequenceFlow sourceRef="decisionMadeGateway" targetRef="sendDenyNotification">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[ ${decision=='reject'} ]]>
</conditionExpression>
</sequenceFlow>
<scriptTask id="sendDenyNotification" 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" : "warning",
"notificationSubtype" : "",
"message" : "Your request to create user " + userName + " was denied."
];
</script>
</scriptTask>
<sequenceFlow sourceRef="sendDenyNotification" targetRef="end"/>
<endEvent id="end"/>
</process>
</definitions>