use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskInvolvedPeopleComponent method initInvolvedPeople.
protected void initInvolvedPeople() {
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
for (final IdentityLink identityLink : identityLinks) {
if (identityLink.getUserId() != null) {
// only user identity links, ignoring the group ids
if (!IdentityLinkType.ASSIGNEE.equals(identityLink.getType()) && !IdentityLinkType.OWNER.equals(identityLink.getType())) {
UserDetailsComponent involvedDetails = new UserDetailsComponent(identityLink.getUserId(), identityLink.getType(), i18nManager.getMessage(Messages.TASK_INVOLVED_REMOVE), new RemoveInvolvedPersonListener(identityLink, task, taskDetailPanel));
peopleGrid.addComponent(involvedDetails);
}
}
}
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class RestResponseFactory method createRestIdentityLinks.
public List<RestIdentityLink> createRestIdentityLinks(List<IdentityLink> links) {
RestUrlBuilder urlBuilder = createUrlBuilder();
List<RestIdentityLink> responseList = new ArrayList<RestIdentityLink>();
for (IdentityLink instance : links) {
responseList.add(createRestIdentityLink(instance, urlBuilder));
}
return responseList;
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class ProcessDefinitionIdentityLinksResourceTest method testDeleteCandidateStarterFromProcessDefinition.
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testDeleteCandidateStarterFromProcessDefinition() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
repositoryService.addCandidateStarterGroup(processDefinition.getId(), "admin");
repositoryService.addCandidateStarterUser(processDefinition.getId(), "kermit");
// Delete user candidate
HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinition.getId(), "users", "kermit"));
CloseableHttpResponse response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT);
closeResponse(response);
// Check if group-link remains
List<IdentityLink> remainingLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
assertEquals(1, remainingLinks.size());
assertEquals("admin", remainingLinks.get(0).getGroupId());
// Delete group candidate
httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinition.getId(), "groups", "admin"));
response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT);
closeResponse(response);
// Check if all links are removed
remainingLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
assertEquals(0, remainingLinks.size());
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class DefaultViewManager method showTaskPage.
// Tasks
/**
* Generic method which will figure out to which
* task page must be jumped, based on the task data.
*
* Note that, if possible, it is always more
* performant to use the more specific showXXXPage() methods.
*/
public void showTaskPage(String taskId) {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
String loggedInUserId = ExplorerApp.get().getLoggedInUser().getId();
if (task == null) {
// If no runtime task exists, our only hope is the archive page
boolean isOwner = historyService.createHistoricTaskInstanceQuery().taskId(taskId).taskOwner(loggedInUserId).count() == 1;
if (isOwner) {
showArchivedPage(taskId);
} else {
showNavigationError(taskId);
}
} else if (loggedInUserId.equals(task.getOwner())) {
showTasksPage(taskId);
} else if (loggedInUserId.equals(task.getAssignee())) {
showInboxPage(taskId);
} else if (taskService.createTaskQuery().taskInvolvedUser(loggedInUserId).count() == 1) {
showInvolvedPage(taskId);
} else {
// queued
List<String> groupIds = getGroupIds(loggedInUserId);
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
Iterator<IdentityLink> identityLinkIterator = identityLinks.iterator();
boolean pageFound = false;
while (!pageFound && identityLinkIterator.hasNext()) {
IdentityLink identityLink = identityLinkIterator.next();
if (identityLink.getGroupId() != null && groupIds.contains(identityLink.getGroupId())) {
showQueuedPage(identityLink.getGroupId(), task.getId());
pageFound = true;
}
}
// We've tried hard enough, the user now gets a notification. He deserves it.
if (!pageFound) {
showNavigationError(taskId);
}
}
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class StartAuthorizationTest method testAddAndRemoveIdentityLinks.
@Deployment
public void testAddAndRemoveIdentityLinks() throws Exception {
setUpUsersAndGroups();
try {
ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarterNoDefinition").singleResult();
assertNotNull(latestProcessDef);
List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(0, links.size());
repositoryService.addCandidateStarterGroup(latestProcessDef.getId(), "group1");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(1, links.size());
assertEquals("group1", links.get(0).getGroupId());
repositoryService.addCandidateStarterUser(latestProcessDef.getId(), "user1");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(2, links.size());
assertEquals(true, containsUserOrGroup(null, "group1", links));
assertEquals(true, containsUserOrGroup("user1", null, links));
repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "nonexisting");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(2, links.size());
repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "group1");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(1, links.size());
assertEquals("user1", links.get(0).getUserId());
repositoryService.deleteCandidateStarterUser(latestProcessDef.getId(), "user1");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(0, links.size());
} finally {
tearDownUsersAndGroups();
}
}
Aggregations