Пример #1
0
 protected internal virtual void addCasePlanModelHandlers(CmmnActivity caseActivity)
 {
     if (caseActivity != null)
     {
         if (historyLevel.isHistoryEventProduced(HistoryEventTypes.CASE_INSTANCE_CREATE, null))
         {
             foreach (string @event in ItemHandler.CASE_PLAN_MODEL_CREATE_EVENTS)
             {
                 caseActivity.addBuiltInListener(@event, CASE_INSTANCE_CREATE_LISTENER);
             }
         }
         if (historyLevel.isHistoryEventProduced(HistoryEventTypes.CASE_INSTANCE_UPDATE, null))
         {
             foreach (string @event in ItemHandler.CASE_PLAN_MODEL_UPDATE_EVENTS)
             {
                 caseActivity.addBuiltInListener(@event, CASE_INSTANCE_UPDATE_LISTENER);
             }
         }
         if (historyLevel.isHistoryEventProduced(HistoryEventTypes.CASE_INSTANCE_CLOSE, null))
         {
             foreach (string @event in ItemHandler.CASE_PLAN_MODEL_CLOSE_EVENTS)
             {
                 caseActivity.addBuiltInListener(@event, CASE_INSTANCE_CLOSE_LISTENER);
             }
         }
     }
 }
Пример #2
0
        protected internal override CaseExecutionEntity createCaseExecution(CmmnActivity activity)
        {
            CaseExecutionEntity child = newCaseExecution();

            // set activity to execute
            child.Activity = activity;

            // handle child/parent-relation
            child.setParent(this);
            CaseExecutionsInternal.Add(child);

            // set case instance
            child.setCaseInstance(getCaseInstance());

            // set case definition
            child.CaseDefinition = CaseDefinition;

            // inherit the tenant id from parent case execution
            if (!string.ReferenceEquals(tenantId, null))
            {
                child.TenantId = tenantId;
            }

            return(child);
        }
Пример #3
0
        // start /////////////////////////////////////////////////////////////////////

        protected internal override void performStart(CmmnActivityExecution execution)
        {
            CmmnActivity         activity        = execution.Activity;
            IList <CmmnActivity> childActivities = activity.Activities;

            if (childActivities != null && childActivities.Count > 0)
            {
                IList <CmmnExecution> children = execution.createChildExecutions(childActivities);
                execution.createSentryParts();
                execution.triggerChildExecutionsLifecycle(children);


                if (execution.Active)
                {
                    execution.fireIfOnlySentryParts();
                    // if "autoComplete == true" and there are no
                    // required nor active child activities,
                    // then the stage will be completed.
                    if (execution.Active)
                    {
                        checkAndCompleteCaseExecution(execution);
                    }
                }
            }
            else
            {
                execution.complete();
            }
        }
Пример #4
0
 protected internal virtual void addEventListenerOrMilestoneHandlers(CmmnActivity caseActivity)
 {
     if (caseActivity != null)
     {
         if (historyLevel.isHistoryEventProduced(HistoryEventTypes.CASE_ACTIVITY_INSTANCE_CREATE, null))
         {
             foreach (string @event in ItemHandler.EVENT_LISTENER_OR_MILESTONE_CREATE_EVENTS)
             {
                 caseActivity.addBuiltInListener(@event, CASE_ACTIVITY_INSTANCE_CREATE_LISTENER);
             }
         }
         if (historyLevel.isHistoryEventProduced(HistoryEventTypes.CASE_ACTIVITY_INSTANCE_UPDATE, null))
         {
             foreach (string @event in ItemHandler.EVENT_LISTENER_OR_MILESTONE_UPDATE_EVENTS)
             {
                 caseActivity.addBuiltInListener(@event, CASE_ACTIVITY_INSTANCE_UPDATE_LISTENER);
             }
         }
         if (historyLevel.isHistoryEventProduced(HistoryEventTypes.CASE_ACTIVITY_INSTANCE_END, null))
         {
             foreach (string @event in ItemHandler.EVENT_LISTENER_OR_MILESTONE_END_EVENTS)
             {
                 caseActivity.addBuiltInListener(@event, CASE_ACTIVITY_INSTANCE_END_LISTENER);
             }
         }
     }
 }
Пример #5
0
        // repetition ///////////////////////////////////////////////////////////////

        public virtual void repeat(CmmnActivityExecution execution, string standardEvent)
        {
            CmmnActivity activity = execution.Activity;
            bool         repeat   = false;

            if (activity.EntryCriteria.Count == 0)
            {
                IList <string> events = activity.Properties.get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
                if (events != null && events.Contains(standardEvent))
                {
                    repeat = evaluateRepetitionRule(execution);
                }
            }
            else
            {
                if (ENABLE.Equals(standardEvent) || START.Equals(standardEvent) || OCCUR.Equals(standardEvent))
                {
                    repeat = evaluateRepetitionRule(execution);
                }
            }

            if (repeat)
            {
                CmmnActivityExecution parent = execution.Parent;

                // instantiate a new instance of given activity
                IList <CmmnExecution> children = parent.createChildExecutions(Arrays.asList(activity));
                // start the lifecycle of the new instance
                parent.triggerChildExecutionsLifecycle(children);
            }
        }
Пример #6
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);
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testClassDelegateHandling()
        public virtual void testClassDelegateHandling()
        {
            ExtensionElements       extensionElements = SpecUtil.createElement(modelInstance, caseTask, null, typeof(ExtensionElements));
            CamundaVariableListener variableListener  = SpecUtil.createElement(modelInstance, extensionElements, null, typeof(CamundaVariableListener));
            CamundaField            field             = SpecUtil.createElement(modelInstance, variableListener, null, typeof(CamundaField));

            field.CamundaName        = "fieldName";
            field.CamundaStringValue = "a string value";

            variableListener.CamundaClass = "a.class.Name";

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.camunda.bpm.engine.delegate.VariableListener<?>> listeners = activity.getVariableListenersLocal(org.camunda.bpm.engine.delegate.CaseVariableListener_Fields.CREATE);
            IList <VariableListener <object> > listeners = activity.getVariableListenersLocal([email protected]_Fields.CREATE);

            Assert.assertEquals(1, listeners.Count);

            ClassDelegateCaseVariableListener listener = (ClassDelegateCaseVariableListener)listeners[0];

            Assert.assertEquals("a.class.Name", listener.ClassName);
            Assert.assertEquals(1, listener.FieldDeclarations.Count);
            Assert.assertEquals("fieldName", listener.FieldDeclarations[0].Name);
            object fieldValue = listener.FieldDeclarations[0].Value;

            assertTrue(fieldValue is Expression);
            Expression expressionValue = (Expression)fieldValue;

            assertEquals("a string value", expressionValue.ExpressionText);

            Assert.assertEquals(listener, activity.getVariableListenersLocal([email protected]_Fields.UPDATE)[0]);
            Assert.assertEquals(listener, activity.getVariableListenersLocal([email protected]_Fields.DELETE)[0]);
        }
Пример #8
0
        ///
        /// <summary>
        ///   +-----------------+                    +-----------------+
        ///   | Case1            \                   | aCaseDefinition |
        ///   +-------------------+---+              +-----------------+
        ///   |                       |                      |
        ///   |     +-------+         |   ==>        +-----------------+
        ///   |     |   A   |         |              |  aCasePlanModel |
        ///   |     +-------+         |              +-----------------+
        ///   |                       |                      |
        ///   +-----------------------+              +-----------------+
        ///                                          |       A         |
        ///                                          +-----------------+
        ///
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testActivityTreeWithOneHumanTask()
        public virtual void testActivityTreeWithOneHumanTask()
        {
            // given
            HumanTask humanTask = createElement(casePlanModel, "A", typeof(HumanTask));
            PlanItem  planItem  = createElement(casePlanModel, "PI_A", typeof(PlanItem));

            planItem.Definition = humanTask;

            // when
            IList <CaseDefinitionEntity> caseDefinitions = transform();

            // then
            assertEquals(1, caseDefinitions.Count);

            CaseDefinitionEntity caseDefinition = caseDefinitions[0];
            IList <CmmnActivity> activities     = caseDefinition.Activities;

            CmmnActivity casePlanModelActivity = activities[0];

            IList <CmmnActivity> planItemActivities = casePlanModelActivity.Activities;

            assertEquals(1, planItemActivities.Count);

            CmmnActivity child = planItemActivities[0];

            assertEquals(planItem.Id, child.Id);
            assertTrue(child.Activities.Count == 0);
        }
Пример #9
0
 protected internal virtual void ensureActivityInitialized()
 {
     if ((activity == null) && (!string.ReferenceEquals(activityId, null)))
     {
         Activity = CaseDefinition.findActivity(activityId);
     }
 }
Пример #10
0
        protected internal virtual CmmnActivity getActivity(CmmnActivityExecution execution)
        {
            string       id       = execution.Id;
            CmmnActivity activity = execution.Activity;

            ensureNotNull(typeof(PvmException), "Case execution '" + id + "': has no current activity.", "activity", activity);

            return(activity);
        }
Пример #11
0
        protected internal override void initializeAutoComplete(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context)
        {
            PlanItemDefinition definition = getDefinition(element);

            if (definition is Stage)
            {
                Stage stage = (Stage)definition;
                activity.setProperty(PROPERTY_AUTO_COMPLETE, stage.AutoComplete);
            }
        }
Пример #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCaseHasNoParent()
        public virtual void testCaseHasNoParent()
        {
            // given: a caseDefinition

            // when
            CmmnActivity activity = handler.handleElement(caseDefinition, context);

            // then
            assertNull(activity.Parent);
        }
Пример #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testWithoutParent()
        public virtual void testWithoutParent()
        {
            // given

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            assertNull(activity.Parent);
        }
Пример #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCaseExecutionListener()
        public virtual void testCaseExecutionListener()
        {
            // given:
            testSpecification.addListenerToElement(modelInstance, caseTask);

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            testSpecification.verify(activity);
        }
Пример #15
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);
            }
        }
Пример #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCallableElement()
        public virtual void testCallableElement()
        {
            // given

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            DecisionTaskActivityBehavior behavior = (DecisionTaskActivityBehavior)activity.ActivityBehavior;

            assertNotNull(behavior.CallableElement);
        }
Пример #17
0
        // sentries //////////////////////////////////////////////////////////////////////////////

        protected internal virtual bool isAtLeastOneEntryCriterionSatisfied(CmmnActivityExecution execution)
        {
            if (execution.EntryCriterionSatisfied)
            {
                return(true);
            }

            CmmnActivity activity = getActivity(execution);
            IList <CmmnSentryDeclaration> criteria = activity.EntryCriteria;

            return(!(criteria != null && criteria.Count > 0));
        }
Пример #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testActivityType()
        public virtual void testActivityType()
        {
            // given

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            string activityType = (string)activity.getProperty(PROPERTY_ACTIVITY_TYPE);

            assertEquals("decisionTask", activityType);
        }
Пример #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testActivityBehavior()
        public virtual void testActivityBehavior()
        {
            // given: a case

            // when
            CmmnActivity activity = handler.handleElement(caseDefinition, context);

            // then
            CmmnActivityBehavior behavior = activity.ActivityBehavior;

            assertNull(behavior);
        }
Пример #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testActivityBehavior()
        public virtual void testActivityBehavior()
        {
            // given: a planItem

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            CmmnActivityBehavior behavior = activity.ActivityBehavior;

            assertTrue(behavior is DmnDecisionTaskActivityBehavior);
        }
Пример #21
0
        public virtual void testIsBlockingEqualsTrueProperty()
        {
            // given

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            bool?isBlocking = (bool?)activity.getProperty(PROPERTY_IS_BLOCKING);

            assertTrue(isBlocking);
        }
Пример #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSentryWithOnPartReferencesSentry()
        public virtual void testSentryWithOnPartReferencesSentry()
        {
            // given
            Sentry exitSentry = createElement(casePlanModel, "anotherSentry", typeof(Sentry));
            IfPart ifPart     = createElement(exitSentry, "IfPart_1", typeof(IfPart));
            ConditionExpression conditionExpression = createElement(ifPart, "con_1", typeof(ConditionExpression));
            Body body = createElement(conditionExpression, null, typeof(Body));

            body.TextContent = "${test}";

            onPart.Sentry = exitSentry;

            CmmnActivity casePlanModelActivity = (new CasePlanModelHandler()).handleElement(casePlanModel, context);

            context.Parent = casePlanModelActivity;

            CmmnSentryDeclaration sentryDeclaration     = sentryHandler.handleElement(sentry, context);
            CmmnSentryDeclaration exitSentryDeclaration = sentryHandler.handleElement(exitSentry, context);
            CmmnActivity          source = taskItemHandler.handleElement(planItem, context);

            // when
            sentryHandler.initializeOnParts(sentry, context);

            // then
            assertNotNull(sentryDeclaration);

            IList <CmmnOnPartDeclaration> onParts = sentryDeclaration.OnParts;

            assertNotNull(onParts);
            assertFalse(onParts.Count == 0);
            assertEquals(1, onParts.Count);

            IList <CmmnOnPartDeclaration> onPartsAssociatedWithSource = sentryDeclaration.getOnParts(source.Id);

            assertNotNull(onPartsAssociatedWithSource);
            assertFalse(onPartsAssociatedWithSource.Count == 0);
            assertEquals(1, onParts.Count);

            CmmnOnPartDeclaration onPartDeclaration = onPartsAssociatedWithSource[0];

            assertNotNull(onPartDeclaration);
            // source
            assertEquals(source, onPartDeclaration.Source);
            assertEquals(onPart.Source.Id, onPartDeclaration.Source.Id);
            // standardEvent
            assertEquals(onPart.StandardEvent.name(), onPartDeclaration.StandardEvent);
            // sentry
            assertNotNull(onPartDeclaration.Sentry);
            assertEquals(exitSentryDeclaration, onPartDeclaration.Sentry);

            assertNull(sentryDeclaration.IfPart);
        }
Пример #23
0
        // rules (required and repetition rule) /////////////////////////////////////////

        protected internal virtual void evaluateRequiredRule(CmmnActivityExecution execution)
        {
            CmmnActivity activity = execution.Activity;

            object requiredRule = activity.getProperty(PROPERTY_REQUIRED_RULE);

            if (requiredRule != null)
            {
                CaseControlRule rule     = (CaseControlRule)requiredRule;
                bool            required = rule.evaluate(execution);
                execution.Required = required;
            }
        }
Пример #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testActivityName()
        public virtual void testActivityName()
        {
            // given:
            string name = "A DecisionTask";

            decisionTask.Name = name;

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            assertEquals(name, activity.Name);
        }
Пример #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPlanItemDescriptionProperty()
        public virtual void testPlanItemDescriptionProperty()
        {
            // given
            string description = "This is a planItem";

            planItem.Description = description;

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            assertEquals(description, activity.getProperty(PROPERTY_ACTIVITY_DESCRIPTION));
        }
Пример #26
0
        public virtual void verify(CmmnActivity activity)
        {
            assertEquals(expectedRegisteredEvents.Count, activity.Listeners.Count);

            foreach (string expectedRegisteredEvent in expectedRegisteredEvents)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.camunda.bpm.engine.delegate.DelegateListener<? extends org.camunda.bpm.engine.delegate.BaseDelegateExecution>> listeners = activity.getListeners(expectedRegisteredEvent);
                IList <DelegateListener <BaseDelegateExecution> > listeners = activity.getListeners(expectedRegisteredEvent);
                assertEquals(1, listeners.Count);
                verifyListener(listeners[0]);
            }
        }
Пример #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDefaultMapDecisionResult()
        public virtual void testDefaultMapDecisionResult()
        {
            // given:

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            DmnDecisionTaskActivityBehavior behavior = (DmnDecisionTaskActivityBehavior)activity.ActivityBehavior;
            DecisionResultMapper            mapper   = behavior.DecisionTableResultMapper;

            assertTrue(mapper is ResultListDecisionTableResultMapper);
        }
Пример #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testResultVariable()
        public virtual void testResultVariable()
        {
            // given:
            decisionTask.CamundaResultVariable = "aResultVariable";

            // when
            CmmnActivity activity = handler.handleElement(planItem, context);

            // then
            DecisionTaskActivityBehavior behavior = (DecisionTaskActivityBehavior)activity.ActivityBehavior;

            assertEquals("aResultVariable", behavior.ResultVariable);
        }
Пример #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMultipleEntryCriteria()
        public virtual void testMultipleEntryCriteria()
        {
            // given

            // create first sentry containing ifPart
            Sentry sentry1 = createElement(casePlanModel, "Sentry_1", typeof(Sentry));
            IfPart ifPart1 = createElement(sentry1, "abc", typeof(IfPart));
            ConditionExpression conditionExpression1 = createElement(ifPart1, "def", typeof(ConditionExpression));
            Body body1 = createElement(conditionExpression1, null, typeof(Body));

            body1.TextContent = "${test}";

            // set first entryCriteria
            EntryCriterion criterion1 = createElement(planItem, typeof(EntryCriterion));

            criterion1.Sentry = sentry1;

            // create first sentry containing ifPart
            Sentry sentry2 = createElement(casePlanModel, "Sentry_2", typeof(Sentry));
            IfPart ifPart2 = createElement(sentry2, "ghi", typeof(IfPart));
            ConditionExpression conditionExpression2 = createElement(ifPart2, "jkl", typeof(ConditionExpression));
            Body body2 = createElement(conditionExpression2, null, typeof(Body));

            body2.TextContent = "${test}";

            // set second entryCriteria
            EntryCriterion criterion2 = createElement(planItem, typeof(EntryCriterion));

            criterion2.Sentry = sentry2;

            // transform casePlanModel as parent
            CmmnActivity parent = (new CasePlanModelHandler()).handleElement(casePlanModel, context);

            context.Parent = parent;

            // transform Sentry
            CmmnSentryDeclaration firstSentryDeclaration  = (new SentryHandler()).handleElement(sentry1, context);
            CmmnSentryDeclaration secondSentryDeclaration = (new SentryHandler()).handleElement(sentry2, context);

            // when
            CmmnActivity newActivity = handler.handleElement(planItem, context);

            // then
            assertTrue(newActivity.ExitCriteria.Count == 0);

            assertFalse(newActivity.EntryCriteria.Count == 0);
            assertEquals(2, newActivity.EntryCriteria.Count);

            assertTrue(newActivity.EntryCriteria.Contains(firstSentryDeclaration));
            assertTrue(newActivity.EntryCriteria.Contains(secondSentryDeclaration));
        }
Пример #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCaseActivityName()
        public virtual void testCaseActivityName()
        {
            // given:
            // the case has a name "A Case"
            string name = "A Case";

            caseDefinition.Name = name;

            // when
            CmmnActivity activity = handler.handleElement(caseDefinition, context);

            // then
            assertEquals(name, activity.Name);
        }