This is an automated email from the ASF dual-hosted git repository.
fjtiradosarti pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git
The following commit(s) were added to refs/heads/main by this push:
new 41cfa19c6a [Fix #3415] Allow constant values in user task assignments
(#3416)
41cfa19c6a is described below
commit 41cfa19c6ad1652f814f1f2be5e51ca5f2c25e03
Author: Francisco Javier Tirado Sarti
<[email protected]>
AuthorDate: Wed Feb 28 10:21:03 2024 +0100
[Fix #3415] Allow constant values in user task assignments (#3416)
* [Fix #3415] Allow constant values in user task assignments
* [Fix #3415] Gonzalos comments
---
.../canonical/ActivityGenerationModelTest.java | 1 +
.../src/test/resources/BPMN2-UserTask.bpmn2 | 194 +++++++++++++++------
.../compiler/canonical/UserTaskModelMetaData.java | 29 ++-
.../process/core/context/variable/Variable.java | 7 +-
4 files changed, 153 insertions(+), 78 deletions(-)
diff --git
a/jbpm/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/canonical/ActivityGenerationModelTest.java
b/jbpm/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/canonical/ActivityGenerationModelTest.java
index ef979162bb..55eda0b45e 100644
---
a/jbpm/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/canonical/ActivityGenerationModelTest.java
+++
b/jbpm/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/canonical/ActivityGenerationModelTest.java
@@ -151,6 +151,7 @@ public class ActivityGenerationModelTest extends
JbpmBpmn2TestCase {
KogitoWorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
assertThat(workItem.getParameter("ActorId")).isEqualTo("john");
+ assertThat(workItem.getParameter("fixedValue")).isEqualTo("pepe");
processInstance.completeWorkItem(workItem.getStringId(), null,
SecurityPolicy.of(new StaticIdentityProvider("john")));
assertThat(processInstance.status()).isEqualTo(STATE_COMPLETED);
}
diff --git a/jbpm/jbpm-bpmn2/src/test/resources/BPMN2-UserTask.bpmn2
b/jbpm/jbpm-bpmn2/src/test/resources/BPMN2-UserTask.bpmn2
index 85e40725b6..8ec23a6c65 100755
--- a/jbpm/jbpm-bpmn2/src/test/resources/BPMN2-UserTask.bpmn2
+++ b/jbpm/jbpm-bpmn2/src/test/resources/BPMN2-UserTask.bpmn2
@@ -1,64 +1,146 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<definitions id="Definition"
- targetNamespace="http://www.example.org/MinimalExample"
- typeLanguage="http://www.java.com/javaTypes"
- expressionLanguage="http://www.mvel.org/2.0"
- xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL
BPMN20.xsd"
- 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:tns="http://www.jboss.org/drools">
-
- <itemDefinition id="_sItem" structureRef="String" />
- <process processType="Private" isExecutable="true" id="UserTask" name="User
Task" >
- <property id="s" itemSubjectRef="_sItem"/>
- <!-- nodes -->
- <startEvent id="_1" name="StartProcess" />
- <userTask id="_2" name="Hello" >
- <ioSpecification>
- <inputSet>
- </inputSet>
- <outputSet>
- </outputSet>
- </ioSpecification>
- <potentialOwner>
- <resourceAssignmentExpression>
- <formalExpression>john</formalExpression>
- </resourceAssignmentExpression>
- </potentialOwner>
- </userTask>
- <endEvent id="_3" name="EndProcess" >
- <terminateEventDefinition/>
- </endEvent>
-
- <!-- connections -->
- <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
- <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" />
-
- </process>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:bpsim="http://www.bpsim.org/schemas/1.0"
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="_1aP80Le_EDyttMyrW6hRzg"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd
http://www. [...]
+ <bpmn2:itemDefinition id="_sItem" structureRef="String"/>
+ <bpmn2:itemDefinition id="__2_SkippableInputXItem" structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_PriorityInputXItem" structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_CommentInputXItem" structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_DescriptionInputXItem" structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_CreatedByInputXItem" structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_TaskNameInputXItem" structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_GroupIdInputXItem" structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_ContentInputXItem" structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_NotStartedReassignInputXItem"
structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_NotCompletedReassignInputXItem"
structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_NotStartedNotifyInputXItem"
structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_NotCompletedNotifyInputXItem"
structureRef="Object"/>
+ <bpmn2:itemDefinition id="__2_fixedValueInputXItem" structureRef="String"/>
+ <bpmn2:collaboration id="_D7750A25-5E14-45E3-A2DA-93F7E305C4AB"
name="Default Collaboration">
+ <bpmn2:participant id="_BACF0FB2-F397-4F2D-9041-5D68D40E6875" name="Pool
Participant" processRef="BPMN2_UserTask"/>
+ </bpmn2:collaboration>
+ <bpmn2:process id="UserTask" isExecutable="true" processType="Private"
name="User Task">
+ <bpmn2:property id="s" itemSubjectRef="_sItem" name="s"/>
+ <bpmn2:sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2"/>
+ <bpmn2:sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3"/>
+ <bpmn2:startEvent id="_1" name="StartProcess">
+ <bpmn2:extensionElements>
+ <drools:metaData name="elementname">
+ <drools:metaValue><![CDATA[StartProcess]]></drools:metaValue>
+ </drools:metaData>
+ </bpmn2:extensionElements>
+ <bpmn2:outgoing>_1-_2</bpmn2:outgoing>
+ </bpmn2:startEvent>
+ <bpmn2:userTask id="_2" name="Hello">
+ <bpmn2:extensionElements>
+ <drools:metaData name="elementname">
+ <drools:metaValue><![CDATA[Hello]]></drools:metaValue>
+ </drools:metaData>
+ </bpmn2:extensionElements>
+ <bpmn2:incoming>_1-_2</bpmn2:incoming>
+ <bpmn2:outgoing>_2-_3</bpmn2:outgoing>
+ <bpmn2:ioSpecification>
+ <bpmn2:dataInput id="_2_TaskNameInputX" drools:dtype="Object"
itemSubjectRef="__2_TaskNameInputXItem" name="TaskName"/>
+ <bpmn2:dataInput id="_2_fixedValueInputX" drools:dtype="String"
itemSubjectRef="__2_fixedValueInputXItem" name="fixedValue"/>
+ <bpmn2:dataInput id="_2_SkippableInputX" drools:dtype="Object"
itemSubjectRef="__2_SkippableInputXItem" name="Skippable"/>
+ <bpmn2:inputSet>
+ <bpmn2:dataInputRefs>_2_TaskNameInputX</bpmn2:dataInputRefs>
+ <bpmn2:dataInputRefs>_2_fixedValueInputX</bpmn2:dataInputRefs>
+ <bpmn2:dataInputRefs>_2_SkippableInputX</bpmn2:dataInputRefs>
+ </bpmn2:inputSet>
+ </bpmn2:ioSpecification>
+ <bpmn2:dataInputAssociation>
+ <bpmn2:targetRef>_2_TaskNameInputX</bpmn2:targetRef>
+ <bpmn2:assignment>
+ <bpmn2:from
xsi:type="bpmn2:tFormalExpression"><![CDATA[Task]]></bpmn2:from>
+ <bpmn2:to
xsi:type="bpmn2:tFormalExpression"><![CDATA[_2_TaskNameInputX]]></bpmn2:to>
+ </bpmn2:assignment>
+ </bpmn2:dataInputAssociation>
+ <bpmn2:dataInputAssociation>
+ <bpmn2:targetRef>_2_fixedValueInputX</bpmn2:targetRef>
+ <bpmn2:assignment>
+ <bpmn2:from
xsi:type="bpmn2:tFormalExpression"><![CDATA[pepe]]></bpmn2:from>
+ <bpmn2:to
xsi:type="bpmn2:tFormalExpression"><![CDATA[_2_fixedValueInputX]]></bpmn2:to>
+ </bpmn2:assignment>
+ </bpmn2:dataInputAssociation>
+ <bpmn2:dataInputAssociation>
+ <bpmn2:targetRef>_2_SkippableInputX</bpmn2:targetRef>
+ <bpmn2:assignment>
+ <bpmn2:from
xsi:type="bpmn2:tFormalExpression"><![CDATA[false]]></bpmn2:from>
+ <bpmn2:to
xsi:type="bpmn2:tFormalExpression"><![CDATA[_2_SkippableInputX]]></bpmn2:to>
+ </bpmn2:assignment>
+ </bpmn2:dataInputAssociation>
+ <bpmn2:potentialOwner id="_1aVcYLe_EDyttMyrW6hRzg">
+ <bpmn2:resourceAssignmentExpression id="_1aVcYbe_EDyttMyrW6hRzg">
+ <bpmn2:formalExpression>john</bpmn2:formalExpression>
+ </bpmn2:resourceAssignmentExpression>
+ </bpmn2:potentialOwner>
+ </bpmn2:userTask>
+ <bpmn2:endEvent id="_3" name="EndProcess">
+ <bpmn2:extensionElements>
+ <drools:metaData name="elementname">
+ <drools:metaValue><![CDATA[EndProcess]]></drools:metaValue>
+ </drools:metaData>
+ </bpmn2:extensionElements>
+ <bpmn2:incoming>_2-_3</bpmn2:incoming>
+ <bpmn2:terminateEventDefinition/>
+ </bpmn2:endEvent>
+ </bpmn2:process>
<bpmndi:BPMNDiagram>
- <bpmndi:BPMNPlane bpmnElement="UserTask" >
- <bpmndi:BPMNShape bpmnElement="_1" >
- <dc:Bounds x="16" y="16" width="48" height="48" />
+ <bpmndi:BPMNPlane bpmnElement="BPMN2_UserTask">
+ <bpmndi:BPMNShape id="shape__3" bpmnElement="_3">
+ <dc:Bounds height="56" width="56" x="228" y="16"/>
</bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="_2" >
- <dc:Bounds x="96" y="16" width="100" height="48" />
+ <bpmndi:BPMNShape id="shape__2" bpmnElement="_2">
+ <dc:Bounds height="48" width="100" x="96" y="16"/>
</bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="_3" >
- <dc:Bounds x="228" y="16" width="48" height="48" />
+ <bpmndi:BPMNShape id="shape__1" bpmnElement="_1">
+ <dc:Bounds height="56" width="56" x="16" y="16"/>
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge bpmnElement="_1-_2" >
- <di:waypoint x="40" y="40" />
- <di:waypoint x="146" y="40" />
+ <bpmndi:BPMNEdge id="edge_shape__2_to_shape__3" bpmnElement="_2-_3">
+ <di:waypoint x="146" y="40"/>
+ <di:waypoint x="252" y="40"/>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="_2-_3" >
- <di:waypoint x="146" y="40" />
- <di:waypoint x="252" y="40" />
+ <bpmndi:BPMNEdge id="edge_shape__1_to_shape__2" bpmnElement="_1-_2">
+ <di:waypoint x="40" y="40"/>
+ <di:waypoint x="146" y="40"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
-
-</definitions>
\ No newline at end of file
+ <bpmn2:relationship type="BPSimData">
+ <bpmn2:extensionElements>
+ <bpsim:BPSimData>
+ <bpsim:Scenario id="default" name="Simulationscenario">
+ <bpsim:ScenarioParameters/>
+ <bpsim:ElementParameters elementRef="_2">
+ <bpsim:TimeParameters>
+ <bpsim:ProcessingTime>
+ <bpsim:NormalDistribution mean="0" standardDeviation="0"/>
+ </bpsim:ProcessingTime>
+ </bpsim:TimeParameters>
+ <bpsim:ResourceParameters>
+ <bpsim:Availability>
+ <bpsim:FloatingParameter value="0"/>
+ </bpsim:Availability>
+ <bpsim:Quantity>
+ <bpsim:FloatingParameter value="0"/>
+ </bpsim:Quantity>
+ </bpsim:ResourceParameters>
+ <bpsim:CostParameters>
+ <bpsim:UnitCost>
+ <bpsim:FloatingParameter value="0"/>
+ </bpsim:UnitCost>
+ </bpsim:CostParameters>
+ </bpsim:ElementParameters>
+ <bpsim:ElementParameters elementRef="_1">
+ <bpsim:TimeParameters>
+ <bpsim:ProcessingTime>
+ <bpsim:NormalDistribution mean="0" standardDeviation="0"/>
+ </bpsim:ProcessingTime>
+ </bpsim:TimeParameters>
+ </bpsim:ElementParameters>
+ </bpsim:Scenario>
+ </bpsim:BPSimData>
+ </bpmn2:extensionElements>
+ <bpmn2:source>_1aP80Le_EDyttMyrW6hRzg</bpmn2:source>
+ <bpmn2:target>_1aP80Le_EDyttMyrW6hRzg</bpmn2:target>
+ </bpmn2:relationship>
+</bpmn2:definitions>
\ No newline at end of file
diff --git
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/UserTaskModelMetaData.java
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/UserTaskModelMetaData.java
index 7f8de5e2ac..e2134e0e02 100644
---
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/UserTaskModelMetaData.java
+++
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/UserTaskModelMetaData.java
@@ -24,10 +24,10 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
-import java.util.regex.Matcher;
import org.jbpm.process.core.context.variable.Variable;
import org.jbpm.process.core.context.variable.VariableScope;
+import org.jbpm.process.core.datatype.DataType;
import org.jbpm.process.core.datatype.DataTypeResolver;
import org.jbpm.util.PatternConstants;
import org.jbpm.workflow.core.node.HumanTaskNode;
@@ -199,13 +199,12 @@ public class UserTaskModelMetaData {
.orElse(processVariableScope.findVariable(entry.getValue()));
if (variable == null) {
- Matcher matcher =
PatternConstants.PARAMETER_MATCHER.matcher(entry.getValue());
- if (matcher.find()) {
- variable = new Variable();
- variable.setName(entry.getKey());
-
variable.setType(DataTypeResolver.fromType(inputTypes.get(entry.getKey()),
Thread.currentThread().getContextClassLoader()));
- } else {
- throw new IllegalStateException("Task " +
humanTaskNode.getName() + " (input) " + entry.getKey() + " reference not
existing variable " + entry.getValue());
+ variable = new Variable();
+ variable.setName(entry.getKey());
+ DataType type =
DataTypeResolver.fromType(inputTypes.get(entry.getKey()),
Thread.currentThread().getContextClassLoader());
+ variable.setType(type);
+ if
(!PatternConstants.PARAMETER_MATCHER.matcher(entry.getValue()).find()) {
+ variable.setValue(type.readValue(entry.getValue()));
}
}
@@ -313,14 +312,12 @@ public class UserTaskModelMetaData {
.orElse(processVariableScope.findVariable(entry.getValue()));
if (variable == null) {
- // check if given mapping is an expression
- Matcher matcher =
PatternConstants.PARAMETER_MATCHER.matcher(entry.getValue());
- if (matcher.find()) {
- variable = new Variable();
- variable.setName(entry.getKey());
-
variable.setType(DataTypeResolver.fromType(outputTypes.get(entry.getKey()),
Thread.currentThread().getContextClassLoader()));
- } else {
- throw new IllegalStateException("Task " +
humanTaskNode.getName() + " (output) " + entry.getKey() + " reference not
existing variable " + entry.getValue());
+ variable = new Variable();
+ variable.setName(entry.getKey());
+ DataType type =
DataTypeResolver.fromType(outputTypes.get(entry.getKey()),
Thread.currentThread().getContextClassLoader());
+ variable.setType(type);
+ if
(!PatternConstants.PARAMETER_MATCHER.matcher(entry.getValue()).find()) {
+ variable.setValue(type.readValue(entry.getValue()));
}
}
diff --git
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/Variable.java
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/Variable.java
index e33a97a6da..f70815a044 100755
---
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/Variable.java
+++
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/Variable.java
@@ -128,12 +128,7 @@ public class Variable implements TypeObject, ValueObject,
Serializable {
if (this.type.verifyDataType(value)) {
this.value = value;
} else {
- final StringBuilder sb = new StringBuilder();
- sb.append("Value <");
- sb.append(value);
- sb.append("> is not valid for datatype: ");
- sb.append(this.type);
- throw new IllegalArgumentException(sb.toString());
+ throw new IllegalArgumentException("Value <" + value + "> of
datatype: " + value.getClass() + " is not valid for datatype: " +
type.getObjectClass());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]