org.flowable.engine.history.HistoricProcessInstance Java Examples
The following examples show how to use
org.flowable.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: HistoryServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/oneTaskProcess.bpmn20.xml", "org/flowable/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" }) public void testHistoricProcessInstanceQueryByDeploymentIdIn() { org.flowable.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult(); for (int i = 0; i < 4; i++) { runtimeService.startProcessInstanceByKey("oneTaskProcess", String.valueOf(i)); } runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1"); HistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(processEngineConfiguration, managementService, 7000, 200); List<String> deploymentIds = new ArrayList<>(); deploymentIds.add(deployment.getId()); deploymentIds.add("invalid"); HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentIdIn(deploymentIds); assertThat(processInstanceQuery.count()).isEqualTo(5); List<HistoricProcessInstance> processInstances = processInstanceQuery.list(); assertThat(processInstances).isNotNull(); assertThat(processInstances).hasSize(5); deploymentIds = new ArrayList<>(); deploymentIds.add("invalid"); processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentIdIn(deploymentIds); assertThat(processInstanceQuery.count()).isZero(); }
Example #2
Source File: HistoryServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/oneTaskProcess.bpmn20.xml", "org/flowable/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" }) public void testHistoricProcessInstanceQueryByDeploymentId() { org.flowable.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult(); for (int i = 0; i < 4; i++) { runtimeService.startProcessInstanceByKey("oneTaskProcess", String.valueOf(i)); } runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1"); HistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(processEngineConfiguration, managementService, 7000, 200); HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentId(deployment.getId()); assertThat(processInstanceQuery.count()).isEqualTo(5); assertThat(processInstanceQuery.list().get(0).getDeploymentId()).isEqualTo(deployment.getId()); List<HistoricProcessInstance> processInstances = processInstanceQuery.list(); assertThat(processInstances).isNotNull(); assertThat(processInstances).hasSize(5); processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentId("invalid"); assertThat(processInstanceQuery.count()).isZero(); }
Example #3
Source File: HistoricProcessInstanceQueryEscapeClauseTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void testQueryByTenantIdLike() { if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { // tenantIdLike HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceTenantIdLike("%|%%") .singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance1.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceTenantIdLike("%|_%").singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance2.getId()); // orQuery historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceTenantIdLike("%|%%") .processDefinitionId("undefined").singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance1.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceTenantIdLike("%|_%") .processDefinitionId("undefined").singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance2.getId()); } }
Example #4
Source File: FlowableHistoricDataCleanerTest.java From multiapps-controller with Apache License 2.0 | 6 votes |
@Test public void testExecuteResilience() { HistoricProcessInstance process1 = mockHistoricProcessInstanceWithId(OPERATION_ID_1); HistoricProcessInstance process2 = mockHistoricProcessInstanceWithId(OPERATION_ID_2); List<HistoricProcessInstance> page1 = Arrays.asList(process1, process2); List<HistoricProcessInstance> page2 = Collections.emptyList(); HistoricProcessInstanceQuery query = mockHistoricProcessInstanceQueryWithPages(Arrays.asList(page1, page2)); when(historyService.createHistoricProcessInstanceQuery()).thenReturn(query); doThrow(new FlowableObjectNotFoundException("Oops! Someone was faster than you!")).when(historyService) .deleteHistoricProcessInstance(OPERATION_ID_1); cleaner.execute(EXPIRATION_TIME); verify(historyService).deleteHistoricProcessInstance(OPERATION_ID_1); verify(historyService).deleteHistoricProcessInstance(OPERATION_ID_2); }
Example #5
Source File: HistoricProcessInstanceCommentResource.java From flowable-engine with Apache License 2.0 | 6 votes |
@ApiOperation(value = "Delete a comment on a historic process instance", tags = { "History Process" }, notes = "") @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the historic process instance and comment were found and the comment is deleted. Response body is left empty intentionally."), @ApiResponse(code = 404, message = "Indicates the requested historic process instance was not found or the historic process instance does not have a comment with the given ID.") }) @DeleteMapping(value = "/history/historic-process-instances/{processInstanceId}/comments/{commentId}") public void deleteComment(@ApiParam(name = "processInstanceId") @PathVariable("processInstanceId") String processInstanceId, @ApiParam(name = "commentId") @PathVariable("commentId") String commentId, HttpServletRequest request, HttpServletResponse response) { HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId); Comment comment = taskService.getComment(commentId); if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) { throw new FlowableObjectNotFoundException("Process instance '" + instance.getId() + "' does not have a comment with id '" + commentId + "'.", Comment.class); } taskService.deleteComment(commentId); response.setStatus(HttpStatus.NO_CONTENT.value()); }
Example #6
Source File: HistoryServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/examples/bpmn/callactivity/orderProcess.bpmn20.xml", "org/activiti/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml" }) public void testOrderProcessWithCallActivity() { // After the process has started, the 'verify credit history' task should be // active ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess"); TaskQuery taskQuery = taskService.createTaskQuery(); org.flowable.task.api.Task verifyCreditTask = taskQuery.singleResult(); // Completing the task with approval, will end the subprocess and continue // the original process taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true)); org.flowable.task.api.Task prepareAndShipTask = taskQuery.singleResult(); assertEquals("Prepare and Ship", prepareAndShipTask.getName()); // verify HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult(); assertNotNull(historicProcessInstance); assertTrue(historicProcessInstance.getProcessDefinitionId().contains("checkCreditProcess")); }
Example #7
Source File: HistoricProcessInstanceQueryEscapeClauseTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void testQueryLikeIgnoreCaseByQueryVariableValue() { if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { // queryVariableValueIgnoreCase HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("var1", "%|%%") .singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance1.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("var1", "%|_%").singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance2.getId()); // orQuery historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLikeIgnoreCase("var1", "%|%%") .processDefinitionId("undefined").singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance1.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLikeIgnoreCase("var1", "%|_%") .processDefinitionId("undefined").singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance2.getId()); } }
Example #8
Source File: HistoryServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" }) public void testHistoricProcessInstanceQueryByDeploymentId() { org.flowable.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult(); for (int i = 0; i < 4; i++) { runtimeService.startProcessInstanceByKey("oneTaskProcess", String.valueOf(i)).getId(); } 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 #9
Source File: HistoryServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" }) public void testHistoricProcessInstanceQueryByDeploymentIdIn() { org.flowable.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult(); for (int i = 0; i < 4; i++) { runtimeService.startProcessInstanceByKey("oneTaskProcess", String.valueOf(i)).getId(); } runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId(); List<String> deploymentIds = new ArrayList<String>(); deploymentIds.add(deployment.getId()); deploymentIds.add("invalid"); HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentIdIn(deploymentIds); assertEquals(5, processInstanceQuery.count()); List<HistoricProcessInstance> processInstances = processInstanceQuery.list(); assertNotNull(processInstances); assertEquals(5, processInstances.size()); deploymentIds = new ArrayList<String>(); deploymentIds.add("invalid"); processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentIdIn(deploymentIds); assertEquals(0, processInstanceQuery.count()); }
Example #10
Source File: HistoricProcessInstanceQueryEscapeClauseTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void testQueryByProcessInstanceNameLike() { if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { // processInstanceNameLike HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceNameLike("%|%%") .singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance1.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceNameLike("%|_%").singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance2.getId()); // orQuery historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceNameLike("%|%%").processDefinitionId("undefined") .singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance1.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceNameLike("%|_%").processDefinitionId("undefined") .singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getId()).isEqualTo(processInstance2.getId()); } }
Example #11
Source File: ServiceCacheTask.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void execute(DelegateExecution execution) { ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); RuntimeService runtimeService = processEngineConfiguration.getRuntimeService(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId()).singleResult(); if (processInstance != null && processInstance.getId().equals(execution.getProcessInstanceId())) { processInstanceId = processInstance.getId(); } Execution queryExecution = runtimeService.createExecutionQuery().executionId(execution.getId()).singleResult(); if (queryExecution != null && execution.getId().equals(queryExecution.getId())) { executionId = queryExecution.getId(); } HistoryService historyService = processEngineConfiguration.getHistoryService(); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId()).singleResult(); if (historicProcessInstance != null && historicProcessInstance.getId().equals(execution.getProcessInstanceId())) { historicProcessInstanceId = historicProcessInstance.getId(); } }
Example #12
Source File: FullHistoryTest.java From flowable-engine with Apache License 2.0 | 6 votes |
/** * Test confirming fix for ACT-1731 */ @Test @Deployment(resources = { "org/flowable/engine/test/history/oneTaskProcess.bpmn20.xml" }) public void testQueryHistoricProcessInstanceIncludeBinaryVariable() throws Exception { // Start process with a binary variable ProcessInstance processInstance = runtimeService .startProcessInstanceByKey("oneTaskProcess", Collections.singletonMap("binaryVariable", (Object) "It is I, le binary".getBytes())); org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertThat(task).isNotNull(); // Complete task to end process taskService.complete(task.getId()); // Query task, including processVariables HistoricProcessInstance historicProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()) .includeProcessVariables().singleResult(); assertThat(historicProcess).isNotNull(); assertThat(historicProcess.getProcessVariables()).isNotNull(); byte[] bytes = (byte[]) historicProcess.getProcessVariables().get("binaryVariable"); assertThat(new String(bytes)).isEqualTo("It is I, le binary"); }
Example #13
Source File: BoundaryErrorEventTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment public void testDeeplyNestedErrorThrownOnlyAutomaticSteps() { // input == 1 -> error2 is thrown -> caught on subprocess2 -> end event in subprocess -> proc inst end 1 String procId = runtimeService.startProcessInstanceByKey("deeplyNestedErrorThrown", CollectionUtil.singletonMap("input", 1)).getId(); assertProcessEnded(procId); HistoricProcessInstance hip; if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult(); assertEquals("processEnd1", hip.getEndActivityId()); } // input == 2 -> error2 is thrown -> caught on subprocess1 -> proc inst end 2 procId = runtimeService.startProcessInstanceByKey("deeplyNestedErrorThrown", CollectionUtil.singletonMap("input", 1)).getId(); assertProcessEnded(procId); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult(); assertEquals("processEnd1", hip.getEndActivityId()); } }
Example #14
Source File: RuntimeServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testDeleteProcessInstanceNullReason() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertThat(runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count()).isEqualTo(1); // Deleting without a reason should be possible runtimeService.deleteProcessInstance(processInstance.getId(), null); assertThat(runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count()).isZero(); if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()) .singleResult(); assertThat(historicInstance).isNotNull(); assertThat(historicInstance.getDeleteReason()).isEqualTo(DeleteReason.PROCESS_INSTANCE_DELETED); } }
Example #15
Source File: HistoryServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" }) public void testHistoricProcessInstanceQueryByProcessInstanceIds() { HashSet<String> processInstanceIds = new HashSet<String>(); for (int i = 0; i < 4; i++) { processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", String.valueOf(i)).getId()); } processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId()); // start an instance that will not be part of the query runtimeService.startProcessInstanceByKey("oneTaskProcess2", "2"); HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().processInstanceIds(processInstanceIds); assertEquals(5, processInstanceQuery.count()); List<HistoricProcessInstance> processInstances = processInstanceQuery.list(); assertNotNull(processInstances); assertEquals(5, processInstances.size()); for (HistoricProcessInstance historicProcessInstance : processInstances) { assertTrue(processInstanceIds.contains(historicProcessInstance.getId())); } }
Example #16
Source File: AbstractProcessInstanceDeleteHistoryTransformer.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void deleteProcessInstance(String processInstanceId, CommandContext commandContext) { HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager = CommandContextUtil.getHistoricProcessInstanceEntityManager(commandContext); HistoricProcessInstanceEntity historicProcessInstance = historicProcessInstanceEntityManager.findById(processInstanceId); CommandContextUtil.getHistoricDetailEntityManager(commandContext).deleteHistoricDetailsByProcessInstanceId(processInstanceId); CommandContextUtil.getHistoricVariableService().deleteHistoricVariableInstancesByProcessInstanceId(processInstanceId); CommandContextUtil.getHistoricActivityInstanceEntityManager(commandContext).deleteHistoricActivityInstancesByProcessInstanceId(processInstanceId); TaskHelper.deleteHistoricTaskInstancesByProcessInstanceId(processInstanceId); CommandContextUtil.getHistoricIdentityLinkService().deleteHistoricIdentityLinksByProcessInstanceId(processInstanceId); HistoricEntityLinkService historicEntityLinkService = CommandContextUtil.getHistoricEntityLinkService(); if (historicEntityLinkService != null) { historicEntityLinkService.deleteHistoricEntityLinksByScopeIdAndScopeType(processInstanceId, ScopeTypes.BPMN); } CommandContextUtil.getCommentEntityManager(commandContext).deleteCommentsByProcessInstanceId(processInstanceId); historicProcessInstanceEntityManager.delete(historicProcessInstance, false); // Also delete any sub-processes that may be active (ACT-821) List<HistoricProcessInstance> selectList = historicProcessInstanceEntityManager.findHistoricProcessInstancesBySuperProcessInstanceId(processInstanceId); for (HistoricProcessInstance child : selectList) { deleteProcessInstance(child.getId(), commandContext); } }
Example #17
Source File: HistoricProcessInstanceCommentCollectionResource.java From flowable-engine with Apache License 2.0 | 6 votes |
@ApiOperation(value = "Create a new comment on a historic process instance", tags = { "History Process" }, notes = "Parameter saveProcessInstanceId is optional, if true save process instance id of task with comment.") @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the comment was created and the result is returned."), @ApiResponse(code = 400, message = "Indicates the comment is missing from the request."), @ApiResponse(code = 404, message = "Indicates that the historic process instance could not be found.") }) @PostMapping(value = "/history/historic-process-instances/{processInstanceId}/comments", produces = "application/json") public CommentResponse createComment(@ApiParam(name = "processInstanceId") @PathVariable String processInstanceId, @RequestBody CommentResponse comment, HttpServletRequest request, HttpServletResponse response) { HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId); if (comment.getMessage() == null) { throw new FlowableIllegalArgumentException("Comment text is required."); } Comment createdComment = taskService.addComment(null, instance.getId(), comment.getMessage()); response.setStatus(HttpStatus.CREATED.value()); return restResponseFactory.createRestComment(createdComment); }
Example #18
Source File: FlowableCommentService.java From flowable-engine with Apache License 2.0 | 6 votes |
public CommentRepresentation addProcessInstanceComment(CommentRepresentation commentRequest, String processInstanceId) { if (StringUtils.isBlank(commentRequest.getMessage())) { throw new BadRequestException("Comment should not be empty"); } HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if (processInstance == null) { throw new NotFoundException("No process instance found with id: " + processInstanceId); } // Check read permission and message User currentUser = SecurityUtils.getCurrentUserObject(); checkReadPermissionOnProcessInstance(currentUser, processInstanceId); // Create comment Comment comment = createComment(commentRequest.getMessage(), currentUser, processInstanceId); return new CommentRepresentation(comment); }
Example #19
Source File: FlowableAbstractTaskService.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void verifyProcessInstanceStartUser(TaskRepresentation taskRepresentation, TaskInfo task) { if (task.getProcessInstanceId() != null) { HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); if (historicProcessInstance != null && StringUtils.isNotEmpty(historicProcessInstance.getStartUserId())) { taskRepresentation.setProcessInstanceStartUserId(historicProcessInstance.getStartUserId()); BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; List<ExtensionElement> extensionElements = userTask.getExtensionElements().get("initiator-can-complete"); if (CollectionUtils.isNotEmpty(extensionElements)) { String value = extensionElements.get(0).getElementText(); if (StringUtils.isNotEmpty(value)) { taskRepresentation.setInitiatorCanCompleteTask(Boolean.valueOf(value)); } } } } } }
Example #20
Source File: HistoryServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testHistoricProcessInstanceUserIdAndActivityId() { identityService.setAuthenticatedUserId("johndoe"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); HistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(processEngineConfiguration, managementService, 7000, 200); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertThat(historicProcessInstance.getStartUserId()).isEqualTo("johndoe"); assertThat(historicProcessInstance.getStartActivityId()).isEqualTo("theStart"); List<org.flowable.task.api.Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); assertThat(tasks).hasSize(1); taskService.complete(tasks.get(0).getId()); HistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(processEngineConfiguration, managementService, 7000, 200); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertThat(historicProcessInstance.getEndActivityId()).isEqualTo("theEnd"); }
Example #21
Source File: FullHistoryTest.java From flowable-engine with Apache License 2.0 | 6 votes |
/** * Test confirming fix for ACT-1731 */ @Deployment(resources = { "org/activiti/engine/test/history/oneTaskProcess.bpmn20.xml" }) public void testQueryHistoricProcessInstanceIncludeBinaryVariable() throws Exception { // Start process with a binary variable ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.singletonMap("binaryVariable", (Object) "It is I, le binary".getBytes())); org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertNotNull(task); // Complete task to end process taskService.complete(task.getId()); // Query task, including processVariables HistoricProcessInstance historicProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).includeProcessVariables().singleResult(); assertNotNull(historicProcess); assertNotNull(historicProcess.getProcessVariables()); byte[] bytes = (byte[]) historicProcess.getProcessVariables().get("binaryVariable"); assertEquals("It is I, le binary", new String(bytes)); }
Example #22
Source File: HistoricProcessInstanceQueryEscapeClauseTest.java From flowable-engine with Apache License 2.0 | 6 votes |
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 #23
Source File: HistoricProcessInstanceQueryEscapeClauseTest.java From flowable-engine with Apache License 2.0 | 6 votes |
public void testQueryLikeByQueryVariableValue() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // queryVariableValue HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLike("var1", "%|%%").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance1.getId(), historicProcessInstance.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLike("var1", "%|_%").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance2.getId(), historicProcessInstance.getId()); // orQuery historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLike("var1", "%|%%").processDefinitionId("undefined").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance1.getId(), historicProcessInstance.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLike("var1", "%|_%").processDefinitionId("undefined").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance2.getId(), historicProcessInstance.getId()); } }
Example #24
Source File: HistoricProcessInstanceQueryEscapeClauseTest.java From flowable-engine with Apache License 2.0 | 6 votes |
public void testQueryByTenantIdLike() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // tenantIdLike HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceTenantIdLike("%|%%").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance1.getId(), historicProcessInstance.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceTenantIdLike("%|_%").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance2.getId(), historicProcessInstance.getId()); // orQuery historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceTenantIdLike("%|%%").processDefinitionId("undefined").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance1.getId(), historicProcessInstance.getId()); historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceTenantIdLike("%|_%").processDefinitionId("undefined").singleResult(); assertNotNull(historicProcessInstance); assertEquals(processInstance2.getId(), historicProcessInstance.getId()); } }
Example #25
Source File: HistoricActivityInstanceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/engine/test/history/calledProcess.bpmn20.xml", "org/activiti/engine/test/history/HistoricActivityInstanceTest.testCallSimpleSubProcess.bpmn20.xml" }) public void testHistoricActivityInstanceCalledProcessId() { runtimeService.startProcessInstanceByKey("callSimpleSubProcess"); HistoricActivityInstance historicActivityInstance = historyService .createHistoricActivityInstanceQuery() .activityId("callSubProcess") .singleResult(); HistoricProcessInstance oldInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("calledProcess").singleResult(); assertEquals(oldInstance.getId(), historicActivityInstance.getCalledProcessInstanceId()); }
Example #26
Source File: RuntimeActivityInstanceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/history/calledProcess.bpmn20.xml", "org/flowable/engine/test/api/runtime/RuntimeActivityInstanceTest.testCallSimpleSubProcess.bpmn20.xml" }) public void testActivityInstanceCalledProcessId() { runtimeService.startProcessInstanceByKey("callSimpleSubProcess"); waitForHistoryJobExecutorToProcessAllJobs(7000, 100); ActivityInstance activityInstance = runtimeService.createActivityInstanceQuery().activityId("callSubProcess").singleResult(); if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("callSubProcess").singleResult(); assertActivityInstancesAreSame(historicActivityInstance, activityInstance); HistoricProcessInstance oldInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("calledProcess").singleResult(); assertThat(activityInstance.getCalledProcessInstanceId()).isEqualTo(oldInstance.getId()); } }
Example #27
Source File: HistoricProcessInstanceAndVariablesQueryTest.java From flowable-engine with Apache License 2.0 | 5 votes |
public void testQueryByprocessDefinition() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // DeploymentId String deploymentId = repositoryService.createDeploymentQuery().list().get(0).getId(); HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 123).deploymentId(deploymentId).singleResult(); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertEquals(1, variableMap.size()); assertEquals(123, variableMap.get("anothertest")); assertEquals(deploymentId, processInstance.getDeploymentId()); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", "invalid").deploymentId(deploymentId).singleResult(); assertNull(processInstance); // ProcessDefinitionName processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 123).processDefinitionName(PROCESS_DEFINITION_NAME_2).singleResult(); variableMap = processInstance.getProcessVariables(); assertEquals(1, variableMap.size()); assertEquals(123, variableMap.get("anothertest")); assertEquals(PROCESS_DEFINITION_NAME_2, processInstance.getProcessDefinitionName()); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("test", "test").processDefinitionName(PROCESS_DEFINITION_NAME_2).singleResult(); assertNull(processInstance); // ProcessDefinitionCategory processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 123).processDefinitionCategory(PROCESS_DEFINITION_CATEGORY_2).singleResult(); variableMap = processInstance.getProcessVariables(); assertEquals(1, variableMap.size()); assertEquals(123, variableMap.get("anothertest")); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("test", "test").processDefinitionCategory(PROCESS_DEFINITION_CATEGORY_2).singleResult(); assertNull(processInstance); } }
Example #28
Source File: RestResponseFactory.java From plumdo-work with Apache License 2.0 | 5 votes |
public List<HistoricProcessInstanceResponse> createHistoricProcessInstanceResponseList(List<HistoricProcessInstance> processInstances) { List<HistoricProcessInstanceResponse> responseList = new ArrayList<>(); for (HistoricProcessInstance instance : processInstances) { responseList.add(createHistoricProcessInstanceResponse(instance)); } return responseList; }
Example #29
Source File: HistoryServiceTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/oneTaskProcess.bpmn20.xml", "org/flowable/examples/bpmn/callactivity/orderProcess.bpmn20.xml", "org/flowable/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml" }) public void testHistoricProcessInstanceQueryByProcessDefinitionKey() { String processDefinitionKey = "oneTaskProcess"; runtimeService.startProcessInstanceByKey(processDefinitionKey); runtimeService.startProcessInstanceByKey("orderProcess"); HistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(processEngineConfiguration, managementService, 7000, 200); HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey(processDefinitionKey) .singleResult(); assertThat(historicProcessInstance).isNotNull(); assertThat(historicProcessInstance.getProcessDefinitionKey()).isEqualTo(processDefinitionKey); assertThat(historicProcessInstance.getStartActivityId()).isEqualTo("theStart"); // now complete the task to end the process instance org.flowable.task.api.Task task = taskService.createTaskQuery().processDefinitionKey("checkCreditProcess").singleResult(); Map<String, Object> map = new HashMap<>(); map.put("creditApproved", true); taskService.complete(task.getId(), map); HistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(processEngineConfiguration, managementService, 7000, 200); // and make sure the super process instance is set correctly on the HistoricProcessInstance HistoricProcessInstance historicProcessInstanceSub = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("checkCreditProcess") .singleResult(); HistoricProcessInstance historicProcessInstanceSuper = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("orderProcess") .singleResult(); assertThat(historicProcessInstanceSub.getSuperProcessInstanceId()).isEqualTo(historicProcessInstanceSuper.getId()); }
Example #30
Source File: HistoryServiceTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testNativeHistoricActivityInstanceTest() { runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertEquals(1, historyService.createNativeHistoricActivityInstanceQuery().sql("SELECT count(*) FROM " + managementService.getTableName(HistoricProcessInstance.class)).count()); assertEquals(1, historyService.createNativeHistoricActivityInstanceQuery().sql("SELECT * FROM " + managementService.getTableName(HistoricProcessInstance.class)).list().size()); assertEquals(1, historyService.createNativeHistoricActivityInstanceQuery().sql("SELECT * FROM " + managementService.getTableName(HistoricProcessInstance.class)).listPage(0, 1).size()); }