}
}
protected void directToSpecificTaskPage(String category, String taskId, UriFragment uriFragment) {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
ViewManager viewManager = ExplorerApp.get().getViewManager();
String loggedInUserId = ExplorerApp.get().getLoggedInUser().getId();
boolean pageFound = false;
if (CATEGORY_TASKS.equals(category)) {
if (loggedInUserId.equals(task.getOwner())) {
viewManager.showTasksPage(task.getId());
pageFound = true;
}
} else if (CATEGORY_INBOX.equals(category)) {
if (loggedInUserId.equals(task.getAssignee())) {
viewManager.showInboxPage(task.getId());
pageFound = true;
}
} else if(CATEGORY_QUEUED.equals(category)) {
String groupId = uriFragment.getParameter(PARAMETER_GROUP);
boolean isTaskAssignedToGroup = taskService.createTaskQuery()
.taskId(task.getId())
.taskCandidateGroup(groupId)
.count() == 1;
boolean isUserMemberOfGroup = identityService.createGroupQuery()
.groupMember(loggedInUserId)
.groupId(groupId)
.count() == 1;
if (isTaskAssignedToGroup && isUserMemberOfGroup) {
viewManager.showQueuedPage(groupId, task.getId());
pageFound = true;
}
} else if (CATEGORY_INVOLVED.equals(category)){
boolean isUserInvolved = taskService.createTaskQuery()
.taskInvolvedUser(loggedInUserId)
.count() == 1;
if (isUserInvolved) {
viewManager.showInvolvedPage(task.getId());
pageFound = true;
}
} else if (CATEGORY_ARCHIVED.equals(category)) {
if (task == null) {
boolean isOwner = historyService.createHistoricTaskInstanceQuery()
.taskId(taskId)
.taskOwner(loggedInUserId)
.finished()
.count() == 1;
if (isOwner) {
viewManager.showArchivedPage(taskId);
pageFound = true;
}
}
} else {
throw new ActivitiException("Couldn't find a matching category");
}
if (!pageFound) {
// If URL doesnt match anymore, we must use the task data to redirect to the right page
viewManager.showTaskPage(taskId);
}
}