예제 #1
0
  @Before
  public void setup() throws OseeCoreException {
    MockitoAnnotations.initMocks(this);

    when(user.getName()).thenReturn("joe");
    when(user.getUserId()).thenReturn("joe");
  }
예제 #2
0
  @Override
  protected Collection<Artifact> searchIt(IAtsUser user) throws OseeCoreException {

    Set<Artifact> assigned = AtsUtil.getAssigned(user);
    Set<Artifact> artifacts = new HashSet<Artifact>(50);
    // Because user can be assigned directly to review or through being assigned to task, add in
    // all the original artifacts.
    artifacts.addAll(assigned);

    if (reviewState == ReviewState.InWork) {
      artifacts.addAll(
          RelationManager.getRelatedArtifacts(assigned, 1, AtsRelationTypes.TeamWfToTask_TeamWf));
    } else {
      artifacts.addAll(
          ArtifactQuery.getArtifactListFromAttribute(
              AtsAttributeTypes.State,
              "<" + user.getUserId() + ">",
              AtsUtilCore.getAtsBranch(),
              QueryOption.CONTAINS_MATCH_OPTIONS));
    }

    List<Artifact> artifactsToReturn = new ArrayList<Artifact>(artifacts.size());
    for (Artifact artifact : artifacts) {
      if (artifact instanceof AbstractReviewArtifact
          && (reviewState == ReviewState.All
              || reviewState == ReviewState.InWork
                  && !((AbstractWorkflowArtifact) artifact).isCompletedOrCancelled())) {
        artifactsToReturn.add(artifact);
      }
    }
    return artifactsToReturn;
  }
예제 #3
0
 public static void validateItem(IAtsUser user, IAtsLogItem item, Date date)
     throws OseeCoreException {
   Assert.assertEquals(LogType.Error, item.getType());
   Assert.assertEquals(date, item.getDate());
   Assert.assertEquals(user.getUserId(), item.getUserId());
   Assert.assertEquals("Analyze", item.getState());
   Assert.assertEquals("my msg", item.getMsg());
 }
예제 #4
0
  @Test
  public void testToString() throws OseeCoreException {
    Date date = new Date();
    IAtsLogItem item = getTestLogItem(date, user);

    Assert.assertEquals(
        "my msg (Error)from Analyze by " + user.getName() + " on " + DateUtil.getMMDDYYHHMM(date),
        item.toString());
  }
예제 #5
0
  @Test
  public void testLogItemLogTypeStringStringStringStringString() throws OseeCoreException {
    Date date = new Date();
    IAtsLogItem item =
        new LogItem(
            LogType.Error, String.valueOf(date.getTime()), user.getUserId(), "Analyze", "my msg");

    validateItem(user, item, date);
  }
예제 #6
0
  @Override
  public Collection<? extends Artifact> getTaskEditorTaskArtifacts() throws OseeCoreException {
    List<Artifact> workflows = new ArrayList<Artifact>();
    Collection<IAtsTeamDefinition> teamDefs = getSelectedTeamDefinitions();
    IAtsVersion verArt = getSelectedVersionArtifact();
    Collection<Artifact> groups = getSelectedGroups();
    IAtsUser user = getSelectedUser();
    boolean includeCompleted = isIncludeCompletedCheckbox();
    boolean includeCancelled = isIncludeCancelledCheckbox();

    // If user selected, handle that case separately cause it's faster to start with assigned
    if (user != null) {
      Set<TaskArtifact> userTaskArts = getUserAssignedTaskArtifacts();
      if (includeCompleted || includeCancelled) {
        // If include cancelled or completed, need to perform extra search
        // Note: Don't need to do this for Originator, Subscribed or Favorites, cause it does
        // completed canceled in it's own searches
        userTaskArts.addAll(
            Collections.castMatching(
                TaskArtifact.class,
                ArtifactQuery.getArtifactListFromTypeAndAttribute(
                    AtsArtifactTypes.Task,
                    AtsAttributeTypes.State,
                    "<" + user.getUserId() + ">",
                    AtsUtilCore.getAtsBranch(),
                    QueryOption.CONTAINS_MATCH_OPTIONS)));
      }
      Set<TaskArtifact> removeTaskArts = new HashSet<TaskArtifact>();
      for (TaskArtifact taskArt : userTaskArts) {
        if (verArt != null
            && !verArt.equals(
                AtsClientService.get()
                    .getVersionService()
                    .getTargetedVersion(taskArt.getParentTeamWorkflow()))) {
          removeTaskArts.add(taskArt);
        }
        if (!teamDefs.isEmpty()
            && !teamDefs.contains(taskArt.getParentTeamWorkflow().getTeamDefinition())) {
          removeTaskArts.add(taskArt);
        }
      }
      userTaskArts.removeAll(removeTaskArts);
      return filterByCompletedAndStateAndSelectedUser(userTaskArts);
    } // If version specified, get workflows from targeted relation
    if (verArt != null) {
      Collection<IAtsTeamWorkflow> targetedForTeamWorkflows =
          AtsClientService.get().getVersionService().getTargetedForTeamWorkflows(verArt);
      Collection<Artifact> workflowArts = Collections.castAll(targetedForTeamWorkflows);
      for (Artifact art : workflowArts) {
        if (teamDefs.isEmpty()) {
          workflows.add(art);
        }
        // Filter by team def if specified
        else if (teamDefs.contains(((TeamWorkFlowArtifact) art).getTeamDefinition())) {
          workflows.add(art);
        }
      }
    }
    // Else, get workflows from teamdefs
    else if (teamDefs.size() > 0) {
      //         ElapsedTime time = new ElapsedTime("Task Search - Load Team Workflows by Team
      // Defs");
      TeamWorldSearchItem teamWorldSearchItem =
          new TeamWorldSearchItem(
              "",
              teamDefs,
              includeCompleted,
              includeCancelled,
              false,
              false,
              null,
              null,
              ReleasedOption.Both,
              null);
      workflows.addAll(teamWorldSearchItem.performSearchGetResults(false, SearchType.Search));
      //         time.end();
    } else if (groups.size() > 0) {
      Set<TaskArtifact> taskArts = new HashSet<TaskArtifact>();
      for (Artifact groupArt : groups) {
        for (Artifact art :
            groupArt.getRelatedArtifacts(CoreRelationTypes.Universal_Grouping__Members)) {
          if (art.isOfType(AtsArtifactTypes.Task)) {
            taskArts.add((TaskArtifact) art);
          } else if (art instanceof AbstractTaskableArtifact) {
            taskArts.addAll(((AbstractTaskableArtifact) art).getTaskArtifacts());
          }
        }
      }
      return filterByCompletedAndStateAndSelectedUser(taskArts);
    }

    //      ElapsedTime time = new ElapsedTime("Task Search - Bulk Load related tasks");
    // Bulk load tasks related to workflows
    Collection<Artifact> artifacts =
        RelationManager.getRelatedArtifacts(workflows, 1, AtsRelationTypes.TeamWfToTask_Task);
    //      time.end();

    // Apply the remaining criteria
    //      time = new ElapsedTime("Task Search - Filter by remaining criteria");
    Collection<TaskArtifact> tasks = filterByCompletedAndStateAndSelectedUser(artifacts);
    //      time.end();

    return tasks;
  }
예제 #7
0
 public static IAtsLogItem getTestLogItem(Date date, IAtsUser user) throws OseeCoreException {
   return new LogItem(LogType.Error, date, user.getUserId(), "Analyze", "my msg");
 }