Ejemplo n.º 1
0
 private Collection<TaskArtifact> filterByCompletedAndStateAndSelectedUser(
     Collection<? extends Artifact> artifacts) throws OseeCoreException {
   Set<TaskArtifact> tasks = new HashSet<TaskArtifact>();
   String selectedState = getSelectedState();
   boolean isSelectedStateValid = Strings.isValid(selectedState);
   for (Artifact art : artifacts) {
     TaskArtifact taskArt = (TaskArtifact) art;
     if (isSelectedStateValid) {
       if (!taskArt.getCurrentStateName().equals(selectedState)) {
         continue;
       }
     }
     // If not include completed and task is such, skip this task
     if (!isIncludeCompletedCheckbox() && taskArt.isCompleted()) {
       continue;
     }
     if (!isIncludeCancelledCheckbox() && taskArt.isCancelled()) {
       continue;
     }
     boolean isIncludeCompletedAndCompleted =
         isIncludeCompletedCheckbox() && taskArt.isCompleted();
     boolean isIncludeCancelledAndCancelled =
         isIncludeCancelledCheckbox() && taskArt.isCancelled();
     // If include completed and task is such and user not implementer, skip this task
     if ((isIncludeCompletedAndCompleted || isIncludeCancelledAndCancelled)
         && getSelectedUser() != null
         && taskArt.getImplementers().contains(getSelectedUser())) {
       tasks.add(taskArt);
       continue;
     }
     // If user is selected and not user is assigned, skip this task
     else if (getSelectedUser() != null
         && !taskArt.getStateMgr().getAssignees().contains(getSelectedUser())) {
       continue;
     }
     tasks.add(taskArt);
   }
   return tasks;
 }