Skip to content

Commit d4d26c8

Browse files
Allow exit criterion on non blocking task to prevent loss on case model import
1 parent 51c7631 commit d4d26c8

File tree

7 files changed

+112
-109
lines changed

7 files changed

+112
-109
lines changed

modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import javax.xml.validation.SchemaFactory;
4242
import javax.xml.validation.Validator;
4343

44-
import org.apache.commons.lang3.StringUtils;
4544
import org.flowable.cmmn.converter.exception.XMLException;
4645
import org.flowable.cmmn.converter.export.AssociationExport;
4746
import org.flowable.cmmn.converter.export.CaseExport;
@@ -71,7 +70,6 @@
7170
import org.flowable.cmmn.model.Sentry;
7271
import org.flowable.cmmn.model.SentryOnPart;
7372
import org.flowable.cmmn.model.Stage;
74-
import org.flowable.cmmn.model.Task;
7573
import org.flowable.cmmn.model.TextAnnotation;
7674
import org.flowable.cmmn.model.TimerEventListener;
7775
import org.flowable.common.engine.api.FlowableException;
@@ -528,20 +526,7 @@ protected void procesPlanItem(CmmnModel cmmnModel, PlanItem planItem, PlanItemDe
528526
}
529527

530528
if (!planItem.getExitCriteria().isEmpty()) {
531-
boolean exitCriteriaAllowed = true;
532-
if (planItemDefinition instanceof Task) {
533-
Task task = (Task) planItemDefinition;
534-
if (!task.isBlocking() && StringUtils.isEmpty(task.getBlockingExpression())) {
535-
exitCriteriaAllowed = false;
536-
}
537-
}
538-
539-
if (exitCriteriaAllowed) {
540-
resolveExitCriteriaSentry(planItem);
541-
} else {
542-
LOGGER.warn("Ignoring exit criteria on plan item {}", planItem.getId());
543-
planItem.getExitCriteria().clear();
544-
}
529+
resolveExitCriteriaSentry(planItem);
545530
}
546531

547532
if (planItemDefinition instanceof Stage) {

modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/ExitCriteriaNonBlockingCmmnXmlConverterTest.java

-70
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* Licensed under the Apache License, Version 2.0 (the "License");
2+
* you may not use this file except in compliance with the License.
3+
* You may obtain a copy of the License at
4+
*
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
package org.flowable.test.cmmn.converter;
14+
15+
import static org.assertj.core.api.Assertions.assertThat;
16+
17+
import org.flowable.cmmn.model.CmmnModel;
18+
import org.flowable.cmmn.model.HumanTask;
19+
import org.flowable.cmmn.model.PlanItem;
20+
import org.flowable.cmmn.model.PlanItemDefinition;
21+
import org.flowable.test.cmmn.converter.util.CmmnXmlConverterTest;
22+
23+
public class HumanTaskWithEntryAndExitCriterionCmmnXmlConverterTest {
24+
25+
@CmmnXmlConverterTest("org/flowable/test/cmmn/converter/humanTaskWithEntryAndExitCriterion.cmmn")
26+
public void validateModel(CmmnModel cmmnModel) {
27+
assertThat(cmmnModel).isNotNull();
28+
29+
PlanItemDefinition itemDefinition = cmmnModel.findPlanItemDefinition("task1");
30+
31+
assertThat(itemDefinition).isInstanceOf(HumanTask.class);
32+
PlanItem planItem = cmmnModel.findPlanItem("planItem1");
33+
assertThat(planItem.getEntryCriteria()).hasSize(1);
34+
assertThat(planItem.getExitCriteria()).hasSize(1);
35+
}
36+
37+
}

modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/exit-criteria-non-blocking.cmmn

-23
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flowable="http://flowable.org/cmmn" xmlns:cmmndi="http://www.omg.org/spec/CMMN/20151109/CMMNDI" xmlns:dc="http://www.omg.org/spec/CMMN/20151109/DC" xmlns:di="http://www.omg.org/spec/CMMN/20151109/DI" xmlns:design="http://flowable.org/design" targetNamespace="http://flowable.org/cmmn" design:palette="flowable-engage-case-palette">
3+
<case id="test">
4+
<casePlanModel id="onecaseplanmodel1">
5+
<planItem id="planItemexpandedStage1" name="Stage 1" definitionRef="expandedStage1"></planItem>
6+
<stage id="expandedStage1" name="Stage 1">
7+
<planItem id="planItem1" definitionRef="task1">
8+
<itemControl>
9+
<extensionElements>
10+
<flowable:completionNeutralRule></flowable:completionNeutralRule>
11+
</extensionElements>
12+
<repetitionRule flowable:counterVariable="repetitionCounter" flowable:maxInstanceCount="1">
13+
<extensionElements></extensionElements>
14+
</repetitionRule>
15+
<manualActivationRule></manualActivationRule>
16+
</itemControl>
17+
<entryCriterion id="entryCriterion5" sentryRef="sentryentryCriterion5"></entryCriterion>
18+
<exitCriterion id="exitCriterion1" sentryRef="sentryexitCriterion1"></exitCriterion>
19+
</planItem>
20+
<sentry id="sentryentryCriterion5" />
21+
<sentry id="sentryexitCriterion1" />
22+
<humanTask id="task1" isBlocking="false" />
23+
</stage>
24+
</casePlanModel>
25+
</case>
26+
</definitions>

modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/runtime/HumanTaskTest.java

+24
Original file line numberDiff line numberDiff line change
@@ -596,4 +596,28 @@ public Void execute(CommandContext commandContext) {
596596
cmmnEngineConfiguration.getJobServiceConfiguration().setJobHandlers(existingJobHandlers);
597597
}
598598
}
599+
600+
@Test
601+
@CmmnDeployment
602+
public void testTaskNonBlockingWithEntryAndExitCriterion() {
603+
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder()
604+
.caseDefinitionKey("myCase")
605+
.start();
606+
607+
assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()).planItemDefinitionId("task1").list()).hasSize(1);
608+
assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId())
609+
.planItemDefinitionId("task1")
610+
.planItemInstanceStateEnabled().list()).hasSize(1);
611+
612+
cmmnRuntimeService.startPlanItemInstance(cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId())
613+
.planItemDefinitionId("task1")
614+
.planItemInstanceStateEnabled().singleResult().getId());
615+
616+
assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId())
617+
.planItemDefinitionId("task1")
618+
.planItemInstanceStateActive().list()).hasSize(0);
619+
620+
assertThat(cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).list()).hasSize(0);
621+
assertThat(cmmnRuntimeService.createCaseInstanceQuery().count()).isZero();
622+
}
599623
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flowable="http://flowable.org/cmmn" xmlns:cmmndi="http://www.omg.org/spec/CMMN/20151109/CMMNDI" xmlns:dc="http://www.omg.org/spec/CMMN/20151109/DC" xmlns:di="http://www.omg.org/spec/CMMN/20151109/DI" xmlns:design="http://flowable.org/design" targetNamespace="http://flowable.org/cmmn" design:palette="flowable-engage-case-palette">
3+
<case id="myCase">
4+
<casePlanModel id="onecaseplanmodel1">
5+
<planItem id="planItemexpandedStage1" name="Stage 1" definitionRef="expandedStage1"></planItem>
6+
<stage id="expandedStage1" name="Stage 1">
7+
<planItem id="planItem1" definitionRef="task1">
8+
<itemControl>
9+
<manualActivationRule></manualActivationRule>
10+
</itemControl>
11+
<entryCriterion id="entryCriterion5" sentryRef="sentryentryCriterion5"></entryCriterion>
12+
<exitCriterion id="exitCriterion1" sentryRef="sentryexitCriterion1"></exitCriterion>
13+
</planItem>
14+
<sentry id="sentryentryCriterion5" />
15+
<sentry id="sentryexitCriterion1">
16+
<ifPart>
17+
<condition>${false}</condition>
18+
</ifPart>
19+
</sentry>
20+
<humanTask id="task1" isBlocking="false" />
21+
</stage>
22+
</casePlanModel>
23+
</case>
24+
</definitions>

0 commit comments

Comments
 (0)