public static HistoricTaskInstanceDto fromHistoricTaskInstance(HistoricTaskInstance taskInstance) { HistoricTaskInstanceDto dto = new HistoricTaskInstanceDto(); dto.id = taskInstance.Id; dto.processDefinitionKey = taskInstance.ProcessDefinitionKey; dto.processDefinitionId = taskInstance.ProcessDefinitionId; dto.processInstanceId = taskInstance.ProcessInstanceId; dto.executionId = taskInstance.ExecutionId; dto.caseDefinitionKey = taskInstance.CaseDefinitionKey; dto.caseDefinitionId = taskInstance.CaseDefinitionId; dto.caseInstanceId = taskInstance.CaseInstanceId; dto.caseExecutionId = taskInstance.CaseExecutionId; dto.activityInstanceId = taskInstance.ActivityInstanceId; dto.name = taskInstance.Name; dto.description = taskInstance.Description; dto.deleteReason = taskInstance.DeleteReason; dto.owner = taskInstance.Owner; dto.assignee = taskInstance.Assignee; dto.startTime = taskInstance.StartTime; dto.endTime = taskInstance.EndTime; dto.duration = taskInstance.DurationInMillis; dto.taskDefinitionKey = taskInstance.TaskDefinitionKey; dto.priority = taskInstance.Priority; dto.due = taskInstance.DueDate; dto.parentTaskId = taskInstance.ParentTaskId; dto.followUp = taskInstance.FollowUpDate; dto.tenantId = taskInstance.TenantId; dto.removalTime = taskInstance.RemovalTime; dto.rootProcessInstanceId = taskInstance.RootProcessInstanceId; return(dto); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testHistoricTaskInstanceDurationReportResults() public virtual void testHistoricTaskInstanceDurationReportResults() { startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43); startAndCompleteProcessInstance(PROCESS_DEFINITION_KEY, 2016, 7, 14, 11, 43); DurationReportResult taskReportResult = historyService.createHistoricTaskInstanceReport().duration(PeriodUnit.MONTH)[0]; IList <HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).list(); long min = 0; long max = 0; long sum = 0; for (int i = 0; i < historicTaskInstances.Count; i++) { HistoricTaskInstance historicProcessInstance = historicTaskInstances[i]; long?duration = historicProcessInstance.DurationInMillis; sum = sum + duration; max = i > 0 ? Math.Max(max, duration) : duration.Value; min = i > 0 ? Math.Min(min, duration) : duration.Value; } long avg = sum / historicTaskInstances.Count; assertEquals("maximum", max, taskReportResult.Maximum); assertEquals("minimum", min, taskReportResult.Minimum); assertEquals("average", avg, taskReportResult.Average, 0); }
public virtual void testStandaloneTask() { // given // that no activity instances have been executed assertEquals(0l, managementService.createMetricsQuery().name(Metrics.ACTIVTY_INSTANCE_START).sum()); // if // I complete a standalone task Task task = taskService.newTask(); taskService.saveTask(task); // then // the increased count is immediately visible assertEquals(1l, managementService.createMetricsQuery().name(Metrics.ACTIVTY_INSTANCE_START).sum()); // and force the db metrics reporter to report processEngineConfiguration.DbMetricsReporter.reportNow(); // still 1 assertEquals(1l, managementService.createMetricsQuery().name(Metrics.ACTIVTY_INSTANCE_START).sum()); taskService.deleteTask(task.Id); // clean up HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().singleResult(); if (hti != null) { historyService.deleteHistoricTaskInstance(hti.Id); } }
private void ensureTaskExists(Status status) { HistoricTaskInstance historicTaskInstance = engine.HistoryService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult(); if (historicTaskInstance == null) { throw new InvalidRequestException(status, "No task found for task id " + taskId); } }
public virtual void logTaskOperations(string operation, HistoricTaskInstance historicTask, IList <PropertyChange> propertyChanges) { if (UserOperationLogEnabled) { UserOperationLogContext context = new UserOperationLogContext(); UserOperationLogContextEntryBuilder entryBuilder = UserOperationLogContextEntryBuilder.entry(operation, EntityTypes.TASK).inContextOf(historicTask, propertyChanges).category(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR); context.addEntry(entryBuilder.create()); fireUserOperationLog(context); } }
private void assertThatTasksHaveAllImportantInformation(HistoricTaskInstance completedHistoricTaskInstance) { assertThat(completedHistoricTaskInstance, notNullValue()); assertThat(completedHistoricTaskInstance.Id, notNullValue()); assertThat(completedHistoricTaskInstance.TaskDefinitionKey, @is("userTask")); assertThat(completedHistoricTaskInstance.Name, @is("task")); assertThat(completedHistoricTaskInstance.StartTime, notNullValue()); assertThat(completedHistoricTaskInstance.EndTime, nullValue()); assertThat(completedHistoricTaskInstance.ProcessDefinitionKey, @is("process")); assertThat(completedHistoricTaskInstance.ProcessDefinitionId, notNullValue()); assertThat(completedHistoricTaskInstance.Assignee, @is(userId)); }
protected internal virtual void assertHistoricTaskDeletionPresent(IList <string> processIds, string deleteReason, ProcessEngineTestRule testRule) { if (!testRule.HistoryLevelNone) { foreach (string processId in processIds) { HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(processId).singleResult(); assertThat(historicTaskInstance.DeleteReason, @is(deleteReason)); } } }
public virtual UserOperationLogContextEntryBuilder inContextOf(HistoricTaskInstance task, IList <PropertyChange> propertyChanges) { if (propertyChanges == null || propertyChanges.Count == 0) { if (OPERATION_TYPE_CREATE.Equals(entry_Renamed.OperationType)) { propertyChanges = Arrays.asList(PropertyChange.EMPTY_CHANGE); } } entry_Renamed.PropertyChanges = propertyChanges; entry_Renamed.ProcessDefinitionKey = task.ProcessDefinitionKey; entry_Renamed.ProcessDefinitionId = task.ProcessDefinitionId; entry_Renamed.ProcessInstanceId = task.ProcessInstanceId; entry_Renamed.ExecutionId = task.ExecutionId; entry_Renamed.CaseDefinitionId = task.CaseDefinitionId; entry_Renamed.CaseInstanceId = task.CaseInstanceId; entry_Renamed.CaseExecutionId = task.CaseExecutionId; entry_Renamed.TaskId = task.Id; entry_Renamed.RootProcessInstanceId = task.RootProcessInstanceId; return(this); }