Class CmmnOperation
java.lang.Object
org.flowable.cmmn.engine.impl.agenda.operation.CmmnOperation
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
AbstractCaseInstanceOperation
,AbstractPlanItemInstanceOperation
An abstract base class for CMMN engine based operations supporting general functionalities.
- Author:
- Joram Barrez, Micha Kiener
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
childPlanItemInstanceForPlanItemExists
(PlanItemInstanceContainer planItemInstanceContainer, PlanItem planItem) protected void
createPlanItemInstanceIfNeeded
(CommandContext commandContext, PlanItem planItem, Case caseModel, CaseInstanceEntity caseInstanceEntity, PlanItemInstanceEntity stagePlanItemInstanceEntity, String tenantId, List<PlanItemInstanceEntity> newPlanItemInstances) Checks whether the provided plan item needs an instance to be created and optionally activated directly (e.g.protected List<PlanItemInstanceEntity>
createPlanItemInstancesForNewOrReactivatedStage
(CommandContext commandContext, Case caseModel, List<PlanItem> planItems, List<PlanItem> directlyReactivatedPlanItems, CaseInstanceEntity caseInstanceEntity, PlanItemInstanceEntity stagePlanItemInstanceEntity, String tenantId) Creates child plan items for the provided stage, might also be the root plan model.protected Boolean
evaluateReactivationCondition
(String condition, CaseInstanceEntity caseInstanceEntity, VariableContainer parentPlanItemInstance) Evaluates the provided reactivation condition, which might also be null or a constant like "true".protected PlanItemCreationType
evaluateReactivationRule
(ReactivationRule reactivationRule, CaseInstanceEntity caseInstanceEntity, VariableContainer parentPlanItemInstance) Evaluates the provided reactivation rule for a matching rule and returns its creation type, if at least one was matching.protected CaseInstanceEntity
Returns the case instance entity using the entity manager by getting the case instance id throughgetCaseInstanceId()
and returning the case instance entity accordingly.abstract String
protected PlanItemCreationType
getPlanItemCreationOrReactivationType
(CaseInstanceEntity caseInstanceEntity, Case caseModel, PlanItem planItem, VariableContainer parentPlanItemInstance) Evaluates the reactivation rule for the provided plan item, if the case is a reactivated one, otherwise the creation type will always be default.getPlanModel
(CaseInstanceEntity caseInstanceEntity) protected Stage
getStage
(PlanItemInstanceEntity planItemInstanceEntity) boolean
boolean
isNoop()
boolean
isStage
(PlanItemInstanceEntity planItemInstanceEntity) void
protected void
setRepetitionCounter
(PlanItemInstanceEntity repeatingPlanItemInstanceEntity, int counterValue)
-
Field Details
-
commandContext
-
isNoop
protected boolean isNoop
-
-
Constructor Details
-
CmmnOperation
public CmmnOperation() -
CmmnOperation
-
-
Method Details
-
getCaseInstanceId
- Returns:
- The id of the case instance related to this operation.
-
getCaseInstance
Returns the case instance entity using the entity manager by getting the case instance id throughgetCaseInstanceId()
and returning the case instance entity accordingly. If there is no id provided, this method will return null, but not throw an exception.- Returns:
- the case instance entity according the case instance id involved in this operation or null, if there is none involved
-
getStage
-
isStage
-
getPlanModel
-
createPlanItemInstancesForNewOrReactivatedStage
protected List<PlanItemInstanceEntity> createPlanItemInstancesForNewOrReactivatedStage(CommandContext commandContext, Case caseModel, List<PlanItem> planItems, List<PlanItem> directlyReactivatedPlanItems, CaseInstanceEntity caseInstanceEntity, PlanItemInstanceEntity stagePlanItemInstanceEntity, String tenantId) Creates child plan items for the provided stage, might also be the root plan model. It supports both scenarios: a case, running the first time or even a reactivated one which has some reactivation rules to be considered when creating child plan items.- Parameters:
commandContext
- the command context to run this method withcaseModel
- the case model the given stage or plan model is contained withinplanItems
- the plan items of the stage to be checked for creationdirectlyReactivatedPlanItems
- an optional list of plan items already having been reactivated as part of phase 1 of a case reactivation, might be null or empty, specially for a regular casecaseInstanceEntity
- the case instance entity, must be provided as it is used to check for a first time running case or a reactivated onestagePlanItemInstanceEntity
- the optional stage plan item instance, if already available, might be null in very specific use cases (e.g. cross-stage activities, etc)tenantId
- the id of the tenant to run within- Returns:
- the list of created plan item instances for this stage or plan model
-
createPlanItemInstanceIfNeeded
protected void createPlanItemInstanceIfNeeded(CommandContext commandContext, PlanItem planItem, Case caseModel, CaseInstanceEntity caseInstanceEntity, PlanItemInstanceEntity stagePlanItemInstanceEntity, String tenantId, List<PlanItemInstanceEntity> newPlanItemInstances) Checks whether the provided plan item needs an instance to be created and optionally activated directly (e.g. for a reactivation use case). It checks the plan items reactivation model, if the case is a reactivated one.- Parameters:
commandContext
- the command context in which this method runsplanItem
- the plan item to check for an item creationcaseModel
- the case model used to get the creation modecaseInstanceEntity
- the case entity used to check, if it is a reactivated onestagePlanItemInstanceEntity
- the stage the plan item belongs totenantId
- the id of the tenant the case belongs tonewPlanItemInstances
- the array where the new plan item instance will be added, if it was created
-
childPlanItemInstanceForPlanItemExists
protected boolean childPlanItemInstanceForPlanItemExists(PlanItemInstanceContainer planItemInstanceContainer, PlanItem planItem) -
isEventListenerWithAvailableCondition
-
setRepetitionCounter
protected void setRepetitionCounter(PlanItemInstanceEntity repeatingPlanItemInstanceEntity, int counterValue) -
getPlanItemCreationOrReactivationType
protected PlanItemCreationType getPlanItemCreationOrReactivationType(CaseInstanceEntity caseInstanceEntity, Case caseModel, PlanItem planItem, VariableContainer parentPlanItemInstance) Evaluates the reactivation rule for the provided plan item, if the case is a reactivated one, otherwise the creation type will always be default. For a reactivated case, the plan items optional reactivation rule is considered and its creation type returned. If there is none but there is a default one specified on the reactivation listener, that creation type is returned instead.- Parameters:
caseInstanceEntity
- the case instance to check for a reactivated casecaseModel
- the case model to obtain the reactivation listenerplanItem
- the plan item to be evaluated for creation typeparentPlanItemInstance
- the parent plan item (e.g. stage or plan model) of the plan item- Returns:
- the plan item creation type according all the rules for creation and reactivation
-
evaluateReactivationRule
protected PlanItemCreationType evaluateReactivationRule(ReactivationRule reactivationRule, CaseInstanceEntity caseInstanceEntity, VariableContainer parentPlanItemInstance) Evaluates the provided reactivation rule for a matching rule and returns its creation type, if at least one was matching. The rules are evaluated the following way:- reactivation condition: only if explicitly evaluating to true, that type is returned, if false or not existing, it is not considered
- ignore condition: only if explicitly evaluating to true, that type is returned, if false or not existing, it is not considered
- default condition: if explicitly evaluating to either true OR false, type default or type ignore is returned, only if there is no condition, nothing is returned
- Parameters:
reactivationRule
- the reactivation rule to evaluate against the given context of either the parent plan item instance or the case instance itselfcaseInstanceEntity
- the case instance which must not be nullparentPlanItemInstance
- the optional parent plan item instance (e.g. stage or plan model), if already existing, might be null- Returns:
- the evaluated creation type, if explicitly matched against one of the rules, null, if no matching rule was found
-
evaluateReactivationCondition
protected Boolean evaluateReactivationCondition(String condition, CaseInstanceEntity caseInstanceEntity, VariableContainer parentPlanItemInstance) Evaluates the provided reactivation condition, which might also be null or a constant like "true". If it is a condition, it is evaluated in the context of the provided variable container.- Parameters:
condition
- the condition to be evaluated, might be null or a constant like "true"caseInstanceEntity
- the case instance to be used as the expression context, if the parent plan item is not yet available (null)parentPlanItemInstance
- the optional parent plan item to be used as the expression evaluation context- Returns:
- the condition evaluation result
-
markAsNoop
public void markAsNoop() -
isNoop
public boolean isNoop()
-