示例#1
0
 private static SprintFilteredListDialog createDialog(
     SprintItems items, Set<IAgileSprint> activeSprints) {
   SprintFilteredListDialog dialog =
       new SprintFilteredListDialog("Select Sprint", "Select Sprint", activeSprints);
   Window.setDefaultImage(ImageManager.getImage(AtsImage.AGILE_SPRINT));
   dialog.setInput(activeSprints);
   if (items.isCommonSelectedSprint() && items.getMultipleSprints().size() == 1) {
     dialog.setInitialSelections(Arrays.asList(items.getMultipleSprints().iterator().next()));
   }
   return dialog;
 }
示例#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;
  }