Skip to content

Commit fc80559

Browse files
committed
APSPOL-4114: Support Fluxnova namespace
1 parent 14a5690 commit fc80559

10 files changed

Lines changed: 338 additions & 59 deletions

engine/src/main/java/org/finos/fluxnova/bpm/engine/impl/HistoryTimeToLiveParser.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.finos.fluxnova.bpm.engine.impl;
1919

2020
import static org.finos.fluxnova.bpm.engine.impl.bpmn.parser.BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS;
21+
import static org.finos.fluxnova.bpm.engine.impl.bpmn.parser.BpmnParse.FLUXNOVA_BPMN_EXTENSIONS_NS;
2122

2223
import java.util.Objects;
2324
import org.finos.fluxnova.bpm.engine.exception.NotAllowedException;
@@ -73,7 +74,12 @@ public void validate(Integer historyTimeToLive) {
7374
}
7475

7576
public Integer parse(Element processElement, String definitionKey, boolean skipEnforceTtl) {
77+
// Check camunda namespace first for backward compatibility
7678
String historyTimeToLiveString = processElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "historyTimeToLive");
79+
if (historyTimeToLiveString == null) {
80+
// Fallback to fluxnova namespace
81+
historyTimeToLiveString = processElement.attributeNS(FLUXNOVA_BPMN_EXTENSIONS_NS, "historyTimeToLive");
82+
}
7783

7884
return parseAndValidate(historyTimeToLiveString, definitionKey, skipEnforceTtl);
7985
}

engine/src/main/java/org/finos/fluxnova/bpm/engine/impl/bpmn/behavior/ClassDelegateActivityBehavior.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,8 @@ protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution executi
123123
}
124124
}
125125

126+
public String getClassName() {
127+
return className;
128+
}
129+
126130
}

engine/src/main/java/org/finos/fluxnova/bpm/engine/impl/bpmn/behavior/ServiceTaskDelegateExpressionActivityBehavior.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,8 @@ protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution executi
138138
}
139139
}
140140

141+
public String getExpressionText() {
142+
return expression.getExpressionText();
143+
}
144+
141145
}

engine/src/main/java/org/finos/fluxnova/bpm/engine/impl/bpmn/behavior/ServiceTaskExpressionActivityBehavior.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@ public Void call() throws Exception {
5757
});
5858

5959
}
60+
61+
public String getExpressionText() {
62+
return expression.getExpressionText();
63+
}
6064
}

engine/src/main/java/org/finos/fluxnova/bpm/engine/impl/bpmn/parser/BpmnParse.java

Lines changed: 97 additions & 59 deletions
Large diffs are not rendered by default.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3+
* under one or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information regarding copyright
5+
* ownership. Camunda licenses this file to you under the Apache License,
6+
* Version 2.0; you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.finos.fluxnova.bpm.engine.test.bpmn.parse;
18+
19+
import static org.assertj.core.api.Assertions.assertThat;
20+
21+
import org.finos.fluxnova.bpm.engine.RepositoryService;
22+
import org.finos.fluxnova.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior;
23+
import org.finos.fluxnova.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior;
24+
import org.finos.fluxnova.bpm.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior;
25+
import org.finos.fluxnova.bpm.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior;
26+
import org.finos.fluxnova.bpm.engine.impl.context.Context;
27+
import org.finos.fluxnova.bpm.engine.impl.interceptor.Command;
28+
import org.finos.fluxnova.bpm.engine.impl.interceptor.CommandContext;
29+
import org.finos.fluxnova.bpm.engine.impl.interceptor.CommandExecutor;
30+
import org.finos.fluxnova.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity;
31+
import org.finos.fluxnova.bpm.engine.impl.pvm.process.ActivityImpl;
32+
import org.finos.fluxnova.bpm.engine.test.Deployment;
33+
import org.finos.fluxnova.bpm.engine.test.util.PluggableProcessEngineTest;
34+
import org.junit.jupiter.api.Test;
35+
36+
/**
37+
* Tests to verify that the BPMN parser recognizes fluxnova: namespace attributes
38+
* for service task implementation (class, delegateExpression, type, expression)
39+
* in addition to the legacy camunda: namespace.
40+
*
41+
* This ensures backward compatibility while supporting the Fluxnova namespace.
42+
*/
43+
public class FluxnovaNamespaceServiceTaskTest extends PluggableProcessEngineTest {
44+
45+
46+
@Test
47+
@Deployment(resources = "org/finos/fluxnova/bpm/engine/test/bpmn/parse/FluxnovaNamespaceServiceTaskTest.testFluxnovaClass.bpmn20.xml")
48+
public void testFluxnovaClassAttributeIsRecognized() {
49+
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
50+
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
51+
@Override
52+
public ProcessDefinitionEntity execute(CommandContext commandContext) {
53+
return Context.getProcessEngineConfiguration().getDeploymentCache()
54+
.findDeployedLatestProcessDefinitionByKey("fluxnovaClassDelegation");
55+
}
56+
});
57+
58+
assertThat(processDefinitionEntity).isNotNull();
59+
ActivityImpl activity = processDefinitionEntity.findActivity("javaService");
60+
assertThat(activity).isNotNull();
61+
assertThat(activity.getActivityBehavior()).isInstanceOf(ClassDelegateActivityBehavior.class);
62+
ClassDelegateActivityBehavior behavior = (ClassDelegateActivityBehavior) activity.getActivityBehavior();
63+
assertThat(behavior.getClassName()).isEqualTo("org.finos.fluxnova.bpm.engine.test.bpmn.servicetask.util.ToUppercase");
64+
}
65+
66+
@Test
67+
@Deployment(resources = "org/finos/fluxnova/bpm/engine/test/bpmn/parse/FluxnovaNamespaceServiceTaskTest.testFluxnovaDelegateExpression.bpmn20.xml")
68+
public void testFluxnovaDelegateExpressionAttributeIsRecognized() {
69+
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
70+
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
71+
@Override
72+
public ProcessDefinitionEntity execute(CommandContext commandContext) {
73+
return Context.getProcessEngineConfiguration().getDeploymentCache()
74+
.findDeployedLatestProcessDefinitionByKey("fluxnovaDelegateExpressionTest");
75+
}
76+
});
77+
78+
assertThat(processDefinitionEntity).isNotNull();
79+
ActivityImpl activity = processDefinitionEntity.findActivity("javaService");
80+
81+
assertThat(activity).isNotNull();
82+
assertThat(activity.getActivityBehavior()).isInstanceOf(ServiceTaskDelegateExpressionActivityBehavior.class);
83+
84+
ServiceTaskDelegateExpressionActivityBehavior behavior =
85+
(ServiceTaskDelegateExpressionActivityBehavior) activity.getActivityBehavior();
86+
assertThat(behavior.getExpressionText()).isEqualTo("${toUppercaseBean}");
87+
}
88+
89+
@Test
90+
@Deployment(resources = "org/finos/fluxnova/bpm/engine/test/bpmn/parse/FluxnovaNamespaceServiceTaskTest.testFluxnovaExpression.bpmn20.xml")
91+
public void testFluxnovaExpressionAttributeIsRecognized() {
92+
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
93+
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
94+
@Override
95+
public ProcessDefinitionEntity execute(CommandContext commandContext) {
96+
return Context.getProcessEngineConfiguration().getDeploymentCache()
97+
.findDeployedLatestProcessDefinitionByKey("fluxnovaExpressionTest");
98+
}
99+
});
100+
101+
assertThat(processDefinitionEntity).isNotNull();
102+
ActivityImpl activity = processDefinitionEntity.findActivity("javaService");
103+
104+
assertThat(activity).isNotNull();
105+
assertThat(activity.getActivityBehavior()).isInstanceOf(ServiceTaskExpressionActivityBehavior.class);
106+
107+
ServiceTaskExpressionActivityBehavior behavior =
108+
(ServiceTaskExpressionActivityBehavior) activity.getActivityBehavior();
109+
assertThat(behavior.getExpressionText()).isEqualTo("${execution.setVariable('myVar', 'test')}");
110+
}
111+
112+
@Test
113+
@Deployment(resources = "org/finos/fluxnova/bpm/engine/test/bpmn/parse/FluxnovaNamespaceServiceTaskTest.testFluxnovaType.bpmn20.xml")
114+
public void testFluxnovaTypeAttributeIsRecognized() {
115+
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
116+
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
117+
@Override
118+
public ProcessDefinitionEntity execute(CommandContext commandContext) {
119+
return Context.getProcessEngineConfiguration().getDeploymentCache()
120+
.findDeployedLatestProcessDefinitionByKey("fluxnovaTypeTest");
121+
}
122+
});
123+
124+
assertThat(processDefinitionEntity).isNotNull();
125+
ActivityImpl activity = processDefinitionEntity.findActivity("externalService");
126+
127+
assertThat(activity).isNotNull();
128+
assertThat(activity.getActivityBehavior()).isInstanceOf(ExternalTaskActivityBehavior.class);
129+
}
130+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions id="definitions"
3+
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
4+
xmlns:fluxnova="http://fluxnova.finos.org/schema/1.0/bpmn"
5+
targetNamespace="Examples">
6+
7+
<process id="fluxnovaClassDelegation" isExecutable="true">
8+
9+
<startEvent id="theStart" />
10+
11+
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="javaService" />
12+
13+
<serviceTask id="javaService"
14+
name="Java service invocation with fluxnova namespace"
15+
fluxnova:class="org.finos.fluxnova.bpm.engine.test.bpmn.servicetask.util.ToUppercase" />
16+
17+
<sequenceFlow id="flow2" sourceRef="javaService" targetRef="theEnd" />
18+
19+
<endEvent id="theEnd" />
20+
21+
</process>
22+
23+
</definitions>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions id="definitions"
3+
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
4+
xmlns:fluxnova="http://fluxnova.finos.org/schema/1.0/bpmn"
5+
targetNamespace="Examples">
6+
7+
<process id="fluxnovaDelegateExpressionTest" isExecutable="true">
8+
9+
<startEvent id="theStart" />
10+
11+
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="javaService" />
12+
13+
<serviceTask id="javaService"
14+
name="Java service with fluxnova delegateExpression"
15+
fluxnova:delegateExpression="${toUppercaseBean}" />
16+
17+
<sequenceFlow id="flow2" sourceRef="javaService" targetRef="theEnd" />
18+
19+
<endEvent id="theEnd" />
20+
21+
</process>
22+
23+
</definitions>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions id="definitions"
3+
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
4+
xmlns:fluxnova="http://fluxnova.finos.org/schema/1.0/bpmn"
5+
targetNamespace="Examples">
6+
7+
<process id="fluxnovaExpressionTest" isExecutable="true">
8+
9+
<startEvent id="theStart" />
10+
11+
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="javaService" />
12+
13+
<serviceTask id="javaService"
14+
name="Java service with fluxnova expression"
15+
fluxnova:expression="${execution.setVariable('myVar', 'test')}" />
16+
17+
<sequenceFlow id="flow2" sourceRef="javaService" targetRef="theEnd" />
18+
19+
<endEvent id="theEnd" />
20+
21+
</process>
22+
23+
</definitions>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions id="definitions"
3+
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
4+
xmlns:fluxnova="http://fluxnova.finos.org/schema/1.0/bpmn"
5+
targetNamespace="Examples">
6+
7+
<process id="fluxnovaTypeTest" isExecutable="true">
8+
9+
<startEvent id="theStart" />
10+
11+
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="externalService" />
12+
13+
<serviceTask id="externalService"
14+
name="External service with fluxnova type"
15+
fluxnova:type="external"
16+
fluxnova:topic="testTopic" />
17+
18+
<sequenceFlow id="flow2" sourceRef="externalService" targetRef="theEnd" />
19+
20+
<endEvent id="theEnd" />
21+
22+
</process>
23+
24+
</definitions>

0 commit comments

Comments
 (0)