protected internal virtual void EnsureHistoricProcessInstanceNotActive(IHistoricProcessInstance instance) { if (instance.EndTime == null) { throw LOG.HistoricProcessInstanceActive(instance); } }
public virtual void CheckDeleteHistoricProcessInstance(IHistoricProcessInstance instance) { if (instance != null && !TenantManager.IsAuthenticatedTenant(instance.TenantId)) { throw Log.ExceptionCommandWithUnauthorizedTenant("delete the historic process instance '" + instance.Id + "'"); } }
protected internal virtual void EnsureSameProcessDefinition(IHistoricProcessInstance instance, string processDefinitionId) { if (!processDefinitionId.Equals(instance.ProcessDefinitionId)) { throw LOG.ProcessDefinitionOfHistoricInstanceDoesNotMatchTheGivenOne(instance, processDefinitionId); } }
public ProcessEngineException HistoricProcessInstanceActive(IHistoricProcessInstance historicProcessInstance) { return(new ProcessEngineException(ExceptionMessage( "040", "Historic process instance '{}' cannot be restarted. It is not completed or terminated.", historicProcessInstance.Id, historicProcessInstance.ProcessDefinitionId ))); }
public virtual void deployAndCompleteProcesses() { IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess); processInstance = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id); processInstance2 = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id); IList <string> processInstanceIds = (new string[] { processInstance.Id, processInstance2.Id }); runtimeService.DeleteProcessInstances(processInstanceIds, null, false, false); historicProcessInstance = historyService.CreateHistoricProcessInstanceQuery(c => c.ProcessInstanceId == processInstance.Id).First(); historicProcessInstance2 = historyService.CreateHistoricProcessInstanceQuery(c => c.ProcessInstanceId == processInstance2.Id).First(); }
protected internal virtual IVariableMap CollectVariables(CommandContext commandContext, IHistoricProcessInstance processInstance) { IVariableMap variables = null; if (builder.InitialVariables) { variables = CollectInitialVariables(commandContext, processInstance); } else { variables = CollectLastVariables(commandContext, processInstance); } return(variables); }
public virtual void testSimpleQueryWithReadHistoryPermissionOnAnyProcessDefinition() { // given string ProcessInstanceId = StartProcessInstanceByKey(PROCESS_KEY).Id; createGrantAuthorization(Resources.ProcessDefinition, AuthorizationFields.Any, userId, Permissions.ReadHistory); // when IQueryable <IHistoricProcessInstance> query = historyService.CreateHistoricProcessInstanceQuery(); // then //verifyQueryResults(query, 1); IHistoricProcessInstance instance = query.First(); Assert.NotNull(instance); Assert.AreEqual(ProcessInstanceId, instance.Id); }
public virtual void testTerminateInSubProcessConcurrentShouldNotEndProcessInstanceInHistory() { // when process instance is started and terminate end event in subprocess executed IProcessInstance pi = runtimeService.StartProcessInstanceByKey("terminateEndEventExample"); // then the historic process instance should not appear ended AssertProcessNotEnded(pi.Id); if (processEngineConfiguration.HistoryLevel.Id > ProcessEngineConfigurationImpl.HistorylevelNone) { IHistoricProcessInstance hpi = historyService.CreateHistoricProcessInstanceQuery().First(); Assert.NotNull(hpi); Assert.IsNull(hpi.EndTime); Assert.IsNull(hpi.DurationInMillis); Assert.IsNull(hpi.DeleteReason); } }
protected internal virtual IVariableMap CollectLastVariables(CommandContext commandContext, IHistoricProcessInstance processInstance) { var historyService = commandContext.ProcessEngineConfiguration.HistoryService; IList <IHistoricVariableInstance> historicVariables = historyService .CreateHistoricVariableInstanceQuery(c => c.ExecutionId == processInstance.Id) .ToList(); IVariableMap variables = new VariableMapImpl(); foreach (var variable in historicVariables) { variables.PutValueTyped(variable.Name, variable.TypedValue); } return(variables); }
public virtual void FAILING_testCatchErrorOnCallActivityShouldEndCalledProcessProperly() { // given a process instance that has instantiated (called) a sub process instance var id = runtimeService.StartProcessInstanceByKey("catchErrorOnCallActivity").Id; ITask task = taskService.CreateTaskQuery().First(); Assert.AreEqual("ITask in subprocess", task.Name); // when an error end event is triggered in the sub process instance and catched in the super process instance taskService.Complete(task.Id); task = taskService.CreateTaskQuery().First(); Assert.AreEqual("Escalated ITask", task.Name); // then the called historic process instance should have properly ended IHistoricProcessInstance historicSubProcessInstance = historyService.CreateHistoricProcessInstanceQuery(c => c.ProcessDefinitionKey == "simpleSubProcess").First(); Assert.NotNull(historicSubProcessInstance); Assert.IsNull(historicSubProcessInstance.DeleteReason); Assert.AreEqual("theEnd", historicSubProcessInstance.EndActivityId); }
protected internal virtual IHistoricActivityInstance ResolveStartActivityInstance( IHistoricProcessInstance processInstance) { var historyService = Context.ProcessEngineConfiguration.HistoryService; var processInstanceId = processInstance.Id; var startActivityId = processInstance.StartActivityId; EnsureUtil.EnsureNotNull("startActivityId", startActivityId); IList <IHistoricActivityInstance> historicActivityInstances = historyService .CreateHistoricActivityInstanceQuery(c => c.ProcessInstanceId == processInstanceId && c.ActivityId == startActivityId) /*.OrderPartiallyByOccurrence().Asc()*/ .ToList(); EnsureUtil.EnsureNotEmpty("historicActivityInstances", historicActivityInstances); var startActivityInstance = historicActivityInstances[0]; return(startActivityInstance); }
public virtual object Execute(ICommandContext commandContext) { if (processInstanceId is null) { throw new ActivitiIllegalArgumentException("processInstanceId is null"); } // Check if process instance is still running IHistoricProcessInstance instance = commandContext.HistoricProcessInstanceEntityManager.FindById <IHistoricProcessInstance>(new KeyValuePair <string, object>("id", processInstanceId)); if (instance == null) { throw new ActivitiObjectNotFoundException("No historic process instance found with id: " + processInstanceId, typeof(IHistoricProcessInstance)); } if (instance.EndTime == null) { throw new ActivitiException("Process instance is still running, cannot delete historic process instance: " + processInstanceId); } commandContext.HistoricProcessInstanceEntityManager.Delete(new KeyValuePair <string, object>("id", processInstanceId)); return(null); }
public virtual object Execute(CommandContext commandContext) { EnsureUtil.EnsureNotNull("processInstanceId", ProcessInstanceId); // Check if process instance is still running IHistoricProcessInstance instance = commandContext.HistoricProcessInstanceManager.FindHistoricProcessInstance(ProcessInstanceId); EnsureUtil.EnsureNotNull("No historic process instance found with id: " + ProcessInstanceId, "instance", instance); foreach (var checker in commandContext.ProcessEngineConfiguration.CommandCheckers) { checker.CheckDeleteHistoricProcessInstance(instance); } EnsureUtil.EnsureNotNull( "Process instance is still running, cannot delete historic process instance: " + ProcessInstanceId, "instance.getEndTime()", instance.EndTime); commandContext.HistoricProcessInstanceManager.DeleteHistoricProcessInstanceById(ProcessInstanceId); return(null); }
protected internal virtual IVariableMap CollectInitialVariables(CommandContext commandContext, IHistoricProcessInstance processInstance) { var historyService = commandContext.ProcessEngineConfiguration.HistoryService; var startActivityInstance = ResolveStartActivityInstance(processInstance); var query = historyService.CreateHistoricDetailQuery(c => c.EventType == "VariableUpdate" && c.ExecutionId == processInstance.Id && c.ActivityInstanceId == startActivityInstance.Id); //IList<IHistoricDetail> historicDetails = query.Where(c => c.SequenceCounter == 1) // .ToList(); IVariableMap variables = new VariableMapImpl(); foreach (var detail in query /*historicDetails*/) { var variableUpdate = (IHistoricVariableUpdate)detail; variables.PutValueTyped(variableUpdate.VariableName, variableUpdate.TypedValue); } return(variables); }
/// <summary> /// /// </summary> public virtual HistoricInstance GetHistoryProcessInstanceById(string processInstanceId) { IHistoricProcessInstance processInstance = (this.historyService as ServiceImpl).CommandExecutor.Execute(new Engine.Impl.Cmd.GetHistoricProcessInstanceByIdCmd(processInstanceId)); return(historicInstanceConverter.From(processInstance)); }
//delete permission ///////////////////////////////////////////////// public virtual void CheckDeleteHistoricProcessInstance(IHistoricProcessInstance instance) { AuthorizationManager.CheckAuthorization(Permissions.DeleteHistory, Resources.ProcessDefinition, instance.ProcessDefinitionKey); }
protected internal virtual void ApplyProperties(ProcessInstantiationBuilderImpl instantiationBuilder, IProcessDefinition processDefinition, IHistoricProcessInstance processInstance) { var tenantId = processInstance.TenantId; //if (processDefinition.TenantId == null && !ReferenceEquals(tenantId, null)) //instantiationBuilder.TenantId(tenantId); //if (!builder.WithoutBusinessKey) //instantiationBuilder.BusinessKey(processInstance.BusinessKey); }
public ProcessInstanceHistoryLogImpl(IHistoricProcessInstance historicProcessInstance) { this.historicProcessInstance = historicProcessInstance; }
public ProcessEngineException ProcessDefinitionOfHistoricInstanceDoesNotMatchTheGivenOne(IHistoricProcessInstance historicProcessInstance, string processDefinitionId) { return(new ProcessEngineException(ExceptionMessage( "039", "Historic process instance '{}' cannot be restarted. Its process definition '{}' does not match given process definition '{}'", historicProcessInstance.Id, historicProcessInstance.ProcessDefinitionId, processDefinitionId ))); }