I created a Process Engine, Repository Service, Runtime Service and deployed a BPMN workflow.
I also created a Process instance and was able to start it.
The issue is that when I try to either suspend or delete the process instance using the "deleteProcessInstance" method I get an error saying that the ProcessInstanceId could not be found!!
PS: I learnt somewhere that the processId in BPMN is treated as processKey in Activiti.
Code:
public void startProcess(String processDefinitionKey)
{
ListenerClass.processInstance=ListenerClass.runtimeService.startProcessInstanceByKey(processDefinitionKey);
}
public void deleteProcess(String processInstanceId)
{
System.out.println("Stopping Process instance id " +processInstanceId);
ListenerClass.runtimeService.deleteProcessInstance(processInstanceId, "Ok");
}
In the code above while starting the process instance, I pass the "Process Id" of the BPMN.xml file.(which means processId of BPMN.xml=processInstanceKey of Activiti)
My BPMN.xml:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1" xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="Process_11" isExecutable="true" name="Hima">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_06sykhd</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_06sykhd" sourceRef="StartEvent_1" targetRef="Task_1dt8brv" />
<bpmn:endEvent id="EndEvent_0cb0ioi">
<bpmn:incoming>SequenceFlow_1doj4n6</bpmn:incoming>
</bpmn:endEvent>
<bpmn:serviceTask id="Task_1dt8brv"
name="My Java Service Task"
activiti:class="com.bosch.bip.Service.task1" >
<bpmn:incoming>SequenceFlow_06sykhd</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_156te78</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="Task_10bfll9" activiti:class="com.bosch.bip.Service.task1">
<bpmn:incoming>SequenceFlow_156te78</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1doj4n6</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="SequenceFlow_156te78" sourceRef="Task_1dt8brv" targetRef="Task_10bfll9" />
<bpmn:sequenceFlow id="SequenceFlow_1doj4n6" sourceRef="Task_10bfll9" targetRef="EndEvent_0cb0ioi" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_11">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="173" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_06sykhd_di" bpmnElement="SequenceFlow_06sykhd">
<di:waypoint xsi:type="dc:Point" x="209" y="120" />
<di:waypoint xsi:type="dc:Point" x="264" y="120" />
<di:waypoint xsi:type="dc:Point" x="264" y="147" />
<di:waypoint xsi:type="dc:Point" x="318" y="147" />
<bpmndi:BPMNLabel>
<dc:Bounds x="219" y="123.5" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_0cb0ioi_di" bpmnElement="EndEvent_0cb0ioi">
<dc:Bounds x="768" y="173" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="741" y="209" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_1dt8brv_di" bpmnElement="Task_1dt8brv">
<dc:Bounds x="318" y="107" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_10bfll9_di" bpmnElement="Task_10bfll9">
<dc:Bounds x="528" y="94" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_156te78_di" bpmnElement="SequenceFlow_156te78">
<di:waypoint xsi:type="dc:Point" x="418" y="147" />
<di:waypoint xsi:type="dc:Point" x="473" y="147" />
<di:waypoint xsi:type="dc:Point" x="473" y="134" />
<di:waypoint xsi:type="dc:Point" x="528" y="134" />
<bpmndi:BPMNLabel>
<dc:Bounds x="386" y="202.5" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1doj4n6_di" bpmnElement="SequenceFlow_1doj4n6">
<di:waypoint xsi:type="dc:Point" x="628" y="134" />
<di:waypoint xsi:type="dc:Point" x="698" y="134" />
<di:waypoint xsi:type="dc:Point" x="698" y="191" />
<di:waypoint xsi:type="dc:Point" x="768" y="191" />
<bpmndi:BPMNLabel>
<dc:Bounds x="653" y="152.5" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Any help in this regards would be really helpful.
For a running process use this, as you did above:
runtimeService.deleteProcessInstance(processInstanceId, null);
If the process has been ended you need to delete it from the history, maybe your process has already ended?
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId).singleResult();
if (historicProcessInstance != null) {
historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
}
Related
im having a hard time figuring out how to pass data from a custom JR Datasource to a chart, I got the data passed to the report however whenver I try to pass it to a chart it doesnt show anything.
The Values im trying to pass are the mean, the days, and the SD to create a levey jenning report
heres the code below for the datasource class:
package MyDataAdapt;
import java.sql.Date;
import java.util.ArrayList;
import java.util.HashMap;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
public class GoImplementation implements JRDataSource {
public GoImplementation() {
// TODO Auto-generated constructor stub
}
/**
* For this data adapter the informations are embedded in the code
*/
private static final Integer[] lotNum = {33301141,33301143 };
private static final Integer[] level= {1,3};
private static final double[] mean= {4.49,457.04};
private static final double[] SD= {0.30,22.58};
private static final double[] CV= {6.79,4.94};
private static final Integer[] N= {54,53};
private HashMap<String, String> capitalCities = new HashMap<String, String>();
private static final double[] mean2= {3.92,465.95};
private static final double[] SD2= {0.35,31.11};
private static final double[] CV2= {9.04,6.68};
private static final Integer[] N2= {333,340};
private static final String[] department = {"GENERAL"," "};
private static final String[] instruementArray = {"ARCHITECT cI4100-I1SR"," "};
private static final String[] test = {"Human Chronic Gonadotropin (BhCG) {7K78}(mIU/mL"," "};
private static final String[] method = {"NONE"," "};
private static final String[] reagentArray = {"ABBOTT"," "};
private static final String[] month = {"January, 2015"," "};
private static final String[] shift = {"All"," "};
private static final String[] qcProduct = {"MULTICHEM IA PLUS(05P76-10)"," "};
private static final Integer[] days = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
HashMap<String, Integer> lotp = new HashMap<String, Integer>();
HashMap<String, Double> meanp = new HashMap<String, Double>();
HashMap<String, Double> sdp= new HashMap<String, Double>();
HashMap<String,Integer> dayp = new HashMap<String, Integer>();
/**
* Variable to store how much records were read
*/
private int counter = -1;
/**
* Variables to store the number of fields, and their names, in the report
*/
private HashMap<String, Integer> fieldsNumber = new HashMap<String, Integer>();
/**
* Method used to know if there are records to read.
*/
private int lastFieldsAdded = 0;
#Override
public boolean next() throws JRException {
if (counter<lotNum.length-1) {
counter++;
return true;
}
return false;
}
/**
* This method is called for every field defined in the report. So if i have 2 fields it is called 2 times for every record, and
* for each of them it must provide a value.
* The parameter can be used to understand for which field is requested, in fact it contains the name of the requested field. This
* data adapter is done with the goal of return two values, a name and an age. An easy option would be expect a field with the name
* "Name" and one with name "Age". But we can do something more flexible, in this case we will enumerate all the fields requested and
* and the first two will be assumed to be for name and age, for all the others will be returned an empty string. So we can have a report
* with more than two fields, but the name and the age will be returned each time only for the first two.
*
* If this example is too much complex refer to the method getFieldValue2, where is shown the first explained, and simple solution, where we
* expect two fields with a precise name.
*/
#Override
public Object getFieldValue(JRField jrField) throws JRException {
Integer fieldIndex;
if (fieldsNumber.containsKey(jrField.getName())) {
fieldIndex = fieldsNumber.get(jrField.getName());
}
else {
fieldsNumber.put(jrField.getName(), lastFieldsAdded);
fieldIndex = lastFieldsAdded;
lastFieldsAdded ++;
}
if (fieldIndex == 0) return lotNum[counter];
else if (fieldIndex == 1) return level[counter];
else if (fieldIndex == 2) return mean[counter];
else if (fieldIndex == 3) return SD[counter];
else if (fieldIndex == 4) return CV[counter];
else if (fieldIndex == 5) return N[counter];
else if (fieldIndex == 6) return mean2[counter];
else if (fieldIndex == 7) return SD2[counter];
else if (fieldIndex == 8) return CV2[counter];
else if (fieldIndex == 9) return N2[counter];
else if (fieldIndex == 10) return department[0];
else if (fieldIndex == 11) return instruementArray[0];
else if (fieldIndex == 12) return test[0];
else if (fieldIndex == 13) return method[0];
else if (fieldIndex == 14) return reagentArray[0];
else if (fieldIndex == 15) return month[0];
else if (fieldIndex == 16) return shift[0];
else if (fieldIndex == 17) return qcProduct[0];
else if (fieldIndex == 18) return days;
return "";
}
/**
* Return an instance of the class that implements the custom data adapter.
*/
public static JRDataSource getDataSource(){
return new GoImplementation();
}
}
The Jrxml File
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="GraphReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b0db03f9-1d9d-4eb5-8f2e-bc1174d4b926">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="CustomDataPackage\DataAdapter.xml"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="LeveyJen" uuid="7a90870e-2a65-494c-9a60-0c66448362de">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="CustomDataPackage\DataAdapter.xml"/>
<parameter name="Mean" class="java.lang.Double">
<property name="com.jaspersoft.studio.js.ic.ds" value="com.jaspersoft.studio.data.defaultdataadapter"/>
</parameter>
<parameter name="SD" class="java.lang.Double"/>
<parameter name="Days" class="java.lang.Integer"/>
<queryString language="SQL">
<![CDATA[]]>
</queryString>
<field name="days" class="java.lang.Integer">
<fieldDescription><![CDATA[The dAYS Used]]></fieldDescription>
</field>
<field name="Mean" class="java.lang.Double">
<fieldDescription><![CDATA[The Mean]]></fieldDescription>
</field>
<field name="SD" class="java.lang.Double">
<fieldDescription><![CDATA[The Standard Deviation]]></fieldDescription>
</field>
<field name="Lot#" class="java.lang.Integer">
<fieldDescription><![CDATA[The lot number]]></fieldDescription>
</field>
<field name="CV" class="java.lang.Double">
<fieldDescription><![CDATA[The Coeficent Variation]]></fieldDescription>
</field>
<group name="Mean">
<groupExpression><![CDATA[$F{Mean}]]></groupExpression>
</group>
</subDataset>
<parameter name="Mean" class="java.lang.Double" evaluationTime="Early">
<defaultValueExpression><![CDATA[4.49]]></defaultValueExpression>
</parameter>
<parameter name="SD" class="java.lang.Double" evaluationTime="Early">
<defaultValueExpression><![CDATA[.30]]></defaultValueExpression>
</parameter>
<parameter name="days" class="java.lang.Integer" evaluationTime="Early">
<defaultValueExpression><![CDATA[1]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Lot#" class="java.lang.Integer">
<fieldDescription><![CDATA[The lot number]]></fieldDescription>
</field>
<field name="Level" class="java.lang.Integer">
<fieldDescription><![CDATA[The level]]></fieldDescription>
</field>
<field name="Mean" class="java.lang.Double">
<fieldDescription><![CDATA[The Mean]]></fieldDescription>
</field>
<field name="SD" class="java.lang.Double">
<fieldDescription><![CDATA[The Standard Deviation]]></fieldDescription>
</field>
<field name="CV" class="java.lang.Double">
<fieldDescription><![CDATA[The Coeficent Variation]]></fieldDescription>
</field>
<field name="N" class="java.lang.Integer">
<fieldDescription><![CDATA[The Sample]]></fieldDescription>
</field>
<field name="cMean" class="java.lang.Double">
<fieldDescription><![CDATA[The Cummulative Mean]]></fieldDescription>
</field>
<field name="cSD" class="java.lang.Double">
<fieldDescription><![CDATA[The Cummulative Standard Deviation]]></fieldDescription>
</field>
<field name="cCV" class="java.lang.Double">
<fieldDescription><![CDATA[The Cummulative Variation]]></fieldDescription>
</field>
<field name="cN" class="java.lang.Integer">
<fieldDescription><![CDATA[The Cummulative Sample]]></fieldDescription>
</field>
<field name="department" class="java.lang.String">
<fieldDescription><![CDATA[The Department]]></fieldDescription>
</field>
<field name="instrument" class="java.lang.String">
<fieldDescription><![CDATA[The Instrument]]></fieldDescription>
</field>
<field name="test" class="java.lang.String">
<fieldDescription><![CDATA[The Test]]></fieldDescription>
</field>
<field name="method" class="java.lang.String">
<fieldDescription><![CDATA[The Method]]></fieldDescription>
</field>
<field name="reagent" class="java.lang.String">
<fieldDescription><![CDATA[The Reagent]]></fieldDescription>
</field>
<field name="month" class="java.lang.String">
<fieldDescription><![CDATA[The Month]]></fieldDescription>
</field>
<field name="shift" class="java.lang.String">
<fieldDescription><![CDATA[The Shift]]></fieldDescription>
</field>
<field name="qcProduct" class="java.lang.String">
<fieldDescription><![CDATA[The Product Used]]></fieldDescription>
</field>
<field name="days" class="java.lang.Integer">
<fieldDescription><![CDATA[The dAYS Used]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="626">
<componentElement>
<reportElement x="20" y="0" width="200" height="200" uuid="80fb1a9e-e915-4f0a-8841-5ec4dc3e3e62">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" whenNoDataType="AllSectionsNoDetail">
<datasetRun subDataset="LeveyJen" uuid="b73b13da-6c82-476a-b05b-a76ceb8b0ace">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="40" uuid="870bbd63-dd2a-4a61-8488-ae55835df694">
<jr:tableHeader style="Table_TH" height="30"/>
<jr:tableFooter style="Table_TH" height="30"/>
<jr:groupHeader groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupHeader>
<jr:groupFooter groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupFooter>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="dc2219e0-b6bb-4957-bf7e-ebad553c307d"/>
<text><![CDATA[days]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="c508b8f7-a940-4c21-8704-65df0d812521"/>
<textFieldExpression><![CDATA[$F{days}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="b7ae7382-8aa7-466f-96f8-ec5549e7ea7f">
<jr:tableHeader style="Table_TH" height="30"/>
<jr:tableFooter style="Table_TH" height="30"/>
<jr:groupHeader groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupHeader>
<jr:groupFooter groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupFooter>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="4c916eef-3956-41c7-81b5-86ed59d8f816"/>
<text><![CDATA[Mean]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="3fba2b84-0d0a-4be9-8e39-2e883dc20962"/>
<textFieldExpression><![CDATA[$F{Mean}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="f50bd22f-deee-4ff7-b001-7e5515386adf">
<jr:tableHeader style="Table_TH" height="30"/>
<jr:tableFooter style="Table_TH" height="30"/>
<jr:groupHeader groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupHeader>
<jr:groupFooter groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupFooter>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="960b3408-1558-4c43-9f90-366aef4bf4fa"/>
<text><![CDATA[SD]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="ce6ed33b-3b8a-4be7-96e9-4d6032342ba2"/>
<textFieldExpression><![CDATA[$F{SD}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="6ccc302d-bfbf-49c2-b1a9-1574cace4c20">
<jr:tableHeader style="Table_TH" height="30"/>
<jr:tableFooter style="Table_TH" height="30"/>
<jr:groupHeader groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupHeader>
<jr:groupFooter groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupFooter>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="80e5d6b0-074c-4c5a-9a71-32d7e5ecbef9"/>
<text><![CDATA[Lot#]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="0d711de1-e894-4c2f-8247-f95a9ae14b14"/>
<textFieldExpression><![CDATA[$F{Lot#}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="40" uuid="361c4990-a417-4dbe-8fad-354daf2da30c">
<jr:tableHeader style="Table_TH" height="30"/>
<jr:tableFooter style="Table_TH" height="30"/>
<jr:groupHeader groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupHeader>
<jr:groupFooter groupName="Mean">
<jr:cell style="Table_CH" height="30"/>
</jr:groupFooter>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="40" height="30" uuid="cb377e1c-7426-45d5-b063-c70ba13d3189"/>
<text><![CDATA[CV]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table_CH" height="30"/>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="40" height="30" uuid="a5b3191c-e675-4018-8727-6afec6544feb"/>
<textFieldExpression><![CDATA[$F{CV}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
<lineChart>
<chart evaluationTime="Report">
<reportElement x="0" y="426" width="555" height="200" uuid="e6cccf0d-fe31-4417-ab27-f8a13aa142ad"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="LeveyJen" uuid="49b8c004-a74d-4b9f-a772-9f0996c2c7fc">
<datasetParameter name="Mean">
<datasetParameterExpression><![CDATA[$P{Mean}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="SD">
<datasetParameterExpression><![CDATA[$P{SD}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="Days">
<datasetParameterExpression><![CDATA[$P{days}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA[$F{Mean}]]></seriesExpression>
<categoryExpression><![CDATA[$F{days}]]></categoryExpression>
<valueExpression><![CDATA[$F{SD}]]></valueExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA[$F{days}]]></seriesExpression>
<categoryExpression><![CDATA[$F{days}]]></categoryExpression>
<valueExpression><![CDATA[$F{SD}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</linePlot>
</lineChart>
</band>
</summary>
</jasperReport>
I'm building some test BPMN 2.0 models and saving them to xml files, in a Java project, by following the examples provided by the official doc, in this case the example 2.
I imported the lib in my pom like below:
<!-- https://mvnrepository.com/artifact/org.camunda.bpm.model/camunda-bpmn-model -->
<dependency>
<groupId>org.camunda.bpm.model</groupId>
<artifactId>camunda-bpmn-model</artifactId>
<version>7.10.0</version>
</dependency>
and this is my test class, following the example 2:
import org.camunda.bpm.model.bpmn.Bpmn;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import org.camunda.bpm.model.bpmn.instance.*;
import org.camunda.bpm.model.bpmn.instance.Process;
import java.io.File;
import java.io.IOException;
public class Test {
protected static <T extends BpmnModelElementInstance> T createElement(BpmnModelInstance modelInstance, BpmnModelElementInstance parentElement, String id, Class<T> elementClass) {
T element = modelInstance.newInstance(elementClass);
element.setAttributeValue("id", id, true);
parentElement.addChildElement(element);
return element;
}
public static SequenceFlow createSequenceFlow(BpmnModelInstance modelInstance, Process process, FlowNode from, FlowNode to) {
String identifier = from.getId() + "-" + to.getId();
SequenceFlow sequenceFlow = createElement(modelInstance, process, identifier, SequenceFlow.class);
process.addChildElement(sequenceFlow);
sequenceFlow.setSource(from);
from.getOutgoing().add(sequenceFlow);
sequenceFlow.setTarget(to);
to.getIncoming().add(sequenceFlow);
return sequenceFlow;
}
public static void main(String[] args) throws IOException {
// create an empty model
BpmnModelInstance modelInstance = Bpmn.createEmptyModel();
Definitions definitions = modelInstance.newInstance(Definitions.class);
definitions.setTargetNamespace("http://camunda.org/examples");
modelInstance.setDefinitions(definitions);
// create a process
Process process = modelInstance.newInstance(Process.class);
process.setId("process");
definitions.addChildElement(process);
// create elements
StartEvent startEvent = createElement(modelInstance, process, "start", StartEvent.class);
ParallelGateway fork = createElement(modelInstance, process, "fork", ParallelGateway.class);
ServiceTask task1 = createElement(modelInstance, process, "task1", ServiceTask.class);
task1.setName("Service Task");
UserTask task2 = createElement(modelInstance, process, "task2", UserTask.class);
task2.setName("User Task");
ParallelGateway join = createElement(modelInstance, process, "join", ParallelGateway.class);
EndEvent endEvent = createElement(modelInstance, process, "end", EndEvent.class);
// create flows
createSequenceFlow(modelInstance, process, startEvent, fork);
createSequenceFlow(modelInstance, process, fork, task1);
createSequenceFlow(modelInstance, process, fork, task2);
createSequenceFlow(modelInstance, process, task1, join);
createSequenceFlow(modelInstance, process, task2, join);
createSequenceFlow(modelInstance, process, join, endEvent);
// validate and write model to file
Bpmn.validateModel(modelInstance);
File file = new File("bpmn-model.bpmn.xml");
file.createNewFile();
Bpmn.writeModelToFile(file, modelInstance);
}
}
Here the generated BPMN 2.0 xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions id="definitions_7b2df680-1d9c-4897-ba8b-a83548ab937f" targetNamespace="http://camunda.org/examples" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">
<process id="process">
<startEvent id="start">
<outgoing>start-fork</outgoing>
</startEvent>
<parallelGateway id="fork">
<incoming>start-fork</incoming>
<outgoing>fork-task1</outgoing>
<outgoing>fork-task2</outgoing>
</parallelGateway>
<serviceTask id="task1" name="Service Task">
<incoming>fork-task1</incoming>
<outgoing>task1-join</outgoing>
</serviceTask>
<userTask id="task2" name="User Task">
<incoming>fork-task2</incoming>
<outgoing>task2-join</outgoing>
</userTask>
<parallelGateway id="join">
<incoming>task1-join</incoming>
<incoming>task2-join</incoming>
<outgoing>join-end</outgoing>
</parallelGateway>
<endEvent id="end">
<incoming>join-end</incoming>
</endEvent>
<sequenceFlow id="start-fork" sourceRef="start" targetRef="fork"/>
<sequenceFlow id="fork-task1" sourceRef="fork" targetRef="task1"/>
<sequenceFlow id="fork-task2" sourceRef="fork" targetRef="task2"/>
<sequenceFlow id="task1-join" sourceRef="task1" targetRef="join"/>
<sequenceFlow id="task2-join" sourceRef="task2" targetRef="join"/>
<sequenceFlow id="join-end" sourceRef="join" targetRef="end"/>
</process>
</definitions>
Altough the validation method, the generated xml appears to be invalid when trying to display the BPMN using both the Camunda Modeler app and bpmn.io.
What is wrong with this example, hence with my code?
How can I make the generated xml to be valid? Since bpmn 2.0 is a standard, I'm also a bit surprised of this problem.
I finally got it working by switching to the fluent model builder API, following this https://blog.camunda.com/post/2014/02/the-new-camunda-bpmn-model-api/
This is my updated test calss:
import org.camunda.bpm.model.bpmn.Bpmn;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import org.camunda.bpm.model.bpmn.GatewayDirection;
import java.io.File;
import java.io.IOException;
public class Test {
public static void main(String[] args) throws IOException {
BpmnModelInstance modelInstance = Bpmn.createProcess()
.name("BPMN API Invoice Process")
.executable()
.startEvent()
.name("Invoice received")
.camundaFormKey("embedded:app:forms/start-form.html")
.userTask()
.name("Assign Approver")
.camundaFormKey("embedded:app:forms/assign-approver.html")
.camundaAssignee("demo")
.userTask()
.id("approveInvoice")
.name("Approve Invoice")
.camundaFormKey("embedded:app:forms/approve-invoice.html")
.camundaAssignee("${approver}")
.exclusiveGateway()
.name("Invoice approved?")
.gatewayDirection(GatewayDirection.Diverging)
.condition("yes", "${approved}")
.userTask()
.name("Prepare Bank Transfer")
.camundaFormKey("embedded:app:forms/prepare-bank-transfer.html")
.camundaCandidateGroups("accounting")
.serviceTask()
.name("Archive Invoice")
.endEvent()
.name("Invoice processed")
.moveToLastGateway()
.condition("no", "${!approved}")
.userTask()
.name("Review Invoice")
.camundaFormKey("embedded:app:forms/review-invoice.html")
.camundaAssignee("demo")
.exclusiveGateway()
.name("Review successful?")
.gatewayDirection(GatewayDirection.Diverging)
.condition("no", "${!clarified}")
.endEvent()
.name("Invoice not processed")
.moveToLastGateway()
.condition("yes", "${clarified}")
.connectTo("approveInvoice")
.done();
// validate and write model to file
Bpmn.validateModel(modelInstance);
File file = new File("bpmn-model.bpmn.xml");
file.createNewFile();
String bpmnString = Bpmn.convertToString(modelInstance);
System.out.println("bpmnString");
System.out.println(bpmnString);
Bpmn.writeModelToFile(file, modelInstance);
}
}
and this is the generated xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="definitions_3bd3e094-3e53-4644-af0c-1a048653920c" targetNamespace="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">
<process id="process_e14ca74e-6095-4a2b-bced-debcb3b37954" isExecutable="true" name="BPMN API Invoice Process">
<startEvent camunda:formKey="embedded:app:forms/start-form.html" id="startEvent_e8daa33a-af99-4b7a-87ee-200b0e7bedcd" name="Invoice received">
<outgoing>sequenceFlow_cb28e7e5-ebc0-4f27-b8b2-24403ab87ce3</outgoing>
</startEvent>
<userTask camunda:assignee="demo" camunda:formKey="embedded:app:forms/assign-approver.html" id="userTask_029f48b9-de24-4292-af49-845e81fdcc4b" name="Assign Approver">
<incoming>sequenceFlow_cb28e7e5-ebc0-4f27-b8b2-24403ab87ce3</incoming>
<outgoing>sequenceFlow_57a81fcd-fb35-42cd-afca-7c4c7914936d</outgoing>
</userTask>
<sequenceFlow id="sequenceFlow_cb28e7e5-ebc0-4f27-b8b2-24403ab87ce3" sourceRef="startEvent_e8daa33a-af99-4b7a-87ee-200b0e7bedcd" targetRef="userTask_029f48b9-de24-4292-af49-845e81fdcc4b"/>
<userTask camunda:assignee="${approver}" camunda:formKey="embedded:app:forms/approve-invoice.html" id="approveInvoice" name="Approve Invoice">
<incoming>sequenceFlow_57a81fcd-fb35-42cd-afca-7c4c7914936d</incoming>
<incoming>sequenceFlow_6987bcb8-5f6a-467b-9b25-e21b90dd0d4d</incoming>
<outgoing>sequenceFlow_1fe15a36-427e-4000-8fc7-50b8925ea1e5</outgoing>
</userTask>
<sequenceFlow id="sequenceFlow_57a81fcd-fb35-42cd-afca-7c4c7914936d" sourceRef="userTask_029f48b9-de24-4292-af49-845e81fdcc4b" targetRef="approveInvoice"/>
<exclusiveGateway gatewayDirection="Diverging" id="exclusiveGateway_b66a0444-2889-4cae-ac78-c1f65405ba0b" name="Invoice approved?">
<incoming>sequenceFlow_1fe15a36-427e-4000-8fc7-50b8925ea1e5</incoming>
<outgoing>sequenceFlow_9156c1d4-f756-447b-a384-e3bf17c43ff4</outgoing>
<outgoing>sequenceFlow_29bab2ba-6108-4731-94c3-93a6955d1946</outgoing>
</exclusiveGateway>
<sequenceFlow id="sequenceFlow_1fe15a36-427e-4000-8fc7-50b8925ea1e5" sourceRef="approveInvoice" targetRef="exclusiveGateway_b66a0444-2889-4cae-ac78-c1f65405ba0b"/>
<sequenceFlow id="sequenceFlow_9156c1d4-f756-447b-a384-e3bf17c43ff4" name="yes" sourceRef="exclusiveGateway_b66a0444-2889-4cae-ac78-c1f65405ba0b" targetRef="userTask_79a63b4f-96a7-43d7-aab3-e8e0e83769e5">
<conditionExpression id="conditionExpression_13d7607b-d7e7-4fa4-a364-aeabff28a0f1">${approved}</conditionExpression>
</sequenceFlow>
<userTask camunda:candidateGroups="accounting" camunda:formKey="embedded:app:forms/prepare-bank-transfer.html" id="userTask_79a63b4f-96a7-43d7-aab3-e8e0e83769e5" name="Prepare Bank Transfer">
<incoming>sequenceFlow_9156c1d4-f756-447b-a384-e3bf17c43ff4</incoming>
<outgoing>sequenceFlow_b82e04ab-a0cc-4969-989a-1ec64d74d990</outgoing>
</userTask>
<serviceTask id="serviceTask_9d976f99-f8fb-4705-ae6d-a606758111f4" name="Archive Invoice">
<incoming>sequenceFlow_b82e04ab-a0cc-4969-989a-1ec64d74d990</incoming>
<outgoing>sequenceFlow_f0f99688-25b1-417e-9a5d-0d17503cb3ba</outgoing>
</serviceTask>
<sequenceFlow id="sequenceFlow_b82e04ab-a0cc-4969-989a-1ec64d74d990" sourceRef="userTask_79a63b4f-96a7-43d7-aab3-e8e0e83769e5" targetRef="serviceTask_9d976f99-f8fb-4705-ae6d-a606758111f4"/>
<endEvent id="endEvent_affc9949-819a-4b79-98bd-0f2fd844d014" name="Invoice processed">
<incoming>sequenceFlow_f0f99688-25b1-417e-9a5d-0d17503cb3ba</incoming>
</endEvent>
<sequenceFlow id="sequenceFlow_f0f99688-25b1-417e-9a5d-0d17503cb3ba" sourceRef="serviceTask_9d976f99-f8fb-4705-ae6d-a606758111f4" targetRef="endEvent_affc9949-819a-4b79-98bd-0f2fd844d014"/>
<sequenceFlow id="sequenceFlow_29bab2ba-6108-4731-94c3-93a6955d1946" name="no" sourceRef="exclusiveGateway_b66a0444-2889-4cae-ac78-c1f65405ba0b" targetRef="userTask_7b955191-5741-44df-b7ba-d154ddfbe616">
<conditionExpression id="conditionExpression_ce06d35f-8638-4699-802b-7f1b94732f46">${!approved}</conditionExpression>
</sequenceFlow>
<userTask camunda:assignee="demo" camunda:formKey="embedded:app:forms/review-invoice.html" id="userTask_7b955191-5741-44df-b7ba-d154ddfbe616" name="Review Invoice">
<incoming>sequenceFlow_29bab2ba-6108-4731-94c3-93a6955d1946</incoming>
<outgoing>sequenceFlow_74d95e16-7907-4000-9ffb-cdba8c3ddde4</outgoing>
</userTask>
<exclusiveGateway gatewayDirection="Diverging" id="exclusiveGateway_5aa645c5-a5e7-4453-8498-8462092b85b1" name="Review successful?">
<incoming>sequenceFlow_74d95e16-7907-4000-9ffb-cdba8c3ddde4</incoming>
<outgoing>sequenceFlow_3bf21b37-c534-4541-b84f-03d3fe05c989</outgoing>
<outgoing>sequenceFlow_6987bcb8-5f6a-467b-9b25-e21b90dd0d4d</outgoing>
</exclusiveGateway>
<sequenceFlow id="sequenceFlow_74d95e16-7907-4000-9ffb-cdba8c3ddde4" sourceRef="userTask_7b955191-5741-44df-b7ba-d154ddfbe616" targetRef="exclusiveGateway_5aa645c5-a5e7-4453-8498-8462092b85b1"/>
<sequenceFlow id="sequenceFlow_3bf21b37-c534-4541-b84f-03d3fe05c989" name="no" sourceRef="exclusiveGateway_5aa645c5-a5e7-4453-8498-8462092b85b1" targetRef="endEvent_68057c88-fa46-43cc-a93c-774b26be7b50">
<conditionExpression id="conditionExpression_8bb43e50-dd2f-40ba-9cc9-91a69813a835">${!clarified}</conditionExpression>
</sequenceFlow>
<endEvent id="endEvent_68057c88-fa46-43cc-a93c-774b26be7b50" name="Invoice not processed">
<incoming>sequenceFlow_3bf21b37-c534-4541-b84f-03d3fe05c989</incoming>
</endEvent>
<sequenceFlow id="sequenceFlow_6987bcb8-5f6a-467b-9b25-e21b90dd0d4d" name="yes" sourceRef="exclusiveGateway_5aa645c5-a5e7-4453-8498-8462092b85b1" targetRef="approveInvoice">
<conditionExpression id="conditionExpression_c3fb4bcf-905a-47dd-84cf-6cfe1980ca2e">${clarified}</conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_946186ab-976d-40e2-9ed2-4672566340a2">
<bpmndi:BPMNPlane bpmnElement="process_e14ca74e-6095-4a2b-bced-debcb3b37954" id="BPMNPlane_78d2c2b7-e5e7-414f-abae-0dcddaefbdfd">
<bpmndi:BPMNShape bpmnElement="startEvent_e8daa33a-af99-4b7a-87ee-200b0e7bedcd" id="BPMNShape_2da46013-859f-418a-8612-25bd57aabb52">
<dc:Bounds height="36.0" width="36.0" x="100.0" y="100.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="userTask_029f48b9-de24-4292-af49-845e81fdcc4b" id="BPMNShape_79fd4553-cfb0-4740-b4fe-093d1c96474b">
<dc:Bounds height="80.0" width="100.0" x="186.0" y="78.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_cb28e7e5-ebc0-4f27-b8b2-24403ab87ce3" id="BPMNEdge_77315869-b425-4daf-85b6-6121867d91bc">
<di:waypoint x="136.0" y="118.0"/>
<di:waypoint x="186.0" y="118.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="approveInvoice" id="BPMNShape_b54e1244-b4fb-4e70-8c0d-4b76eb2798b0">
<dc:Bounds height="80.0" width="100.0" x="336.0" y="78.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_57a81fcd-fb35-42cd-afca-7c4c7914936d" id="BPMNEdge_dfa41f0e-273b-4d62-b8b8-ef9286b24f7d">
<di:waypoint x="286.0" y="118.0"/>
<di:waypoint x="336.0" y="118.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="exclusiveGateway_b66a0444-2889-4cae-ac78-c1f65405ba0b" id="BPMNShape_bc1af4c3-ef1f-4c26-a42c-b1c2982bf35c" isMarkerVisible="true">
<dc:Bounds height="50.0" width="50.0" x="486.0" y="93.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_1fe15a36-427e-4000-8fc7-50b8925ea1e5" id="BPMNEdge_9e81a730-2822-4c70-8061-9bbecf05022d">
<di:waypoint x="436.0" y="118.0"/>
<di:waypoint x="486.0" y="118.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="userTask_79a63b4f-96a7-43d7-aab3-e8e0e83769e5" id="BPMNShape_8c455164-1097-43ca-814f-6d601735b27a">
<dc:Bounds height="80.0" width="100.0" x="586.0" y="78.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_9156c1d4-f756-447b-a384-e3bf17c43ff4" id="BPMNEdge_47ba6c2b-fd10-4faf-8ee9-cbe019282080">
<di:waypoint x="536.0" y="118.0"/>
<di:waypoint x="586.0" y="118.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="serviceTask_9d976f99-f8fb-4705-ae6d-a606758111f4" id="BPMNShape_d2e257f4-4c63-44e6-a8ab-d3179a83682c">
<dc:Bounds height="80.0" width="100.0" x="736.0" y="78.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_b82e04ab-a0cc-4969-989a-1ec64d74d990" id="BPMNEdge_e5727f31-71a0-4f03-8a9d-7aca2cd9999a">
<di:waypoint x="686.0" y="118.0"/>
<di:waypoint x="736.0" y="118.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="endEvent_affc9949-819a-4b79-98bd-0f2fd844d014" id="BPMNShape_4a1b2f6f-6929-4fd7-b6cf-9f49410242d7">
<dc:Bounds height="36.0" width="36.0" x="886.0" y="100.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_f0f99688-25b1-417e-9a5d-0d17503cb3ba" id="BPMNEdge_28346c07-6da9-41d2-bcf2-76a9583ea933">
<di:waypoint x="836.0" y="118.0"/>
<di:waypoint x="886.0" y="118.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="userTask_7b955191-5741-44df-b7ba-d154ddfbe616" id="BPMNShape_1c62b32d-2c17-48b0-bbc7-ac0074c97e62">
<dc:Bounds height="80.0" width="100.0" x="586.0" y="208.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_29bab2ba-6108-4731-94c3-93a6955d1946" id="BPMNEdge_40c826c8-638d-4cd2-b9a1-ccdfa9a5ee6e">
<di:waypoint x="511.0" y="143.0"/>
<di:waypoint x="511.0" y="248.0"/>
<di:waypoint x="586.0" y="248.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="exclusiveGateway_5aa645c5-a5e7-4453-8498-8462092b85b1" id="BPMNShape_36d66f18-3b46-4fde-9342-3ccd8d0f838d" isMarkerVisible="true">
<dc:Bounds height="50.0" width="50.0" x="736.0" y="223.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_74d95e16-7907-4000-9ffb-cdba8c3ddde4" id="BPMNEdge_257a94d2-a5f6-4a88-9503-f5b9fd65cc7e">
<di:waypoint x="686.0" y="248.0"/>
<di:waypoint x="736.0" y="248.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="endEvent_68057c88-fa46-43cc-a93c-774b26be7b50" id="BPMNShape_2dff264a-5f15-44d9-ba38-b962be76ea74">
<dc:Bounds height="36.0" width="36.0" x="836.0" y="230.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_3bf21b37-c534-4541-b84f-03d3fe05c989" id="BPMNEdge_0a149725-d17c-4b6f-b7db-7854d0a27b00">
<di:waypoint x="786.0" y="248.0"/>
<di:waypoint x="836.0" y="248.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_6987bcb8-5f6a-467b-9b25-e21b90dd0d4d" id="BPMNEdge_8b25f14c-9653-42ab-a57f-48fc07bd7ee8">
<di:waypoint x="761.0" y="273.0"/>
<di:waypoint x="761.0" y="118.0"/>
<di:waypoint x="336.0" y="118.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
By comparing it to the above xml, I notice a few new <bpmndi ...> elements not present before.
Missing isExecutable parameter in process
// create a process
Process process = modelInstance.newInstance(Process.class);
process.setExecutable(true);
We're going to build a workflow management system and We're embedding the camunda engine Rest API into our Rest Application.
Now I have Inventory defined like this:
public class Inventory {
private String objectName;
private int objectCount;
// getters and setters
}
and this is a sample workflow:
in xml:
<?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_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3">
<bpmn:process id="test" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1v6clcy</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1v6clcy" sourceRef="StartEvent_1" targetRef="testtask" />
<bpmn:userTask id="testtask" name="testtask" camunda:formKey="testform">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="inventories" label="name" type="List<org.example.Inventory>" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1v6clcy</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_07kdfp4</bpmn:outgoing>
</bpmn:userTask>
<bpmn:endEvent id="EndEvent_0vm605w">
<bpmn:incoming>SequenceFlow_07kdfp4</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_07kdfp4" sourceRef="testtask" targetRef="EndEvent_0vm605w" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="test">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="173" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1v6clcy_di" bpmnElement="SequenceFlow_1v6clcy">
<di:waypoint xsi:type="dc:Point" x="209" y="120" />
<di:waypoint xsi:type="dc:Point" x="275" y="120" />
<bpmndi:BPMNLabel>
<dc:Bounds x="242" y="99" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_1s01hea_di" bpmnElement="testtask">
<dc:Bounds x="275" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0vm605w_di" bpmnElement="EndEvent_0vm605w">
<dc:Bounds x="439" y="109" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="412" y="149" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_07kdfp4_di" bpmnElement="SequenceFlow_07kdfp4">
<di:waypoint xsi:type="dc:Point" x="375" y="120" />
<di:waypoint xsi:type="dc:Point" x="407" y="120" />
<di:waypoint xsi:type="dc:Point" x="407" y="127" />
<di:waypoint xsi:type="dc:Point" x="439" y="127" />
<bpmndi:BPMNLabel>
<dc:Bounds x="377" y="117.5" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
I'll eventually have a html form which will submit something like this:
{
"inventories" : [{"name": "banana","count": 3},{"name":"orange","count": 4}]
}
I want to submit this to /task/{id}/submit-form but I don't know what to put as type.
I tried putting the type in modeler as List<org.example.Inventory> but the rest api throws an exception when deploying the process definition like this:
org.camunda.bpm.engine.ProcessEngineException: ENGINE-09005 Could not parse BPMN process. Errors:
* unknown type 'List' | org.example/PM.bpmn | line 65 | column 90
I've seen this example as well but I'm only using the Rest API not the whole bpm platform(besides we prefer to have pure html forms).
So how to do it ? what should I put in type ?
my camunda.cfg.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<property name="databaseSchemaUpdate" value="true" />
</bean>
</beans>
my processengineprovider:
public class MyProcessEngineProvider implements ProcessEngineProvider {
#Override
public ProcessEngine getDefaultProcessEngine() {
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = engine.getRepositoryService();
repositoryService.createDeployment()
.addClasspathResource("org.newtech/PM.bpmn")
.deploy();
return engine;
}
#Override
public ProcessEngine getProcessEngine(String s) {
return getDefaultProcessEngine();
}
#Override
public Set<String> getProcessEngineNames() {
Set<String> names = new HashSet<>(1);
names.add("default");
return names;
}
}
Process Compilation error : org.drools.lang.descr.ProcessDescr#4c60d6e9
com/sample/Process_com_sample_ruleflowsample.java (21:862) : Type mismatch: cannot convert from int to String
com/sample/Process_com_sample_ruleflowsample.java (29:1151) : Type mismatch: cannot convert from int to String
This is my ruleflowsample.rf under src/main/rules that is throwing the above error.
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
type="RuleFlow" name="ruleflowsample" id="com.sample.ruleflowsample" package-name="com.sample" >
<header>
<imports>
<import name="com.sample.Employee" />
</imports>
<variables>
<variable name="caffeineIntake" >
<type name="org.drools.process.core.datatype.impl.type.FloatDataType" />
</variable>
</variables>
</header>
<nodes>
<start id="1" name="Start" x="12" y="129" width="48" height="48" />
<split id="2" name="Gateway" x="101" y="128" width="49" height="49" type="2" >
<constraints>
<constraint toNodeId="4" toType="DROOLS_DEFAULT" name="Coffee" priority="1" type="code" dialect="java" >return caffeineIntake>0.105F;</constraint>
<constraint toNodeId="5" toType="DROOLS_DEFAULT" name="Tea" priority="1" type="code" dialect="java" >return caffeineIntake>0.04F;</constraint>
</constraints>
</split>
<actionNode id="4" name="Coffee" x="198" y="205" width="80" height="48" >
<action type="expression" dialect="java" >String noOfCups = 1;
System.out.println("No of coffee cups = "+noOfCups);
System.out.println("caffeineIntake");</action>
</actionNode>
<actionNode id="5" name="Tea" x="196" y="61" width="80" height="48" >
<action type="expression" dialect="java" >String noOfCups = 1;
System.out.println("No of tea cups = "+noOfCups);
System.out.println("caffeineIntake");</action>
</actionNode>
<end id="6" name="End" x="386" y="127" width="48" height="48" />
<join id="7" name="Gateway" x="311" y="127" width="49" height="49" type="2" />
</nodes>
<connections>
<connection from="1" to="2" />
<connection from="2" to="4" />
<connection from="2" to="5" />
<connection from="7" to="6" />
<connection from="5" to="7" />
<connection from="4" to="7" />
</connections>
</process>
I know the error is occurring because of this line: System.out.println("caffeineIntake");
I want to access this input variable i.e. caffeineIntake to perform some operation on it.
The error is not occurring because of this line: System.out.println("caffeineIntake");
It is occurring because of the Dialect option selection:
Using this option as mvel rather than java resolved the issue.
Well,
from my point of view
String noOfCups = 1;
is the problem.
perhaps change it to
String noOfCups = "1";
I'm trying to create a multi axis chart with one plot which shows a bar chart and another plot which shows a line chart. I found the multi axis chart to do this, but when I run my code only one plot is showing (image provided here). Any idea's on how to solve this?
In my search for a solution I came accross this post, but when I execute this it just does the same.
(When I switch the order of the barChart and lineChart in the jrxml it only shows the lineChart. Code provided below.)
Java bean
public class OperationSuccessrateBean {
private Integer week;
private Integer totalOrders;
private Double successrate;
public OperationSuccessrateBean(Integer week, Integer totalOrders, Double successrate) {
this.week = week;
this.totalOrders = totalOrders;
this.successrate = successrate;
}
public Integer getWeek() {
return week;
}
public Integer getTotalOrders() {
return totalOrders;
}
public Double getSuccessrate() {
return successrate;
}
}
Java: Filling the report
private void setOperationSuccessrate(String operationType, Map<String, Object> paramMap,
List<OperationSuccessrateBean> successrateBeans) {
paramMap.put(operationType + "_OPERATION_SUCCESSRATE_SET", new JRBeanCollectionDataSource(
successrateBeans));
paramMap.put(operationType + "_OPERATION_SUCCESSRATE_ORDERS_SET",
new JRBeanCollectionDataSource(successrateBeans));
}
jrxml: define datasets and parameters
<subDataset name="loadOperationSuccesrateSet" uuid="247b3e44-ef98-45f4-a909-e8b5678acc8f">
<field name="week" class="java.lang.Integer"/>
<field name="totalOrders" class="java.lang.Integer"/>
<field name="successrate" class="java.lang.Double"/>
</subDataset>
<subDataset name="loadOperationSuccesrateOrdersSet" uuid="247b3e44-ef98-45f4-a909-e8b5678acc8f">
<field name="week" class="java.lang.Integer"/>
<field name="totalOrders" class="java.lang.Integer"/>
<field name="successrate" class="java.lang.Double"/>
</subDataset>
<parameter name="LOAD_OPERATION_SUCCESSRATE_SET" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource" isForPrompting="false"/>
<parameter name="LOAD_OPERATION_SUCCESSRATE_ORDERS_SET" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource" isForPrompting="false"/>
jrxml: multi chart
<multiAxisChart>
<chart evaluationTime="Report">
<reportElement x="0" y="41" width="550" height="200" uuid="5078c050-dd35-43db-bf30-d04152672bd6"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<multiAxisPlot>
<plot/>
<axis position="rightOrBottom">
<lineChart>
<chart evaluationTime="Report">
<reportElement positionType="Float" x="0" y="25" width="270" height="175" backcolor="#FFFFFF" uuid="013d7a7d-2280-46d0-8d44-d537d062a182"/>
<chartTitle color="#000000"/>
<chartSubtitle color="#000000"/>
<chartLegend textColor="#000000" backgroundColor="#FFFFFF"/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="loadOperationSuccesrateSet" uuid="53426928-1245-4443-97da-509b00ba1f98">
<dataSourceExpression><![CDATA[$P{LOAD_OPERATION_SUCCESSRATE_SET}]]></dataSourceExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["Success rate"]]></seriesExpression>
<categoryExpression><![CDATA[$F{week}]]></categoryExpression>
<valueExpression><![CDATA[$F{successrate}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat/>
</categoryAxisFormat>
<valueAxisLabelExpression><![CDATA["Success rate"]]></valueAxisLabelExpression>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" tickLabelMask="#0%" axisLineColor="#000000">
<labelFont/>
</axisFormat>
</valueAxisFormat>
<rangeAxisMinValueExpression><![CDATA[0]]></rangeAxisMinValueExpression>
<rangeAxisMaxValueExpression><![CDATA[1]]></rangeAxisMaxValueExpression>
</linePlot>
</lineChart>
</axis>
<axis>
<barChart>
<chart evaluationTime="Report">
<reportElement x="0" y="0" width="0" height="0" backcolor="#FFFFFF" uuid="15a15c89-a2d4-4971-b4b3-1c5ac224a91e"/>
<chartTitle color="#000000"/>
<chartSubtitle color="#000000"/>
<chartLegend textColor="#000000" backgroundColor="#FFFFFF"/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="loadOperationSuccesrateOrdersSet" uuid="4d001c74-1fde-47cd-b525-85d828d6ccf2">
<dataSourceExpression><![CDATA[$P{LOAD_OPERATION_SUCCESSRATE_ORDERS_SET}]]></dataSourceExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["TotalOrders"]]></seriesExpression>
<categoryExpression><![CDATA[$F{week}]]></categoryExpression>
<valueExpression><![CDATA[$F{totalOrders}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot/>
<itemLabel/>
<categoryAxisFormat>
<axisFormat/>
</categoryAxisFormat>
<valueAxisLabelExpression><![CDATA["# Orders"]]></valueAxisLabelExpression>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" tickLabelMask="# ##0" axisLineColor="#000000">
<labelFont/>
</axisFormat>
</valueAxisFormat>
<rangeAxisMinValueExpression><![CDATA[0]]></rangeAxisMinValueExpression>
</barPlot>
</barChart>
</axis>
</multiAxisPlot>
</multiAxisChart>
When I run my code without the multi axis chart so just to create the 2 plots next to each other it creates just fine. So I assume the data is correctely passed to the report.
The relevant libraries I use are:
net.sf.jasperreports.engine-6.4.0.jar
jfreechart-1.0.19.jar
Lorenz, I had the same issue.
The reason for the missing graph was that I was passing directly a net.sf.jasperreports.engine.data.JRBeanCollectionDataSource as parameter in the report.
Apparently for this to work you have to pass a List:
<parameter name="FIRST_DATA_SOURCE" class="java.util.List" isForPrompting="false"/>
<parameter name="SECOND_DATA_SOURCE" class="java.util.List" isForPrompting="false"/>
and then create the JRBeanCollectionDataSource inside the report:
<dataset>
<datasetRun subDataset="YOUR_SUBDATASET" uuid="a5941ba5-2088-4a31-8236-64704b54d979">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{FIRST_DATA_SOURCE})]]></dataSourceExpression>
</datasetRun>
</dataset>
In the post you referenced it was used this way and it worked!