reporting now throws error 500
authorDavid Kaufmann <david.kaufmann@student.tuwien.ac.at>
Sun, 25 Nov 2018 15:58:08 +0000 (16:58 +0100)
committerDavid Kaufmann <david.kaufmann@student.tuwien.ac.at>
Sun, 25 Nov 2018 15:58:08 +0000 (16:58 +0100)
camunda-overlay/sentiment-analysis.bpmn

index e8243ae490857eda20b01945c3cf8e40ea9adca1..c9595328e06bc5ba76d2b313b14c43b6977efca1 100644 (file)
@@ -12,8 +12,8 @@
     <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:script scriptFormat="javascript">// make variable global
+execution.setVariable("results", S('[]'))</camunda:script>
         </camunda:executionListener>
       </bpmn:extensionElements>
       <bpmn:outgoing>SequenceFlow_15dip2q</bpmn:outgoing>
@@ -30,10 +30,14 @@ execution.setVariable('tweets', S('[]'), "terms_loop");</camunda:script>
 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)
+
+// this is for dictionary
+//results.prop(termStr, analysis);
+// this is for list
+var item = {};
+item[termStr] = analysis;
+results.append(item)
+
 execution.setVariable("results", S(results))</camunda:script>
         </camunda:executionListener>
       </bpmn:extensionElements>
@@ -107,16 +111,21 @@ S(response);</camunda:script>
         <camunda:connector>
           <camunda:inputOutput>
             <camunda:inputParameter name="url">http://reporting:80/generatePDF/</camunda:inputParameter>
-            <camunda:inputParameter name="method">GET</camunda:inputParameter>
+            <camunda:inputParameter name="method">POST</camunda:inputParameter>
             <camunda:inputParameter name="headers">
               <camunda:map>
                 <camunda:entry key="Accept">application/pdf</camunda:entry>
+                <camunda:entry key="Content-Type">application/json</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>
+print ("response: ")
+print (response)
+var file = Java.type('org.camunda.bpm.engine.variable.Variables').fileValue("pdfTest").file(response.getBytes("utf-8")).mimeType('application/pdf').create()
+//response.getBytes("utf-8")
+file</camunda:script>
             </camunda:outputParameter>
           </camunda:inputOutput>
           <camunda:connectorId>http-connector</camunda:connectorId>