Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BZ807640 - Conditional sequence flow is not supported by jBPM engine
- Loading branch information
1 parent
4e36f76
commit e19270b
Showing
13 changed files
with
373 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
jbpm-bpmn2/src/test/resources/BPMN2-ConditionalFlowWithoutGateway.bpmn2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.omg.org/bpmn20" xmlns:bpmn2="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" xmlns:drools="http://www.jboss.org/drools" id="_OSAkwHM-EeGROt7AmBKBUg" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" targetNamespace="http://www.omg.org/bpmn20"> | ||
<bpmn2:itemDefinition id="_xItem" structureRef="Integer"/> | ||
<bpmn2:process id="designer.conditional-flow" drools:packageName="org.jboss.qa.brms.jbpm.functional.bpmn2.designer" name="conditional-flow" isExecutable="true"> | ||
<bpmn2:property id="x" itemSubjectRef="_xItem"/> | ||
<bpmn2:startEvent id="_CF9831F9-AFE1-4F57-86C4-662C73090C42" drools:bgcolor="#ffffff" name="start"> | ||
<bpmn2:outgoing>_1897CC4D-9026-42F4-A3E9-663EBD1B00F3</bpmn2:outgoing> | ||
</bpmn2:startEvent> | ||
<bpmn2:scriptTask id="_E4D6AD1A-F7EC-445A-B43E-12566A22221E" name="script" scriptFormat="http://www.java.com/java"> | ||
<bpmn2:incoming>_1897CC4D-9026-42F4-A3E9-663EBD1B00F3</bpmn2:incoming> | ||
<bpmn2:outgoing>_99179D07-2AD3-4F1D-9851-11A6F92179C5</bpmn2:outgoing> | ||
<bpmn2:outgoing>_53A779A0-66A0-4A12-BD82-6CCDDE3D5CE9</bpmn2:outgoing> | ||
<bpmn2:outgoing>_0DD13F4B-C5E8-4AA3-84EE-B98461099FC4</bpmn2:outgoing> | ||
<bpmn2:script><![CDATA[kcontext.setVariable("x", 5);]]></bpmn2:script> | ||
</bpmn2:scriptTask> | ||
<bpmn2:endEvent id="_5DC17F4C-389B-4150-A034-39D599347FB2" drools:bgcolor="#ffffff" name="end1"> | ||
<bpmn2:incoming>_99179D07-2AD3-4F1D-9851-11A6F92179C5</bpmn2:incoming> | ||
</bpmn2:endEvent> | ||
<bpmn2:endEvent id="_F5220DC7-5A9A-460C-8125-FB17947EA334" drools:bgcolor="#ffffff" name="end2"> | ||
<bpmn2:incoming>_53A779A0-66A0-4A12-BD82-6CCDDE3D5CE9</bpmn2:incoming> | ||
</bpmn2:endEvent> | ||
<bpmn2:endEvent id="_40A0F353-CEA3-4EE9-850C-260D1D48BB13" drools:bgcolor="#ffffff" name="end3"> | ||
<bpmn2:incoming>_0DD13F4B-C5E8-4AA3-84EE-B98461099FC4</bpmn2:incoming> | ||
</bpmn2:endEvent> | ||
<bpmn2:sequenceFlow id="_1897CC4D-9026-42F4-A3E9-663EBD1B00F3" sourceRef="_CF9831F9-AFE1-4F57-86C4-662C73090C42" targetRef="_E4D6AD1A-F7EC-445A-B43E-12566A22221E"/> | ||
<bpmn2:sequenceFlow id="_99179D07-2AD3-4F1D-9851-11A6F92179C5" sourceRef="_E4D6AD1A-F7EC-445A-B43E-12566A22221E" targetRef="_5DC17F4C-389B-4150-A034-39D599347FB2"> | ||
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression" id="_OSAkwXM-EeGROt7AmBKBUg" language="http://www.java.com/java"><![CDATA[return x > 1;]]></bpmn2:conditionExpression> | ||
</bpmn2:sequenceFlow> | ||
<bpmn2:sequenceFlow id="_53A779A0-66A0-4A12-BD82-6CCDDE3D5CE9" sourceRef="_E4D6AD1A-F7EC-445A-B43E-12566A22221E" targetRef="_F5220DC7-5A9A-460C-8125-FB17947EA334"> | ||
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression" id="_OSAkwnM-EeGROt7AmBKBUg" language="http://www.java.com/java"><![CDATA[return x > 10;]]></bpmn2:conditionExpression> | ||
</bpmn2:sequenceFlow> | ||
<bpmn2:sequenceFlow id="_0DD13F4B-C5E8-4AA3-84EE-B98461099FC4" sourceRef="_E4D6AD1A-F7EC-445A-B43E-12566A22221E" targetRef="_40A0F353-CEA3-4EE9-850C-260D1D48BB13"> | ||
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression" id="_OSAkw3M-EeGROt7AmBKBUg" language="http://www.java.com/java"><![CDATA[return x > 100;]]></bpmn2:conditionExpression> | ||
</bpmn2:sequenceFlow> | ||
</bpmn2:process> | ||
<bpmndi:BPMNDiagram id="_OSAkxHM-EeGROt7AmBKBUg"> | ||
<bpmndi:BPMNPlane id="_OSAkxXM-EeGROt7AmBKBUg" bpmnElement="designer.conditional-flow"> | ||
<bpmndi:BPMNShape id="_OSAkxnM-EeGROt7AmBKBUg" bpmnElement="_CF9831F9-AFE1-4F57-86C4-662C73090C42"> | ||
<dc:Bounds height="30.0" width="30.0" x="135.0" y="168.0"/> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="_OSAkx3M-EeGROt7AmBKBUg" bpmnElement="_E4D6AD1A-F7EC-445A-B43E-12566A22221E"> | ||
<dc:Bounds height="80.0" width="100.0" x="270.0" y="143.0"/> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="_OSAkyHM-EeGROt7AmBKBUg" bpmnElement="_5DC17F4C-389B-4150-A034-39D599347FB2"> | ||
<dc:Bounds height="28.0" width="28.0" x="493.0" y="59.0"/> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="_OSAkyXM-EeGROt7AmBKBUg" bpmnElement="_F5220DC7-5A9A-460C-8125-FB17947EA334"> | ||
<dc:Bounds height="28.0" width="28.0" x="493.0" y="167.0"/> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="_OSAkynM-EeGROt7AmBKBUg" bpmnElement="_40A0F353-CEA3-4EE9-850C-260D1D48BB13"> | ||
<dc:Bounds height="28.0" width="28.0" x="493.0" y="268.0"/> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNEdge id="_OSAky3M-EeGROt7AmBKBUg" bpmnElement="_1897CC4D-9026-42F4-A3E9-663EBD1B00F3"> | ||
<di:waypoint xsi:type="dc:Point" x="150.0" y="183.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="320.0" y="183.0"/> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="_OSAkzHM-EeGROt7AmBKBUg" bpmnElement="_99179D07-2AD3-4F1D-9851-11A6F92179C5"> | ||
<di:waypoint xsi:type="dc:Point" x="320.0" y="183.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="430.0" y="79.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="507.0" y="73.0"/> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="_OSAkzXM-EeGROt7AmBKBUg" bpmnElement="_53A779A0-66A0-4A12-BD82-6CCDDE3D5CE9"> | ||
<di:waypoint xsi:type="dc:Point" x="320.0" y="183.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="507.0" y="181.0"/> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="_OSAkznM-EeGROt7AmBKBUg" bpmnElement="_0DD13F4B-C5E8-4AA3-84EE-B98461099FC4"> | ||
<di:waypoint xsi:type="dc:Point" x="320.0" y="183.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="432.0" y="284.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="507.0" y="282.0"/> | ||
</bpmndi:BPMNEdge> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn2:definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...ilder/src/main/java/org/jbpm/process/builder/MultiConditionalSequenceFlowNodeBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2012 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jbpm.process.builder; | ||
|
||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
import org.drools.compiler.ReturnValueDescr; | ||
import org.drools.definition.process.Connection; | ||
import org.drools.definition.process.Node; | ||
import org.drools.definition.process.Process; | ||
import org.drools.lang.descr.ProcessDescr; | ||
import org.jbpm.process.builder.dialect.ProcessDialect; | ||
import org.jbpm.process.builder.dialect.ProcessDialectRegistry; | ||
import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator; | ||
import org.jbpm.process.instance.impl.RuleConstraintEvaluator; | ||
import org.jbpm.workflow.core.Constraint; | ||
import org.jbpm.workflow.core.impl.ConnectionRef; | ||
import org.jbpm.workflow.core.impl.ConstraintImpl; | ||
import org.jbpm.workflow.core.impl.NodeImpl; | ||
import org.jbpm.workflow.core.node.Split; | ||
|
||
public class MultiConditionalSequenceFlowNodeBuilder implements ProcessNodeBuilder { | ||
|
||
public void build(Process process, ProcessDescr processDescr, | ||
ProcessBuildContext context, Node node) { | ||
|
||
Map<ConnectionRef, Constraint> constraints = ((NodeImpl) node).getConstraints(); | ||
|
||
// exclude split as it is handled with separate builder and nodes with non conditional sequence flows | ||
if (node instanceof Split || constraints.size() == 0) { | ||
return; | ||
} | ||
|
||
// we need to clone the map, so we can update the original while iterating. | ||
Map<ConnectionRef, Constraint> map = new HashMap<ConnectionRef, Constraint>( constraints ); | ||
for ( Iterator<Map.Entry<ConnectionRef, Constraint>> it = map.entrySet().iterator(); it.hasNext(); ) { | ||
Map.Entry<ConnectionRef, Constraint> entry = it.next(); | ||
ConnectionRef connection = entry.getKey(); | ||
ConstraintImpl constraint = (ConstraintImpl) entry.getValue(); | ||
Connection outgoingConnection = null; | ||
for (Connection out: ((NodeImpl) node).getDefaultOutgoingConnections()) { | ||
if (out.getToType().equals(connection.getToType()) | ||
&& out.getTo().getId() == connection.getNodeId()) { | ||
outgoingConnection = out; | ||
} | ||
} | ||
if (outgoingConnection == null) { | ||
throw new IllegalArgumentException("Could not find outgoing connection"); | ||
} | ||
if ( "rule".equals( constraint.getType() )) { | ||
RuleConstraintEvaluator ruleConstraint = new RuleConstraintEvaluator(); | ||
ruleConstraint.setDialect( constraint.getDialect() ); | ||
ruleConstraint.setName( constraint.getName() ); | ||
ruleConstraint.setPriority( constraint.getPriority() ); | ||
ruleConstraint.setDefault( constraint.isDefault() ); | ||
((NodeImpl) node).setConstraint( outgoingConnection, ruleConstraint ); | ||
} else if ( "code".equals( constraint.getType() ) ) { | ||
ReturnValueConstraintEvaluator returnValueConstraint = new ReturnValueConstraintEvaluator(); | ||
returnValueConstraint.setDialect( constraint.getDialect() ); | ||
returnValueConstraint.setName( constraint.getName() ); | ||
returnValueConstraint.setPriority( constraint.getPriority() ); | ||
returnValueConstraint.setDefault( constraint.isDefault() ); | ||
((NodeImpl) node).setConstraint( outgoingConnection, returnValueConstraint ); | ||
|
||
ReturnValueDescr returnValueDescr = new ReturnValueDescr(); | ||
returnValueDescr.setText( constraint.getConstraint() ); | ||
|
||
ProcessDialect dialect = ProcessDialectRegistry.getDialect( constraint.getDialect() ); | ||
dialect.getReturnValueEvaluatorBuilder().build( context, returnValueConstraint, returnValueDescr, (NodeImpl) node ); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.