示例#1
0
 private static Set<IAgileSprint> getActiveSprints(Artifact agileTeamArt) {
   Set<IAgileSprint> activeSprints = new HashSet<>();
   for (Artifact sprintArt :
       agileTeamArt.getRelatedArtifacts(AtsRelationTypes.AgileTeamToSprint_Sprint)) {
     IAgileSprint agileSprint =
         AtsClientService.get().getWorkItemFactory().getAgileSprint(sprintArt);
     if (agileSprint.isActive()) {
       activeSprints.add(agileSprint);
     }
   }
   return activeSprints;
 }
示例#2
0
 @Override
 public void setTeamDefinition(IAtsVersion version, IAtsTeamDefinition teamDef)
     throws OseeCoreException {
   Artifact verArt =
       ArtifactQuery.getArtifactFromId(version.getGuid(), AtsUtilCore.getAtsBranch());
   if (verArt == null) {
     throw new OseeStateException("Version [%s] does not exist.", version);
   }
   Artifact teamDefArt =
       ArtifactQuery.getArtifactFromId(teamDef.getGuid(), AtsUtilCore.getAtsBranch());
   if (teamDefArt == null) {
     throw new OseeStateException("Team Definition [%s] does not exist.", teamDef);
   }
   if (!verArt
       .getRelatedArtifacts(AtsRelationTypes.TeamDefinitionToVersion_TeamDefinition)
       .contains(teamDefArt)) {
     verArt.addRelation(AtsRelationTypes.TeamDefinitionToVersion_TeamDefinition, teamDefArt);
   }
 }
  @Override
  public void run(TableLoadOption... tableLoadOptions) {
    try {
      Set<Artifact> groupOptions = getEmailGroupsAndUserGroups(UserManager.getUser());
      UserGroupsCheckTreeDialog dialog = new UserGroupsCheckTreeDialog(groupOptions);
      dialog.setTitle("Select Groups to Email");
      if (dialog.open() == 0) {

        Set<String> emails = new HashSet<String>();
        for (Artifact artifact : dialog.getSelection()) {
          if (artifact.isOfType(CoreArtifactTypes.UniversalGroup)) {
            for (Artifact userArt :
                artifact.getRelatedArtifacts(CoreRelationTypes.Universal_Grouping__Members)) {
              if (userArt instanceof User) {
                if (!EmailUtil.isEmailValid((User) userArt)) {
                  OseeLog.logf(
                      Activator.class,
                      Level.SEVERE,
                      "Invalid email [%s] for user [%s]; skipping",
                      ((User) userArt).getEmail(),
                      userArt);
                } else if (((User) userArt).isActive()) {
                  emails.add(((User) userArt).getEmail());
                }
              }
            }
          } else if (artifact.isOfType(CoreArtifactTypes.UserGroup)) {
            for (User user :
                artifact.getRelatedArtifacts(CoreRelationTypes.Users_User, User.class)) {
              if (!EmailUtil.isEmailValid(user)) {
                OseeLog.logf(
                    Activator.class,
                    Level.SEVERE,
                    "Invalid email [%s] for user [%s]; skipping",
                    user.getEmail(),
                    user);
              } else if (user.isActive()) {
                emails.add(user.getEmail());
              }
            }
          }
        }
        if (emails.isEmpty()) {
          AWorkbench.popup("Error", "No emails configured.");
          return;
        }
        String emailStr =
            org.eclipse.osee.framework.jdk.core.util.Collections.toString(";", emails);
        if (emailStr.length() > 2048) {
          AWorkbench.popup(
              "Email list too big for auto-open. Emails opened in editor for copy/paste.");
          ResultsEditor.open("Email Addresses", "Email Addresses", emailStr);
        } else {
          Program.launch("mailto:" + emailStr);
        }
        AWorkbench.popup("Complete", "Configured emails openened in local email client.");
      }
    } catch (OseeCoreException ex) {
      OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
    }
  }
  @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;
  }