1 <?xml version="1.0" encoding="UTF-8"?>
2 <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0co5an7" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
3 <bpmn:collaboration id="Collaboration">
4 <bpmn:participant id="Sentiment_Analysis" name="Sentiment Analysis" processRef="sentiment-analysis" />
6 <bpmn:process id="sentiment-analysis" name="Sentiment Analysis" isExecutable="true" camunda:versionTag="0.0.1">
7 <bpmn:laneSet id="LaneSet_1u08y0e" />
8 <bpmn:sequenceFlow id="SequenceFlow_14nqu0e" sourceRef="service-report" targetRef="IntermediateThrowEvent_0sns4tf" />
9 <bpmn:sequenceFlow id="SequenceFlow_0jebdb9" sourceRef="Task_1e7059p" targetRef="EndEvent_0bmuv13" />
10 <bpmn:sequenceFlow id="SequenceFlow_15dip2q" sourceRef="StartEvent_1t6nxib" targetRef="IntermediateThrowEvent_193oik9" />
11 <bpmn:sequenceFlow id="SequenceFlow_1j2y6tv" sourceRef="terms_loop" targetRef="service-report" />
12 <bpmn:sequenceFlow id="SequenceFlow_0o77usd" sourceRef="IntermediateThrowEvent_193oik9" targetRef="terms_loop" />
13 <bpmn:subProcess id="terms_loop">
14 <bpmn:extensionElements>
15 <camunda:executionListener event="start">
16 <camunda:script scriptFormat="javascript">// make variables local to loop
17 execution.setVariable("analysis", 0, "terms_loop");
18 execution.setVariable('tweets', S('[]'), "terms_loop");</camunda:script>
19 </camunda:executionListener>
20 <camunda:executionListener event="end">
21 <camunda:script scriptFormat="javascript">var results = execution.getVariable("results");
22 var term = execution.getVariable("term");
23 var analysis = execution.getVariable("analysis");
24 var termStr = term.prop('term').value();
26 // this is for dictionary
27 //results.prop(termStr, analysis);
30 item["name"] = termStr;
31 item["sentiment"] = S(analysis).prop("sentiment").value();
34 execution.setVariable("results", S(results))</camunda:script>
35 </camunda:executionListener>
36 </bpmn:extensionElements>
37 <bpmn:incoming>SequenceFlow_0o77usd</bpmn:incoming>
38 <bpmn:outgoing>SequenceFlow_1j2y6tv</bpmn:outgoing>
39 <bpmn:multiInstanceLoopCharacteristics camunda:collection="${terms.elements()}" camunda:elementVariable="term" />
40 <bpmn:serviceTask id="service-analysis" name="Analysis Service">
41 <bpmn:extensionElements>
44 <camunda:inputParameter name="url">http://analysis:8081/</camunda:inputParameter>
45 <camunda:inputParameter name="method">POST</camunda:inputParameter>
46 <camunda:inputParameter name="headers">
48 <camunda:entry key="Accept">application/json</camunda:entry>
49 <camunda:entry key="Content-Type">application/json</camunda:entry>
51 </camunda:inputParameter>
52 <camunda:inputParameter name="payload">${tweets.toString()}</camunda:inputParameter>
53 <camunda:outputParameter name="analysis">${response.trim()}</camunda:outputParameter>
54 </camunda:inputOutput>
55 <camunda:connectorId>http-connector</camunda:connectorId>
57 </bpmn:extensionElements>
58 <bpmn:incoming>SequenceFlow_0g6bfz6</bpmn:incoming>
59 <bpmn:outgoing>SequenceFlow_1bz7zx2</bpmn:outgoing>
61 <bpmn:serviceTask id="service-twitter" name="Twitter Service">
62 <bpmn:extensionElements>
65 <camunda:inputParameter name="url">
66 <camunda:script scriptFormat="Javascript">var term = execution.getVariable("term");
67 'http://twitter:8084/search/tweets.json?q='+encodeURI(term.prop('term').value())</camunda:script>
68 </camunda:inputParameter>
69 <camunda:inputParameter name="method">GET</camunda:inputParameter>
70 <camunda:inputParameter name="headers">
72 <camunda:entry key="Accept">application/json</camunda:entry>
74 </camunda:inputParameter>
75 <camunda:outputParameter name="tweets">
76 <camunda:script scriptFormat="Javascript">var response = connector.getVariable("response");
77 S(response);</camunda:script>
78 </camunda:outputParameter>
79 </camunda:inputOutput>
80 <camunda:connectorId>http-connector</camunda:connectorId>
82 </bpmn:extensionElements>
83 <bpmn:incoming>SequenceFlow_0f6v4j4</bpmn:incoming>
84 <bpmn:outgoing>SequenceFlow_0g6bfz6</bpmn:outgoing>
86 <bpmn:startEvent id="StartEvent_parsing_term">
87 <bpmn:outgoing>SequenceFlow_0f6v4j4</bpmn:outgoing>
89 <bpmn:sequenceFlow id="SequenceFlow_0f6v4j4" sourceRef="StartEvent_parsing_term" targetRef="service-twitter" />
90 <bpmn:sequenceFlow id="SequenceFlow_0g6bfz6" sourceRef="service-twitter" targetRef="service-analysis" />
91 <bpmn:sequenceFlow id="SequenceFlow_1bz7zx2" sourceRef="service-analysis" targetRef="EndEvent_parsing_term" />
92 <bpmn:endEvent id="EndEvent_parsing_term">
93 <bpmn:incoming>SequenceFlow_1bz7zx2</bpmn:incoming>
94 <bpmn:incoming>SequenceFlow_0d4q1qg</bpmn:incoming>
96 <bpmn:boundaryEvent id="BoundaryEvent_0qgiers" attachedToRef="service-analysis">
97 <bpmn:outgoing>SequenceFlow_0a608kq</bpmn:outgoing>
98 <bpmn:errorEventDefinition />
100 <bpmn:serviceTask id="ServiceTask_0y5nlkj" name="Analysis Service">
101 <bpmn:extensionElements>
103 <camunda:inputOutput>
104 <camunda:inputParameter name="url">http://analysis:8081/offline_analysis/</camunda:inputParameter>
105 <camunda:inputParameter name="method">POST</camunda:inputParameter>
106 <camunda:inputParameter name="headers">
108 <camunda:entry key="Accept">application/json</camunda:entry>
109 <camunda:entry key="Content-Type">application/json</camunda:entry>
111 </camunda:inputParameter>
112 <camunda:inputParameter name="payload">${tweets.toString()}</camunda:inputParameter>
113 <camunda:outputParameter name="analysis">${response.trim()}</camunda:outputParameter>
114 </camunda:inputOutput>
115 <camunda:connectorId>http-connector</camunda:connectorId>
117 </bpmn:extensionElements>
118 <bpmn:incoming>SequenceFlow_0a608kq</bpmn:incoming>
119 <bpmn:outgoing>SequenceFlow_0d4q1qg</bpmn:outgoing>
121 <bpmn:sequenceFlow id="SequenceFlow_0a608kq" sourceRef="BoundaryEvent_0qgiers" targetRef="ServiceTask_0y5nlkj" />
122 <bpmn:sequenceFlow id="SequenceFlow_0d4q1qg" sourceRef="ServiceTask_0y5nlkj" targetRef="EndEvent_parsing_term" />
124 <bpmn:sequenceFlow id="SequenceFlow_1mnqqvo" sourceRef="IntermediateThrowEvent_0sns4tf" targetRef="Task_1e7059p" />
125 <bpmn:sequenceFlow id="SequenceFlow_0pjn3f9" sourceRef="BoundaryEvent_0vcqy0m" targetRef="IntermediateThrowEvent_193oik9" />
126 <bpmn:boundaryEvent id="BoundaryEvent_0vcqy0m" attachedToRef="terms_loop">
127 <bpmn:outgoing>SequenceFlow_0pjn3f9</bpmn:outgoing>
128 <bpmn:errorEventDefinition />
129 </bpmn:boundaryEvent>
130 <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_193oik9">
131 <bpmn:incoming>SequenceFlow_15dip2q</bpmn:incoming>
132 <bpmn:incoming>SequenceFlow_0pjn3f9</bpmn:incoming>
133 <bpmn:outgoing>SequenceFlow_0o77usd</bpmn:outgoing>
134 <bpmn:timerEventDefinition>
135 <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT0S</bpmn:timeDuration>
136 </bpmn:timerEventDefinition>
137 </bpmn:intermediateCatchEvent>
138 <bpmn:startEvent id="StartEvent_1t6nxib" camunda:formKey="embedded:deployment:input-terms.html">
139 <bpmn:extensionElements>
140 <camunda:executionListener event="start">
141 <camunda:script scriptFormat="javascript">// make variable global
142 execution.setVariable("results", S('[]'))</camunda:script>
143 </camunda:executionListener>
144 </bpmn:extensionElements>
145 <bpmn:outgoing>SequenceFlow_15dip2q</bpmn:outgoing>
147 <bpmn:serviceTask id="service-report" name="Report Service">
148 <bpmn:extensionElements>
150 <camunda:inputOutput>
151 <camunda:inputParameter name="url">http://reporting:8083/generatePDF/</camunda:inputParameter>
152 <camunda:inputParameter name="method">POST</camunda:inputParameter>
153 <camunda:inputParameter name="headers">
155 <camunda:entry key="Accept">application/base64</camunda:entry>
156 <camunda:entry key="Content-Type">application/json</camunda:entry>
158 </camunda:inputParameter>
159 <camunda:inputParameter name="payload">${results.toString()}</camunda:inputParameter>
160 <camunda:outputParameter name="reportPDF">
161 <camunda:script scriptFormat="javascript">var response = connector.getVariable("response");
162 // from nodejs base64 package
165 var javaByteArray = Java.type('byte[]')
167 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
168 for (var i = 0, len = code.length; i < len; ++i) {
170 revLookup[code.charCodeAt(i)] = i
173 // Support decoding URL-safe base64 strings, as Node.js does.
174 // See: https://en.wikipedia.org/wiki/Base64#URL_applications
175 revLookup['-'.charCodeAt(0)] = 62
176 revLookup['_'.charCodeAt(0)] = 63
178 function getLens (b64) {
181 if (len % 4 > 0) {
182 throw new Error('Invalid string. Length must be a multiple of 4: '+b64)
185 // Trim off extra bytes after placeholder bytes are found
186 // See: https://github.com/beatgammit/base64-js/issues/42
187 var validLen = b64.indexOf('=')
188 if (validLen === -1) validLen = len
190 var placeHoldersLen = validLen === len
194 return [validLen, placeHoldersLen]
197 function _byteLength (b64, validLen, placeHoldersLen) {
198 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
201 function toByteArray (b64) {
203 var lens = getLens(b64)
204 var validLen = lens[0]
205 var placeHoldersLen = lens[1]
207 var arr = new javaByteArray(_byteLength(b64, validLen, placeHoldersLen))
211 // if there are placeholders, only get up to the last complete 4 chars
212 var len = placeHoldersLen > 0
216 for (var i = 0; i < len; i += 4) {
218 (revLookup[b64.charCodeAt(i)] << 18) |
219 (revLookup[b64.charCodeAt(i + 1)] << 12) |
220 (revLookup[b64.charCodeAt(i + 2)] << 6) |
221 revLookup[b64.charCodeAt(i + 3)]
222 arr[curByte++] = (tmp >> 16) & 0xFF
223 arr[curByte++] = (tmp >> 8) & 0xFF
224 arr[curByte++] = tmp & 0xFF
227 if (placeHoldersLen === 2) {
229 (revLookup[b64.charCodeAt(i)] << 2) |
230 (revLookup[b64.charCodeAt(i + 1)] >> 4)
231 arr[curByte++] = tmp & 0xFF
234 if (placeHoldersLen === 1) {
236 (revLookup[b64.charCodeAt(i)] << 10) |
237 (revLookup[b64.charCodeAt(i + 1)] << 4) |
238 (revLookup[b64.charCodeAt(i + 2)] >> 2)
239 arr[curByte++] = (tmp >> 8) & 0xFF
240 arr[curByte++] = tmp & 0xFF
246 var source = "kP/+kA==";
247 var decoded = toByteArray(source);
249 var file = Java.type('org.camunda.bpm.engine.variable.Variables').fileValue("pdfTest").file(toByteArray(response)).mimeType('application/pdf').create()
250 file</camunda:script>
251 </camunda:outputParameter>
252 </camunda:inputOutput>
253 <camunda:connectorId>http-connector</camunda:connectorId>
255 </bpmn:extensionElements>
256 <bpmn:incoming>SequenceFlow_1j2y6tv</bpmn:incoming>
257 <bpmn:outgoing>SequenceFlow_14nqu0e</bpmn:outgoing>
259 <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0sns4tf">
260 <bpmn:incoming>SequenceFlow_14nqu0e</bpmn:incoming>
261 <bpmn:outgoing>SequenceFlow_1mnqqvo</bpmn:outgoing>
262 <bpmn:timerEventDefinition>
263 <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT0S</bpmn:timeDuration>
264 </bpmn:timerEventDefinition>
265 </bpmn:intermediateCatchEvent>
266 <bpmn:userTask id="Task_1e7059p" name="download pdf" camunda:formKey="embedded:deployment:download-pdf.html">
267 <bpmn:incoming>SequenceFlow_1mnqqvo</bpmn:incoming>
268 <bpmn:outgoing>SequenceFlow_0jebdb9</bpmn:outgoing>
270 <bpmn:endEvent id="EndEvent_0bmuv13">
271 <bpmn:incoming>SequenceFlow_0jebdb9</bpmn:incoming>
274 <bpmndi:BPMNDiagram id="BPMNDiagram_1">
275 <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
276 <bpmndi:BPMNShape id="Participant_0gzc3m9_di" bpmnElement="Sentiment_Analysis">
277 <dc:Bounds x="0" y="0" width="1087" height="369" />
279 <bpmndi:BPMNShape id="SubProcess_1skl2rb_di" bpmnElement="terms_loop" isExpanded="true">
280 <dc:Bounds x="188" y="19" width="440" height="297" />
282 <bpmndi:BPMNShape id="ServiceTask_01bq7a6_di" bpmnElement="service-analysis">
283 <dc:Bounds x="434" y="60" width="100" height="80" />
285 <bpmndi:BPMNShape id="ServiceTask_1o2usc9_di" bpmnElement="service-twitter">
286 <dc:Bounds x="283" y="60" width="100" height="80" />
288 <bpmndi:BPMNShape id="StartEvent_1nx6b6f_di" bpmnElement="StartEvent_parsing_term">
289 <dc:Bounds x="209" y="82" width="36" height="36" />
291 <bpmndi:BPMNEdge id="SequenceFlow_0f6v4j4_di" bpmnElement="SequenceFlow_0f6v4j4">
292 <di:waypoint x="245" y="100" />
293 <di:waypoint x="283" y="100" />
295 <bpmndi:BPMNEdge id="SequenceFlow_0g6bfz6_di" bpmnElement="SequenceFlow_0g6bfz6">
296 <di:waypoint x="383" y="100" />
297 <di:waypoint x="434" y="100" />
299 <bpmndi:BPMNEdge id="SequenceFlow_1bz7zx2_di" bpmnElement="SequenceFlow_1bz7zx2">
300 <di:waypoint x="534" y="100" />
301 <di:waypoint x="569" y="100" />
303 <bpmndi:BPMNShape id="StartEvent_1t6nxib_di" bpmnElement="StartEvent_1t6nxib">
304 <dc:Bounds x="54" y="151" width="36" height="36" />
306 <bpmndi:BPMNShape id="ServiceTask_1gaqtzh_di" bpmnElement="service-report">
307 <dc:Bounds x="664" y="129" width="100" height="80" />
309 <bpmndi:BPMNShape id="UserTask_0iooc2g_di" bpmnElement="Task_1e7059p">
310 <dc:Bounds x="882" y="129" width="100" height="80" />
312 <bpmndi:BPMNShape id="EndEvent_0bmuv13_di" bpmnElement="EndEvent_0bmuv13">
313 <dc:Bounds x="1021" y="151" width="36" height="36" />
315 <bpmndi:BPMNEdge id="SequenceFlow_14nqu0e_di" bpmnElement="SequenceFlow_14nqu0e">
316 <di:waypoint x="764" y="169" />
317 <di:waypoint x="804" y="169" />
319 <bpmndi:BPMNEdge id="SequenceFlow_0jebdb9_di" bpmnElement="SequenceFlow_0jebdb9">
320 <di:waypoint x="982" y="169" />
321 <di:waypoint x="1021" y="169" />
323 <bpmndi:BPMNEdge id="SequenceFlow_15dip2q_di" bpmnElement="SequenceFlow_15dip2q">
324 <di:waypoint x="90" y="169" />
325 <di:waypoint x="122" y="169" />
327 <bpmndi:BPMNEdge id="SequenceFlow_1j2y6tv_di" bpmnElement="SequenceFlow_1j2y6tv">
328 <di:waypoint x="628" y="169" />
329 <di:waypoint x="664" y="169" />
331 <bpmndi:BPMNShape id="EndEvent_07g109m_di" bpmnElement="EndEvent_parsing_term">
332 <dc:Bounds x="569" y="82" width="36" height="36" />
334 <bpmndi:BPMNEdge id="SequenceFlow_0o77usd_di" bpmnElement="SequenceFlow_0o77usd">
335 <di:waypoint x="158" y="169" />
336 <di:waypoint x="188" y="169" />
338 <bpmndi:BPMNShape id="IntermediateCatchEvent_1248i6u_di" bpmnElement="IntermediateThrowEvent_193oik9">
339 <dc:Bounds x="122" y="151" width="36" height="36" />
341 <bpmndi:BPMNEdge id="SequenceFlow_1mnqqvo_di" bpmnElement="SequenceFlow_1mnqqvo">
342 <di:waypoint x="840" y="169" />
343 <di:waypoint x="882" y="169" />
345 <bpmndi:BPMNShape id="IntermediateCatchEvent_065fcij_di" bpmnElement="IntermediateThrowEvent_0sns4tf">
346 <dc:Bounds x="804" y="151" width="36" height="36" />
348 <bpmndi:BPMNShape id="BoundaryEvent_1yw4jbm_di" bpmnElement="BoundaryEvent_0vcqy0m">
349 <dc:Bounds x="566" y="298" width="36" height="36" />
351 <bpmndi:BPMNEdge id="SequenceFlow_0pjn3f9_di" bpmnElement="SequenceFlow_0pjn3f9">
352 <di:waypoint x="584" y="334" />
353 <di:waypoint x="584" y="354" />
354 <di:waypoint x="140" y="354" />
355 <di:waypoint x="140" y="187" />
357 <bpmndi:BPMNShape id="BoundaryEvent_1gxbbqe_di" bpmnElement="BoundaryEvent_0qgiers">
358 <dc:Bounds x="466" y="122" width="36" height="36" />
360 <bpmndi:BPMNShape id="ServiceTask_0y5nlkj_di" bpmnElement="ServiceTask_0y5nlkj">
361 <dc:Bounds x="434" y="202" width="100" height="80" />
363 <bpmndi:BPMNEdge id="SequenceFlow_0a608kq_di" bpmnElement="SequenceFlow_0a608kq">
364 <di:waypoint x="484" y="158" />
365 <di:waypoint x="484" y="202" />
367 <bpmndi:BPMNEdge id="SequenceFlow_0d4q1qg_di" bpmnElement="SequenceFlow_0d4q1qg">
368 <di:waypoint x="534" y="242" />
369 <di:waypoint x="552" y="242" />
370 <di:waypoint x="552" y="100" />
371 <di:waypoint x="569" y="100" />
374 </bpmndi:BPMNDiagram>