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[termStr] = analysis;
41 execution.setVariable("results", S(results))</camunda:script>
42 </camunda:executionListener>
43 </bpmn:extensionElements>
44 <bpmn:incoming>SequenceFlow_15dip2q</bpmn:incoming>
45 <bpmn:outgoing>SequenceFlow_1j2y6tv</bpmn:outgoing>
46 <bpmn:multiInstanceLoopCharacteristics camunda:collection="${terms.elements()}" camunda:elementVariable="term" />
47 <bpmn:serviceTask id="service-analysis" name="Analysis Service">
48 <bpmn:extensionElements>
51 <camunda:inputParameter name="url">http://analysis:8081/</camunda:inputParameter>
52 <camunda:inputParameter name="method">POST</camunda:inputParameter>
53 <camunda:inputParameter name="headers">
55 <camunda:entry key="Accept">application/json</camunda:entry>
56 <camunda:entry key="Content-Type">application/json</camunda:entry>
58 </camunda:inputParameter>
59 <camunda:inputParameter name="payload">${tweets.toString()}</camunda:inputParameter>
60 <camunda:outputParameter name="analysis">
61 <camunda:script scriptFormat="Javascript">var response = connector.getVariable("response");
62 response.trim()</camunda:script>
63 </camunda:outputParameter>
64 </camunda:inputOutput>
65 <camunda:connectorId>http-connector</camunda:connectorId>
67 </bpmn:extensionElements>
68 <bpmn:incoming>SequenceFlow_0g6bfz6</bpmn:incoming>
69 <bpmn:outgoing>SequenceFlow_1bz7zx2</bpmn:outgoing>
71 <bpmn:serviceTask id="service-twitter" name="Twitter Service">
72 <bpmn:extensionElements>
75 <camunda:inputParameter name="url">
76 <camunda:script scriptFormat="Javascript">var term = execution.getVariable("term");
77 'http://twitter:8084/search/tweets.json?q='+term.prop('term').value()</camunda:script>
78 </camunda:inputParameter>
79 <camunda:inputParameter name="method">GET</camunda:inputParameter>
80 <camunda:inputParameter name="headers">
82 <camunda:entry key="Accept">application/json</camunda:entry>
84 </camunda:inputParameter>
85 <camunda:outputParameter name="tweets">
86 <camunda:script scriptFormat="Javascript">var response = connector.getVariable("response");
87 S(response);</camunda:script>
88 </camunda:outputParameter>
89 </camunda:inputOutput>
90 <camunda:connectorId>http-connector</camunda:connectorId>
92 </bpmn:extensionElements>
93 <bpmn:incoming>SequenceFlow_0f6v4j4</bpmn:incoming>
94 <bpmn:outgoing>SequenceFlow_0g6bfz6</bpmn:outgoing>
96 <bpmn:startEvent id="StartEvent_parsing_term">
97 <bpmn:outgoing>SequenceFlow_0f6v4j4</bpmn:outgoing>
99 <bpmn:sequenceFlow id="SequenceFlow_0f6v4j4" sourceRef="StartEvent_parsing_term" targetRef="service-twitter" />
100 <bpmn:sequenceFlow id="SequenceFlow_0g6bfz6" sourceRef="service-twitter" targetRef="service-analysis" />
101 <bpmn:sequenceFlow id="SequenceFlow_1bz7zx2" sourceRef="service-analysis" targetRef="EndEvent_parsing_term" />
102 <bpmn:endEvent id="EndEvent_parsing_term">
103 <bpmn:incoming>SequenceFlow_1bz7zx2</bpmn:incoming>
106 <bpmn:endEvent id="EndEvent_0bmuv13">
107 <bpmn:incoming>SequenceFlow_0jebdb9</bpmn:incoming>
109 <bpmn:serviceTask id="service-report" name="Report Service">
110 <bpmn:extensionElements>
112 <camunda:inputOutput>
113 <camunda:inputParameter name="url">http://reporting:80/generatePDF/</camunda:inputParameter>
114 <camunda:inputParameter name="method">POST</camunda:inputParameter>
115 <camunda:inputParameter name="headers">
117 <camunda:entry key="Accept">application/pdf</camunda:entry>
118 <camunda:entry key="Content-Type">application/json</camunda:entry>
120 </camunda:inputParameter>
121 <camunda:inputParameter name="payload">${results.toString()}</camunda:inputParameter>
122 <camunda:outputParameter name="reportPDF">
123 <camunda:script scriptFormat="javascript">var response = connector.getVariable("response");
126 var file = Java.type('org.camunda.bpm.engine.variable.Variables').fileValue("pdfTest").file(response.getBytes("utf-8")).mimeType('application/pdf').create()
127 //response.getBytes("utf-8")
128 file</camunda:script>
129 </camunda:outputParameter>
130 </camunda:inputOutput>
131 <camunda:connectorId>http-connector</camunda:connectorId>
133 </bpmn:extensionElements>
134 <bpmn:incoming>SequenceFlow_1j2y6tv</bpmn:incoming>
135 <bpmn:outgoing>SequenceFlow_14nqu0e</bpmn:outgoing>
137 <bpmn:userTask id="Task_1e7059p" name="download pdf" camunda:formKey="embedded:deployment:download-pdf.html">
138 <bpmn:incoming>SequenceFlow_14nqu0e</bpmn:incoming>
139 <bpmn:outgoing>SequenceFlow_0jebdb9</bpmn:outgoing>
142 <bpmndi:BPMNDiagram id="BPMNDiagram_1">
143 <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
144 <bpmndi:BPMNShape id="Participant_0gzc3m9_di" bpmnElement="Sentiment_Analysis">
145 <dc:Bounds x="0" y="0" width="1084" height="202" />
147 <bpmndi:BPMNShape id="SubProcess_1skl2rb_di" bpmnElement="terms_loop" isExpanded="true">
148 <dc:Bounds x="135" y="19" width="443" height="163" />
150 <bpmndi:BPMNShape id="ServiceTask_01bq7a6_di" bpmnElement="service-analysis">
151 <dc:Bounds x="381" y="60" width="100" height="80" />
153 <bpmndi:BPMNShape id="ServiceTask_1o2usc9_di" bpmnElement="service-twitter">
154 <dc:Bounds x="230" y="60" width="100" height="80" />
156 <bpmndi:BPMNShape id="StartEvent_1nx6b6f_di" bpmnElement="StartEvent_parsing_term">
157 <dc:Bounds x="156" y="82" width="36" height="36" />
159 <bpmndi:BPMNEdge id="SequenceFlow_0f6v4j4_di" bpmnElement="SequenceFlow_0f6v4j4">
160 <di:waypoint x="192" y="100" />
161 <di:waypoint x="230" y="100" />
163 <bpmndi:BPMNEdge id="SequenceFlow_0g6bfz6_di" bpmnElement="SequenceFlow_0g6bfz6">
164 <di:waypoint x="330" y="100" />
165 <di:waypoint x="381" y="100" />
167 <bpmndi:BPMNEdge id="SequenceFlow_1bz7zx2_di" bpmnElement="SequenceFlow_1bz7zx2">
168 <di:waypoint x="481" y="100" />
169 <di:waypoint x="516" y="100" />
171 <bpmndi:BPMNShape id="StartEvent_1t6nxib_di" bpmnElement="StartEvent_1t6nxib">
172 <dc:Bounds x="56" y="83" width="36" height="36" />
174 <bpmndi:BPMNShape id="ServiceTask_1gaqtzh_di" bpmnElement="service-report">
175 <dc:Bounds x="619" y="61" width="100" height="80" />
177 <bpmndi:BPMNShape id="UserTask_0iooc2g_di" bpmnElement="Task_1e7059p">
178 <dc:Bounds x="766" y="61" width="100" height="80" />
180 <bpmndi:BPMNShape id="EndEvent_0bmuv13_di" bpmnElement="EndEvent_0bmuv13">
181 <dc:Bounds x="1024" y="83" width="36" height="36" />
183 <bpmndi:BPMNEdge id="SequenceFlow_14nqu0e_di" bpmnElement="SequenceFlow_14nqu0e">
184 <di:waypoint x="719" y="101" />
185 <di:waypoint x="766" y="101" />
187 <bpmndi:BPMNEdge id="SequenceFlow_0jebdb9_di" bpmnElement="SequenceFlow_0jebdb9">
188 <di:waypoint x="866" y="101" />
189 <di:waypoint x="1024" y="101" />
191 <bpmndi:BPMNEdge id="SequenceFlow_15dip2q_di" bpmnElement="SequenceFlow_15dip2q">
192 <di:waypoint x="92" y="101" />
193 <di:waypoint x="135" y="101" />
195 <bpmndi:BPMNEdge id="SequenceFlow_1j2y6tv_di" bpmnElement="SequenceFlow_1j2y6tv">
196 <di:waypoint x="578" y="101" />
197 <di:waypoint x="619" y="101" />
199 <bpmndi:BPMNShape id="EndEvent_07g109m_di" bpmnElement="EndEvent_parsing_term">
200 <dc:Bounds x="516" y="82" width="36" height="36" />
203 </bpmndi:BPMNDiagram>