Skip to content

Commit

Permalink
Merge branch 'main' into flowable-release-7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphr committed Aug 29, 2024
2 parents 3544bba + 97a241d commit f458a81
Show file tree
Hide file tree
Showing 40 changed files with 2,944 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ public interface PlanItemInstanceQuery extends Query<PlanItemInstanceQuery, Plan
PlanItemInstanceQuery planItemDefinitionType(String planItemDefinitionType);
PlanItemInstanceQuery planItemDefinitionTypes(List<String> planItemDefinitionType);

/**
* Begin an OR statement. Make sure you invoke the endOr method at the end of your OR statement.
*/
PlanItemInstanceQuery or();

/**
* End an OR statement.
*/
PlanItemInstanceQuery endOr();

/**
* @return The query will only return ended (completed/terminated/occurred/exited) plan item instances.
* No runtime instances will be returned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;

import org.apache.commons.lang3.StringUtils;
import org.flowable.cmmn.converter.exception.XMLException;
import org.flowable.cmmn.converter.export.AssociationExport;
import org.flowable.cmmn.converter.export.CaseExport;
Expand Down Expand Up @@ -71,7 +70,6 @@
import org.flowable.cmmn.model.Sentry;
import org.flowable.cmmn.model.SentryOnPart;
import org.flowable.cmmn.model.Stage;
import org.flowable.cmmn.model.Task;
import org.flowable.cmmn.model.TextAnnotation;
import org.flowable.cmmn.model.TimerEventListener;
import org.flowable.common.engine.api.FlowableException;
Expand Down Expand Up @@ -528,20 +526,7 @@ protected void procesPlanItem(CmmnModel cmmnModel, PlanItem planItem, PlanItemDe
}

if (!planItem.getExitCriteria().isEmpty()) {
boolean exitCriteriaAllowed = true;
if (planItemDefinition instanceof Task) {
Task task = (Task) planItemDefinition;
if (!task.isBlocking() && StringUtils.isEmpty(task.getBlockingExpression())) {
exitCriteriaAllowed = false;
}
}

if (exitCriteriaAllowed) {
resolveExitCriteriaSentry(planItem);
} else {
LOGGER.warn("Ignoring exit criteria on plan item {}", planItem.getId());
planItem.getExitCriteria().clear();
}
resolveExitCriteriaSentry(planItem);
}

if (planItemDefinition instanceof Stage) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* 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.flowable.test.cmmn.converter;

import static org.assertj.core.api.Assertions.assertThat;

import org.flowable.cmmn.model.CmmnModel;
import org.flowable.cmmn.model.HumanTask;
import org.flowable.cmmn.model.PlanItem;
import org.flowable.cmmn.model.PlanItemDefinition;
import org.flowable.test.cmmn.converter.util.CmmnXmlConverterTest;

public class HumanTaskWithEntryAndExitCriterionCmmnXmlConverterTest {

@CmmnXmlConverterTest("org/flowable/test/cmmn/converter/humanTaskWithEntryAndExitCriterion.cmmn")
public void validateModel(CmmnModel cmmnModel) {
assertThat(cmmnModel).isNotNull();

PlanItemDefinition itemDefinition = cmmnModel.findPlanItemDefinition("task1");

assertThat(itemDefinition).isInstanceOf(HumanTask.class);
PlanItem planItem = cmmnModel.findPlanItem("planItem1");
assertThat(planItem.getEntryCriteria()).hasSize(1);
assertThat(planItem.getExitCriteria()).hasSize(1);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<case id="test">
<casePlanModel id="onecaseplanmodel1">
<planItem id="planItemexpandedStage1" name="Stage 1" definitionRef="expandedStage1"></planItem>
<stage id="expandedStage1" name="Stage 1">
<planItem id="planItem1" definitionRef="task1">
<itemControl>
<extensionElements>
<flowable:completionNeutralRule></flowable:completionNeutralRule>
</extensionElements>
<repetitionRule flowable:counterVariable="repetitionCounter" flowable:maxInstanceCount="1">
<extensionElements></extensionElements>
</repetitionRule>
<manualActivationRule></manualActivationRule>
</itemControl>
<entryCriterion id="entryCriterion5" sentryRef="sentryentryCriterion5"></entryCriterion>
<exitCriterion id="exitCriterion1" sentryRef="sentryexitCriterion1"></exitCriterion>
</planItem>
<sentry id="sentryentryCriterion5" />
<sentry id="sentryexitCriterion1" />
<humanTask id="task1" isBlocking="false" />
</stage>
</casePlanModel>
</case>
</definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.apache.commons.lang3.StringUtils;
import org.flowable.cmmn.api.delegate.DelegatePlanItemInstance;
import org.flowable.cmmn.api.runtime.PlanItemInstanceState;
import org.flowable.cmmn.engine.impl.behavior.CoreCmmnTriggerableActivityBehavior;
import org.flowable.cmmn.engine.impl.behavior.PlanItemActivityBehavior;
import org.flowable.cmmn.engine.impl.persistence.entity.PlanItemInstanceEntity;
Expand Down Expand Up @@ -92,6 +93,10 @@ protected void handleChildPlanItemInstances(CommandContext commandContext, Deleg
} else if (PlanItemTransition.EXIT.equals(transition)) {
CommandContextUtil.getAgenda(commandContext).planExitPlanItemInstanceOperation(childPlanItemInstance, null, null, null);
}

} else if (PlanItemTransition.TERMINATE.equals(transition) || PlanItemTransition.EXIT.equals(transition)) {
CommandContextUtil.getCmmnEngineConfiguration(commandContext).getListenerNotificationHelper()
.executeLifecycleListeners(commandContext, childPlanItemInstance, childPlanItemInstance.getState(), PlanItemInstanceState.TERMINATED);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,11 @@ protected void setSafeInValueLists(PlanItemInstanceQueryImpl planItemInstanceQue
if (planItemInstanceQuery.getInvolvedGroups() != null) {
planItemInstanceQuery.setSafeInvolvedGroups(createSafeInValuesList(planItemInstanceQuery.getInvolvedGroups()));
}

if (planItemInstanceQuery.getOrQueryObjects() != null && !planItemInstanceQuery.getOrQueryObjects().isEmpty()) {
for (PlanItemInstanceQueryImpl oInstanceQuery : planItemInstanceQuery.getOrQueryObjects()) {
setSafeInValueLists(oInstanceQuery);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected void doMovePlanItemState(CaseInstanceChangeState caseInstanceChangeSta

executeChangePlanItemDefinitionWithNewTargetIds(caseInstanceChangeState, originalCaseDefinitionId, commandContext);

navigatePlanItemInstances(currentPlanItemInstances, caseInstanceChangeState.getCaseDefinitionToMigrateTo());
navigatePlanItemInstances(currentPlanItemInstances, caseInstanceChangeState.getCaseDefinitionToMigrateTo(), originalCaseDefinitionId);

// Set the case variables first so they are available during the change state logic
caseInstance.setVariables(caseInstanceChangeState.getCaseVariables());
Expand Down Expand Up @@ -856,9 +856,11 @@ protected void setCaseDefinitionIdForPlanItemInstances(Map<String, List<PlanItem
}
}

protected void navigatePlanItemInstances(Map<String, List<PlanItemInstanceEntity>> stagesByPlanItemDefinitionId, CaseDefinition caseDefinition) {
protected void navigatePlanItemInstances(Map<String, List<PlanItemInstanceEntity>> stagesByPlanItemDefinitionId, CaseDefinition caseDefinition, String originalCaseDefinitionId) {
if (caseDefinition != null) {
TaskService taskService = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService();
CmmnModel originalCmmnModel = CaseDefinitionUtil.getCmmnModel(originalCaseDefinitionId);
CmmnModel targetCmmnModel = CaseDefinitionUtil.getCmmnModel(caseDefinition.getId());
for (List<PlanItemInstanceEntity> planItemInstances : stagesByPlanItemDefinitionId.values()) {
for (PlanItemInstanceEntity planItemInstance : planItemInstances) {

Expand All @@ -869,6 +871,31 @@ protected void navigatePlanItemInstances(Map<String, List<PlanItemInstanceEntity
.subScopeId(planItemInstance.getId()).scopeType(ScopeTypes.CMMN).singleResult();
if (task != null) {
task.setScopeDefinitionId(caseDefinition.getId());
PlanItemDefinition originalTaskDef = originalCmmnModel.findPlanItemDefinition(task.getTaskDefinitionKey());
PlanItemDefinition targetTaskDef = targetCmmnModel.findPlanItemDefinition(task.getTaskDefinitionKey());
if (originalTaskDef != null && targetTaskDef != null && originalTaskDef instanceof HumanTask && targetTaskDef instanceof HumanTask) {
HumanTask originalHumanTask = (HumanTask) originalTaskDef;
HumanTask targetHumanTask = (HumanTask) targetTaskDef;

if (taskPropertyValueIsDifferent(originalHumanTask.getName(), targetHumanTask.getName())) {
task.setName(targetHumanTask.getName());
}

if (taskPropertyValueIsDifferent(originalHumanTask.getFormKey(), targetHumanTask.getFormKey())) {
task.setFormKey(targetHumanTask.getFormKey());
}

if (taskPropertyValueIsDifferent(originalHumanTask.getCategory(), targetHumanTask.getCategory())) {
task.setCategory(targetHumanTask.getCategory());
}

if (taskPropertyValueIsDifferent(originalHumanTask.getDocumentation(), targetHumanTask.getDocumentation())) {
task.setDescription(targetHumanTask.getDocumentation());
}
}

CmmnHistoryManager cmmnHistoryManager = cmmnEngineConfiguration.getCmmnHistoryManager();
cmmnHistoryManager.recordTaskInfoChange(task, cmmnEngineConfiguration.getClock().getCurrentTime());
}
}
}
Expand Down Expand Up @@ -1334,4 +1361,8 @@ protected <T extends PlanItemDefinitionMapping> boolean evaluateCondition(Variab
return true;
}

protected boolean taskPropertyValueIsDifferent(String originalValue, String targetValue) {
return (StringUtils.isNotEmpty(originalValue) && !originalValue.equals(targetValue)) ||
(StringUtils.isEmpty(originalValue) && StringUtils.isNotEmpty(targetValue));
}
}
Loading

0 comments on commit f458a81

Please sign in to comment.