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:startEvent id="StartEvent_1t6nxib" camunda:formKey="embedded:deployment:input-terms.html">
13 <bpmn:extensionElements>
14 <camunda:executionListener event="start">
15 <camunda:script scriptFormat="javascript">// make variable global
16 execution.setVariable("results", S('[]'))</camunda:script>
17 </camunda:executionListener>
18 </bpmn:extensionElements>
19 <bpmn:outgoing>SequenceFlow_15dip2q</bpmn:outgoing>
21 <bpmn:endEvent id="EndEvent_0bmuv13">
22 <bpmn:incoming>SequenceFlow_0jebdb9</bpmn:incoming>
24 <bpmn:sequenceFlow id="SequenceFlow_0o77usd" sourceRef="IntermediateThrowEvent_193oik9" targetRef="terms_loop" />
25 <bpmn:userTask id="Task_1e7059p" name="download pdf" camunda:formKey="embedded:deployment:download-pdf.html">
26 <bpmn:incoming>SequenceFlow_1mnqqvo</bpmn:incoming>
27 <bpmn:outgoing>SequenceFlow_0jebdb9</bpmn:outgoing>
29 <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_193oik9">
30 <bpmn:incoming>SequenceFlow_15dip2q</bpmn:incoming>
31 <bpmn:incoming>SequenceFlow_1mphutj</bpmn:incoming>
32 <bpmn:outgoing>SequenceFlow_0o77usd</bpmn:outgoing>
33 <bpmn:timerEventDefinition>
34 <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT0S</bpmn:timeDuration>
35 </bpmn:timerEventDefinition>
36 </bpmn:intermediateCatchEvent>
37 <bpmn:subProcess id="terms_loop">
38 <bpmn:extensionElements>
39 <camunda:executionListener event="start">
40 <camunda:script scriptFormat="javascript">// make variables local to loop
41 execution.setVariable("analysis", 0, "terms_loop");
42 execution.setVariable('tweets', S('[]'), "terms_loop");</camunda:script>
43 </camunda:executionListener>
44 <camunda:executionListener event="end">
45 <camunda:script scriptFormat="javascript">var results = execution.getVariable("results");
46 var term = execution.getVariable("term");
47 var analysis = execution.getVariable("analysis");
48 var termStr = term.prop('term').value();
50 // this is for dictionary
51 //results.prop(termStr, analysis);
54 item["name"] = termStr;
55 item["sentiment"] = S(analysis).prop("sentiment").value();
58 execution.setVariable("results", S(results))</camunda:script>
59 </camunda:executionListener>
60 </bpmn:extensionElements>
61 <bpmn:incoming>SequenceFlow_0o77usd</bpmn:incoming>
62 <bpmn:outgoing>SequenceFlow_1j2y6tv</bpmn:outgoing>
63 <bpmn:multiInstanceLoopCharacteristics camunda:collection="${terms.elements()}" camunda:elementVariable="term" />
64 <bpmn:serviceTask id="service-analysis" name="Analysis Service">
65 <bpmn:extensionElements>
68 <camunda:inputParameter name="url">http://analysis:8081/</camunda:inputParameter>
69 <camunda:inputParameter name="method">POST</camunda:inputParameter>
70 <camunda:inputParameter name="headers">
72 <camunda:entry key="Accept">application/json</camunda:entry>
73 <camunda:entry key="Content-Type">application/json</camunda:entry>
75 </camunda:inputParameter>
76 <camunda:inputParameter name="payload">${tweets.toString()}</camunda:inputParameter>
77 <camunda:outputParameter name="analysis">${response.trim()}</camunda:outputParameter>
78 </camunda:inputOutput>
79 <camunda:connectorId>http-connector</camunda:connectorId>
81 </bpmn:extensionElements>
82 <bpmn:incoming>SequenceFlow_0g6bfz6</bpmn:incoming>
83 <bpmn:outgoing>SequenceFlow_1bz7zx2</bpmn:outgoing>
85 <bpmn:serviceTask id="service-twitter" name="Twitter Service">
86 <bpmn:extensionElements>
89 <camunda:inputParameter name="url">
90 <camunda:script scriptFormat="Javascript">var term = execution.getVariable("term");
91 'http://twitter:8084/search/tweets.json?q='+encodeURI(term.prop('term').value())</camunda:script>
92 </camunda:inputParameter>
93 <camunda:inputParameter name="method">GET</camunda:inputParameter>
94 <camunda:inputParameter name="headers">
96 <camunda:entry key="Accept">application/json</camunda:entry>
98 </camunda:inputParameter>
99 <camunda:outputParameter name="tweets">
100 <camunda:script scriptFormat="Javascript">var response = connector.getVariable("response");
101 S(response);</camunda:script>
102 </camunda:outputParameter>
103 </camunda:inputOutput>
104 <camunda:connectorId>http-connector</camunda:connectorId>
106 </bpmn:extensionElements>
107 <bpmn:incoming>SequenceFlow_0f6v4j4</bpmn:incoming>
108 <bpmn:outgoing>SequenceFlow_0g6bfz6</bpmn:outgoing>
110 <bpmn:startEvent id="StartEvent_parsing_term">
111 <bpmn:outgoing>SequenceFlow_0f6v4j4</bpmn:outgoing>
113 <bpmn:sequenceFlow id="SequenceFlow_0f6v4j4" sourceRef="StartEvent_parsing_term" targetRef="service-twitter" />
114 <bpmn:sequenceFlow id="SequenceFlow_0g6bfz6" sourceRef="service-twitter" targetRef="service-analysis" />
115 <bpmn:sequenceFlow id="SequenceFlow_1bz7zx2" sourceRef="service-analysis" targetRef="EndEvent_parsing_term" />
116 <bpmn:endEvent id="EndEvent_parsing_term">
117 <bpmn:incoming>SequenceFlow_1bz7zx2</bpmn:incoming>
120 <bpmn:serviceTask id="service-report" name="Report Service">
121 <bpmn:extensionElements>
123 <camunda:inputOutput>
124 <camunda:inputParameter name="url">http://reporting:8083/generatePDF/</camunda:inputParameter>
125 <camunda:inputParameter name="method">POST</camunda:inputParameter>
126 <camunda:inputParameter name="headers">
128 <camunda:entry key="Accept">application/base64</camunda:entry>
129 <camunda:entry key="Content-Type">application/json</camunda:entry>
131 </camunda:inputParameter>
132 <camunda:inputParameter name="payload">${results.toString()}</camunda:inputParameter>
133 <camunda:outputParameter name="reportPDF">
134 <camunda:script scriptFormat="javascript">var response = connector.getVariable("response");
135 // from nodejs base64 package
138 var javaByteArray = Java.type('byte[]')
140 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
141 for (var i = 0, len = code.length; i < len; ++i) {
143 revLookup[code.charCodeAt(i)] = i
146 // Support decoding URL-safe base64 strings, as Node.js does.
147 // See: https://en.wikipedia.org/wiki/Base64#URL_applications
148 revLookup['-'.charCodeAt(0)] = 62
149 revLookup['_'.charCodeAt(0)] = 63
151 function getLens (b64) {
154 if (len % 4 > 0) {
155 throw new Error('Invalid string. Length must be a multiple of 4: '+b64)
158 // Trim off extra bytes after placeholder bytes are found
159 // See: https://github.com/beatgammit/base64-js/issues/42
160 var validLen = b64.indexOf('=')
161 if (validLen === -1) validLen = len
163 var placeHoldersLen = validLen === len
167 return [validLen, placeHoldersLen]
170 function _byteLength (b64, validLen, placeHoldersLen) {
171 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
174 function toByteArray (b64) {
176 var lens = getLens(b64)
177 var validLen = lens[0]
178 var placeHoldersLen = lens[1]
180 var arr = new javaByteArray(_byteLength(b64, validLen, placeHoldersLen))
184 // if there are placeholders, only get up to the last complete 4 chars
185 var len = placeHoldersLen > 0
189 for (var i = 0; i < len; i += 4) {
191 (revLookup[b64.charCodeAt(i)] << 18) |
192 (revLookup[b64.charCodeAt(i + 1)] << 12) |
193 (revLookup[b64.charCodeAt(i + 2)] << 6) |
194 revLookup[b64.charCodeAt(i + 3)]
195 arr[curByte++] = (tmp >> 16) & 0xFF
196 arr[curByte++] = (tmp >> 8) & 0xFF
197 arr[curByte++] = tmp & 0xFF
200 if (placeHoldersLen === 2) {
202 (revLookup[b64.charCodeAt(i)] << 2) |
203 (revLookup[b64.charCodeAt(i + 1)] >> 4)
204 arr[curByte++] = tmp & 0xFF
207 if (placeHoldersLen === 1) {
209 (revLookup[b64.charCodeAt(i)] << 10) |
210 (revLookup[b64.charCodeAt(i + 1)] << 4) |
211 (revLookup[b64.charCodeAt(i + 2)] >> 2)
212 arr[curByte++] = (tmp >> 8) & 0xFF
213 arr[curByte++] = tmp & 0xFF
219 var source = "kP/+kA==";
220 var decoded = toByteArray(source);
222 var file = Java.type('org.camunda.bpm.engine.variable.Variables').fileValue("pdfTest").file(toByteArray(response)).mimeType('application/pdf').create()
223 file</camunda:script>
224 </camunda:outputParameter>
225 </camunda:inputOutput>
226 <camunda:connectorId>http-connector</camunda:connectorId>
228 </bpmn:extensionElements>
229 <bpmn:incoming>SequenceFlow_1j2y6tv</bpmn:incoming>
230 <bpmn:outgoing>SequenceFlow_14nqu0e</bpmn:outgoing>
232 <bpmn:sequenceFlow id="SequenceFlow_1mnqqvo" sourceRef="IntermediateThrowEvent_0sns4tf" targetRef="Task_1e7059p" />
233 <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0sns4tf">
234 <bpmn:incoming>SequenceFlow_14nqu0e</bpmn:incoming>
235 <bpmn:outgoing>SequenceFlow_1mnqqvo</bpmn:outgoing>
236 <bpmn:timerEventDefinition>
237 <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT0S</bpmn:timeDuration>
238 </bpmn:timerEventDefinition>
239 </bpmn:intermediateCatchEvent>
240 <bpmn:boundaryEvent id="BoundaryEvent_0vcqy0m" attachedToRef="terms_loop">
241 <bpmn:outgoing>SequenceFlow_1mphutj</bpmn:outgoing>
242 <bpmn:errorEventDefinition />
243 </bpmn:boundaryEvent>
244 <bpmn:sequenceFlow id="SequenceFlow_1mphutj" sourceRef="BoundaryEvent_0vcqy0m" targetRef="IntermediateThrowEvent_193oik9" />
246 <bpmndi:BPMNDiagram id="BPMNDiagram_1">
247 <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
248 <bpmndi:BPMNShape id="Participant_0gzc3m9_di" bpmnElement="Sentiment_Analysis">
249 <dc:Bounds x="0" y="0" width="1084" height="245" />
251 <bpmndi:BPMNShape id="SubProcess_1skl2rb_di" bpmnElement="terms_loop" isExpanded="true">
252 <dc:Bounds x="188" y="19" width="443" height="163" />
254 <bpmndi:BPMNShape id="ServiceTask_01bq7a6_di" bpmnElement="service-analysis">
255 <dc:Bounds x="434" y="60" width="100" height="80" />
257 <bpmndi:BPMNShape id="ServiceTask_1o2usc9_di" bpmnElement="service-twitter">
258 <dc:Bounds x="283" y="60" width="100" height="80" />
260 <bpmndi:BPMNShape id="StartEvent_1nx6b6f_di" bpmnElement="StartEvent_parsing_term">
261 <dc:Bounds x="209" y="82" width="36" height="36" />
263 <bpmndi:BPMNEdge id="SequenceFlow_0f6v4j4_di" bpmnElement="SequenceFlow_0f6v4j4">
264 <di:waypoint x="245" y="100" />
265 <di:waypoint x="283" y="100" />
267 <bpmndi:BPMNEdge id="SequenceFlow_0g6bfz6_di" bpmnElement="SequenceFlow_0g6bfz6">
268 <di:waypoint x="383" y="100" />
269 <di:waypoint x="434" y="100" />
271 <bpmndi:BPMNEdge id="SequenceFlow_1bz7zx2_di" bpmnElement="SequenceFlow_1bz7zx2">
272 <di:waypoint x="534" y="100" />
273 <di:waypoint x="569" y="100" />
275 <bpmndi:BPMNShape id="StartEvent_1t6nxib_di" bpmnElement="StartEvent_1t6nxib">
276 <dc:Bounds x="56" y="83" width="36" height="36" />
278 <bpmndi:BPMNShape id="ServiceTask_1gaqtzh_di" bpmnElement="service-report">
279 <dc:Bounds x="664" y="61" width="100" height="80" />
281 <bpmndi:BPMNShape id="UserTask_0iooc2g_di" bpmnElement="Task_1e7059p">
282 <dc:Bounds x="889" y="61" width="100" height="80" />
284 <bpmndi:BPMNShape id="EndEvent_0bmuv13_di" bpmnElement="EndEvent_0bmuv13">
285 <dc:Bounds x="1024" y="83" width="36" height="36" />
287 <bpmndi:BPMNEdge id="SequenceFlow_14nqu0e_di" bpmnElement="SequenceFlow_14nqu0e">
288 <di:waypoint x="764" y="101" />
289 <di:waypoint x="803" y="101" />
291 <bpmndi:BPMNEdge id="SequenceFlow_0jebdb9_di" bpmnElement="SequenceFlow_0jebdb9">
292 <di:waypoint x="989" y="101" />
293 <di:waypoint x="1024" y="101" />
295 <bpmndi:BPMNEdge id="SequenceFlow_15dip2q_di" bpmnElement="SequenceFlow_15dip2q">
296 <di:waypoint x="92" y="101" />
297 <di:waypoint x="122" y="101" />
299 <bpmndi:BPMNEdge id="SequenceFlow_1j2y6tv_di" bpmnElement="SequenceFlow_1j2y6tv">
300 <di:waypoint x="631" y="101" />
301 <di:waypoint x="664" y="101" />
303 <bpmndi:BPMNShape id="EndEvent_07g109m_di" bpmnElement="EndEvent_parsing_term">
304 <dc:Bounds x="569" y="82" width="36" height="36" />
306 <bpmndi:BPMNEdge id="SequenceFlow_0o77usd_di" bpmnElement="SequenceFlow_0o77usd">
307 <di:waypoint x="158" y="101" />
308 <di:waypoint x="188" y="101" />
310 <bpmndi:BPMNShape id="IntermediateCatchEvent_1248i6u_di" bpmnElement="IntermediateThrowEvent_193oik9">
311 <dc:Bounds x="122" y="83" width="36" height="36" />
313 <bpmndi:BPMNEdge id="SequenceFlow_1mnqqvo_di" bpmnElement="SequenceFlow_1mnqqvo">
314 <di:waypoint x="839" y="101" />
315 <di:waypoint x="889" y="101" />
317 <bpmndi:BPMNShape id="IntermediateCatchEvent_065fcij_di" bpmnElement="IntermediateThrowEvent_0sns4tf">
318 <dc:Bounds x="803" y="83" width="36" height="36" />
320 <bpmndi:BPMNShape id="BoundaryEvent_1yw4jbm_di" bpmnElement="BoundaryEvent_0vcqy0m">
321 <dc:Bounds x="569" y="164" width="36" height="36" />
323 <bpmndi:BPMNEdge id="SequenceFlow_1mphutj_di" bpmnElement="SequenceFlow_1mphutj">
324 <di:waypoint x="587" y="200" />
325 <di:waypoint x="587" y="220" />
326 <di:waypoint x="140" y="220" />
327 <di:waypoint x="140" y="119" />
330 </bpmndi:BPMNDiagram>