Esempio n. 1
0
        public virtual ProcessInstanceWithVariables execute(CommandContext commandContext)
        {
            ProcessDefinitionEntity processDefinition = (new GetDeployedProcessDefinitionCmd(instantiationBuilder, false)).execute(commandContext);

            foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.checkCreateProcessInstance(processDefinition);
            }

            ProcessInstanceModificationBuilderImpl modificationBuilder = instantiationBuilder.ModificationBuilder;

            ensureNotEmpty("At least one instantiation instruction required (e.g. by invoking startBefore(..), startAfter(..) or startTransition(..))", "instructions", modificationBuilder.ModificationOperations);

            // instantiate the process
            ActivityImpl initialActivity = determineFirstActivity(processDefinition, modificationBuilder);

            ExecutionEntity processInstance = processDefinition.createProcessInstance(instantiationBuilder.BusinessKey, instantiationBuilder.CaseInstanceId, initialActivity);

            if (!string.ReferenceEquals(instantiationBuilder.TenantId, null))
            {
                processInstance.TenantId = instantiationBuilder.TenantId;
            }

            processInstance.SkipCustomListeners = modificationBuilder.SkipCustomListeners;
            VariableMap variables = modificationBuilder.ProcessVariables;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.ExecutionVariableSnapshotObserver variablesListener = new org.camunda.bpm.engine.impl.persistence.entity.ExecutionVariableSnapshotObserver(processInstance);
            ExecutionVariableSnapshotObserver variablesListener = new ExecutionVariableSnapshotObserver(processInstance);

            processInstance.startWithoutExecuting(variables);

            // prevent ending of the process instance between instructions
            processInstance.PreserveScope = true;

            // apply modifications
            IList <AbstractProcessInstanceModificationCommand> instructions = modificationBuilder.ModificationOperations;

            for (int i = 0; i < instructions.Count; i++)
            {
                AbstractProcessInstanceModificationCommand instruction = instructions[i];
                LOG.debugStartingInstruction(processInstance.Id, i, instruction.describe());

                instruction.ProcessInstanceId   = processInstance.Id;
                instruction.SkipCustomListeners = modificationBuilder.SkipCustomListeners;
                instruction.SkipIoMappings      = modificationBuilder.SkipIoMappings;
                instruction.execute(commandContext);
            }

            if (!processInstance.hasChildren() && processInstance.Ended)
            {
                // process instance has ended regularly but this has not been propagated yet
                // due to preserveScope setting
                processInstance.propagateEnd();
            }

            commandContext.OperationLogManager.logProcessInstanceOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE, processInstance.Id, processInstance.ProcessDefinitionId, processInstance.getProcessDefinition().Key, Collections.singletonList(PropertyChange.EMPTY_CHANGE));

            return(new ProcessInstanceWithVariablesImpl(processInstance, variablesListener.Variables));
        }
Esempio n. 2
0
        public virtual ProcessInstanceWithVariables execute(CommandContext commandContext)
        {
            ProcessDefinitionEntity processDefinition = (new GetDeployedProcessDefinitionCmd(instantiationBuilder, false)).execute(commandContext);

            foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.checkCreateProcessInstance(processDefinition);
            }

            // Start the process instance
            ExecutionEntity processInstance = processDefinition.createProcessInstance(instantiationBuilder.BusinessKey, instantiationBuilder.CaseInstanceId);

            if (!string.ReferenceEquals(instantiationBuilder.TenantId, null))
            {
                processInstance.TenantId = instantiationBuilder.TenantId;
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.ExecutionVariableSnapshotObserver variablesListener = new org.camunda.bpm.engine.impl.persistence.entity.ExecutionVariableSnapshotObserver(processInstance);
            ExecutionVariableSnapshotObserver variablesListener = new ExecutionVariableSnapshotObserver(processInstance);

            processInstance.start(instantiationBuilder.Variables);

            commandContext.OperationLogManager.logProcessInstanceOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_CREATE, processInstance.Id, processInstance.ProcessDefinitionId, processInstance.getProcessDefinition().Key, Collections.singletonList(PropertyChange.EMPTY_CHANGE));

            return(new ProcessInstanceWithVariablesImpl(processInstance, variablesListener.Variables));
        }
Esempio n. 3
0
        public virtual ProcessInstance execute(CommandContext commandContext)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;
            DeploymentCache         deploymentCache   = processEngineConfiguration.DeploymentCache;
            ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);

            ensureNotNull("No process definition found for id = '" + processDefinitionId + "'", "processDefinition", processDefinition);

            foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.checkCreateProcessInstance(processDefinition);
            }

            ExecutionEntity processInstance = null;

            if (!string.ReferenceEquals(businessKey, null))
            {
                processInstance = processDefinition.createProcessInstance(businessKey);
            }
            else
            {
                processInstance = processDefinition.createProcessInstance();
            }

            // if the start event is async, we have to set the variables already here
            // since they are lost after the async continuation otherwise
            // see CAM-2828
            if (processDefinition.Initial.AsyncBefore)
            {
                // avoid firing history events
                processInstance.StartContext = new ProcessInstanceStartContext(processInstance.getActivity());
                FormPropertyHelper.initFormPropertiesOnScope(variables, processInstance);
                processInstance.start();
            }
            else
            {
                processInstance.startWithFormProperties(variables);
            }


            return(processInstance);
        }
Esempio n. 4
0
        protected internal virtual ProcessInstance instantiateProcess(CommandContext commandContext, ConditionHandlerResult result)
        {
            ProcessDefinitionEntity processDefinitionEntity = result.ProcessDefinition;

            ActivityImpl    startEvent      = processDefinitionEntity.findActivity(result.Activity.ActivityId);
            ExecutionEntity processInstance = processDefinitionEntity.createProcessInstance(builder.BusinessKey, startEvent);

            processInstance.start(builder.getVariables());

            return(processInstance);
        }
Esempio n. 5
0
        protected internal virtual void handleStartEvent(EventSubscriptionEntity eventSubscription,IDictionary <string,object> payload,string businessKey,CommandContext commandContext)
        {
            string processDefinitionId = eventSubscription.Configuration;

            ensureNotNull("Configuration of signal start event subscription '" + eventSubscription.Id + "' contains no process definition id.",processDefinitionId);

            DeploymentCache         deploymentCache   = Context.ProcessEngineConfiguration.DeploymentCache;
            ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);

            if (processDefinition == null || processDefinition.Suspended)
            {
                // ignore event subscription
                LOG.debugIgnoringEventSubscription(eventSubscription,processDefinitionId);
            }
            else
            {
                ActivityImpl       signalStartEvent = processDefinition.findActivity(eventSubscription.ActivityId);
                PvmProcessInstance processInstance  = processDefinition.createProcessInstance(businessKey,signalStartEvent);
                processInstance.start(payload);
            }
        }