org.activiti.engine.history.HistoricIdentityLink Java Examples
The following examples show how to use
org.activiti.engine.history.HistoricIdentityLink.
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: HistoricProcessInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/engine/test/history/oneTaskProcess.bpmn20.xml" }) public void testHistoricIdentityLinksOnProcessInstance() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.addUserIdentityLink(pi.getId(), "kermit", "myType"); // Check historic links List<HistoricIdentityLink> historicLinks = historyService.getHistoricIdentityLinksForProcessInstance(pi.getId()); assertEquals(1, historicLinks.size()); assertEquals("myType", historicLinks.get(0).getType()); assertEquals("kermit", historicLinks.get(0).getUserId()); assertNull(historicLinks.get(0).getGroupId()); assertEquals(pi.getId(), historicLinks.get(0).getProcessInstanceId()); // When process is ended, link should remain taskService.complete(taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult().getId()); assertNull(runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult()); assertEquals(1, historyService.getHistoricIdentityLinksForProcessInstance(pi.getId()).size()); // When process is deleted, identitylinks shouldn't exist anymore historyService.deleteHistoricProcessInstance(pi.getId()); assertEquals(0, historyService.getHistoricIdentityLinksForProcessInstance(pi.getId()).size()); } }
Example #2
Source File: AbstractTaskResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected List<UserRepresentation> getInvolvedUsers(String taskId) { List<HistoricIdentityLink> idLinks = historyService.getHistoricIdentityLinksForTask(taskId); List<UserRepresentation> result = new ArrayList<UserRepresentation>(idLinks.size()); for (HistoricIdentityLink link : idLinks) { // Only include users and non-assignee links if (link.getUserId() != null && !IdentityLinkType.ASSIGNEE.equals(link.getType())) { CachedUser cachedUser = userCache.getUser(link.getUserId()); if (cachedUser != null && cachedUser.getUser() != null) { result.add(new UserRepresentation(cachedUser.getUser())); } } } return result; }
Example #3
Source File: ActivitiTaskActionService.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected List<UserRepresentation> getInvolvedUsers(String taskId) { List<HistoricIdentityLink> idLinks = historyService.getHistoricIdentityLinksForTask(taskId); List<UserRepresentation> result = new ArrayList<UserRepresentation>(idLinks.size()); for (HistoricIdentityLink link : idLinks) { // Only include users and non-assignee links if (link.getUserId() != null && !IdentityLinkType.ASSIGNEE.equals(link.getType())) { CachedUser cachedUser = userCache.getUser(link.getUserId()); if (cachedUser != null && cachedUser.getUser() != null) { result.add(new UserRepresentation(cachedUser.getUser())); } } } return result; }
Example #4
Source File: GetHistoricIdentityLinksForTaskCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public List<HistoricIdentityLink> execute(CommandContext commandContext) { if (taskId != null) { return getLinksForTask(commandContext); } else { return getLinksForProcessInstance(commandContext); } }
Example #5
Source File: GetHistoricIdentityLinksForTaskCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public List<HistoricIdentityLink> execute(CommandContext commandContext) { if (taskId != null) { return getLinksForTask(commandContext); } else { return getLinksForProcessInstance(commandContext); } }
Example #6
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 testHistoricIdenityLinksOnProcessInstance() { Authentication.setAuthenticatedUserId(null); if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.addUserIdentityLink(pi.getId(), "kermit", "myType"); // Check historic links List<HistoricIdentityLink> historicLinks = historyService.getHistoricIdentityLinksForProcessInstance(pi.getId()); assertEquals(1, historicLinks.size()); assertEquals("myType", historicLinks.get(0).getType()); assertEquals("kermit", historicLinks.get(0).getUserId()); assertNull(historicLinks.get(0).getGroupId()); assertEquals(pi.getId(), historicLinks.get(0).getProcessInstanceId()); // When process is ended, link should remain taskService.complete(taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult().getId()); assertNull(runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult()); assertEquals(1, historyService.getHistoricIdentityLinksForProcessInstance(pi.getId()).size()); // When process is deleted, identitylinks shouldn't exist anymore historyService.deleteHistoricProcessInstance(pi.getId()); assertEquals(0, historyService.getHistoricIdentityLinksForProcessInstance(pi.getId()).size()); } }
Example #7
Source File: RestResponseFactory.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public List<HistoricIdentityLinkResponse> createHistoricIdentityLinkResponseList(List<HistoricIdentityLink> identityLinks) { RestUrlBuilder urlBuilder = createUrlBuilder(); List<HistoricIdentityLinkResponse> responseList = new ArrayList<HistoricIdentityLinkResponse>(); for (HistoricIdentityLink instance : identityLinks) { responseList.add(createHistoricIdentityLinkResponse(instance, urlBuilder)); } return responseList; }
Example #8
Source File: HistoricProcessInstanceIdentityLinkCollectionResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@ApiOperation(value = "Get the identity links of a historic process instance", tags = { "History" }, notes = "") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates request was successful and the identity links are returned", response = HistoricIdentityLinkResponse.class, responseContainer="List"), @ApiResponse(code = 404, message = "Indicates the process instance could not be found..") }) @RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/identitylinks", method = RequestMethod.GET, produces = "application/json") public List<HistoricIdentityLinkResponse> getProcessIdentityLinks(@ApiParam(name="processInstanceId") @PathVariable String processInstanceId, HttpServletRequest request) { List<HistoricIdentityLink> identityLinks = historyService.getHistoricIdentityLinksForProcessInstance(processInstanceId); if (identityLinks != null) { return restResponseFactory.createHistoricIdentityLinkResponseList(identityLinks); } return new ArrayList<HistoricIdentityLinkResponse>(); }
Example #9
Source File: RestResponseFactory.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public HistoricIdentityLinkResponse createHistoricIdentityLinkResponse(HistoricIdentityLink identityLink, RestUrlBuilder urlBuilder) { HistoricIdentityLinkResponse result = new HistoricIdentityLinkResponse(); result.setType(identityLink.getType()); result.setUserId(identityLink.getUserId()); result.setGroupId(identityLink.getGroupId()); result.setTaskId(identityLink.getTaskId()); if (StringUtils.isNotEmpty(identityLink.getTaskId())) { result.setTaskUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_TASK_INSTANCE, identityLink.getTaskId())); } result.setProcessInstanceId(identityLink.getProcessInstanceId()); if (StringUtils.isNotEmpty(identityLink.getProcessInstanceId())) { result.setProcessInstanceUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, identityLink.getProcessInstanceId())); } return result; }
Example #10
Source File: HistoricTaskInstanceIdentityLinkCollectionResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@ApiOperation(value = "Get the identity links of a historic task instance", tags = { "History" }, notes = "") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates request was successful and the identity links are returned", response = HistoricIdentityLinkResponse.class, responseContainer="List"), @ApiResponse(code = 404, message = "Indicates the task instance could not be found.") }) @RequestMapping(value = "/history/historic-task-instances/{taskId}/identitylinks", method = RequestMethod.GET, produces = "application/json") public List<HistoricIdentityLinkResponse> getTaskIdentityLinks(@ApiParam(name="taskId") @PathVariable String taskId, HttpServletRequest request) { List<HistoricIdentityLink> identityLinks = historyService.getHistoricIdentityLinksForTask(taskId); if (identityLinks != null) { return restResponseFactory.createHistoricIdentityLinkResponseList(identityLinks); } return new ArrayList<HistoricIdentityLinkResponse>(); }
Example #11
Source File: GetHistoricIdentityLinksForTaskCmd.java From flowable-engine with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) protected List<HistoricIdentityLink> getLinksForProcessInstance(CommandContext commandContext) { return (List) commandContext .getHistoricIdentityLinkEntityManager() .findHistoricIdentityLinksByProcessInstanceId(processInstanceId); }
Example #12
Source File: HistoryServiceImpl.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public List<HistoricIdentityLink> getHistoricIdentityLinksForTask(String taskId) { return commandExecutor.execute(new GetHistoricIdentityLinksForTaskCmd(taskId, null)); }
Example #13
Source File: HistoryServiceImpl.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public List<HistoricIdentityLink> getHistoricIdentityLinksForProcessInstance(String processInstanceId) { return commandExecutor.execute(new GetHistoricIdentityLinksForTaskCmd(null, processInstanceId)); }
Example #14
Source File: HistoricTaskInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Deployment public void testHistoricIdentityLinksOnTask() throws Exception { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("historicIdentityLinks"); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertNotNull(task); // Set additional identity-link not coming from process taskService.addUserIdentityLink(task.getId(), "gonzo", "customUseridentityLink"); assertEquals(4, taskService.getIdentityLinksForTask(task.getId()).size()); // Check historic identity-links when task is still active List<HistoricIdentityLink> historicIdentityLinks = historyService.getHistoricIdentityLinksForTask(task.getId()); assertEquals(4, historicIdentityLinks.size()); // Validate all links boolean foundCandidateUser= false, foundCandidateGroup = false, foundAssignee = false, foundCustom = false; for(HistoricIdentityLink link : historicIdentityLinks) { assertEquals(task.getId(), link.getTaskId()); if(link.getGroupId() != null) { assertEquals("sales", link.getGroupId()); foundCandidateGroup = true; } else { if(link.getType().equals("candidate")) { assertEquals("fozzie", link.getUserId()); foundCandidateUser = true; } else if(link.getType().equals("assignee")){ assertEquals("kermit", link.getUserId()); foundAssignee = true; } else if(link.getType().equals("customUseridentityLink")){ assertEquals("gonzo", link.getUserId()); foundCustom = true; } } } assertTrue(foundAssignee); assertTrue(foundCandidateGroup); assertTrue(foundCandidateUser); assertTrue(foundCustom); // Now complete the task and check if links are still there taskService.complete(task.getId()); assertEquals(4, historyService.getHistoricIdentityLinksForTask(task.getId()).size()); // After deleting historic task, exception should be thrown when trying to get links historyService.deleteHistoricTaskInstance(task.getId()); try { historyService.getHistoricIdentityLinksForTask(task.getId()).size(); fail("Exception expected"); } catch(ActivitiObjectNotFoundException aonfe) { assertEquals(HistoricTaskInstance.class, aonfe.getObjectClass()); } }
Example #15
Source File: RestResponseFactory.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public HistoricIdentityLinkResponse createHistoricIdentityLinkResponse(HistoricIdentityLink identityLink) { return createHistoricIdentityLinkResponse(identityLink, createUrlBuilder()); }
Example #16
Source File: HistoricTaskInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Deployment public void testHistoricIdentityLinksOnTask() throws Exception { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("historicIdentityLinks"); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertNotNull(task); // Set additional identity-link not coming from process taskService.addUserIdentityLink(task.getId(), "gonzo", "customUseridentityLink"); assertEquals(4, taskService.getIdentityLinksForTask(task.getId()).size()); // Check historic identity-links when task is still active List<HistoricIdentityLink> historicIdentityLinks = historyService.getHistoricIdentityLinksForTask(task.getId()); assertEquals(4, historicIdentityLinks.size()); // Validate all links boolean foundCandidateUser = false, foundCandidateGroup = false, foundAssignee = false, foundCustom = false; for (HistoricIdentityLink link : historicIdentityLinks) { assertEquals(task.getId(), link.getTaskId()); if (link.getGroupId() != null) { assertEquals("sales", link.getGroupId()); foundCandidateGroup = true; } else { if (link.getType().equals("candidate")) { assertEquals("fozzie", link.getUserId()); foundCandidateUser = true; } else if (link.getType().equals("assignee")) { assertEquals("kermit", link.getUserId()); foundAssignee = true; } else if (link.getType().equals("customUseridentityLink")) { assertEquals("gonzo", link.getUserId()); foundCustom = true; } } } assertTrue(foundAssignee); assertTrue(foundCandidateGroup); assertTrue(foundCandidateUser); assertTrue(foundCustom); // Now complete the task and check if links are still there taskService.complete(task.getId()); assertEquals(4, historyService.getHistoricIdentityLinksForTask(task.getId()).size()); // After deleting historic task, exception should be thrown when trying // to get links historyService.deleteHistoricTaskInstance(task.getId()); try { historyService.getHistoricIdentityLinksForTask(task.getId()).size(); fail("Exception expected"); } catch (ActivitiObjectNotFoundException aonfe) { assertEquals(HistoricTaskInstance.class, aonfe.getObjectClass()); } }
Example #17
Source File: GetHistoricIdentityLinksForTaskCmd.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) protected List<HistoricIdentityLink> getLinksForProcessInstance(CommandContext commandContext) { return (List) commandContext.getHistoricIdentityLinkEntityManager().findHistoricIdentityLinksByProcessInstanceId(processInstanceId); }
Example #18
Source File: HistoryServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public List<HistoricIdentityLink> getHistoricIdentityLinksForTask(String taskId) { return commandExecutor.execute(new GetHistoricIdentityLinksForTaskCmd(taskId, null)); }
Example #19
Source File: HistoryServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public List<HistoricIdentityLink> getHistoricIdentityLinksForProcessInstance(String processInstanceId) { return commandExecutor.execute(new GetHistoricIdentityLinksForTaskCmd(null, processInstanceId)); }
Example #20
Source File: HistoryService.java From flowable-engine with Apache License 2.0 | 2 votes |
/** * Retrieves the {@link HistoricIdentityLink}s associated with the given task. Such an {@link IdentityLink} informs how a certain identity (eg. group or user) is associated with a certain task * (eg. as candidate, assignee, etc.), even if the task is completed as opposed to {@link IdentityLink}s which only exist for active tasks. */ List<HistoricIdentityLink> getHistoricIdentityLinksForTask(String taskId);
Example #21
Source File: HistoryService.java From flowable-engine with Apache License 2.0 | 2 votes |
/** * Retrieves the {@link HistoricIdentityLink}s associated with the given process instance. Such an {@link IdentityLink} informs how a certain identity (eg. group or user) is associated with a * certain process instance, even if the instance is completed as opposed to {@link IdentityLink}s which only exist for active instances. */ List<HistoricIdentityLink> getHistoricIdentityLinksForProcessInstance(String processInstanceId);
Example #22
Source File: HistoryService.java From activiti6-boot2 with Apache License 2.0 | 2 votes |
/** * Retrieves the {@link HistoricIdentityLink}s associated with the given process instance. Such an {@link IdentityLink} informs how a certain identity (eg. group or user) is associated with a * certain process instance, even if the instance is completed as opposed to {@link IdentityLink}s which only exist for active instances. */ List<HistoricIdentityLink> getHistoricIdentityLinksForProcessInstance(String processInstanceId);
Example #23
Source File: HistoryService.java From activiti6-boot2 with Apache License 2.0 | 2 votes |
/** * Retrieves the {@link HistoricIdentityLink}s associated with the given task. Such an {@link IdentityLink} informs how a certain identity (eg. group or user) is associated with a certain task (eg. * as candidate, assignee, etc.), even if the task is completed as opposed to {@link IdentityLink}s which only exist for active tasks. */ List<HistoricIdentityLink> getHistoricIdentityLinksForTask(String taskId);