Ejemplo n.º 1
0
        protected internal virtual CmmnActivity createActivity(CmmnElement element, CmmnHandlerContext context)
        {
            string       id     = element.Id;
            CmmnActivity parent = context.Parent;

            CmmnActivity newActivity = null;

            if (parent != null)
            {
                newActivity = parent.createActivity(id);
            }
            else
            {
                CmmnCaseDefinition caseDefinition = context.CaseDefinition;
                newActivity = new CmmnActivity(id, caseDefinition);
            }

            newActivity.CmmnElement = element;

            CmmnActivityBehavior behavior = ActivityBehavior;

            newActivity.ActivityBehavior = behavior;

            return(newActivity);
        }
Ejemplo n.º 2
0
        public virtual CmmnCaseDefinition handleElement(Case element, CmmnHandlerContext context)
        {
            CaseDefinitionEntity definition = createActivity(element, context);

            initializeActivity(element, definition, context);

            return(definition);
        }
Ejemplo n.º 3
0
        public virtual CmmnActivity handleElement(CmmnElement element, CmmnHandlerContext context)
        {
            // create a new activity
            CmmnActivity newActivity = createActivity(element, context);

            // initialize activity
            initializeActivity(element, newActivity, context);

            return(newActivity);
        }
Ejemplo n.º 4
0
        public override CmmnActivity handleElement(CmmnElement element, CmmnHandlerContext context)
        {
            HumanTask definition = getDefinition(element);

            if (!definition.Blocking)
            {
                // The CMMN 1.0 specification says:
                // When a HumanTask is not 'blocking' (isBlocking is 'false'),
                // it can be considered a 'manual' Task, i.e., the Case management
                // system is not tracking the lifecycle of the HumanTask (instance).
                return(null);
            }

            return(base.handleElement(element, context));
        }
Ejemplo n.º 5
0
        public virtual void initializeOnParts(Sentry sentry, CmmnHandlerContext context)
        {
            ICollection <OnPart> onParts = sentry.OnParts;

            foreach (OnPart onPart in onParts)
            {
                if (onPart is PlanItemOnPart)
                {
                    initializeOnPart((PlanItemOnPart)onPart, sentry, context);
                }
                else
                {
                    initializeOnPart((CaseFileItemOnPart)onPart, sentry, context);
                }
            }
        }
Ejemplo n.º 6
0
        protected internal virtual void initializeCallableElement(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
        {
            Deployment deployment   = context.Deployment;
            string     deploymentId = null;

            if (deployment != null)
            {
                deploymentId = deployment.Id;
            }

            BaseCallableElement callableElement = createCallableElement();

            callableElement.DeploymentId = deploymentId;

            // set callableElement on behavior
            CallingTaskActivityBehavior behavior = (CallingTaskActivityBehavior)activity.ActivityBehavior;

            behavior.CallableElement = callableElement;

            // definition key
            initializeDefinitionKey(element, activity, context, callableElement);

            // binding
            initializeBinding(element, activity, context, callableElement);

            // version
            initializeVersion(element, activity, context, callableElement);

            // tenant-id
            initializeTenantId(element, activity, context, callableElement);
        }
Ejemplo n.º 7
0
        protected internal override void initializeActivity(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
        {
            base.initializeActivity(element, activity, context);

            initializeCallableElement(element, activity, context);
        }
Ejemplo n.º 8
0
 protected internal abstract string getTenantId(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context);
Ejemplo n.º 9
0
 protected internal abstract string getDefinitionKey(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context);
Ejemplo n.º 10
0
        protected internal virtual void initializeTaskDefinitionCandidateGroups(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context)
        {
            HumanTask         definition        = getDefinition(element);
            ExpressionManager expressionManager = context.ExpressionManager;

            IList <string> candidateGroups = definition.CamundaCandidateGroupsList;

            foreach (string candidateGroup in candidateGroups)
            {
                Expression candidateGroupExpression = expressionManager.createExpression(candidateGroup);
                taskDefinition.addCandidateGroupIdExpression(candidateGroupExpression);
            }
        }
Ejemplo n.º 11
0
        protected internal override void initializeCallableElement(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
        {
            base.initializeCallableElement(element, activity, context);

            ProcessOrCaseTaskActivityBehavior behavior = (ProcessOrCaseTaskActivityBehavior)activity.ActivityBehavior;
            CallableElement callableElement            = behavior.CallableElement;

            // inputs
            initializeInputParameter(element, activity, context, callableElement);

            // outputs
            initializeOutputParameter(element, activity, context, callableElement);
        }
Ejemplo n.º 12
0
        public virtual void initializeExitCriterias(CasePlanModel casePlanModel, CmmnActivity activity, CmmnHandlerContext context)
        {
            ICollection <Sentry> exitCriterias = casePlanModel.ExitCriteria;

            foreach (Sentry sentry in exitCriterias)
            {
                string sentryId = sentry.Id;
                CmmnSentryDeclaration sentryDeclaration = activity.getSentry(sentryId);
                activity.addExitCriteria(sentryDeclaration);
            }
        }
Ejemplo n.º 13
0
 protected internal override void initializeRequiredRule(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
 {
     // required rule is not applicable on event listeners
 }
Ejemplo n.º 14
0
        protected internal virtual void initializeTaskListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, TaskDefinition taskDefinition)
        {
            HumanTask humanTask = getDefinition(element);

            IList <CamundaTaskListener> listeners = queryExtensionElementsByClass(humanTask, typeof(CamundaTaskListener));

            foreach (CamundaTaskListener listener in listeners)
            {
                TaskListener taskListener = initializeTaskListener(element, activity, context, listener);

                string eventName = listener.CamundaEvent;
                if (!string.ReferenceEquals(eventName, null))
                {
                    taskDefinition.addTaskListener(eventName, taskListener);
                }
                else
                {
                    taskDefinition.addTaskListener([email protected]_Fields.EVENTNAME_CREATE, taskListener);
                    taskDefinition.addTaskListener([email protected]_Fields.EVENTNAME_ASSIGNMENT, taskListener);
                    taskDefinition.addTaskListener([email protected]_Fields.EVENTNAME_COMPLETE, taskListener);
                    taskDefinition.addTaskListener([email protected]_Fields.EVENTNAME_DELETE, taskListener);
                }
            }
        }
Ejemplo n.º 15
0
        protected internal virtual TaskListener initializeTaskListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaTaskListener listener)
        {
            ICollection <CamundaField> fields            = listener.CamundaFields;
            IList <FieldDeclaration>   fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);

            ExpressionManager expressionManager = context.ExpressionManager;

            TaskListener taskListener = null;

            string        className          = listener.CamundaClass;
            string        expression         = listener.CamundaExpression;
            string        delegateExpression = listener.CamundaDelegateExpression;
            CamundaScript scriptElement      = listener.CamundaScript;

            if (!string.ReferenceEquals(className, null))
            {
                taskListener = new ClassDelegateTaskListener(className, fieldDeclarations);
            }
            else if (!string.ReferenceEquals(expression, null))
            {
                Expression expressionExp = expressionManager.createExpression(expression);
                taskListener = new ExpressionTaskListener(expressionExp);
            }
            else if (!string.ReferenceEquals(delegateExpression, null))
            {
                Expression delegateExp = expressionManager.createExpression(delegateExpression);
                taskListener = new DelegateExpressionTaskListener(delegateExp, fieldDeclarations);
            }
            else if (scriptElement != null)
            {
                ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
                if (executableScript != null)
                {
                    taskListener = new ScriptTaskListener(executableScript);
                }
            }

            return(taskListener);
        }
Ejemplo n.º 16
0
        protected internal virtual void initializeTaskDescription(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context)
        {
            string description = getDesciption(element);

            if (!string.ReferenceEquals(description, null) && description.Length > 0)
            {
                ExpressionManager expressionManager     = context.ExpressionManager;
                Expression        descriptionExpression = expressionManager.createExpression(description);
                taskDefinition.DescriptionExpression = descriptionExpression;
            }
            else
            {
                string documentation = getDocumentation(element);
                if (!string.ReferenceEquals(documentation, null) && documentation.Length > 0)
                {
                    ExpressionManager expressionManager       = context.ExpressionManager;
                    Expression        documentationExpression = expressionManager.createExpression(documentation);
                    taskDefinition.DescriptionExpression = documentationExpression;
                }
            }
        }
Ejemplo n.º 17
0
        protected internal virtual void initializeTaskDefinitionPriority(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context)
        {
            HumanTask definition = getDefinition(element);

            string priority = definition.CamundaPriority;

            if (!string.ReferenceEquals(priority, null))
            {
                ExpressionManager expressionManager  = context.ExpressionManager;
                Expression        priorityExpression = expressionManager.createExpression(priority);
                taskDefinition.PriorityExpression = priorityExpression;
            }
        }
Ejemplo n.º 18
0
        protected internal virtual void initializeTaskDefinitionFollowUpDate(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context)
        {
            HumanTask definition = getDefinition(element);

            string followUpDate = definition.CamundaFollowUpDate;

            if (!string.ReferenceEquals(followUpDate, null))
            {
                ExpressionManager expressionManager      = context.ExpressionManager;
                Expression        followUpDateExpression = expressionManager.createExpression(followUpDate);
                taskDefinition.FollowUpDateExpression = followUpDateExpression;
            }
        }
Ejemplo n.º 19
0
        protected internal virtual void initializeDefinitionKey(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, BaseCallableElement callableElement)
        {
            ExpressionManager      expressionManager     = context.ExpressionManager;
            string                 definitionKey         = getDefinitionKey(element, activity, context);
            ParameterValueProvider definitionKeyProvider = createParameterValueProvider(definitionKey, expressionManager);

            callableElement.DefinitionKeyValueProvider = definitionKeyProvider;
        }
Ejemplo n.º 20
0
 protected internal override void initializeExitCriterias(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
 {
     // exit criteria is not applicable on milestones
 }
Ejemplo n.º 21
0
        protected internal virtual void initializeBinding(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, BaseCallableElement callableElement)
        {
            string binding = getBinding(element, activity, context);

            if (BaseCallableElement.CallableElementBinding.DEPLOYMENT.Value.Equals(binding))
            {
                callableElement.Binding = BaseCallableElement.CallableElementBinding.DEPLOYMENT;
            }
            else if (BaseCallableElement.CallableElementBinding.LATEST.Value.Equals(binding))
            {
                callableElement.Binding = BaseCallableElement.CallableElementBinding.LATEST;
            }
            else if (BaseCallableElement.CallableElementBinding.VERSION.Value.Equals(binding))
            {
                callableElement.Binding = BaseCallableElement.CallableElementBinding.VERSION;
            }
        }
Ejemplo n.º 22
0
        protected internal virtual void initializeTaskDefinitionAssignee(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context)
        {
            HumanTask definition = getDefinition(element);
            Role      performer  = definition.Performer;

            string assignee = null;

            if (performer != null)
            {
                assignee = performer.Name;
            }
            else
            {
                assignee = definition.CamundaAssignee;
            }

            if (!string.ReferenceEquals(assignee, null))
            {
                ExpressionManager expressionManager  = context.ExpressionManager;
                Expression        assigneeExpression = expressionManager.createExpression(assignee);
                taskDefinition.AssigneeExpression = assigneeExpression;
            }
        }
Ejemplo n.º 23
0
 protected internal override void initializeEntryCriterias(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
 {
     // entry criteria is not applicable on event listeners
 }
Ejemplo n.º 24
0
        protected internal override void initializeActivity(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
        {
            // execute standard initialization
            base.initializeActivity(element, activity, context);

            // create a taskDefinition
            TaskDefinition taskDefinition = createTaskDefinition(element, context);

            // get the caseDefinition...
            CaseDefinitionEntity caseDefinition = (CaseDefinitionEntity)context.CaseDefinition;

            // ... and taskDefinition to caseDefinition
            caseDefinition.TaskDefinitions[taskDefinition.Key] = taskDefinition;

            ExpressionManager expressionManager = context.ExpressionManager;
            // create decorator
            TaskDecorator taskDecorator = new TaskDecorator(taskDefinition, expressionManager);

            // set taskDecorator on behavior
            HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior)activity.ActivityBehavior;

            behavior.TaskDecorator = taskDecorator;

            // task listeners
            initializeTaskListeners(element, activity, context, taskDefinition);
        }
Ejemplo n.º 25
0
 protected internal override void initializeManualActivationRule(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
 {
     // manual activation rule is not applicable on milestones
 }
Ejemplo n.º 26
0
        protected internal virtual TaskDefinition createTaskDefinition(CmmnElement element, CmmnHandlerContext context)
        {
            Deployment deployment   = context.Deployment;
            string     deploymentId = deployment.Id;

            // at the moment a default task form handler is only supported,
            // custom task form handler are not supported.
            DefaultTaskFormHandler taskFormHandler = new DefaultTaskFormHandler();

            taskFormHandler.DeploymentId = deploymentId;

            // create new taskDefinition
            TaskDefinition taskDefinition = new TaskDefinition(taskFormHandler);

            // the plan item id will be handled as taskDefinitionKey
            string taskDefinitionKey = element.Id;

            taskDefinition.Key = taskDefinitionKey;

            // name
            initializeTaskDefinitionName(element, taskDefinition, context);
            // dueDate
            initializeTaskDefinitionDueDate(element, taskDefinition, context);
            // followUp
            initializeTaskDefinitionFollowUpDate(element, taskDefinition, context);
            // priority
            initializeTaskDefinitionPriority(element, taskDefinition, context);
            // assignee
            initializeTaskDefinitionAssignee(element, taskDefinition, context);
            // candidateUsers
            initializeTaskDefinitionCandidateUsers(element, taskDefinition, context);
            // candidateGroups
            initializeTaskDefinitionCandidateGroups(element, taskDefinition, context);
            // formKey
            initializeTaskDefinitionFormKey(element, taskDefinition, context);
            // description
            initializeTaskDescription(element, taskDefinition, context);

            return(taskDefinition);
        }
Ejemplo n.º 27
0
        protected internal virtual void initializeOutputParameter(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CallableElement callableElement)
        {
            ExpressionManager expressionManager = context.ExpressionManager;

            IList <CamundaOut> outputs = getOutputs(element);

            foreach (CamundaOut output in outputs)
            {
                // create new parameter
                CallableElementParameter parameter = new CallableElementParameter();
                callableElement.addOutput(parameter);

                // all variables
                string variables = output.CamundaVariables;
                if ("all".Equals(variables))
                {
                    parameter.AllVariables = true;
                    continue;
                }

                // source/sourceExpression
                string source = output.CamundaSource;
                if (string.ReferenceEquals(source, null) || source.Length == 0)
                {
                    source = output.CamundaSourceExpression;
                }

                ParameterValueProvider sourceValueProvider = createParameterValueProvider(source, expressionManager);
                parameter.SourceValueProvider = sourceValueProvider;

                // target
                string target = output.CamundaTarget;
                parameter.Target = target;
            }
        }
Ejemplo n.º 28
0
        protected internal virtual void initializeVersion(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, BaseCallableElement callableElement)
        {
            ExpressionManager      expressionManager = context.ExpressionManager;
            string                 version           = getVersion(element, activity, context);
            ParameterValueProvider versionProvider   = createParameterValueProvider(version, expressionManager);

            callableElement.VersionValueProvider = versionProvider;
        }
Ejemplo n.º 29
0
        protected internal virtual void initializeInputParameter(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CallableElement callableElement)
        {
            ExpressionManager expressionManager = context.ExpressionManager;

            IList <CamundaIn> inputs = getInputs(element);

            foreach (CamundaIn input in inputs)
            {
                // businessKey
                string businessKey = input.CamundaBusinessKey;
                if (!string.ReferenceEquals(businessKey, null) && businessKey.Length > 0)
                {
                    ParameterValueProvider businessKeyValueProvider = createParameterValueProvider(businessKey, expressionManager);
                    callableElement.BusinessKeyValueProvider = businessKeyValueProvider;
                }
                else
                {
                    // create new parameter
                    CallableElementParameter parameter = new CallableElementParameter();
                    callableElement.addInput(parameter);

                    if (input.CamundaLocal)
                    {
                        parameter.ReadLocal = true;
                    }

                    // all variables
                    string variables = input.CamundaVariables;
                    if ("all".Equals(variables))
                    {
                        parameter.AllVariables = true;
                        continue;
                    }

                    // source/sourceExpression
                    string source = input.CamundaSource;
                    if (string.ReferenceEquals(source, null) || source.Length == 0)
                    {
                        source = input.CamundaSourceExpression;
                    }

                    ParameterValueProvider sourceValueProvider = createParameterValueProvider(source, expressionManager);
                    parameter.SourceValueProvider = sourceValueProvider;

                    // target
                    string target = input.CamundaTarget;
                    parameter.Target = target;
                }
            }
        }
Ejemplo n.º 30
0
        protected internal virtual void initializeTenantId(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, BaseCallableElement callableElement)
        {
            ParameterValueProvider tenantIdProvider;

            ExpressionManager expressionManager = context.ExpressionManager;
            string            tenantId          = getTenantId(element, activity, context);

            if (!string.ReferenceEquals(tenantId, null) && tenantId.Length > 0)
            {
                tenantIdProvider = createParameterValueProvider(tenantId, expressionManager);
            }
            else
            {
                tenantIdProvider = new DefaultCallableElementTenantIdProvider();
            }

            callableElement.TenantIdProvider = tenantIdProvider;
        }