org.activiti.engine.history.HistoricProcessInstance Java Examples
The following examples show how to use
org.activiti.engine.history.HistoricProcessInstance.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalTaskService.java From maven-framework-project with MIT License | 6 votes |
/** * Returns a list of <strong>completed</strong> Doc Approval Tasks. * * @param businessKey * @return */ public List<HistoricTask> getDocApprovalHistory(String businessKey) { log.debug("getting historic tasks for doc: " + businessKey); HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery(). includeProcessVariables().processInstanceBusinessKey(businessKey).singleResult(); if (pi == null) { return Collections.emptyList(); } log.debug("Duration time in millis: " + pi.getDurationInMillis()); List<HistoricTaskInstance> hTasks; hTasks = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().processInstanceBusinessKey(businessKey).list(); List<HistoricTask> historicTasks = Lists.newArrayList(); for (HistoricTaskInstance hti : hTasks) { if (StringUtils.startsWith(hti.getProcessDefinitionId(), Workflow.PROCESS_ID_DOC_APPROVAL) && hti.getEndTime() != null) { historicTasks.add(fromActiviti(hti)); } } Collections.sort(historicTasks); return historicTasks; }
Example #2
Source File: HistoricProcessInstanceQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testQueryByProcessInstanceNameLike() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // processInstanceNameLike HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceNameLike("%\\%%").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance1.getId(), historicProcessInstance.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceNameLike("%\\_%").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance2.getId(), historicProcessInstance.getId()); // orQuery historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceNameLike("%\\%%").processDefinitionId("undefined").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance1.getId(), historicProcessInstance.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceNameLike("%\\_%").processDefinitionId("undefined").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance2.getId(), historicProcessInstance.getId()); } }
Example #3
Source File: HistoricProcessInstanceQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testQueryLikeIgnoreCaseByQueryVariableValue() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // queryVariableValueIgnoreCase HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("var1", "%\\%%").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance1.getId(), historicProcessInstance.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("var1", "%\\_%").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance2.getId(), historicProcessInstance.getId()); // orQuery historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLikeIgnoreCase("var1", "%\\%%").processDefinitionId("undefined").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance1.getId(), historicProcessInstance.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLikeIgnoreCase("var1", "%\\_%").processDefinitionId("undefined").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance2.getId(), historicProcessInstance.getId()); } }
Example #4
Source File: HistoryServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti5/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" }) public void testHistoricProcessInstanceQueryByDeploymentId() { org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult(); HashSet<String> processInstanceIds = new HashSet<String>(); for (int i = 0; i < 4; i++) { processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId()); } processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId()); HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentId(deployment.getId()); assertEquals(5, processInstanceQuery.count()); assertEquals(deployment.getId(), processInstanceQuery.list().get(0).getDeploymentId()); List<HistoricProcessInstance> processInstances = processInstanceQuery.list(); assertNotNull(processInstances); assertEquals(5, processInstances.size()); processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentId("invalid"); assertEquals(0, processInstanceQuery.count()); }
Example #5
Source File: ViewService.java From lemon with Apache License 2.0 | 6 votes |
public void findGraph(String processInstanceId) { HistoryService historyService = processEngine.getHistoryService(); HistoricProcessInstance historicProcessInstance = historyService .createHistoricProcessInstanceQuery() .processInstanceId(processInstanceId).singleResult(); // model.addAttribute("nodeDtos", // traceService.traceProcessInstance(processInstanceId)); // model.addAttribute("historyActivities", processEngine // .getHistoryService().createHistoricActivityInstanceQuery() // .processInstanceId(processInstanceId).list()); // if (historicProcessInstance.getEndTime() == null) { // model.addAttribute("currentActivities", processEngine // .getRuntimeService() // .getActiveActivityIds(processInstanceId)); // } else { // model.addAttribute("currentActivities", Collections // .singletonList(historicProcessInstance.getEndActivityId())); // } }
Example #6
Source File: AbstractProcessInstanceQueryResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected List<ProcessInstanceRepresentation> convertInstanceList(List<HistoricProcessInstance> instances) { List<ProcessInstanceRepresentation> result = new ArrayList<ProcessInstanceRepresentation>(); if (CollectionUtils.isNotEmpty(instances)) { for (HistoricProcessInstance processInstance : instances) { User userRep = null; if (processInstance.getStartUserId() != null) { CachedUser user = userCache.getUser(processInstance.getStartUserId()); if (user != null && user.getUser() != null) { userRep = user.getUser(); } } ProcessDefinitionEntity procDef = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId()); ProcessInstanceRepresentation instanceRepresentation = new ProcessInstanceRepresentation(processInstance, procDef, procDef.isGraphicalNotationDefined(), userRep); result.add(instanceRepresentation); } } return result; }
Example #7
Source File: ProcessConnectorImpl.java From lemon with Apache License 2.0 | 6 votes |
/** * 参与流程. */ public Page findInvolvedProcessInstances(String userId, String tenantId, Page page) { HistoryService historyService = processEngine.getHistoryService(); // TODO: finished(), unfinished() long count = historyService.createHistoricProcessInstanceQuery() .processInstanceTenantId(tenantId).involvedUser(userId).count(); List<HistoricProcessInstance> historicProcessInstances = historyService .createHistoricProcessInstanceQuery() .processInstanceTenantId(tenantId).involvedUser(userId) .orderByProcessInstanceStartTime().desc() .listPage((int) page.getStart(), page.getPageSize()); page.setResult(historicProcessInstances); page.setTotalCount(count); return page; }
Example #8
Source File: HistoricProcessInstanceQueryImpl.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void localize(HistoricProcessInstance processInstance, CommandContext commandContext) { processInstance.setLocalizedName(null); processInstance.setLocalizedDescription(null); if (locale != null && processInstance.getProcessDefinitionId() != null) { ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processInstance.getProcessDefinitionId()); ObjectNode languageNode = Context.getLocalizationElementProperties(locale, processDefinition.getKey(), processInstance.getProcessDefinitionId(), withLocalizationFallback); if (languageNode != null) { JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME); if (languageNameNode != null && !languageNameNode.isNull()) { processInstance.setLocalizedName(languageNameNode.asText()); } JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION); if (languageDescriptionNode != null && !languageDescriptionNode.isNull()) { processInstance.setLocalizedDescription(languageDescriptionNode.asText()); } } } }
Example #9
Source File: ActivitiKit.java From my_curd with Apache License 2.0 | 6 votes |
/** * 流程高亮跟踪图 * * @param processInstanceId 流程实例Id * @return 图片输入流 */ public static InputStream getInstanceDiagram(String processInstanceId) { HistoricProcessInstance processInstance = ActivitiKit.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); BpmnModel bpmnModel = ActivitiKit.getRepositoryService().getBpmnModel(processInstance.getProcessDefinitionId()); ProcessEngineConfiguration processEngineConfiguration = ActivitiKit.getProcessEngine().getProcessEngineConfiguration(); Context.setProcessEngineConfiguration((ProcessEngineConfigurationImpl) processEngineConfiguration); ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator(); ProcessDefinitionEntity definitionEntity = (ProcessDefinitionEntity) ActivitiKit.getRepositoryService().getProcessDefinition(processInstance.getProcessDefinitionId()); List<HistoricActivityInstance> highLightedActivitList = ActivitiKit.getHistoryService().createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list(); List<String> highLightedActivitis = new ArrayList<>(); List<String> highLightedFlows = getHighLightedFlows(definitionEntity, highLightedActivitList); for (HistoricActivityInstance tempActivity : highLightedActivitList) { String activityId = tempActivity.getActivityId(); highLightedActivitis.add(activityId); } // 中文乱码 解决 return diagramGenerator.generateDiagram(bpmnModel, "png", highLightedActivitis, highLightedFlows, "黑体", "黑体", "黑体", null, 1.0); }
Example #10
Source File: AbstractRelatedContentResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected List<ProcessInstanceRepresentation> convertInstanceList(List<HistoricProcessInstance> instances) { List<ProcessInstanceRepresentation> result = new ArrayList<ProcessInstanceRepresentation>(); if (CollectionUtils.isNotEmpty(instances)) { for (HistoricProcessInstance processInstance : instances) { User userRep = null; if(processInstance.getStartUserId() != null) { UserCache.CachedUser user = userCache.getUser(processInstance.getStartUserId()); if(user != null && user.getUser() != null) { userRep = user.getUser(); } } ProcessDefinitionEntity procDef = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId()); ProcessInstanceRepresentation instanceRepresentation = new ProcessInstanceRepresentation( processInstance, procDef, procDef.isGraphicalNotationDefined(), userRep); result.add(instanceRepresentation); } } return result; }
Example #11
Source File: ActivitiWorkflowServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testBuildWorkflowWithNoUserTasks() throws Exception { // Deploy a definition containing only a service task WorkflowDefinition testDefinition = deployDefinition("activiti/testWorkflowNoUserTasks.bpmn20.xml"); WorkflowBuilder builder = new WorkflowBuilder(testDefinition, workflowService, nodeService, null); // Build a workflow WorkflowInstance builtInstance = builder.build(); assertNotNull(builtInstance); // Check that there is no active workflow for the deployed definition(it should have finished already due to absence of user tasks) List<WorkflowInstance> activeInstances = workflowService.getActiveWorkflows(testDefinition.getId()); assertNotNull(activeInstances); assertEquals(0, activeInstances.size()); // Check that there's a historic record of our 'only service task' workflow being run. HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .finishedAfter(builtInstance.getStartDate()) .singleResult(); assertNotNull(historicProcessInstance); }
Example #12
Source File: ActivitiServiceTest.java From herd with Apache License 2.0 | 6 votes |
@Test public void testGetHistoricProcessInstancesByStatusAndProcessDefinitionKeysWhenStatusNotSpecified() { JobStatusEnum jobStatus = null; Collection<String> processDefinitionKeys = new ArrayList<>(); DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); HistoricProcessInstanceQuery historicProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class); when(activitiHistoryService.createHistoricProcessInstanceQuery()).thenReturn(historicProcessInstanceQuery); when(historicProcessInstanceQuery.processDefinitionKeyIn(new ArrayList<>(processDefinitionKeys))).thenReturn(historicProcessInstanceQuery); when(historicProcessInstanceQuery.unfinished()).thenReturn(historicProcessInstanceQuery); when(historicProcessInstanceQuery.startedAfter(startTime.toDate())).thenReturn(historicProcessInstanceQuery); when(historicProcessInstanceQuery.finishedBefore(endTime.toDate())).thenReturn(historicProcessInstanceQuery); List<HistoricProcessInstance> expectedHistoricProcessInstances = new ArrayList<>(); when(historicProcessInstanceQuery.list()).thenReturn(expectedHistoricProcessInstances); List<HistoricProcessInstance> actualHistoricProcessInstance = activitiService.getHistoricProcessInstancesByStatusAndProcessDefinitionKeys(jobStatus, processDefinitionKeys, startTime, endTime); assertSame(expectedHistoricProcessInstances, actualHistoricProcessInstance); InOrder inOrder = inOrder(historicProcessInstanceQuery); inOrder.verify(historicProcessInstanceQuery).processDefinitionKeyIn(new ArrayList<>(processDefinitionKeys)); inOrder.verify(historicProcessInstanceQuery).startedAfter(startTime.toDate()); inOrder.verify(historicProcessInstanceQuery).finishedBefore(endTime.toDate()); inOrder.verify(historicProcessInstanceQuery).list(); inOrder.verifyNoMoreInteractions(); }
Example #13
Source File: ProcessConnectorImpl.java From lemon with Apache License 2.0 | 6 votes |
/** * 已结流程. */ public Page findCompletedProcessInstances(String userId, String tenantId, Page page) { HistoryService historyService = processEngine.getHistoryService(); long count = historyService.createHistoricProcessInstanceQuery() .processInstanceTenantId(tenantId).startedBy(userId).finished() .count(); List<HistoricProcessInstance> historicProcessInstances = historyService .createHistoricProcessInstanceQuery().startedBy(userId) .processInstanceTenantId(tenantId).finished() .orderByProcessInstanceStartTime().desc() .listPage((int) page.getStart(), page.getPageSize()); page.setResult(historicProcessInstances); page.setTotalCount(count); return page; }
Example #14
Source File: RuntimeServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources={ "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testDeleteProcessInstanceNullReason() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count()); // Deleting without a reason should be possible runtimeService.deleteProcessInstance(processInstance.getId(), null); assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(processInstance.getId()) .singleResult(); assertNotNull(historicInstance); assertEquals("ACTIVITY_DELETED", historicInstance.getDeleteReason()); } }
Example #15
Source File: AbstractActivitiTestCase.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void assertProcessEnded(final String processInstanceId) { ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if (processInstance != null) { throw new AssertionFailedError("Expected finished process instance '" + processInstanceId + "' but it was still in the db"); } // Verify historical data if end times are correctly set if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { // process instance HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(processInstanceId).singleResult(); assertEquals(processInstanceId, historicProcessInstance.getId()); assertNotNull("Historic process instance has no start time", historicProcessInstance.getStartTime()); assertNotNull("Historic process instance has no end time", historicProcessInstance.getEndTime()); // tasks List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstanceId).list(); if (historicTaskInstances != null && historicTaskInstances.size() > 0) { for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) { assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime()); } } // activities List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery() .processInstanceId(processInstanceId).list(); if (historicActivityInstances != null && historicActivityInstances.size() > 0) { for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) { assertEquals(processInstanceId, historicActivityInstance.getProcessInstanceId()); assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no start time", historicActivityInstance.getStartTime()); assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no end time", historicActivityInstance.getEndTime()); } } } }
Example #16
Source File: MultiInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelCallActivity.bpmn20.xml", "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" }) public void testParallelCallActivityHistory() { runtimeService.startProcessInstanceByKey("miParallelCallActivity"); List<Task> tasks = taskService.createTaskQuery().list(); assertEquals(12, tasks.size()); for (int i = 0; i < tasks.size(); i++) { taskService.complete(tasks.get(i).getId()); } if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // Validate historic processes List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list(); assertEquals(7, historicProcessInstances.size()); // 6 subprocesses // + main process for (HistoricProcessInstance hpi : historicProcessInstances) { assertNotNull(hpi.getStartTime()); assertNotNull(hpi.getEndTime()); } // Validate historic tasks List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list(); assertEquals(12, historicTaskInstances.size()); for (HistoricTaskInstance hti : historicTaskInstances) { assertNotNull(hti.getStartTime()); assertNotNull(hti.getEndTime()); assertNotNull(hti.getAssignee()); assertNull(hti.getDeleteReason()); } // Validate historic activities List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("callActivity").list(); assertEquals(6, historicActivityInstances.size()); for (HistoricActivityInstance hai : historicActivityInstances) { assertNotNull(hai.getStartTime()); assertNotNull(hai.getEndTime()); } } }
Example #17
Source File: ProcessInfo.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public ProcessInfo(HistoricProcessInstance processInstance) { this.id = processInstance.getId(); this.processDefinitionId = processInstance.getProcessDefinitionId(); this.startedAt = processInstance.getStartTime(); this.endedAt = processInstance.getEndTime(); this.durationInMs = processInstance.getDurationInMillis(); this.deleteReason = processInstance.getDeleteReason(); this.startUserId = processInstance.getStartUserId(); this.startActivityId = processInstance.getStartActivityId(); this.endActivityId = processInstance.getEndActivityId(); this.businessKey = processInstance.getBusinessKey(); this.superProcessInstanceId = processInstance.getSuperProcessInstanceId(); this.completed = (processInstance.getEndTime() != null); }
Example #18
Source File: HistoryServiceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testHistoricProcessInstanceUserIdAndActivityId() { identityService.setAuthenticatedUserId("johndoe"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertEquals("johndoe", historicProcessInstance.getStartUserId()); assertEquals("theStart", historicProcessInstance.getStartActivityId()); List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); assertEquals(1, tasks.size()); taskService.complete(tasks.get(0).getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertEquals("theEnd", historicProcessInstance.getEndActivityId()); }
Example #19
Source File: HistoricProcessInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = {"org/activiti5/engine/test/history/oneTaskProcess.bpmn20.xml"}) public void testDeleteProcessInstanceHistoryCreated() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertNotNull(processInstance); // delete process instance should not delete the history runtimeService.deleteProcessInstance(processInstance.getId(), "cancel"); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult(); assertNotNull(historicProcessInstance.getEndTime()); }
Example #20
Source File: TraceProcessController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 读取历史数据 * * @return */ @RequestMapping(value = "trace/view/{executionId}") public ModelAndView historyDatas(@PathVariable("executionId") String executionId) { ModelAndView mav = new ModelAndView("chapter13/trace-process"); // 查询Execution对象 Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult(); // 查询所有的历史活动记录 String processInstanceId = execution.getProcessInstanceId(); List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list(); // 查询历史流程实例 HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(processInstanceId).singleResult(); // 查询流程有关的变量 List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery() .processInstanceId(processInstanceId).list(); List<HistoricDetail> formProperties = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).formProperties().list(); // 查询流程定义对象 ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult(); // 查询运行时流程实例 ProcessInstance parentProcessInstance = runtimeService.createProcessInstanceQuery() .subProcessInstanceId(execution.getProcessInstanceId()).singleResult(); mav.addObject("parentProcessInstance", parentProcessInstance); mav.addObject("historicProcessInstance", historicProcessInstance); mav.addObject("variableInstances", variableInstances); mav.addObject("activities", activityInstances); mav.addObject("formProperties", formProperties); mav.addObject("processDefinition", processDefinition); mav.addObject("executionId", executionId); return mav; }
Example #21
Source File: HistoricProcessInstanceQueryVersionTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testHistoricProcessInstanceQueryByProcessDefinitionVersion() { assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(1).list().get(0).getProcessDefinitionVersion().intValue()); assertEquals(2, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(2).list().get(0).getProcessDefinitionVersion().intValue()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(1).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(2).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(3).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(1).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(2).list().size()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(3).list().size()); // Variables Case if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("test", 123).processDefinitionVersion(1).singleResult(); assertEquals(1, processInstance.getProcessDefinitionVersion().intValue()); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertEquals(123, variableMap.get("test")); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 456).processDefinitionVersion(1).singleResult(); assertNull(processInstance); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 456).processDefinitionVersion(2).singleResult(); assertEquals(2, processInstance.getProcessDefinitionVersion().intValue()); variableMap = processInstance.getProcessVariables(); assertEquals(456, variableMap.get("anothertest")); } }
Example #22
Source File: HistoricProcessInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti/engine/test/history/oneTaskProcess.bpmn20.xml" }) // ACT-1098 public void testDeleteReason() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { final String deleteReason = "some delete reason"; ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.deleteProcessInstance(pi.getId(), deleteReason); HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(pi.getId()).singleResult(); assertEquals(deleteReason, hpi.getDeleteReason()); } }
Example #23
Source File: ProcessConnectorImpl.java From lemon with Apache License 2.0 | 5 votes |
/** * 历史流程实例. */ public Page findHistoricProcessInstances(String tenantId, Page page) { HistoryService historyService = processEngine.getHistoryService(); long count = historyService.createHistoricProcessInstanceQuery() .processInstanceTenantId(tenantId).count(); List<HistoricProcessInstance> historicProcessInstances = historyService .createHistoricProcessInstanceQuery() .processInstanceTenantId(tenantId) .listPage((int) page.getStart(), page.getPageSize()); page.setResult(historicProcessInstances); page.setTotalCount(count); return page; }
Example #24
Source File: HistoricProcessInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = {"org/activiti5/engine/test/history/oneTaskProcess.bpmn20.xml"}) // ACT-1098 public void testDeleteReason() { if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { final String deleteReason = "some delete reason"; ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.deleteProcessInstance(pi.getId(), deleteReason); HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(pi.getId()).singleResult(); assertEquals(deleteReason, hpi.getDeleteReason()); } }
Example #25
Source File: MyTransactionalOperationTransactionDependentExecutionListener.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void notify(String processInstanceId, String executionId, FlowElement currentFlowElement, Map<String, Object> executionVariables, Map<String, Object> customPropertiesMap) { super.notify(processInstanceId, executionId, currentFlowElement, executionVariables, customPropertiesMap); if (Context.getCommandContext().getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { HistoryService historyService = Context.getCommandContext().getProcessEngineConfiguration().getHistoryService(); // delete first historic instance List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list(); historyService.deleteHistoricProcessInstance(historicProcessInstances.get(0).getId()); } }
Example #26
Source File: PlaybackProcessStartTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void checkStatus() { final List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery(). finished(). list(); assertNotNull(historicProcessInstances); assertEquals(2, historicProcessInstances.size()); }
Example #27
Source File: HistoricProcessInstanceCommentResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected HistoricProcessInstance getHistoricProcessInstanceFromRequest(String processInstanceId) { HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if (processInstance == null) { throw new ActivitiObjectNotFoundException("Could not find a process instance with id '" + processInstanceId + "'.", HistoricProcessInstance.class); } return processInstance; }
Example #28
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ public WorkflowInstance deleteWorkflow(String workflowId) { String localId = createLocalId(workflowId); try { // Delete the runtime process instance if still running, this calls the end-listeners if any ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(localId).singleResult(); if(processInstance != null) { runtimeService.deleteProcessInstance(processInstance.getId(), ActivitiConstants.DELETE_REASON_DELETED); } // Convert historic process instance HistoricProcessInstance deletedInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(localId) .singleResult(); if(deletedInstance == null) { throw new WorkflowException(messageService.getMessage(ERR_DELETE_UNEXISTING_WORKFLOW, localId)); } WorkflowInstance result = typeConverter.convert(deletedInstance); // Delete the historic process instance historyService.deleteHistoricProcessInstance(deletedInstance.getId()); return result; } catch(ActivitiException ae) { String msg = messageService.getMessage(ERR_DELETE_WORKFLOW); if(logger.isDebugEnabled()) { logger.debug(msg, ae); } throw new WorkflowException(msg, ae); } }
Example #29
Source File: ActivitiWorkflowComponentTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testDeleteWorkflow() throws Exception { WorkflowDefinition def = deployTestAdhocDefinition(); ProcessInstance processInstance = runtime.startProcessInstanceById(BPMEngineRegistry.getLocalId(def.getId())); // Validate if a workflow exists List<WorkflowInstance> instances = workflowEngine.getActiveWorkflows(def.getId()); assertNotNull(instances); assertEquals(1, instances.size()); assertEquals(processInstance.getId(), BPMEngineRegistry.getLocalId(instances.get(0).getId())); // Call delete method on component workflowEngine.deleteWorkflow(instances.get(0).getId()); instances = workflowEngine.getActiveWorkflows(def.getId()); assertNotNull(instances); assertEquals(0, instances.size()); // Historic process instance shouldn't be present HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(processInstance.getProcessInstanceId()) .singleResult(); assertNull(historicProcessInstance); }
Example #30
Source File: HistoricProcessInstanceCommentCollectionResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected HistoricProcessInstance getHistoricProcessInstanceFromRequest(String processInstanceId) { HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if (processInstance == null) { throw new ActivitiObjectNotFoundException("Could not find a process instance with id '" + processInstanceId + "'.", HistoricProcessInstance.class); } return processInstance; }