Ejemplo n.º 1
0
 protected boolean validateUserContext() {
   UserContext userContext = UserContext.getInstanceFromPageContext(pageContext);
   if (userContext.isImpersonating()) {
     userContext.restoreSession();
   }
   return userContext.hasRequiredRole(IUserManager.ROLE_EPAVIEWER);
 }
Ejemplo n.º 2
0
  private List<Task> getTasksToDisplay() {
    final List<Task> tasksToDisplay = new LinkedList<Task>();

    final UserContext userContext = UserContext.getInstanceFromPageContext(pageContext);
    final boolean isAdmin = userContext.hasRequiredRole(IUserManager.ROLE_ADMIN);

    final ITaskManager taskManager = ManagementContainer.getInstance().getTaskManager();
    final Calendar whenCompleted = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    whenCompleted.setTime((Date) pageContext.getSession().getAttribute("ems.session.start.time"));
    whenCompleted.add(Calendar.DAY_OF_YEAR, -1);
    final Date searchDate = whenCompleted.getTime();
    final List<Task> tasks =
        taskManager.getDisplayedTasks(userContext.getCurrentCustomer().getCustID(), searchDate);

    final IReviewerGroupManager rgm = ManagementContainer.getInstance().getReviewerGroupManager();
    final Collection<ReviewerGroup> reviewerGroups =
        rgm.getReviewerGroups(
            userContext.getCurrentCustomer().getCustID(), userContext.getActualUser().getUserID());

    final List<Integer> reviewerGroupIdList =
        CollectionBuilder.buildList(reviewerGroups, ReviewerGroup.getReviewerGroupIdFunction());

    for (final Task task : tasks) {
      if (isAdmin
          || userContext.getActualUser().getUserID() == task.getUserID()
          || reviewerGroupIdList.contains(task.getInternalData())) {
        if (getType() == null || getType().equals(task.getType())) {
          tasksToDisplay.add(task);
        }
      }
    }

    return tasksToDisplay;
  }