Advertisement
Guest User

workflow

a guest
Nov 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.83 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <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">
  3. <process id="ksesWorkflow" name="Keystone Document Review" isExecutable="true">
  4. <startEvent id="start" activiti:formKey="wf:submitReviewTask"></startEvent>
  5. <sequenceFlow id="flow1" sourceRef="start" targetRef="reviewTask"></sequenceFlow>
  6. <userTask id="reviewTask" name="Review Task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:activitiReviewTask">
  7. <extensionElements>
  8. <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
  9. <activiti:field name="script">
  10. <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
  11. if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
  12. </activiti:field>
  13. </activiti:taskListener>
  14. <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
  15. <activiti:field name="script">
  16. <activiti:string><![CDATA[execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
  17. <variable name="kswf_comment" access="read,write" />
  18. <variable name="bpm_package" access="read" />
  19. <variable name="bpm_assignee" access="read" />
  20. <variable name="initiator" access="read" />
  21.  
  22. var docList = "\t";
  23. for (var i = 0; i &lt; bpm_package.children.length; i++)
  24. {
  25. docList += bpm_package.children[i].displayPath + "/" + bpm_package.children[i].properties["cm:name"] + "\n\t";
  26.  
  27. bpm_package.children[i].properties["ks:status"] = "Approved";
  28. bpm_package.children[i].properties["ks:reviewComment"] = kswf_comment;
  29. bpm_package.children[i].save();
  30.  
  31. var workingCopy = bpm_package.children[i].checkout();
  32. workingCopy.checkin("Document approved by " + bpm_assignee.properties["cm:userName"], true);
  33.  
  34. /* get name without extension */
  35. var cmname = bpm_package.children[i].properties["cm:name"];
  36. var idx = cmname.length - 1;
  37. if(cmname.lastIndexOf(".") > 0)
  38. {
  39. idx = cmname.lastIndexOf(".");
  40. }
  41. var docname = cmname.substr(0, idx);
  42.  
  43. /* find space where released documents live */
  44. var drafts = bpm_package.children[i].parent;
  45. var docroot = drafts.parent;
  46. var dest = docroot.childByNamePath("Released");
  47. /* see if document was created previously. if not, do initial version bump */
  48. var transdoc = dest.childByNamePath(docname + ".pdf");
  49. var bumpver = false; /* transform to pdf */
  50. if(transdoc == null) var drafts = bpm_package.children[0].parent;
  51. { var docroot = drafts.parent;
  52. bumpver = true; var dest = docroot.childByNamePath("Released");
  53. }
  54.  
  55. var trans = actions.create("transform");
  56. trans.parameters["destination-folder"] = dest;
  57. trans.parameters["assoc-type"] = "{http://www.alfresco.org/model/content/1.0}contains";
  58. trans.parameters["assoc-name"] = String("{http://www.alfresco.org/model/content/1.0}" + bpm_package.children[0].properties["cm:name"]);
  59. trans.parameters["mime-type"] = "application/pdf";
  60. trans.execute(bpm_package.children[0]);
  61.  
  62. /* update properties */
  63. transdoc = dest.childByNamePath(docname + ".pdf");
  64. if(transdoc != null)
  65. {
  66. if(bumpver == true)
  67. {
  68. workingCopy = transdoc.checkout();
  69. workingCopy.checkin("Initial version.", true);
  70. }
  71. workingCopy = transdoc.checkout();
  72. workingCopy.properties["ks:status"] = "Approved";
  73. workingCopy.properties["ks:reviewComment"] = kswf_comment;
  74. workingCopy.save();
  75. workingCopy.checkin("Document approved by " + bpm_assignee.properties["cm:userName"], true);
  76. }
  77. }
  78. var email = actions.create("mail");
  79. email.parameters.subject = "Alfresco Task Update: Approved";
  80. email.parameters.to = initiator.properties["cm:email"];
  81. email.parameters.from = "alfresco@kses.net";
  82. email.parameters.text = "The following documents were approved by \"" + bpm_assignee.properties["cm:userName"] + "\":\n\n" + docList;
  83. email.parameters.text += "\nComments:\n" + kswf_comment;
  84. email.execute(bpm_package);]]></activiti:string>
  85. </activiti:field>
  86. </activiti:taskListener>
  87. </extensionElements>
  88. </userTask>
  89. <sequenceFlow id="flow2" sourceRef="reviewTask" targetRef="reviewDecision"></sequenceFlow>
  90. <exclusiveGateway id="reviewDecision" name="Review Decision"></exclusiveGateway>
  91. <sequenceFlow id="flow3" sourceRef="reviewDecision" targetRef="approved">
  92. <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Approve'}]]></conditionExpression>
  93. </sequenceFlow>
  94. <sequenceFlow id="flow4" sourceRef="reviewDecision" targetRef="rejected"></sequenceFlow>
  95. <userTask id="approved" name="Document Approved" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:approvedTask">
  96. <documentation>The document was reviewed and approved.</documentation>
  97. <extensionElements>
  98. <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
  99. <activiti:field name="script">
  100. <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
  101. if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
  102. </activiti:field>
  103. </activiti:taskListener>
  104. </extensionElements>
  105. </userTask>
  106. <userTask id="rejected" name="Document Rejected" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:rejectedTask">
  107. <documentation>The document was reviewed and rejected.</documentation>
  108. <extensionElements>
  109. <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
  110. <activiti:field name="script">
  111. <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
  112. if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
  113. </activiti:field>
  114. </activiti:taskListener>
  115. </extensionElements>
  116. </userTask>
  117. <sequenceFlow id="flow5" sourceRef="approved" targetRef="end"></sequenceFlow>
  118. <sequenceFlow id="flow6" sourceRef="rejected" targetRef="end"></sequenceFlow>
  119. <endEvent id="end"></endEvent>
  120. </process>
  121. <bpmndi:BPMNDiagram id="BPMNDiagram_ksesWorkflow">
  122. <bpmndi:BPMNPlane bpmnElement="ksesWorkflow" id="BPMNPlane_ksesWorkflow">
  123. <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
  124. <omgdc:Bounds height="35.0" width="35.0" x="30.0" y="200.0"></omgdc:Bounds>
  125. </bpmndi:BPMNShape>
  126. <bpmndi:BPMNShape bpmnElement="reviewTask" id="BPMNShape_reviewTask">
  127. <omgdc:Bounds height="55.0" width="105.0" x="105.0" y="190.0"></omgdc:Bounds>
  128. </bpmndi:BPMNShape>
  129. <bpmndi:BPMNShape bpmnElement="reviewDecision" id="BPMNShape_reviewDecision">
  130. <omgdc:Bounds height="40.0" width="40.0" x="250.0" y="197.0"></omgdc:Bounds>
  131. </bpmndi:BPMNShape>
  132. <bpmndi:BPMNShape bpmnElement="approved" id="BPMNShape_approved">
  133. <omgdc:Bounds height="55.0" width="105.0" x="330.0" y="137.0"></omgdc:Bounds>
  134. </bpmndi:BPMNShape>
  135. <bpmndi:BPMNShape bpmnElement="rejected" id="BPMNShape_rejected">
  136. <omgdc:Bounds height="55.0" width="105.0" x="330.0" y="257.0"></omgdc:Bounds>
  137. </bpmndi:BPMNShape>
  138. <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
  139. <omgdc:Bounds height="35.0" width="35.0" x="620.0" y="147.0"></omgdc:Bounds>
  140. </bpmndi:BPMNShape>
  141. <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
  142. <omgdi:waypoint x="65.0" y="217.0"></omgdi:waypoint>
  143. <omgdi:waypoint x="105.0" y="217.0"></omgdi:waypoint>
  144. </bpmndi:BPMNEdge>
  145. <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
  146. <omgdi:waypoint x="210.0" y="217.0"></omgdi:waypoint>
  147. <omgdi:waypoint x="250.0" y="217.0"></omgdi:waypoint>
  148. </bpmndi:BPMNEdge>
  149. <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
  150. <omgdi:waypoint x="270.0" y="197.0"></omgdi:waypoint>
  151. <omgdi:waypoint x="270.0" y="164.0"></omgdi:waypoint>
  152. <omgdi:waypoint x="330.0" y="164.0"></omgdi:waypoint>
  153. </bpmndi:BPMNEdge>
  154. <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
  155. <omgdi:waypoint x="270.0" y="237.0"></omgdi:waypoint>
  156. <omgdi:waypoint x="270.0" y="284.0"></omgdi:waypoint>
  157. <omgdi:waypoint x="330.0" y="284.0"></omgdi:waypoint>
  158. </bpmndi:BPMNEdge>
  159. <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
  160. <omgdi:waypoint x="435.0" y="164.0"></omgdi:waypoint>
  161. <omgdi:waypoint x="620.0" y="164.0"></omgdi:waypoint>
  162. </bpmndi:BPMNEdge>
  163. <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
  164. <omgdi:waypoint x="435.0" y="284.0"></omgdi:waypoint>
  165. <omgdi:waypoint x="637.0" y="284.0"></omgdi:waypoint>
  166. <omgdi:waypoint x="637.0" y="182.0"></omgdi:waypoint>
  167. </bpmndi:BPMNEdge>
  168. </bpmndi:BPMNPlane>
  169. </bpmndi:BPMNDiagram>
  170. </definitions>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement