Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add change state waiting for repetition #3574

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public ChangePlanItemStateCmd(ChangePlanItemStateBuilderImpl changePlanItemState
public Void execute(CommandContext commandContext) {
if (changePlanItemStateBuilder.getActivatePlanItemDefinitions().size() == 0 &&
changePlanItemStateBuilder.getTerminatePlanItemDefinitions().size() == 0 &&
changePlanItemStateBuilder.getChangeToAvailableStatePlanItemDefinitions().size() == 0) {
changePlanItemStateBuilder.getChangeToAvailableStatePlanItemDefinitions().size() == 0 &&
changePlanItemStateBuilder.getWaitingForRepetitionPlanItemDefinitions().size() == 0 &&
changePlanItemStateBuilder.getRemoveWaitingForRepetitionPlanItemDefinitions().size() == 0) {

throw new FlowableIllegalArgumentException("No move plan item instance or (activate) plan item definition ids provided");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public void movePlanItemInstanceState(ChangePlanItemStateBuilderImpl changePlanI
.setActivatePlanItemDefinitions(changePlanItemStateBuilder.getActivatePlanItemDefinitions())
.setTerminatePlanItemDefinitions(changePlanItemStateBuilder.getTerminatePlanItemDefinitions())
.setChangePlanItemDefinitionsToAvailable(changePlanItemStateBuilder.getChangeToAvailableStatePlanItemDefinitions())
.setWaitingForRepetitionPlanItemDefinitions(changePlanItemStateBuilder.getWaitingForRepetitionPlanItemDefinitions())
.setRemoveWaitingForRepetitionPlanItemDefinitions(changePlanItemStateBuilder.getRemoveWaitingForRepetitionPlanItemDefinitions())
.setCaseVariables(changePlanItemStateBuilder.getCaseVariables())
.setChildInstanceTaskVariables(changePlanItemStateBuilder.getChildInstanceTaskVariables());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,57 @@ public void testChangeHumanTaskFromStage() {

assertCaseInstanceEnded(caseInstance);
}

@Test
@CmmnDeployment
public void testChangeHumanTaskRepetition() {
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("myCase").start();
Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
assertThat(task.getName()).isEqualTo("Task One");

cmmnTaskService.complete(task.getId());

cmmnRuntimeService.createChangePlanItemStateBuilder()
.caseInstanceId(caseInstance.getId())
.addWaitingForRepetitionPlanItemDefinitionId("task2")
.changeState();

List<PlanItemInstance> planItemInstances = cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()).includeEnded().list();
assertThat(planItemInstances)
.extracting(PlanItemInstance::getState)
.containsExactlyInAnyOrder(PlanItemInstanceState.COMPLETED, PlanItemInstanceState.ACTIVE, PlanItemInstanceState.WAITING_FOR_REPETITION);

task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
assertThat(task.getName()).isEqualTo("Task Two");

cmmnRuntimeService.createChangePlanItemStateBuilder()
.caseInstanceId(caseInstance.getId())
.activatePlanItemDefinitionId("task1")
.changeState();

cmmnTaskService.complete(task.getId());


planItemInstances = cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()).includeEnded().list();
assertThat(planItemInstances)
.extracting(PlanItemInstance::getState)
.containsExactlyInAnyOrder(PlanItemInstanceState.COMPLETED, PlanItemInstanceState.COMPLETED, PlanItemInstanceState.ACTIVE, PlanItemInstanceState.WAITING_FOR_REPETITION);

cmmnRuntimeService.createChangePlanItemStateBuilder()
.caseInstanceId(caseInstance.getId())
.addRemoveWaitingForRepetitionPlanItemDefinitionId("task2")
.changeState();

planItemInstances = cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()).includeEnded().list();
assertThat(planItemInstances)
.extracting(PlanItemInstance::getState)
.containsExactlyInAnyOrder(PlanItemInstanceState.COMPLETED, PlanItemInstanceState.COMPLETED, PlanItemInstanceState.ACTIVE);

task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
assertThat(task.getName()).isEqualTo("Task One");

cmmnTaskService.complete(task.getId());

assertCaseInstanceEnded(caseInstance);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL"
xmlns:dc="http://www.omg.org/spec/CMMN/20151109/DC"
xmlns:di="http://www.omg.org/spec/CMMN/20151109/DI"
xmlns:cmmndi="http://www.omg.org/spec/CMMN/20151109/CMMNDI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:flowable="http://flowable.org/cmmn"
targetNamespace="http://flowable.org/cmmn">

<case id="myCase">
<casePlanModel id="myPlanModel" name="My CasePlanModel">

<planItem id="planItem1" name="Task One" definitionRef="task1" />
<planItem id="planItem2" name="Task Two" definitionRef="task2">
<entryCriterion sentryRef="sentry1" />
</planItem>

<sentry id="sentry1">
<planItemOnPart sourceRef="planItem1">
<standardEvent>complete</standardEvent>
</planItemOnPart>
</sentry>

<humanTask id="task1" name="Task One" flowable:assignee="kermit" />
<humanTask id="task2" name="Task Two" flowable:candidateGroups="test" />

</casePlanModel>
</case>

</definitions>