more javascript
authorDavid Kaufmann <david.kaufmann@student.tuwien.ac.at>
Sun, 25 Nov 2018 15:08:10 +0000 (16:08 +0100)
committerDavid Kaufmann <david.kaufmann@student.tuwien.ac.at>
Sun, 25 Nov 2018 15:08:10 +0000 (16:08 +0100)
camunda-overlay/sentiment-analysis.bpmn

index c9392d4f11df17c3ca788e62a94f9fd84f00803f..e8243ae490857eda20b01945c3cf8e40ea9adca1 100644 (file)
@@ -1,95 +1,84 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <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">
-  <bpmn:collaboration id="Collaboration_1x8eoy3">
-    <bpmn:participant id="Participant_0gzc3m9" name="Sentiment Analysis" processRef="sentiment-analysis" />
+  <bpmn:collaboration id="Collaboration">
+    <bpmn:participant id="Sentiment_Analysis" name="Sentiment Analysis" processRef="sentiment-analysis" />
   </bpmn:collaboration>
   <bpmn:process id="sentiment-analysis" name="Sentiment Analysis" isExecutable="true" camunda:versionTag="0.0.1">
     <bpmn:laneSet id="LaneSet_1u08y0e" />
-    <bpmn:sequenceFlow id="SequenceFlow_0jumhlh" sourceRef="IntermediateThrowEvent_0d8ns1p" targetRef="service-report" />
     <bpmn:sequenceFlow id="SequenceFlow_14nqu0e" sourceRef="service-report" targetRef="Task_1e7059p" />
-    <bpmn:sequenceFlow id="SequenceFlow_0htopx7" sourceRef="SubProcess_1skl2rb" targetRef="IntermediateThrowEvent_0d8ns1p" />
-    <bpmn:sequenceFlow id="SequenceFlow_11xavl5" sourceRef="StartEvent_1t6nxib" targetRef="SubProcess_1skl2rb" />
-    <bpmn:sequenceFlow id="SequenceFlow_0tu3w40" sourceRef="IntermediateThrowEvent_1u3snd0" targetRef="EndEvent_0bmuv13" />
-    <bpmn:sequenceFlow id="SequenceFlow_0jebdb9" sourceRef="Task_1e7059p" targetRef="IntermediateThrowEvent_1u3snd0" />
-    <bpmn:endEvent id="EndEvent_0bmuv13">
-      <bpmn:incoming>SequenceFlow_0tu3w40</bpmn:incoming>
-    </bpmn:endEvent>
-    <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_1u3snd0">
-      <bpmn:incoming>SequenceFlow_0jebdb9</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_0tu3w40</bpmn:outgoing>
-      <bpmn:timerEventDefinition>
-        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT5S</bpmn:timeDuration>
-      </bpmn:timerEventDefinition>
-    </bpmn:intermediateCatchEvent>
-    <bpmn:userTask id="Task_1e7059p" name="download pdf" camunda:formKey="embedded:deployment:download-pdf.html">
-      <bpmn:incoming>SequenceFlow_14nqu0e</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_0jebdb9</bpmn:outgoing>
-    </bpmn:userTask>
-    <bpmn:serviceTask id="service-report" name="Report Service" camunda:expression="&#34;&#34;">
-      <bpmn:incoming>SequenceFlow_0jumhlh</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_14nqu0e</bpmn:outgoing>
-    </bpmn:serviceTask>
-    <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_0d8ns1p">
-      <bpmn:incoming>SequenceFlow_0htopx7</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_0jumhlh</bpmn:outgoing>
-      <bpmn:timerEventDefinition>
-        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT5S</bpmn:timeDuration>
-      </bpmn:timerEventDefinition>
-    </bpmn:intermediateCatchEvent>
-    <bpmn:subProcess id="SubProcess_1skl2rb">
-      <bpmn:incoming>SequenceFlow_11xavl5</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_0htopx7</bpmn:outgoing>
+    <bpmn:sequenceFlow id="SequenceFlow_0jebdb9" sourceRef="Task_1e7059p" targetRef="EndEvent_0bmuv13" />
+    <bpmn:sequenceFlow id="SequenceFlow_15dip2q" sourceRef="StartEvent_1t6nxib" targetRef="terms_loop" />
+    <bpmn:sequenceFlow id="SequenceFlow_1j2y6tv" sourceRef="terms_loop" targetRef="service-report" />
+    <bpmn:startEvent id="StartEvent_1t6nxib" camunda:formKey="embedded:deployment:input-terms.html">
+      <bpmn:extensionElements>
+        <camunda:executionListener event="start">
+          <camunda:script scriptFormat="javascript">var results = S('{}');
+execution.setVariable("results", results)</camunda:script>
+        </camunda:executionListener>
+      </bpmn:extensionElements>
+      <bpmn:outgoing>SequenceFlow_15dip2q</bpmn:outgoing>
+    </bpmn:startEvent>
+    <bpmn:subProcess id="terms_loop">
+      <bpmn:extensionElements>
+        <camunda:executionListener event="start">
+          <camunda:script scriptFormat="javascript">// make variables local to loop
+execution.setVariable("analysis", 0, "terms_loop");
+execution.setVariable('tweets', S('[]'), "terms_loop");</camunda:script>
+        </camunda:executionListener>
+        <camunda:executionListener event="end">
+          <camunda:script scriptFormat="javascript">var results = execution.getVariable("results");
+var term = execution.getVariable("term");
+var analysis = execution.getVariable("analysis");
+var termStr = term.prop('term').value();
+//print (termStr)
+results.prop(termStr, analysis);
+//print (analysis)
+//print (results)
+execution.setVariable("results", S(results))</camunda:script>
+        </camunda:executionListener>
+      </bpmn:extensionElements>
+      <bpmn:incoming>SequenceFlow_15dip2q</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1j2y6tv</bpmn:outgoing>
       <bpmn:multiInstanceLoopCharacteristics camunda:collection="${terms.elements()}" camunda:elementVariable="term" />
-      <bpmn:startEvent id="StartEvent_1nx6b6f">
-        <bpmn:outgoing>SequenceFlow_0f6v4j4</bpmn:outgoing>
-      </bpmn:startEvent>
-      <bpmn:serviceTask id="service-twitter" name="Twitter Service">
+      <bpmn:serviceTask id="service-analysis" name="Analysis Service">
         <bpmn:extensionElements>
           <camunda:connector>
             <camunda:inputOutput>
-              <camunda:inputParameter name="url">
-                <camunda:script scriptFormat="Javascript">var term = execution.getVariable("term");
-'http://twitter:8084/search/tweets.json?q='+term.term;</camunda:script>
-              </camunda:inputParameter>
-              <camunda:inputParameter name="method">GET</camunda:inputParameter>
+              <camunda:inputParameter name="url">http://analysis:8081/</camunda:inputParameter>
+              <camunda:inputParameter name="method">POST</camunda:inputParameter>
               <camunda:inputParameter name="headers">
                 <camunda:map>
                   <camunda:entry key="Accept">application/json</camunda:entry>
+                  <camunda:entry key="Content-Type">application/json</camunda:entry>
                 </camunda:map>
               </camunda:inputParameter>
-              <camunda:outputParameter name="tweets">
+              <camunda:inputParameter name="payload">${tweets.toString()}</camunda:inputParameter>
+              <camunda:outputParameter name="analysis">
                 <camunda:script scriptFormat="Javascript">var response = connector.getVariable("response");
-S(response);</camunda:script>
+response.trim()</camunda:script>
               </camunda:outputParameter>
             </camunda:inputOutput>
             <camunda:connectorId>http-connector</camunda:connectorId>
           </camunda:connector>
         </bpmn:extensionElements>
-        <bpmn:incoming>SequenceFlow_0f6v4j4</bpmn:incoming>
-        <bpmn:outgoing>SequenceFlow_0g6bfz6</bpmn:outgoing>
+        <bpmn:incoming>SequenceFlow_0g6bfz6</bpmn:incoming>
+        <bpmn:outgoing>SequenceFlow_1bz7zx2</bpmn:outgoing>
       </bpmn:serviceTask>
-      <bpmn:sequenceFlow id="SequenceFlow_0f6v4j4" sourceRef="StartEvent_1nx6b6f" targetRef="service-twitter" />
-      <bpmn:sequenceFlow id="SequenceFlow_0g6bfz6" sourceRef="service-twitter" targetRef="service-analysis" />
-      <bpmn:endEvent id="EndEvent_1b95153">
-        <bpmn:incoming>SequenceFlow_1bz7zx2</bpmn:incoming>
-      </bpmn:endEvent>
-      <bpmn:sequenceFlow id="SequenceFlow_1bz7zx2" sourceRef="service-analysis" targetRef="EndEvent_1b95153" />
-      <bpmn:serviceTask id="service-analysis" name="Analysis Service">
+      <bpmn:serviceTask id="service-twitter" name="Twitter Service">
         <bpmn:extensionElements>
           <camunda:connector>
             <camunda:inputOutput>
-              <camunda:inputParameter name="url">http://analysis:8081/</camunda:inputParameter>
-              <camunda:inputParameter name="method">POST</camunda:inputParameter>
+              <camunda:inputParameter name="url">
+                <camunda:script scriptFormat="Javascript">var term = execution.getVariable("term");
+'http://twitter:8084/search/tweets.json?q='+term.prop('term').value()</camunda:script>
+              </camunda:inputParameter>
+              <camunda:inputParameter name="method">GET</camunda:inputParameter>
               <camunda:inputParameter name="headers">
                 <camunda:map>
                   <camunda:entry key="Accept">application/json</camunda:entry>
                 </camunda:map>
               </camunda:inputParameter>
-              <camunda:inputParameter name="payload">
-                <camunda:script scriptFormat="Javascript">var tweets = execution.getVariable("tweets");
-'{"q": "'+tweets+'"}';</camunda:script>
-              </camunda:inputParameter>
-              <camunda:outputParameter name="analysis_results">
+              <camunda:outputParameter name="tweets">
                 <camunda:script scriptFormat="Javascript">var response = connector.getVariable("response");
 S(response);</camunda:script>
               </camunda:outputParameter>
@@ -97,91 +86,109 @@ S(response);</camunda:script>
             <camunda:connectorId>http-connector</camunda:connectorId>
           </camunda:connector>
         </bpmn:extensionElements>
-        <bpmn:incoming>SequenceFlow_0g6bfz6</bpmn:incoming>
-        <bpmn:outgoing>SequenceFlow_1bz7zx2</bpmn:outgoing>
+        <bpmn:incoming>SequenceFlow_0f6v4j4</bpmn:incoming>
+        <bpmn:outgoing>SequenceFlow_0g6bfz6</bpmn:outgoing>
       </bpmn:serviceTask>
+      <bpmn:startEvent id="StartEvent_parsing_term">
+        <bpmn:outgoing>SequenceFlow_0f6v4j4</bpmn:outgoing>
+      </bpmn:startEvent>
+      <bpmn:sequenceFlow id="SequenceFlow_0f6v4j4" sourceRef="StartEvent_parsing_term" targetRef="service-twitter" />
+      <bpmn:sequenceFlow id="SequenceFlow_0g6bfz6" sourceRef="service-twitter" targetRef="service-analysis" />
+      <bpmn:sequenceFlow id="SequenceFlow_1bz7zx2" sourceRef="service-analysis" targetRef="EndEvent_parsing_term" />
+      <bpmn:endEvent id="EndEvent_parsing_term">
+        <bpmn:incoming>SequenceFlow_1bz7zx2</bpmn:incoming>
+      </bpmn:endEvent>
     </bpmn:subProcess>
-    <bpmn:startEvent id="StartEvent_1t6nxib" camunda:formKey="embedded:deployment:input-terms.html">
-      <bpmn:outgoing>SequenceFlow_11xavl5</bpmn:outgoing>
-    </bpmn:startEvent>
+    <bpmn:endEvent id="EndEvent_0bmuv13">
+      <bpmn:incoming>SequenceFlow_0jebdb9</bpmn:incoming>
+    </bpmn:endEvent>
+    <bpmn:serviceTask id="service-report" name="Report Service">
+      <bpmn:extensionElements>
+        <camunda:connector>
+          <camunda:inputOutput>
+            <camunda:inputParameter name="url">http://reporting:80/generatePDF/</camunda:inputParameter>
+            <camunda:inputParameter name="method">GET</camunda:inputParameter>
+            <camunda:inputParameter name="headers">
+              <camunda:map>
+                <camunda:entry key="Accept">application/pdf</camunda:entry>
+              </camunda:map>
+            </camunda:inputParameter>
+            <camunda:inputParameter name="payload">${results.toString()}</camunda:inputParameter>
+            <camunda:outputParameter name="reportPDF">
+              <camunda:script scriptFormat="javascript">var response = connector.getVariable("response");
+response</camunda:script>
+            </camunda:outputParameter>
+          </camunda:inputOutput>
+          <camunda:connectorId>http-connector</camunda:connectorId>
+        </camunda:connector>
+      </bpmn:extensionElements>
+      <bpmn:incoming>SequenceFlow_1j2y6tv</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_14nqu0e</bpmn:outgoing>
+    </bpmn:serviceTask>
+    <bpmn:userTask id="Task_1e7059p" name="download pdf" camunda:formKey="embedded:deployment:download-pdf.html">
+      <bpmn:incoming>SequenceFlow_14nqu0e</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_0jebdb9</bpmn:outgoing>
+    </bpmn:userTask>
   </bpmn:process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
-    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1x8eoy3">
-      <bpmndi:BPMNShape id="Participant_0gzc3m9_di" bpmnElement="Participant_0gzc3m9">
-        <dc:Bounds x="0" y="0" width="1383" height="569" />
+    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
+      <bpmndi:BPMNShape id="Participant_0gzc3m9_di" bpmnElement="Sentiment_Analysis">
+        <dc:Bounds x="0" y="0" width="1084" height="202" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="EndEvent_0bmuv13_di" bpmnElement="EndEvent_0bmuv13">
-        <dc:Bounds x="1306" y="231" width="36" height="36" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="StartEvent_1t6nxib_di" bpmnElement="StartEvent_1t6nxib">
-        <dc:Bounds x="53" y="71" width="36" height="36" />
+      <bpmndi:BPMNShape id="SubProcess_1skl2rb_di" bpmnElement="terms_loop" isExpanded="true">
+        <dc:Bounds x="135" y="19" width="443" height="163" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNEdge id="SequenceFlow_0jebdb9_di" bpmnElement="SequenceFlow_0jebdb9">
-        <di:waypoint x="1199" y="249" />
-        <di:waypoint x="1233" y="249" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNShape id="UserTask_0iooc2g_di" bpmnElement="Task_1e7059p">
-        <dc:Bounds x="1099" y="209" width="100" height="80" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNEdge id="SequenceFlow_0tu3w40_di" bpmnElement="SequenceFlow_0tu3w40">
-        <di:waypoint x="1269" y="249" />
-        <di:waypoint x="1306" y="249" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNShape id="IntermediateCatchEvent_15xr8tf_di" bpmnElement="IntermediateThrowEvent_0d8ns1p">
-        <dc:Bounds x="867" y="231" width="36" height="36" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="IntermediateCatchEvent_14dhjgv_di" bpmnElement="IntermediateThrowEvent_1u3snd0">
-        <dc:Bounds x="1233" y="231" width="36" height="36" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNEdge id="SequenceFlow_11xavl5_di" bpmnElement="SequenceFlow_11xavl5">
-        <di:waypoint x="89" y="89" />
-        <di:waypoint x="164" y="89" />
-        <di:waypoint x="164" y="248" />
-        <di:waypoint x="239" y="248" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNShape id="SubProcess_1skl2rb_di" bpmnElement="SubProcess_1skl2rb" isExpanded="true">
-        <dc:Bounds x="239" y="165" width="552" height="164" />
-      </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="StartEvent_1nx6b6f_di" bpmnElement="StartEvent_1nx6b6f">
-        <dc:Bounds x="260" y="228" width="36" height="36" />
+      <bpmndi:BPMNShape id="ServiceTask_01bq7a6_di" bpmnElement="service-analysis">
+        <dc:Bounds x="381" y="60" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ServiceTask_1o2usc9_di" bpmnElement="service-twitter">
-        <dc:Bounds x="388" y="206" width="100" height="80" />
+        <dc:Bounds x="230" y="60" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="StartEvent_1nx6b6f_di" bpmnElement="StartEvent_parsing_term">
+        <dc:Bounds x="156" y="82" width="36" height="36" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0f6v4j4_di" bpmnElement="SequenceFlow_0f6v4j4">
-        <di:waypoint x="296" y="246" />
-        <di:waypoint x="388" y="246" />
+        <di:waypoint x="192" y="100" />
+        <di:waypoint x="230" y="100" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0g6bfz6_di" bpmnElement="SequenceFlow_0g6bfz6">
-        <di:waypoint x="488" y="246" />
-        <di:waypoint x="579" y="246" />
+        <di:waypoint x="330" y="100" />
+        <di:waypoint x="381" y="100" />
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNShape id="EndEvent_1b95153_di" bpmnElement="EndEvent_1b95153">
-        <dc:Bounds x="726" y="228" width="36" height="36" />
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1bz7zx2_di" bpmnElement="SequenceFlow_1bz7zx2">
-        <di:waypoint x="679" y="246" />
-        <di:waypoint x="726" y="246" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="SequenceFlow_0htopx7_di" bpmnElement="SequenceFlow_0htopx7">
-        <di:waypoint x="791" y="248" />
-        <di:waypoint x="829" y="248" />
-        <di:waypoint x="829" y="249" />
-        <di:waypoint x="867" y="249" />
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="SequenceFlow_14nqu0e_di" bpmnElement="SequenceFlow_14nqu0e">
-        <di:waypoint x="1043" y="249" />
-        <di:waypoint x="1099" y="249" />
+        <di:waypoint x="481" y="100" />
+        <di:waypoint x="516" y="100" />
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="StartEvent_1t6nxib_di" bpmnElement="StartEvent_1t6nxib">
+        <dc:Bounds x="56" y="83" width="36" height="36" />
+      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ServiceTask_1gaqtzh_di" bpmnElement="service-report">
-        <dc:Bounds x="943" y="209" width="100" height="80" />
+        <dc:Bounds x="619" y="61" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="UserTask_0iooc2g_di" bpmnElement="Task_1e7059p">
+        <dc:Bounds x="766" y="61" width="100" height="80" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNEdge id="SequenceFlow_0jumhlh_di" bpmnElement="SequenceFlow_0jumhlh">
-        <di:waypoint x="903" y="249" />
-        <di:waypoint x="943" y="249" />
+      <bpmndi:BPMNShape id="EndEvent_0bmuv13_di" bpmnElement="EndEvent_0bmuv13">
+        <dc:Bounds x="1024" y="83" width="36" height="36" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_14nqu0e_di" bpmnElement="SequenceFlow_14nqu0e">
+        <di:waypoint x="719" y="101" />
+        <di:waypoint x="766" y="101" />
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNShape id="ServiceTask_01bq7a6_di" bpmnElement="service-analysis">
-        <dc:Bounds x="579" y="206" width="100" height="80" />
+      <bpmndi:BPMNEdge id="SequenceFlow_0jebdb9_di" bpmnElement="SequenceFlow_0jebdb9">
+        <di:waypoint x="866" y="101" />
+        <di:waypoint x="1024" y="101" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_15dip2q_di" bpmnElement="SequenceFlow_15dip2q">
+        <di:waypoint x="92" y="101" />
+        <di:waypoint x="135" y="101" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1j2y6tv_di" bpmnElement="SequenceFlow_1j2y6tv">
+        <di:waypoint x="578" y="101" />
+        <di:waypoint x="619" y="101" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="EndEvent_07g109m_di" bpmnElement="EndEvent_parsing_term">
+        <dc:Bounds x="516" y="82" width="36" height="36" />
       </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>