Example #1
0
        public virtual CallActivity CreateCallActivity()
        {
            var callActivity = new CallActivity();

            //callActivity.Tag = new CallActivityBehavior();

            return(callActivity);
        }
Example #2
0
        protected internal override bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw)
        {
            CallActivity callActivity = (CallActivity)element;

            didWriteExtensionStartElement = WriteIOParameters(BpmnXMLConstants.ELEMENT_CALL_ACTIVITY_IN_PARAMETERS, callActivity.InParameters, didWriteExtensionStartElement, xtw);
            didWriteExtensionStartElement = WriteIOParameters(BpmnXMLConstants.ELEMENT_CALL_ACTIVITY_OUT_PARAMETERS, callActivity.OutParameters, didWriteExtensionStartElement, xtw);
            return(didWriteExtensionStartElement);
        }
        protected internal virtual void DefaultTerminateEndEventBehaviour(IExecutionEntity execution, ICommandContext commandContext, IExecutionEntityManager executionEntityManager)
        {
            IExecutionEntity scopeExecutionEntity = executionEntityManager.FindFirstScope(execution);

            SendProcessInstanceCancelledEvent(scopeExecutionEntity, execution.CurrentFlowElement);

            // If the scope is the process instance, we can just terminate it all
            // Special treatment is needed when the terminated activity is a subprocess (embedded/callactivity/..)
            // The subprocess is destroyed, but the execution calling it, continues further on.
            // In case of a multi-instance subprocess, only one instance is terminated, the other instances continue to exist.

            string deleteReason = CreateDeleteReason(execution.CurrentActivityId);

            if (scopeExecutionEntity.ProcessInstanceType && scopeExecutionEntity.SuperExecutionId is null)
            {
                EndAllHistoricActivities(scopeExecutionEntity.Id, deleteReason);
                DeleteExecutionEntities(executionEntityManager, scopeExecutionEntity, deleteReason);
                commandContext.HistoryManager.RecordProcessInstanceEnd(scopeExecutionEntity.Id, deleteReason, execution.CurrentActivityId);
            }
            else if (scopeExecutionEntity.CurrentFlowElement != null && scopeExecutionEntity.CurrentFlowElement is SubProcess)
            { // SubProcess
                SubProcess subProcess = (SubProcess)scopeExecutionEntity.CurrentFlowElement;

                scopeExecutionEntity.DeleteReason = deleteReason;
                if (subProcess.HasMultiInstanceLoopCharacteristics())
                {
                    Context.Agenda.PlanDestroyScopeOperation(scopeExecutionEntity);
                    MultiInstanceActivityBehavior multiInstanceBehavior = (MultiInstanceActivityBehavior)subProcess.Behavior;
                    multiInstanceBehavior.Leave(scopeExecutionEntity);
                }
                else
                {
                    Context.Agenda.PlanDestroyScopeOperation(scopeExecutionEntity);
                    IExecutionEntity outgoingFlowExecution = executionEntityManager.CreateChildExecution(scopeExecutionEntity.Parent);
                    outgoingFlowExecution.CurrentFlowElement = scopeExecutionEntity.CurrentFlowElement;
                    Context.Agenda.PlanTakeOutgoingSequenceFlowsOperation(outgoingFlowExecution, true);
                }
            }
            else if (scopeExecutionEntity.ParentId is null && scopeExecutionEntity.SuperExecutionId is object)
            { // CallActivity
                IExecutionEntity callActivityExecution = scopeExecutionEntity.SuperExecution;
                CallActivity     callActivity          = (CallActivity)callActivityExecution.CurrentFlowElement;

                if (callActivity.HasMultiInstanceLoopCharacteristics())
                {
                    MultiInstanceActivityBehavior multiInstanceBehavior = (MultiInstanceActivityBehavior)callActivity.Behavior;
                    multiInstanceBehavior.Leave(callActivityExecution);
                    executionEntityManager.DeleteProcessInstanceExecutionEntity(scopeExecutionEntity.Id, execution.CurrentFlowElement.Id, "terminate end event", false, false);
                }
                else
                {
                    executionEntityManager.DeleteProcessInstanceExecutionEntity(scopeExecutionEntity.Id, execution.CurrentFlowElement.Id, "terminate end event", false, false);
                    IExecutionEntity superExecutionEntity = executionEntityManager.FindById <IExecutionEntity>(scopeExecutionEntity.SuperExecutionId);
                    Context.Agenda.PlanTakeOutgoingSequenceFlowsOperation(superExecutionEntity, true);
                }
            }
        }
Example #4
0
        public StartEventConverter GetStartEventConverter(CallActivity callActivity)
        {
            var converterId = ConversionTemplates.ProcessConverterId(callActivity.CalledElement, callActivity.Id);

            if (processConverters.TryGetValue(converterId, out var processConverter))
            {
                return(processConverter.GetStartEventConverter());
            }
            //TODO throw exception
            return(null);
        }
Example #5
0
        bool TryGetIdentifier(CallActivity callActivity, out ProcessInstanceIdentifier identifier)
        {
            if (callActivity.InstanceType == InstanceType.Parallel && (callActivity.LoopCollection != null || callActivity.LoopCardinality != 0))
            {
                identifier = new ProcessInstanceIdentifier(callActivity.Id);
                return(true);
            }

            identifier = null;
            return(false);
        }
Example #6
0
        protected internal override BaseElement ConvertXMLToElement(XMLStreamReader xtr, BpmnModel model)
        {
            CallActivity callActivity = new CallActivity();

            BpmnXMLUtil.AddXMLLocation(callActivity, xtr);
            callActivity.CalledElement = xtr.GetAttributeValue(BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_CALLEDELEMENT);
            callActivity.BusinessKey   = xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_BUSINESS_KEY);
            bool.TryParse(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERIT_BUSINESS_KEY), out callActivity.inheritBusinessKey);
            bool.TryParse(xtr.GetAttributeValue(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERITVARIABLES), out callActivity.inheritVariables);
            ParseChildElements(XMLElementName, callActivity, childParserMap, model, xtr);
            return(callActivity);
        }
Example #7
0
        public static bool MapException(Exception e, IExecutionEntity execution, IList <MapExceptionEntry> exceptionMap)
        {
            string errorCode = FindMatchingExceptionMapping(e, exceptionMap);

            if (errorCode is object)
            {
                PropagateError(errorCode, execution);
                return(true);
            }
            else
            {
                IExecutionEntity callActivityExecution = null;
                IExecutionEntity parentExecution       = execution.Parent;
                while (parentExecution != null && callActivityExecution == null)
                {
                    if (parentExecution.Id.Equals(parentExecution.ProcessInstanceId))
                    {
                        if (parentExecution.SuperExecution != null)
                        {
                            callActivityExecution = parentExecution.SuperExecution;
                        }
                        else
                        {
                            parentExecution = null;
                        }
                    }
                    else
                    {
                        parentExecution = parentExecution.Parent;
                    }
                }

                if (callActivityExecution != null)
                {
                    CallActivity callActivity = (CallActivity)callActivityExecution.CurrentFlowElement;
                    if (CollectionUtil.IsNotEmpty(callActivity.MapExceptions))
                    {
                        errorCode = FindMatchingExceptionMapping(e, callActivity.MapExceptions);
                        if (errorCode is object)
                        {
                            PropagateError(errorCode, callActivityExecution);
                            return(true);
                        }
                    }
                }

                return(false);
            }
        }
        // Call activity

        public virtual CallActivityBehavior CreateCallActivityBehavior(CallActivity callActivity)
        {
            CallActivityBehavior callActivityBehaviour;

            if (!string.IsNullOrWhiteSpace(callActivity.CalledElement) && EXPR_PATTERN.IsMatch(callActivity.CalledElement))
            {
                callActivityBehaviour = new CallActivityBehavior(expressionManager.CreateExpression(callActivity.CalledElement), callActivity.MapExceptions);
            }
            else
            {
                callActivityBehaviour = new CallActivityBehavior(callActivity.CalledElement, callActivity.MapExceptions);
            }

            return(callActivityBehaviour);
        }
Example #9
0
        static CallActivity CreateCallActivity(XElement xElement)
        {
            var callActivity = new CallActivity();

            FillCommonTaskAttributes(callActivity, xElement);

            var xCalledElement = xElement.Element("CalledElement");

            if (xCalledElement == null)
            {
                throw new InvalidElementException($"CallActivity at line {ContractParser.GetLineNumber(xElement)} " +
                                                  $"is missing called element definition");
            }
            callActivity.CalledElement = xCalledElement.Value;

            return(callActivity);
        }
Example #10
0
        protected internal override void WriteAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        {
            CallActivity callActivity = (CallActivity)element;

            if (!string.IsNullOrWhiteSpace(callActivity.CalledElement))
            {
                xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_CALLEDELEMENT, callActivity.CalledElement);
            }
            if (!string.IsNullOrWhiteSpace(callActivity.BusinessKey))
            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_BUSINESS_KEY, callActivity.BusinessKey, xtw);
            }
            if (callActivity.InheritBusinessKey)
            {
                WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERIT_BUSINESS_KEY, "true", xtw);
            }
            xtw.WriteAttribute(BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_CALL_ACTIVITY_INHERITVARIABLES, callActivity.InheritVariables.ToString());
        }
Example #11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                CallActivity x = new CallActivity();
            }
            finally
            {
            }

            base.OnCreate(savedInstanceState);

            loginListener = new UserLoginListener();
            loginListener.OnRegistrationSucessHandler += OnRegistrationSucessHandler;
            loginListener.OnRegistrationFailedHandler += OnRegistrationFailedHandler;
            // AddMemberHandler();                    // Enable this method for its handler when adding members to contact group

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.login_activity_layout);

            // Get our button from the layout resource,
            // and attach an event to it
            userName = FindViewById <EditText>(Resource.Id.username_input);
            EditText            password    = FindViewById <EditText>(Resource.Id.password_input);
            Button              signIn      = FindViewById <Button>(Resource.Id.sign_in_btn);
            ApplozicChatManager chatManager = new ApplozicChatManager(this);


            signIn.Click += delegate
            {
                chatManager.RegisterUser(userName.Text, userName.Text, password.Text, loginListener);
            };

            if (chatManager.ISUserLoggedIn())
            {
                System.Console.WriteLine("Already Registred ::");
                Intent myIntent = new Intent(this, typeof(MainActivity));
                this.StartActivity(myIntent);
                this.Finish();
            }
        }
        public virtual void Completing(IExecutionEntity execution, IExecutionEntity subProcessInstance)
        {
            // only data. no control flow available on this execution.

            ExpressionManager expressionManager = Context.ProcessEngineConfiguration.ExpressionManager;

            // copy process variables
            CallActivity callActivity = (CallActivity)execution.CurrentFlowElement;

            foreach (IOParameter ioParameter in callActivity.OutParameters)
            {
                object value = null;
                if (!string.IsNullOrWhiteSpace(ioParameter.SourceExpression))
                {
                    IExpression expression = expressionManager.CreateExpression(ioParameter.SourceExpression.Trim());
                    value = expression.GetValue(subProcessInstance);
                }
                else
                {
                    value = subProcessInstance.GetVariable(ioParameter.Source);
                }
                execution.SetVariable(ioParameter.Target, value);
            }
        }
Example #13
0
 public CallActivityConverter(CallActivity callActivity, ProcessConverter converterService)
 {
     this.callActivity = callActivity;
     processConverter  = converterService;
 }
        public override void Execute(IExecutionEntity execution)
        {
            string finalProcessDefinitonKey;

            if (processDefinitionExpression != null)
            {
                finalProcessDefinitonKey = (string)processDefinitionExpression.GetValue(execution);
            }
            else
            {
                finalProcessDefinitonKey = processDefinitonKey;
            }

            IProcessDefinition processDefinition = FindProcessDefinition(finalProcessDefinitonKey, execution.TenantId);

            // Get model from cache
            Process subProcess = ProcessDefinitionUtil.GetProcess(processDefinition.Id);

            if (subProcess == null)
            {
                throw new ActivitiException("Cannot start a sub process instance. Process model " + processDefinition.Name + " (id = " + processDefinition.Id + ") could not be found");
            }

            FlowElement initialFlowElement = subProcess.InitialFlowElement;

            if (initialFlowElement == null)
            {
                throw new ActivitiException("No start element found for process definition " + processDefinition.Id);
            }

            // Do not start a process instance if the process definition is suspended
            if (ProcessDefinitionUtil.IsProcessDefinitionSuspended(processDefinition.Id))
            {
                throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.Name + " (id = " + processDefinition.Id + ") is suspended");
            }

            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;
            IExecutionEntityManager        executionEntityManager     = Context.CommandContext.ExecutionEntityManager;
            ExpressionManager expressionManager = processEngineConfiguration.ExpressionManager;

            CallActivity callActivity = (CallActivity)execution.CurrentFlowElement;

            string businessKey = null;

            if (!string.IsNullOrWhiteSpace(callActivity.BusinessKey))
            {
                IExpression expression = expressionManager.CreateExpression(callActivity.BusinessKey);
                businessKey = expression.GetValue(execution).ToString();
            }
            else if (callActivity.InheritBusinessKey)
            {
                IExecutionEntity processInstance = executionEntityManager.FindById <IExecutionEntity>(execution.ProcessInstanceId);
                businessKey = processInstance.BusinessKey;
            }

            IExecutionEntity subProcessInstance = Context.CommandContext.ExecutionEntityManager.CreateSubprocessInstance(processDefinition, execution, businessKey);

            Context.CommandContext.HistoryManager.RecordSubProcessInstanceStart(execution, subProcessInstance, initialFlowElement);

            // process template-defined data objects
            IDictionary <string, object> variables = ProcessDataObjects(subProcess.DataObjects);

            if (callActivity.InheritVariables)
            {
                IDictionary <string, object> executionVariables = execution.Variables;
                foreach (KeyValuePair <string, object> entry in executionVariables.SetOfKeyValuePairs())
                {
                    variables[entry.Key] = entry.Value;
                }
            }

            // copy process variables
            foreach (IOParameter ioParameter in callActivity.InParameters)
            {
                object value = null;
                if (!string.IsNullOrWhiteSpace(ioParameter.SourceExpression))
                {
                    IExpression expression = expressionManager.CreateExpression(ioParameter.SourceExpression.Trim());
                    value = expression.GetValue(execution);
                }
                else
                {
                    value = execution.GetVariable(ioParameter.Source);
                }
                variables[ioParameter.Target] = value;
            }

            if (variables.Count > 0)
            {
                InitializeVariables(subProcessInstance, variables);
            }

            // Create the first execution that will visit all the process definition elements
            IExecutionEntity subProcessInitialExecution = executionEntityManager.CreateChildExecution(subProcessInstance);

            subProcessInitialExecution.CurrentFlowElement = initialFlowElement;

            Context.Agenda.PlanContinueProcessOperation(subProcessInitialExecution);

            Context.ProcessEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateProcessStartedEvent(subProcessInitialExecution, variables, false));
        }
Example #15
0
 protected internal AbstractCallActivityBuilder(BpmnModelInstance modelInstance, CallActivity element, Type selfType) : base(modelInstance, element, selfType)
 {
 }
Example #16
0
 //@Override
 public void onCallAdded(Call call)
 {
     new OngoingCall().SetCall(call);
     Toast.MakeText(this, "class to CallService", ToastLength.Short).Show();
     CallActivity.start(this, call);
 }