예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void setUp()
        {
            task = createElement(casePlanModel, "aTask", typeof(Task));

            planItem            = createElement(casePlanModel, "PI_aTask", typeof(PlanItem));
            planItem.Definition = task;

            sentry = createElement(casePlanModel, "aSentry", typeof(Sentry));

            onPart        = createElement(sentry, "anOnPart", typeof(PlanItemOnPart));
            onPart.Source = planItem;
            createElement(onPart, null, typeof(PlanItemTransitionStandardEvent));
            onPart.StandardEvent = PlanItemTransition.complete;
        }
예제 #2
0
        protected internal virtual void initializeOnPart(PlanItemOnPart onPart, Sentry sentry, CmmnHandlerContext context)
        {
            CmmnActivity          parent            = context.Parent;
            string                sentryId          = sentry.Id;
            CmmnSentryDeclaration sentryDeclaration = parent.getSentry(sentryId);

            PlanItem           source        = onPart.Source;
            PlanItemTransition standardEvent = onPart.StandardEvent;

            if (source != null && standardEvent != null)
            {
                CmmnOnPartDeclaration onPartDeclaration = new CmmnOnPartDeclaration();

                // initialize standardEvent
                string standardEventName = standardEvent.name();
                onPartDeclaration.StandardEvent = standardEventName;

                // initialize sourceRef
                string       sourceId       = source.Id;
                CmmnActivity sourceActivity = parent.findActivity(sourceId);

                if (sourceActivity != null)
                {
                    onPartDeclaration.Source = sourceActivity;
                }

                // initialize sentryRef
                Sentry sentryRef = onPart.Sentry;
                if (sentryRef != null)
                {
                    string sentryRefId = sentryRef.Id;

                    CmmnSentryDeclaration sentryRefDeclaration = parent.getSentry(sentryRefId);
                    onPartDeclaration.Sentry = sentryRefDeclaration;
                }

                // add onPartDeclaration to sentryDeclaration
                sentryDeclaration.addOnPart(onPartDeclaration);
            }
        }
예제 #3
0
        public virtual CmmnSentryDeclaration handleElement(Sentry element, CmmnHandlerContext context)
        {
            string id = element.Id;
            ICollection <OnPart> onParts = element.OnParts;
            IfPart ifPart = element.IfPart;
            IList <CamundaVariableOnPart> variableOnParts = queryExtensionElementsByClass(element, typeof(CamundaVariableOnPart));

            if ((ifPart == null || ifPart.Conditions.Empty) && variableOnParts.Count == 0)
            {
                if (onParts == null || onParts.Count == 0)
                {
                    LOG.ignoredSentryWithMissingCondition(id);
                    return(null);
                }
                else
                {
                    bool atLeastOneOnPartsValid = false;

                    foreach (OnPart onPart in onParts)
                    {
                        if (onPart is PlanItemOnPart)
                        {
                            PlanItemOnPart planItemOnPart = (PlanItemOnPart)onPart;
                            if (planItemOnPart.Source != null && planItemOnPart.StandardEvent != null)
                            {
                                atLeastOneOnPartsValid = true;
                                break;
                            }
                        }
                    }

                    if (!atLeastOneOnPartsValid)
                    {
                        LOG.ignoredSentryWithInvalidParts(id);
                        return(null);
                    }
                }
            }

            CmmnSentryDeclaration sentryDeclaration = new CmmnSentryDeclaration(id);

            // the ifPart will be initialized immediately
            initializeIfPart(ifPart, sentryDeclaration, context);

            // the variableOnParts will be initialized immediately as it does not have any dependency
            initializeVariableOnParts(element, sentryDeclaration, context, variableOnParts);

            // ...whereas the onParts will be initialized later because the
            // the reference to the plan items (sourceRef) and the reference
            // to the sentry (sentryRef) cannot be set in this step. To set
            // the corresponding reference (sourceRef or sentryRef) on the
            // transformed sentry all planned items and all sentries inside
            // the current stage should be already transformed.

            CmmnActivity parent = context.Parent;

            if (parent != null)
            {
                parent.addSentry(sentryDeclaration);
            }

            return(sentryDeclaration);
        }