Class CmmnOperation

    • Field Detail

      • isNoop

        protected boolean isNoop
    • Constructor Detail

      • CmmnOperation

        public CmmnOperation()
      • CmmnOperation

        public CmmnOperation​(CommandContext commandContext)
    • Method Detail

      • getCaseInstanceId

        public abstract String getCaseInstanceId()
        Returns:
        The id of the case instance related to this operation.
      • getCaseInstance

        protected CaseInstanceEntity getCaseInstance()
        Returns the case instance entity using the entity manager by getting the case instance id through getCaseInstanceId() 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

        protected org.flowable.cmmn.model.Stage getStage​(PlanItemInstanceEntity planItemInstanceEntity)
      • getPlanModel

        public org.flowable.cmmn.model.Stage getPlanModel​(CaseInstanceEntity caseInstanceEntity)
      • createPlanItemInstancesForNewOrReactivatedStage

        protected List<PlanItemInstanceEntity> createPlanItemInstancesForNewOrReactivatedStage​(CommandContext commandContext,
                                                                                               org.flowable.cmmn.model.Case caseModel,
                                                                                               List<org.flowable.cmmn.model.PlanItem> planItems,
                                                                                               List<org.flowable.cmmn.model.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 with
        caseModel - the case model the given stage or plan model is contained within
        planItems - the plan items of the stage to be checked for creation
        directlyReactivatedPlanItems - 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 case
        caseInstanceEntity - the case instance entity, must be provided as it is used to check for a first time running case or a reactivated one
        stagePlanItemInstanceEntity - 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,
                                                      org.flowable.cmmn.model.PlanItem planItem,
                                                      org.flowable.cmmn.model.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 runs
        planItem - the plan item to check for an item creation
        caseModel - the case model used to get the creation mode
        caseInstanceEntity - the case entity used to check, if it is a reactivated one
        stagePlanItemInstanceEntity - the stage the plan item belongs to
        tenantId - the id of the tenant the case belongs to
        newPlanItemInstances - the array where the new plan item instance will be added, if it was created
      • childPlanItemInstanceForPlanItemExists

        protected boolean childPlanItemInstanceForPlanItemExists​(PlanItemInstanceContainer planItemInstanceContainer,
                                                                 org.flowable.cmmn.model.PlanItem planItem)
      • isEventListenerWithAvailableCondition

        public boolean isEventListenerWithAvailableCondition​(org.flowable.cmmn.model.PlanItem planItem)
      • setRepetitionCounter

        protected void setRepetitionCounter​(PlanItemInstanceEntity repeatingPlanItemInstanceEntity,
                                            int counterValue)
      • getPlanItemCreationOrReactivationType

        protected PlanItemCreationType getPlanItemCreationOrReactivationType​(CaseInstanceEntity caseInstanceEntity,
                                                                             org.flowable.cmmn.model.Case caseModel,
                                                                             org.flowable.cmmn.model.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 case
        caseModel - the case model to obtain the reactivation listener
        planItem - the plan item to be evaluated for creation type
        parentPlanItemInstance - 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​(org.flowable.cmmn.model.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
        Or in other words: if there is an explicit matching activate or ignore rule, activate or ignore is returned, if there is an explicit default rule, default is returned if it evaluates to true, ignore if it evaluates to false or null, if none of the above is met.
        Parameters:
        reactivationRule - the reactivation rule to evaluate against the given context of either the parent plan item instance or the case instance itself
        caseInstanceEntity - the case instance which must not be null
        parentPlanItemInstance - 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()