Example #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;
 }
Example #2
0
  public static boolean promptChangeSprint(
      final Collection<? extends Artifact> awas, boolean persist) throws OseeCoreException {
    // verify that all awas belong to the same backlog
    SprintItems items = new SprintItems(awas);

    if (items.isNoBacklogDetected()) {
      AWorkbench.popup("Workflow(s) must belong to a Backlog to set their Sprint.");
      return false;
    }
    if (items.isMultipleBacklogsDetected()) {
      AWorkbench.popup("All workflows must belong to same Backlog.");
      return false;
    }

    Artifact backlogArt = (Artifact) items.getCommonBacklog().getStoreObject();
    Artifact agileTeamArt = null;
    try {
      agileTeamArt = backlogArt.getRelatedArtifact(AtsRelationTypes.AgileTeamToBacklog_AgileTeam);
    } catch (ArtifactDoesNotExist ex) {
      // do nothing
    }
    if (agileTeamArt == null) {
      AWorkbench.popup("No Agile Team for Agile Backlog [%s]", backlogArt.toStringWithId());
    }

    Set<IAgileSprint> activeSprints = getActiveSprints(agileTeamArt);

    if (activeSprints.isEmpty()) {
      AWorkbench.popup(
          "No Active Sprints available for the Agile Team [%s]", agileTeamArt.toStringWithId());
      return false;
    }

    SprintFilteredListDialog dialog = createDialog(items, activeSprints);

    if (dialog.open() == 0) {
      if (dialog.isRemoveFromSprint()) {
        for (Artifact awa : awas) {
          Collection<Artifact> relatedSprintArts = AgileUtilClient.getRelatedSprints(awa);
          for (Artifact relatedSprint : relatedSprintArts) {
            awa.deleteRelation(AtsRelationTypes.AgileSprintToItem_Sprint, relatedSprint);
          }
        }
        Artifacts.persistInTransaction("Remove Sprint", awas);

      } else {
        IAgileSprint selectedSprint = dialog.getSelectedFirst();
        for (Artifact awa : awas) {
          Artifact newSprintArt = (Artifact) selectedSprint.getStoreObject();
          Collection<Artifact> relatedSprintArts = AgileUtilClient.getRelatedSprints(awa);
          for (Artifact relatedSprint : relatedSprintArts) {
            awa.deleteRelation(AtsRelationTypes.AgileSprintToItem_Sprint, relatedSprint);
          }
          awa.addRelation(AtsRelationTypes.AgileSprintToItem_Sprint, newSprintArt);
        }
        Artifacts.persistInTransaction("Set Sprint", awas);
      }
      return true;
    }
    return false;
  }