コード例 #1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void fireJobSuccessfulEvent(final org.camunda.bpm.engine.runtime.Job job)
        public virtual void fireJobSuccessfulEvent(Job job)
        {
            if (isHistoryEventProduced(HistoryEventTypes.JOB_SUCCESS, job))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass3(this, job));
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void fireExternalTaskDeletedEvent(final org.camunda.bpm.engine.externaltask.ExternalTask externalTask)
        public virtual void fireExternalTaskDeletedEvent(ExternalTask externalTask)
        {
            if (isHistoryEventProduced(HistoryEventTypes.EXTERNAL_TASK_DELETE, externalTask))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass4(this, externalTask));
            }
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void fireJobDeletedEvent(final org.camunda.bpm.engine.runtime.Job job)
        public virtual void fireJobDeletedEvent(Job job)
        {
            if (isHistoryEventProduced(HistoryEventTypes.JOB_DELETE, job))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass4(this, job));
            }
        }
コード例 #4
0
 public virtual void FireJobFailedEvent(IJob job, System.Exception exception)
 {
     if (IsHistoryEventProduced(HistoryEventTypes.JobFail, job))
     {
         HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper2(this, job, exception));
     }
 }
コード例 #5
0
 public virtual void FireJobSuccessfulEvent(IJob job)
 {
     if (IsHistoryEventProduced(HistoryEventTypes.JobSuccess, job))
     {
         HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper3(this, job));
     }
 }
コード例 #6
0
        // fire history events ///////////////////////////////////////////////////////

        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        //ORIGINAL LINE: public void fireExternalTaskCreatedEvent(final org.camunda.bpm.engine.externaltask.ExternalTask externalTask)
        public virtual void FireExternalTaskCreatedEvent(IExternalTask externalTask)
        {
            if (IsHistoryEventProduced(HistoryEventTypes.ExternalTaskCreate, externalTask))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper(this, externalTask));
            }
        }
コード例 #7
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void fireExternalTaskSuccessfulEvent(final org.camunda.bpm.engine.externaltask.ExternalTask externalTask)
        public virtual void fireExternalTaskSuccessfulEvent(ExternalTask externalTask)
        {
            if (isHistoryEventProduced(HistoryEventTypes.EXTERNAL_TASK_SUCCESS, externalTask))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass3(this, externalTask));
            }
        }
コード例 #8
0
 public void OnUpdate(ICoreVariableInstance variableInstance, AbstractVariableScope sourceScope)
 {
     if (HistoryLevel.IsHistoryEventProduced(HistoryEventTypes.VariableInstanceUpdate, variableInstance))
     {
         HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper3(this, variableInstance, sourceScope));
     }
 }
コード例 #9
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void fireJobFailedEvent(final org.camunda.bpm.engine.runtime.Job job, final Throwable exception)
        public virtual void fireJobFailedEvent(Job job, Exception exception)
        {
            if (isHistoryEventProduced(HistoryEventTypes.JOB_FAIL, job))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass2(this, job, exception));
            }
        }
コード例 #10
0
 //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
 //ORIGINAL LINE: public void fireJobDeletedEvent(final org.camunda.bpm.engine.runtime.Job job)
 public virtual void FireJobDeletedEvent(IJob job)
 {
     // throw new NotImplementedException();
     if (IsHistoryEventProduced(HistoryEventTypes.JobDelete, job))
     {
         HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper4(this, job));
     }
 }
コード例 #11
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: protected void fireUserOperationLog(final org.camunda.bpm.engine.impl.oplog.UserOperationLogContext context)
        protected internal virtual void fireUserOperationLog(UserOperationLogContext context)
        {
            if (string.ReferenceEquals(context.UserId, null))
            {
                context.UserId = AuthenticatedUserId;
            }

            HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, context));
        }
コード例 #12
0
        protected internal virtual void MigrateHistory()
        {
            var historyLevel = Context.ProcessEngineConfiguration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.IncidentMigrate, this))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this));
            }
        }
コード例 #13
0
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        //ORIGINAL LINE: protected void fireUserOperationLog(final org.camunda.bpm.engine.impl.oplog.UserOperationLogContext context)
        protected void FireUserOperationLog(UserOperationLogContext context)
        {
            if (context.UserId == null)
            {
                context.UserId = AuthenticatedUserId;
            }

            HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper(this, context));
        }
コード例 #14
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void createHistoricTask(final TaskEntity task)
        public virtual void createHistoricTask(TaskEntity task)
        {
            ProcessEngineConfigurationImpl configuration = Context.ProcessEngineConfiguration;

            HistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_CREATE, task))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass3(this, task));
            }
        }
コード例 #15
0
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        //ORIGINAL LINE: public void completeHistoricBatch(final org.camunda.bpm.engine.impl.batch.BatchEntity batch)
        public virtual void CompleteHistoricBatch(BatchEntity batch)
        {
            ProcessEngineConfigurationImpl configuration = context.Impl.Context.ProcessEngineConfiguration;

            IHistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.BatchEnd, batch))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper2(this, batch));
            }
        }
コード例 #16
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void completeHistoricBatch(final org.camunda.bpm.engine.impl.batch.BatchEntity batch)
        public virtual void completeHistoricBatch(BatchEntity batch)
        {
            ProcessEngineConfigurationImpl configuration = Context.ProcessEngineConfiguration;

            HistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.isHistoryEventProduced(HistoryEventTypes.BATCH_END, batch))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass2(this, batch));
            }
        }
コード例 #17
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: protected void migrateActivityInstanceHistory(final org.camunda.bpm.engine.delegate.DelegateExecution execution)
        protected internal virtual void migrateActivityInstanceHistory(DelegateExecution execution)
        {
            HistoryLevel historyLevel = Context.ProcessEngineConfiguration.HistoryLevel;

            if (!historyLevel.isHistoryEventProduced(HistoryEventTypes.ACTIVITY_INSTANCE_MIGRATE, this))
            {
                return;
            }

            HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass2(this));
        }
コード例 #18
0
        protected internal virtual void FireHistoricIncidentEvent(HistoryEventTypes eventType)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = context.Impl.Context.ProcessEngineConfiguration;

            IHistoryLevel historyLevel = processEngineConfiguration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(eventType, this))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper(this, eventType));
            }
        }
コード例 #19
0
        protected internal virtual void fireFormPropertyHistoryEvents(VariableMap properties, VariableScope variableScope)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration = org.camunda.bpm.engine.impl.context.Context.getProcessEngineConfiguration();
            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;
            HistoryLevel historyLevel = processEngineConfiguration.HistoryLevel;

            if (historyLevel.isHistoryEventProduced(HistoryEventTypes.FORM_PROPERTY_UPDATE, variableScope))
            {
                // fire history events
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity executionEntity;
                ExecutionEntity executionEntity;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String taskId;
                string taskId;
                if (variableScope is ExecutionEntity)
                {
                    executionEntity = (ExecutionEntity)variableScope;
                    taskId          = null;
                }
                else if (variableScope is TaskEntity)
                {
                    TaskEntity task = (TaskEntity)variableScope;
                    executionEntity = task.getExecution();
                    taskId          = task.Id;
                }
                else
                {
                    executionEntity = null;
                    taskId          = null;
                }

                if (executionEntity != null)
                {
                    foreach (String variableName in properties.Keys)
                    {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.variable.value.TypedValue value = properties.getValueTyped(variableName);
                        TypedValue value = properties.getValueTyped(variableName);

                        // NOTE: SerializableValues are never stored as form properties
                        if (!(value is SerializableValue) && value.Value != null && value.Value is String)
                        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String stringValue = (String) value.getValue();
                            string stringValue = (String)value.Value;

                            HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, executionEntity, taskId, stringValue));
                        }
                    }
                }
            }
        }
コード例 #20
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void fireHistoricIdentityLinkEvent(final org.camunda.bpm.engine.impl.history.event.HistoryEventType eventType)
        public virtual void fireHistoricIdentityLinkEvent(HistoryEventType eventType)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;

            HistoryLevel historyLevel = processEngineConfiguration.HistoryLevel;

            if (historyLevel.isHistoryEventProduced(eventType, this))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, eventType));
            }
        }
コード例 #21
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: protected void migrateActivityInstanceHistory(final org.camunda.bpm.engine.delegate.DelegateExecution execution)
        protected internal virtual void MigrateActivityInstanceHistory(IDelegateExecution execution)
        {
            var historyLevel = Context.ProcessEngineConfiguration.HistoryLevel;

            if (!historyLevel.IsHistoryEventProduced(HistoryEventTypes.ActivityInstanceMigrate, this))
            {
                return;
            }

            HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClass2(this));
        }
コード例 #22
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public void createHistoricTask(final TaskEntity task)
        public virtual void CreateHistoricTask(TaskEntity task)
        {
            ProcessEngineConfigurationImpl configuration = context.Impl.Context.ProcessEngineConfiguration;

            IHistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.TaskInstanceCreate, task))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper3(this, task));
            }
        }
コード例 #23
0
        public virtual void FireHistoricIdentityLinkEvent(HistoryEventTypes eventType)
        {
            var processEngineConfiguration = Context.ProcessEngineConfiguration;

            var historyLevel = processEngineConfiguration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(eventType, this))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper(this,
                                                                                                            eventType));
            }
        }
コード例 #24
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public void markTaskInstanceEnded(String taskId, final String deleteReason)
        public virtual void MarkTaskInstanceEnded(string taskId, string deleteReason)
        {
            ProcessEngineConfigurationImpl configuration = context.Impl.Context.ProcessEngineConfiguration;

            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final TaskEntity taskEntity = org.camunda.bpm.engine.impl.context.Context.getCommandContext().getDbEntityManager().selectById(TaskEntity.class, taskId);
            //TaskEntity taskEntity = context.Impl.Context.CommandContext.DbEntityManager.SelectById< TaskEntity>(typeof(TaskEntity), taskId);
            TaskEntity    taskEntity   = taskManager.FindTaskById(taskId);
            IHistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.TaskInstanceComplete, taskEntity))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper2(this, deleteReason, taskEntity));
            }
        }
コード例 #25
0
        public virtual void triggerHistoryEvent(IList <ProcessInstance> subProcesslist)
        {
            ProcessEngineConfigurationImpl configuration = Context.ProcessEngineConfiguration;
            HistoryLevel historyLevel = configuration.HistoryLevel;

            foreach (ProcessInstance processInstance in subProcesslist)
            {
                // TODO: This smells bad, as the rest of the history is done via the
                // ParseListener
                if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance))
                {
                    HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this));
                }
            }
        }
コード例 #26
0
        protected internal override void triggerHistoryEvent(CommandContext commandContext)
        {
            HistoryLevel            historyLevel            = commandContext.ProcessEngineConfiguration.HistoryLevel;
            IList <ProcessInstance> updatedProcessInstances = obtainProcessInstances(commandContext);

            //suspension state is not updated synchronously
            if (NewSuspensionState != null && updatedProcessInstances != null)
            {
                foreach (ProcessInstance processInstance in updatedProcessInstances)
                {
                    if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance))
                    {
                        HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this));
                    }
                }
            }
        }
コード例 #27
0
        protected internal override void TriggerHistoryEvent(CommandContext commandContext)
        {
            var historyLevel            = commandContext.ProcessEngineConfiguration.HistoryLevel;
            var updatedProcessInstances = ObtainProcessInstances(commandContext);

            //suspension state is not updated synchronously
            if (NewSuspensionState != null && updatedProcessInstances != null)
            {
                foreach (IProcessInstance processInstance in updatedProcessInstances)
                {
                    if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.ProcessInstanceUpdate, processInstance))
                    {
                        HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, processInstance));
                    }
                }
            }
        }
コード例 #28
0
        protected internal virtual void FireFormPropertyHistoryEvents(IVariableMap properties,
                                                                      IVariableScope variableScope)
        {
            var processEngineConfiguration = Context.ProcessEngineConfiguration;
            var historyLevel = processEngineConfiguration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.FormPropertyUpdate, variableScope))
            {
                // fire history events
                ExecutionEntity executionEntity;
                string          taskId;
                if (variableScope is ExecutionEntity)
                {
                    executionEntity = (ExecutionEntity)variableScope;
                    taskId          = null;
                }
                else if (variableScope is TaskEntity)
                {
                    var task = (TaskEntity)variableScope;
                    executionEntity = task.GetExecution();
                    taskId          = task.Id;
                }
                else
                {
                    executionEntity = null;
                    taskId          = null;
                }

                if (executionEntity != null)
                {
                    foreach (var variableName in properties.Keys)
                    {
                        string stringValue = (String)variableName;

                        HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, executionEntity, taskId, stringValue));
                    }
                }
            }
        }
コード例 #29
0
        public virtual Void execute(CommandContext commandContext)
        {
            ProcessEngineConfigurationImpl configuration = commandContext.ProcessEngineConfiguration;

            // check that the new process definition is just another version of the same
            // process definition that the process instance is using
            ExecutionManager executionManager = commandContext.ExecutionManager;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);
            ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);

            if (processInstance == null)
            {
                throw new ProcessEngineException("No process instance found for id = '" + processInstanceId + "'.");
            }
            else if (!processInstance.ProcessInstanceExecution)
            {
                throw new ProcessEngineException("A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.ProcessInstanceId + "'. " + "Please invoke the " + this.GetType().Name + " with a root execution id.");
            }
            ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.getProcessDefinition();

            DeploymentCache         deploymentCache = configuration.DeploymentCache;
            ProcessDefinitionEntity currentProcessDefinition;

            if (currentProcessDefinitionImpl is ProcessDefinitionEntity)
            {
                currentProcessDefinition = (ProcessDefinitionEntity)currentProcessDefinitionImpl;
            }
            else
            {
                currentProcessDefinition = deploymentCache.findDeployedProcessDefinitionById(currentProcessDefinitionImpl.Id);
            }

            ProcessDefinitionEntity newProcessDefinition = deploymentCache.findDeployedProcessDefinitionByKeyVersionAndTenantId(currentProcessDefinition.Key, processDefinitionVersion, currentProcessDefinition.TenantId);

            validateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);

            HistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, processInstance));
            }

            // switch all sub-executions of the process instance to the new process definition version
            IList <ExecutionEntity> childExecutions = executionManager.findExecutionsByProcessInstanceId(processInstanceId);

            foreach (ExecutionEntity executionEntity in childExecutions)
            {
                validateAndSwitchVersionOfExecution(commandContext, executionEntity, newProcessDefinition);
            }

            // switch all jobs to the new process definition version
            IList <JobEntity>           jobs = commandContext.JobManager.findJobsByProcessInstanceId(processInstanceId);
            IList <JobDefinitionEntity> currentJobDefinitions    = commandContext.JobDefinitionManager.findByProcessDefinitionId(currentProcessDefinition.Id);
            IList <JobDefinitionEntity> newVersionJobDefinitions = commandContext.JobDefinitionManager.findByProcessDefinitionId(newProcessDefinition.Id);

            IDictionary <string, string> jobDefinitionMapping = getJobDefinitionMapping(currentJobDefinitions, newVersionJobDefinitions);

            foreach (JobEntity jobEntity in jobs)
            {
                switchVersionOfJob(jobEntity, newProcessDefinition, jobDefinitionMapping);
            }

            // switch all incidents to the new process definition version
            IList <IncidentEntity> incidents = commandContext.IncidentManager.findIncidentsByProcessInstance(processInstanceId);

            foreach (IncidentEntity incidentEntity in incidents)
            {
                switchVersionOfIncident(commandContext, incidentEntity, newProcessDefinition);
            }

            // add an entry to the op log
            PropertyChange change = new PropertyChange("processDefinitionVersion", currentProcessDefinition.Version, processDefinitionVersion);

            commandContext.OperationLogManager.logProcessInstanceOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE, processInstanceId, null, null, Collections.singletonList(change));

            return(null);
        }
コード例 #30
0
        public virtual object Execute(CommandContext commandContext)
        {
            var configuration = commandContext.ProcessEngineConfiguration;

            //check that the new process definition is just another version of the same
            //process definition that the process instance is using

            IExecutionManager executionManager = commandContext.ExecutionManager;
            ExecutionEntity   processInstance  = executionManager.FindExecutionById(_processInstanceId);

            if (processInstance == null)
            {
                throw new ProcessEngineException("No process instance found for id = '" + _processInstanceId + "'.");
            }
            else if (!processInstance.IsProcessInstanceExecution)
            {
                throw new ProcessEngineException("A process instance id is required, but the provided id " + "'" + _processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.ProcessInstanceId + "'. " + "Please invoke the " + this.GetType().Name + " with a root execution id.");
            }
            ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.ProcessDefinition;

            DeploymentCache         deploymentCache = configuration.DeploymentCache;
            ProcessDefinitionEntity currentProcessDefinition;

            if (currentProcessDefinitionImpl is ProcessDefinitionEntity)
            {
                currentProcessDefinition = (ProcessDefinitionEntity)currentProcessDefinitionImpl;
            }
            else
            {
                currentProcessDefinition = deploymentCache.FindDeployedProcessDefinitionById(currentProcessDefinitionImpl.Id);
            }

            ProcessDefinitionEntity newProcessDefinition = deploymentCache.FindDeployedProcessDefinitionByKeyVersionAndTenantId(currentProcessDefinition.Key, _processDefinitionVersion, currentProcessDefinition.TenantId);

            ValidateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);

            IHistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.ProcessInstanceUpdate, processInstance))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, processInstance));
            }

            // switch all sub-executions of the process instance to the new process definition version
            IList <ExecutionEntity> childExecutions = executionManager.FindExecutionsByProcessInstanceId(_processInstanceId);

            foreach (ExecutionEntity executionEntity in childExecutions)
            {
                ValidateAndSwitchVersionOfExecution(commandContext, executionEntity, newProcessDefinition);
            }

            // switch all jobs to the new process definition version
            IList <JobEntity>           jobs = commandContext.JobManager.FindJobsByProcessInstanceId(_processInstanceId);
            IList <JobDefinitionEntity> currentJobDefinitions    = commandContext.JobDefinitionManager.FindByProcessDefinitionId(currentProcessDefinition.Id);
            IList <JobDefinitionEntity> newVersionJobDefinitions = commandContext.JobDefinitionManager.FindByProcessDefinitionId(newProcessDefinition.Id);

            IDictionary <string, string> jobDefinitionMapping = GetJobDefinitionMapping(currentJobDefinitions, newVersionJobDefinitions);

            foreach (JobEntity jobEntity in jobs)
            {
                SwitchVersionOfJob(jobEntity, newProcessDefinition, jobDefinitionMapping);
            }

            // switch all incidents to the new process definition version
            IList <IncidentEntity> incidents = commandContext.IncidentManager.FindIncidentsByProcessInstance(_processInstanceId);

            foreach (IncidentEntity incidentEntity in incidents)
            {
                SwitchVersionOfIncident(commandContext, incidentEntity, newProcessDefinition);
            }

            // add an entry to the op log
            PropertyChange change = new PropertyChange("processDefinitionVersion", currentProcessDefinition.Version, _processDefinitionVersion);

            commandContext.OperationLogManager.LogProcessInstanceOperation(UserOperationLogEntryFields.OperationTypeModifyProcessInstance, _processInstanceId, null, null, new List <PropertyChange>()
            {
                change
            });
            return(null);
        }