Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20" id="review-definitions">
- <process id="ksesWorkflow" name="Keystone Document Review" isExecutable="true">
- <startEvent id="start" activiti:formKey="wf:submitReviewTask"></startEvent>
- <sequenceFlow id="flow1" sourceRef="start" targetRef="reviewTask"></sequenceFlow>
- <userTask id="reviewTask" name="Review Task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:activitiReviewTask">
- <extensionElements>
- <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
- <activiti:field name="script">
- <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
- if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
- </activiti:field>
- </activiti:taskListener>
- <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
- <activiti:field name="script">
- <activiti:string><![CDATA[execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
- <variable name="kswf_comment" access="read,write" />
- <variable name="bpm_package" access="read" />
- <variable name="bpm_assignee" access="read" />
- <variable name="initiator" access="read" />
- var docList = "\t";
- for (var i = 0; i < bpm_package.children.length; i++)
- {
- docList += bpm_package.children[i].displayPath + "/" + bpm_package.children[i].properties["cm:name"] + "\n\t";
- bpm_package.children[i].properties["ks:status"] = "Approved";
- bpm_package.children[i].properties["ks:reviewComment"] = kswf_comment;
- bpm_package.children[i].save();
- var workingCopy = bpm_package.children[i].checkout();
- workingCopy.checkin("Document approved by " + bpm_assignee.properties["cm:userName"], true);
- /* get name without extension */
- var cmname = bpm_package.children[i].properties["cm:name"];
- var idx = cmname.length - 1;
- if(cmname.lastIndexOf(".") > 0)
- {
- idx = cmname.lastIndexOf(".");
- }
- var docname = cmname.substr(0, idx);
- /* find space where released documents live */
- var drafts = bpm_package.children[i].parent;
- var docroot = drafts.parent;
- var dest = docroot.childByNamePath("Released");
- /* see if document was created previously. if not, do initial version bump */
- var transdoc = dest.childByNamePath(docname + ".pdf");
- var bumpver = false; /* transform to pdf */
- if(transdoc == null) var drafts = bpm_package.children[0].parent;
- { var docroot = drafts.parent;
- bumpver = true; var dest = docroot.childByNamePath("Released");
- }
- var trans = actions.create("transform");
- trans.parameters["destination-folder"] = dest;
- trans.parameters["assoc-type"] = "{http://www.alfresco.org/model/content/1.0}contains";
- trans.parameters["assoc-name"] = String("{http://www.alfresco.org/model/content/1.0}" + bpm_package.children[0].properties["cm:name"]);
- trans.parameters["mime-type"] = "application/pdf";
- trans.execute(bpm_package.children[0]);
- /* update properties */
- transdoc = dest.childByNamePath(docname + ".pdf");
- if(transdoc != null)
- {
- if(bumpver == true)
- {
- workingCopy = transdoc.checkout();
- workingCopy.checkin("Initial version.", true);
- }
- workingCopy = transdoc.checkout();
- workingCopy.properties["ks:status"] = "Approved";
- workingCopy.properties["ks:reviewComment"] = kswf_comment;
- workingCopy.save();
- workingCopy.checkin("Document approved by " + bpm_assignee.properties["cm:userName"], true);
- }
- }
- var email = actions.create("mail");
- email.parameters.subject = "Alfresco Task Update: Approved";
- email.parameters.to = initiator.properties["cm:email"];
- email.parameters.from = "alfresco@kses.net";
- email.parameters.text = "The following documents were approved by \"" + bpm_assignee.properties["cm:userName"] + "\":\n\n" + docList;
- email.parameters.text += "\nComments:\n" + kswf_comment;
- email.execute(bpm_package);]]></activiti:string>
- </activiti:field>
- </activiti:taskListener>
- </extensionElements>
- </userTask>
- <sequenceFlow id="flow2" sourceRef="reviewTask" targetRef="reviewDecision"></sequenceFlow>
- <exclusiveGateway id="reviewDecision" name="Review Decision"></exclusiveGateway>
- <sequenceFlow id="flow3" sourceRef="reviewDecision" targetRef="approved">
- <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Approve'}]]></conditionExpression>
- </sequenceFlow>
- <sequenceFlow id="flow4" sourceRef="reviewDecision" targetRef="rejected"></sequenceFlow>
- <userTask id="approved" name="Document Approved" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:approvedTask">
- <documentation>The document was reviewed and approved.</documentation>
- <extensionElements>
- <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
- <activiti:field name="script">
- <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
- if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
- </activiti:field>
- </activiti:taskListener>
- </extensionElements>
- </userTask>
- <userTask id="rejected" name="Document Rejected" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:rejectedTask">
- <documentation>The document was reviewed and rejected.</documentation>
- <extensionElements>
- <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
- <activiti:field name="script">
- <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
- if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
- </activiti:field>
- </activiti:taskListener>
- </extensionElements>
- </userTask>
- <sequenceFlow id="flow5" sourceRef="approved" targetRef="end"></sequenceFlow>
- <sequenceFlow id="flow6" sourceRef="rejected" targetRef="end"></sequenceFlow>
- <endEvent id="end"></endEvent>
- </process>
- <bpmndi:BPMNDiagram id="BPMNDiagram_ksesWorkflow">
- <bpmndi:BPMNPlane bpmnElement="ksesWorkflow" id="BPMNPlane_ksesWorkflow">
- <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
- <omgdc:Bounds height="35.0" width="35.0" x="30.0" y="200.0"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="reviewTask" id="BPMNShape_reviewTask">
- <omgdc:Bounds height="55.0" width="105.0" x="105.0" y="190.0"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="reviewDecision" id="BPMNShape_reviewDecision">
- <omgdc:Bounds height="40.0" width="40.0" x="250.0" y="197.0"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="approved" id="BPMNShape_approved">
- <omgdc:Bounds height="55.0" width="105.0" x="330.0" y="137.0"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="rejected" id="BPMNShape_rejected">
- <omgdc:Bounds height="55.0" width="105.0" x="330.0" y="257.0"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
- <omgdc:Bounds height="35.0" width="35.0" x="620.0" y="147.0"></omgdc:Bounds>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
- <omgdi:waypoint x="65.0" y="217.0"></omgdi:waypoint>
- <omgdi:waypoint x="105.0" y="217.0"></omgdi:waypoint>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
- <omgdi:waypoint x="210.0" y="217.0"></omgdi:waypoint>
- <omgdi:waypoint x="250.0" y="217.0"></omgdi:waypoint>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
- <omgdi:waypoint x="270.0" y="197.0"></omgdi:waypoint>
- <omgdi:waypoint x="270.0" y="164.0"></omgdi:waypoint>
- <omgdi:waypoint x="330.0" y="164.0"></omgdi:waypoint>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
- <omgdi:waypoint x="270.0" y="237.0"></omgdi:waypoint>
- <omgdi:waypoint x="270.0" y="284.0"></omgdi:waypoint>
- <omgdi:waypoint x="330.0" y="284.0"></omgdi:waypoint>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
- <omgdi:waypoint x="435.0" y="164.0"></omgdi:waypoint>
- <omgdi:waypoint x="620.0" y="164.0"></omgdi:waypoint>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
- <omgdi:waypoint x="435.0" y="284.0"></omgdi:waypoint>
- <omgdi:waypoint x="637.0" y="284.0"></omgdi:waypoint>
- <omgdi:waypoint x="637.0" y="182.0"></omgdi:waypoint>
- </bpmndi:BPMNEdge>
- </bpmndi:BPMNPlane>
- </bpmndi:BPMNDiagram>
- </definitions>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement