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="Task_1e7059p" />
9 <bpmn:sequenceFlow id="SequenceFlow_0jebdb9" sourceRef="Task_1e7059p" targetRef="EndEvent_0bmuv13" />
10 <bpmn:sequenceFlow id="SequenceFlow_15dip2q" sourceRef="StartEvent_1t6nxib" targetRef="terms_loop" />
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:subProcess id="terms_loop">
22 <bpmn:extensionElements>
23 <camunda:executionListener event="start">
24 <camunda:script scriptFormat="javascript">// make variables local to loop
25 execution.setVariable("analysis", 0, "terms_loop");
26 execution.setVariable('tweets', S('[]'), "terms_loop");</camunda:script>
27 </camunda:executionListener>
28 <camunda:executionListener event="end">
29 <camunda:script scriptFormat="javascript">var results = execution.getVariable("results");
30 var term = execution.getVariable("term");
31 var analysis = execution.getVariable("analysis");
32 var termStr = term.prop('term').value();
34 // this is for dictionary
35 //results.prop(termStr, analysis);
38 item["name"] = termStr;
39 item["sentiment"] = analysis;
42 execution.setVariable("results", S(results))</camunda:script>
43 </camunda:executionListener>
44 </bpmn:extensionElements>
45 <bpmn:incoming>SequenceFlow_15dip2q</bpmn:incoming>
46 <bpmn:outgoing>SequenceFlow_1j2y6tv</bpmn:outgoing>
47 <bpmn:multiInstanceLoopCharacteristics camunda:collection="${terms.elements()}" camunda:elementVariable="term" />
48 <bpmn:serviceTask id="service-analysis" name="Analysis Service">
49 <bpmn:extensionElements>
52 <camunda:inputParameter name="url">http://analysis:8081/</camunda:inputParameter>
53 <camunda:inputParameter name="method">POST</camunda:inputParameter>
54 <camunda:inputParameter name="headers">
56 <camunda:entry key="Accept">application/json</camunda:entry>
57 <camunda:entry key="Content-Type">application/json</camunda:entry>
59 </camunda:inputParameter>
60 <camunda:inputParameter name="payload">${tweets.toString()}</camunda:inputParameter>
61 <camunda:outputParameter name="analysis">
62 <camunda:script scriptFormat="Javascript">var response = connector.getVariable("response");
63 response.trim()</camunda:script>
64 </camunda:outputParameter>
65 </camunda:inputOutput>
66 <camunda:connectorId>http-connector</camunda:connectorId>
68 </bpmn:extensionElements>
69 <bpmn:incoming>SequenceFlow_0g6bfz6</bpmn:incoming>
70 <bpmn:outgoing>SequenceFlow_1bz7zx2</bpmn:outgoing>
72 <bpmn:serviceTask id="service-twitter" name="Twitter Service">
73 <bpmn:extensionElements>
76 <camunda:inputParameter name="url">
77 <camunda:script scriptFormat="Javascript">var term = execution.getVariable("term");
78 'http://twitter:8084/search/tweets.json?q='+term.prop('term').value()</camunda:script>
79 </camunda:inputParameter>
80 <camunda:inputParameter name="method">GET</camunda:inputParameter>
81 <camunda:inputParameter name="headers">
83 <camunda:entry key="Accept">application/json</camunda:entry>
85 </camunda:inputParameter>
86 <camunda:outputParameter name="tweets">
87 <camunda:script scriptFormat="Javascript">var response = connector.getVariable("response");
88 S(response);</camunda:script>
89 </camunda:outputParameter>
90 </camunda:inputOutput>
91 <camunda:connectorId>http-connector</camunda:connectorId>
93 </bpmn:extensionElements>
94 <bpmn:incoming>SequenceFlow_0f6v4j4</bpmn:incoming>
95 <bpmn:outgoing>SequenceFlow_0g6bfz6</bpmn:outgoing>
97 <bpmn:startEvent id="StartEvent_parsing_term">
98 <bpmn:outgoing>SequenceFlow_0f6v4j4</bpmn:outgoing>
100 <bpmn:sequenceFlow id="SequenceFlow_0f6v4j4" sourceRef="StartEvent_parsing_term" targetRef="service-twitter" />
101 <bpmn:sequenceFlow id="SequenceFlow_0g6bfz6" sourceRef="service-twitter" targetRef="service-analysis" />
102 <bpmn:sequenceFlow id="SequenceFlow_1bz7zx2" sourceRef="service-analysis" targetRef="EndEvent_parsing_term" />
103 <bpmn:endEvent id="EndEvent_parsing_term">
104 <bpmn:incoming>SequenceFlow_1bz7zx2</bpmn:incoming>
107 <bpmn:endEvent id="EndEvent_0bmuv13">
108 <bpmn:incoming>SequenceFlow_0jebdb9</bpmn:incoming>
110 <bpmn:serviceTask id="service-report" name="Report Service">
111 <bpmn:extensionElements>
113 <camunda:inputOutput>
114 <camunda:inputParameter name="url">http://reporting:8083/generatePDF/</camunda:inputParameter>
115 <camunda:inputParameter name="method">POST</camunda:inputParameter>
116 <camunda:inputParameter name="headers">
118 <camunda:entry key="Accept">application/base64</camunda:entry>
119 <camunda:entry key="Content-Type">application/json</camunda:entry>
121 </camunda:inputParameter>
122 <camunda:inputParameter name="payload">${results.toString()}</camunda:inputParameter>
123 <camunda:outputParameter name="reportPDF">
124 <camunda:script scriptFormat="javascript">var response = connector.getVariable("response");
125 // from nodejs base64 package
128 var javaByteArray = Java.type('byte[]')
130 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
131 for (var i = 0, len = code.length; i < len; ++i) {
133 revLookup[code.charCodeAt(i)] = i
136 // Support decoding URL-safe base64 strings, as Node.js does.
137 // See: https://en.wikipedia.org/wiki/Base64#URL_applications
138 revLookup['-'.charCodeAt(0)] = 62
139 revLookup['_'.charCodeAt(0)] = 63
141 function getLens (b64) {
144 if (len % 4 > 0) {
145 throw new Error('Invalid string. Length must be a multiple of 4')
148 // Trim off extra bytes after placeholder bytes are found
149 // See: https://github.com/beatgammit/base64-js/issues/42
150 var validLen = b64.indexOf('=')
151 if (validLen === -1) validLen = len
153 var placeHoldersLen = validLen === len
157 return [validLen, placeHoldersLen]
160 function _byteLength (b64, validLen, placeHoldersLen) {
161 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
164 function toByteArray (b64) {
166 var lens = getLens(b64)
167 var validLen = lens[0]
168 var placeHoldersLen = lens[1]
170 var arr = new javaByteArray(_byteLength(b64, validLen, placeHoldersLen))
174 // if there are placeholders, only get up to the last complete 4 chars
175 var len = placeHoldersLen > 0
179 for (var i = 0; i < len; i += 4) {
181 (revLookup[b64.charCodeAt(i)] << 18) |
182 (revLookup[b64.charCodeAt(i + 1)] << 12) |
183 (revLookup[b64.charCodeAt(i + 2)] << 6) |
184 revLookup[b64.charCodeAt(i + 3)]
185 arr[curByte++] = (tmp >> 16) & 0xFF
186 arr[curByte++] = (tmp >> 8) & 0xFF
187 arr[curByte++] = tmp & 0xFF
190 if (placeHoldersLen === 2) {
192 (revLookup[b64.charCodeAt(i)] << 2) |
193 (revLookup[b64.charCodeAt(i + 1)] >> 4)
194 arr[curByte++] = tmp & 0xFF
197 if (placeHoldersLen === 1) {
199 (revLookup[b64.charCodeAt(i)] << 10) |
200 (revLookup[b64.charCodeAt(i + 1)] << 4) |
201 (revLookup[b64.charCodeAt(i + 2)] >> 2)
202 arr[curByte++] = (tmp >> 8) & 0xFF
203 arr[curByte++] = tmp & 0xFF
209 var source = "kP/+kA==";
210 var decoded = toByteArray(source);
212 var file = Java.type('org.camunda.bpm.engine.variable.Variables').fileValue("pdfTest").file(toByteArray(response)).mimeType('application/pdf').create()
215 </camunda:outputParameter>
216 </camunda:inputOutput>
217 <camunda:connectorId>http-connector</camunda:connectorId>
219 </bpmn:extensionElements>
220 <bpmn:incoming>SequenceFlow_1j2y6tv</bpmn:incoming>
221 <bpmn:outgoing>SequenceFlow_14nqu0e</bpmn:outgoing>
223 <bpmn:userTask id="Task_1e7059p" name="download pdf" camunda:formKey="embedded:deployment:download-pdf.html">
224 <bpmn:incoming>SequenceFlow_14nqu0e</bpmn:incoming>
225 <bpmn:outgoing>SequenceFlow_0jebdb9</bpmn:outgoing>
228 <bpmndi:BPMNDiagram id="BPMNDiagram_1">
229 <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
230 <bpmndi:BPMNShape id="Participant_0gzc3m9_di" bpmnElement="Sentiment_Analysis">
231 <dc:Bounds x="0" y="0" width="1084" height="202" />
233 <bpmndi:BPMNShape id="SubProcess_1skl2rb_di" bpmnElement="terms_loop" isExpanded="true">
234 <dc:Bounds x="135" y="19" width="443" height="163" />
236 <bpmndi:BPMNShape id="ServiceTask_01bq7a6_di" bpmnElement="service-analysis">
237 <dc:Bounds x="381" y="60" width="100" height="80" />
239 <bpmndi:BPMNShape id="ServiceTask_1o2usc9_di" bpmnElement="service-twitter">
240 <dc:Bounds x="230" y="60" width="100" height="80" />
242 <bpmndi:BPMNShape id="StartEvent_1nx6b6f_di" bpmnElement="StartEvent_parsing_term">
243 <dc:Bounds x="156" y="82" width="36" height="36" />
245 <bpmndi:BPMNEdge id="SequenceFlow_0f6v4j4_di" bpmnElement="SequenceFlow_0f6v4j4">
246 <di:waypoint x="192" y="100" />
247 <di:waypoint x="230" y="100" />
249 <bpmndi:BPMNEdge id="SequenceFlow_0g6bfz6_di" bpmnElement="SequenceFlow_0g6bfz6">
250 <di:waypoint x="330" y="100" />
251 <di:waypoint x="381" y="100" />
253 <bpmndi:BPMNEdge id="SequenceFlow_1bz7zx2_di" bpmnElement="SequenceFlow_1bz7zx2">
254 <di:waypoint x="481" y="100" />
255 <di:waypoint x="516" y="100" />
257 <bpmndi:BPMNShape id="StartEvent_1t6nxib_di" bpmnElement="StartEvent_1t6nxib">
258 <dc:Bounds x="56" y="83" width="36" height="36" />
260 <bpmndi:BPMNShape id="ServiceTask_1gaqtzh_di" bpmnElement="service-report">
261 <dc:Bounds x="619" y="61" width="100" height="80" />
263 <bpmndi:BPMNShape id="UserTask_0iooc2g_di" bpmnElement="Task_1e7059p">
264 <dc:Bounds x="766" y="61" width="100" height="80" />
266 <bpmndi:BPMNShape id="EndEvent_0bmuv13_di" bpmnElement="EndEvent_0bmuv13">
267 <dc:Bounds x="1024" y="83" width="36" height="36" />
269 <bpmndi:BPMNEdge id="SequenceFlow_14nqu0e_di" bpmnElement="SequenceFlow_14nqu0e">
270 <di:waypoint x="719" y="101" />
271 <di:waypoint x="766" y="101" />
273 <bpmndi:BPMNEdge id="SequenceFlow_0jebdb9_di" bpmnElement="SequenceFlow_0jebdb9">
274 <di:waypoint x="866" y="101" />
275 <di:waypoint x="1024" y="101" />
277 <bpmndi:BPMNEdge id="SequenceFlow_15dip2q_di" bpmnElement="SequenceFlow_15dip2q">
278 <di:waypoint x="92" y="101" />
279 <di:waypoint x="135" y="101" />
281 <bpmndi:BPMNEdge id="SequenceFlow_1j2y6tv_di" bpmnElement="SequenceFlow_1j2y6tv">
282 <di:waypoint x="578" y="101" />
283 <di:waypoint x="619" y="101" />
285 <bpmndi:BPMNShape id="EndEvent_07g109m_di" bpmnElement="EndEvent_parsing_term">
286 <dc:Bounds x="516" y="82" width="36" height="36" />
289 </bpmndi:BPMNDiagram>