public virtual void LogProcessInstanceOperation(string operation, string processInstanceId, string processDefinitionId, string processDefinitionKey, IList <PropertyChange> propertyChanges) { if (UserOperationLogEnabled) { UserOperationLogContext context = new UserOperationLogContext(); UserOperationLogContextEntryBuilder entryBuilder = UserOperationLogContextEntryBuilder.Entry(operation, EntityTypes.ProcessInstance).PropertyChanges(propertyChanges).ProcessInstanceId(processInstanceId).ProcessDefinitionId(processDefinitionId).ProcessDefinitionKey(processDefinitionKey); if (processInstanceId != null) { ExecutionEntity instance = processInstanceManager.FindExecutionById(processInstanceId); if (instance != null) { entryBuilder.InContextOf(instance); } } else if (processDefinitionId != null) { ProcessDefinitionEntity definition = processDefinitionManager.FindLatestProcessDefinitionById(processDefinitionId); if (definition != null) { entryBuilder.InContextOf(definition); } } context.AddEntry(entryBuilder.Create()); FireUserOperationLog(context); } }
public virtual object Execute(CommandContext commandContext) { var processInstanceId = Builder.ProcessInstanceId; IExecutionManager executionManager = commandContext.ExecutionManager; ExecutionEntity processInstance = executionManager.FindExecutionById(processInstanceId); CheckUpdateProcessInstance(processInstance, commandContext); processInstance.PreserveScope = true; var instructions = Builder.ModificationOperations; for (var i = 0; i < instructions.Count; i++) { var instruction = instructions[i]; Log.DebugModificationInstruction(processInstanceId, i + 1, instruction.Describe()); instruction.SkipCustomListeners = Builder.SkipCustomListeners; instruction.SkipIoMappings = Builder.SkipIoMappings; instruction.Execute(commandContext); } processInstance = executionManager.FindExecutionById(processInstanceId); if (!processInstance.HasChildren()) { if (processInstance.Activity == null) { // process instance was cancelled CheckDeleteProcessInstance(processInstance, commandContext); DeletePropagate(processInstance, "Cancellation due to process instance modification", Builder.SkipCustomListeners, Builder.SkipIoMappings); } else if (processInstance.IsEnded) { // process instance has ended regularly processInstance.PropagateEnd(); } } commandContext.OperationLogManager.LogProcessInstanceOperation(LogEntryOperation, processInstanceId, null, null, new List <PropertyChange>() { PropertyChange.EmptyChange }); return(null); }
public virtual IList <string> Execute(CommandContext commandContext) { EnsureUtil.EnsureNotNull("executionId", ExecutionId); // fetch execution IExecutionManager executionManager = commandContext.ExecutionManager; ExecutionEntity execution = executionManager.FindExecutionById(ExecutionId); EnsureUtil.EnsureNotNull("execution " + ExecutionId + " doesn't exist", "execution", execution); CheckGetActivityIds(execution, commandContext); // fetch active activities return(execution.FindActiveActivityIds()); }
protected internal virtual void SendSignalToExecution(CommandContext commandContext, string signalName, string executionId) { IExecutionManager executionManager = commandContext.ExecutionManager; ExecutionEntity execution = executionManager.FindExecutionById(executionId); EnsureUtil.EnsureNotNull("Cannot find execution with id '" + executionId + "'", "execution", execution); IEventSubscriptionManager eventSubscriptionManager = commandContext.EventSubscriptionManager; IList <EventSubscriptionEntity> signalEvents = eventSubscriptionManager.FindSignalEventSubscriptionsByNameAndExecution(signalName, executionId); EnsureUtil.EnsureNotEmpty("Execution '" + executionId + "' has not subscribed to a signal event with name '" + signalName + "'.", ListExt.ConvertToIlist(signalEvents)); CheckAuthorizationOfCatchSignals(commandContext, signalEvents); NotifyExecutions(signalEvents); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public java.Util.List<EventSubscriptionEntity> findEventSubscriptionsByNameAndExecution(String type, String eventName, String executionId, boolean lockResult) public virtual IList <EventSubscriptionEntity> FindEventSubscriptionsByNameAndExecution(string type, string eventName, string executionId, bool lockResult) { // first check cache in case entity is already loaded //ExecutionEntity cachedExecution = DbEntityManager.GetCachedEntity<ExecutionEntity>(typeof(ExecutionEntity), executionId); ExecutionEntity cachedExecution = _executionManager.FindExecutionById(executionId); if (cachedExecution != null && !lockResult) { IList <EventSubscriptionEntity> eventSubscriptions = cachedExecution.EventSubscriptions; IList <EventSubscriptionEntity> result = new List <EventSubscriptionEntity>(); foreach (EventSubscriptionEntity subscription in eventSubscriptions) { if (MatchesSubscription(subscription, type, eventName)) { result.Add(subscription); } } return(result); } else { //const string query = "selectEventSubscriptionsByNameAndExecution"; //IDictionary<string, object> @params = new Dictionary<string, object>(); //@params["eventType"] = type; //@params["eventName"] = eventName; //@params["executionId"] = executionId; //@params["lockResult"] = lockResult; //return ListExt.ConvertToListT<EventSubscriptionEntity>(DbEntityManager.SelectList(query, @params)); //select* //from ${ prefix}ACT_RU_EVENT_SUBSCR //where(EVENT_TYPE_ = #{parameter.eventType}) //and(EVENT_NAME_ = #{parameter.eventName}) //and(EXECUTION_ID_ = #{parameter.executionId}) //<if test = "parameter.lockResult" > //${ constant_for_update} //</if> //Todo: ${constant_for_update} return(Find(c => c.EventType.Equals(type) && c.EventName.Equals(eventName) && c.ExecutionId.Equals(executionId)).ToList()); } }
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); }