@Override
 public void run(TableLoadOption... tableLoadOptions) throws OseeCoreException {
   if (AtsUtil.isProductionDb()) {
     AWorkbench.popup("ERROR", "This should not to be run on production DB");
     return;
   }
   MessageDialog dialog =
       new MessageDialog(
           Displays.getActiveShell(),
           getName(),
           null,
           getName() + "\n\nSelect Source or Destination Client",
           MessageDialog.QUESTION,
           new String[] {
             "Source Client", "Destination Client - Start", "Destination Client - End", "Cancel"
           },
           2);
   int result = dialog.open();
   resultData = new XResultData();
   if (result == 0) {
     runClientTest();
   } else if (result == 1) {
     EntryDialog diag =
         new EntryDialog(getName(), "Enter tt number of Source Client created Action");
     if (diag.open() == 0) {
       runDestinationTestStart(diag.getEntry());
     }
   } else if (result == 2) {
     EntryDialog diag =
         new EntryDialog(getName(), "Enter tt number of Source Client created Action");
     if (diag.open() == 0) {
       runDestinationTestEnd(diag.getEntry());
     }
   }
 }
  @Override
  public void run(TableLoadOption... tableLoadOptions) throws OseeCoreException {

    List<Artifact> activeTeams = new LinkedList<>();
    for (Artifact agTeam :
        ArtifactQuery.getArtifactListFromType(
            AtsArtifactTypes.AgileTeam, AtsUtilCore.getAtsBranch())) {
      if (agTeam.getSoleAttributeValue(AtsAttributeTypes.Active, true)) {
        activeTeams.add(agTeam);
      }
    }
    FilteredTreeArtifactDialog dialog =
        new FilteredTreeArtifactDialog(
            getName(),
            "Select Agile Team",
            activeTeams,
            new ArtifactTreeContentProvider(),
            new ArtifactLabelProvider());
    if (dialog.open() == 0) {

      EntryDialog ed =
          new EntryDialog(getName(), "Enter new Agile Sprint name(s) (comma delimited)");
      if (ed.open() == 0) {
        if (Strings.isValid(ed.getEntry())) {
          try {
            AgileEndpointApi ageilEp = AtsClientService.getAgileEndpoint();
            JaxNewAgileSprint newSprint = new JaxNewAgileSprint();
            int teamUuid = ((Artifact) dialog.getSelectedFirst()).getArtId();
            for (String name : ed.getEntry().split(",")) {
              newSprint.setName(name);
              newSprint.setTeamUuid(teamUuid);
              Response response = ageilEp.createSprint(new Long(teamUuid), newSprint);
              JaxAgileSprint sprint = response.readEntity(JaxAgileSprint.class);
              if (sprint != null) {
                long uuid = sprint.getUuid();
                Artifact sprintArt =
                    ArtifactQuery.getArtifactFromId(
                        new Long(uuid).intValue(), AtsUtilCore.getAtsBranch());
                sprintArt.getParent().reloadAttributesAndRelations();
                AtsUtil.openArtifact(sprintArt.getGuid(), OseeCmEditor.CmPcrEditor);
              } else {
                AWorkbench.popup("Error creating Agile Team [%s]", response.toString());
                return;
              }
            }
          } catch (Exception ex) {
            OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
          }
        }
      }
    }
  }
 public void copyArtifactsToGroup(
     DropTargetEvent event, final GroupExplorerItem dragOverExplorerItem) {
   // Items dropped on Group; simply add items to group
   final Artifact[] artsToRelate = ((ArtifactData) event.data).getArtifacts();
   for (Artifact artifact : artsToRelate) {
     if (!artifact.getBranch().equals(branch)) {
       AWorkbench.popup(
           "ERROR",
           "Cross-branch grouping not supported.\n\nGroup and Artifacts must belong to same branch.");
       return;
     }
   }
   boolean alreadyRelated = true;
   for (Artifact artifact : artsToRelate) {
     if (!dragOverExplorerItem.contains(artifact)) {
       alreadyRelated = false;
       break;
     }
   }
   if (alreadyRelated) {
     AWorkbench.popup("ERROR", "Artifact(s) already related.");
     return;
   }
   try {
     for (Artifact art : artsToRelate) {
       if (!dragOverExplorerItem.contains(art)) {
         dragOverExplorerItem
             .getArtifact()
             .addRelation(CoreRelationTypes.Universal_Grouping__Members, art);
       }
     }
     dragOverExplorerItem.getArtifact().persist("Drag and drop: copy artifacts to group");
   } catch (Exception ex) {
     OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
   }
 }
 public void onScriptRunning(final boolean running) {
   AWorkbench.getDisplay()
       .asyncExec(
           new Runnable() {
             @Override
             public void run() {
               if (running) {
                 runButton.setEnabled(false);
                 abortButton.setEnabled(true);
                 abortBatchButton.setEnabled(true);
               } else {
                 runButton.setEnabled(true);
                 abortButton.setEnabled(false);
                 abortBatchButton.setEnabled(false);
               }
             }
           });
 }
  @Override
  protected void doWork(IProgressMonitor monitor) throws Exception {
    data.validate();
    data.getResultData().log(getName() + "\n");
    monitor.worked(calculateWork(0.20));

    try {
      AtsChangeSet changes = new AtsChangeSet(getName());

      // Import Work Definition sheets
      data.getResultData().log("Importing Work Definitions");
      Artifact folder = getWorkDefinitionFolder();
      Set<String> stateNames = new HashSet<String>();
      AtsWorkDefinitionSheetProviders.importWorkDefinitionSheets(
          data.getResultData(), changes, folder, data.getWorkDefSheets(), stateNames);

      monitor.worked(calculateWork(0.30));
      data.getResultData().log("Importing Work Definitions...Complete");

      // Import AI and Team sheets
      data.getResultData().log("Importing AIs and Teams");
      for (WorkDefinitionSheet sheet : data.getTeamsAiSheets()) {
        AtsWorkDefinitionSheetProviders.importAIsAndTeamsToDb(sheet, changes);
      }
      monitor.worked(calculateWork(0.40));

      // Perform specialized configuration code (eg set extra attributes, create branches, etc)
      data.performPostConfig(changes, data);

      if (data.getResultData().isErrors()) {
        String errorStr = "Errors found, not persisting.  May need to restart your OSEE";
        data.getResultData().log(errorStr);
        AWorkbench.popup(errorStr);
      } else {
        changes.execute();
      }
    } catch (Exception ex) {
      data.getResultData().logError("Exception " + ex.getLocalizedMessage());
    }
    XResultDataUI.report(data.getResultData(), getName());
    monitor.worked(calculateWork(0.10));
  }
Exemple #6
0
 @Override
 public void handleColumnMultiEdit(TreeColumn treeColumn, Collection<TreeItem> treeItems) {
   try {
     Set<AbstractWorkflowArtifact> awas = new HashSet<>();
     for (TreeItem item : treeItems) {
       Artifact art = (Artifact) item.getData();
       if (art instanceof AbstractWorkflowArtifact) {
         awas.add((AbstractWorkflowArtifact) art);
       }
       if (art.isOfType(AtsArtifactTypes.Action) && ActionManager.getTeams(art).size() == 1) {
         awas.add(ActionManager.getFirstTeam(art));
       }
     }
     if (awas.isEmpty()) {
       AWorkbench.popup("Invalid selection for setting assignees.");
       return;
     }
     promptChangeAssignees(awas, true);
   } catch (OseeCoreException ex) {
     OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
   }
 }
Exemple #7
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;
  }
 /**
  * The action has been activated. The argument of the method represents the 'real' action sitting
  * in the workbench UI.
  *
  * @see IWorkbenchWindowActionDelegate#run
  */
 @Override
 public void run(IAction action) {
   AWorkbench.openPerspective(DefinePerspectiveFactory.ID);
 }
  @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);
    }
  }
Exemple #10
0
  public Result export(String speratorChar, String fileExtension) {
    if (!popupConfirm
        || popupConfirm
            && MessageDialog.openConfirm(
                Displays.getActiveShell(), "Export Table", "Export Table to CSV?")) {
      StringBuilder sb = new StringBuilder();
      sb.append(title + "\n");
      String htmlStr = AHTML.htmlToText(html);
      Matcher m =
          Pattern.compile(
                  "<table.*?</table>",
                  Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE)
              .matcher(htmlStr);
      if (m.find()) {
        String csv = m.group();
        Matcher rowM =
            Pattern.compile(
                    "<tr.*?>(.*?)</tr>",
                    Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE)
                .matcher(csv);
        while (rowM.find()) {
          String row = rowM.group(1);
          row = row.replaceAll("[\n\r]*", "");
          // Handle all the headers
          for (String tag : elementTags) {
            Matcher thM =
                Pattern.compile(
                        "<" + tag + ".*?>(.*?)</" + tag + ">",
                        Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE)
                    .matcher(row);
            String csvRow = "";
            while (thM.find()) {
              String cellStr = removeLeadTrailSpaces(thM.group(1));
              String excelTextPrefix = (excelTextFields && !cellStr.contains(",")) ? "=" : "";
              csvRow += excelTextPrefix + "\"" + cellStr + "\"" + speratorChar;
            }
            if (!csvRow.equals("")) {
              csvRow = csvRow.replaceFirst(speratorChar + "$", "\n");
              sb.append(csvRow);
            }
          }
        }
        String path = "";
        if (popupConfirm) {
          FileDialog dialog = new FileDialog(Displays.getActiveShell(), SWT.SAVE | SWT.SINGLE);
          dialog.setFilterExtensions(new String[] {"*." + fileExtension});
          dialog.setFilterPath(System.getProperty("user.home"));
          dialog.setFileName("table.csv");
          path = dialog.open();
        } else {
          path = System.getProperty("user.home") + File.separator + "table." + fileExtension;
        }

        if (path != null) {
          try {
            File file = new File(path);
            Lib.writeStringToFile(sb.toString(), file);
            if (openInSystem) {
              Program.launch(file.getAbsolutePath());
            }
            return Result.TrueResult;
          } catch (IOException ex) {
            OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
          }
        }
      } else {
        AWorkbench.popup("ERROR", "Can't find table in results.\n\nNothing to export");
      }
    }
    return Result.FalseResult;
  }
Exemple #11
0
  public static boolean promptChangeAssignees(
      final Collection<? extends AbstractWorkflowArtifact> awas, boolean persist)
      throws OseeCoreException {
    for (AbstractWorkflowArtifact awa : awas) {
      if (awa.isCompleted()) {
        AWorkbench.popup(
            "ERROR",
            "Can't assign completed " + awa.getArtifactTypeName() + " (" + awa.getAtsId() + ")");
        return false;
      } else if (awa.isCancelled()) {
        AWorkbench.popup(
            "ERROR",
            "Can't assign cancelled " + awa.getArtifactTypeName() + " (" + awa.getAtsId() + ")");
        return false;
      }
    }
    UserCheckTreeDialog uld =
        new UserCheckTreeDialog(
            "Select Assigness",
            "Select to assign.\nDeSelect to un-assign.",
            AtsClientService.get()
                .getUserServiceClient()
                .getOseeUsers(AtsClientService.get().getUserService().getUsers(Active.Active)));
    if (awas.iterator().next().getParentTeamWorkflow() != null) {
      uld.setTeamMembers(
          AtsClientService.get()
              .getUserServiceClient()
              .getOseeUsers(
                  awas.iterator()
                      .next()
                      .getParentTeamWorkflow()
                      .getTeamDefinition()
                      .getMembersAndLeads()));
    }

    if (awas.size() == 1) {
      uld.setInitialSelections(
          AtsClientService.get()
              .getUserServiceClient()
              .getOseeUsers(awas.iterator().next().getStateMgr().getAssignees()));
    }
    if (uld.open() != 0) {
      return false;
    }
    Collection<IAtsUser> users =
        AtsClientService.get().getUserServiceClient().getAtsUsers(uld.getUsersSelected());
    if (users.isEmpty()) {
      AWorkbench.popup("ERROR", "Must have at least one assignee");
      return false;
    }
    // As a convenience, remove the UnAssigned user if another user is selected
    if (users.size() > 1) {
      users.remove(AtsCoreUsers.SYSTEM_USER);
    }
    for (AbstractWorkflowArtifact awa : awas) {
      awa.getStateMgr().setAssignees(users);
    }
    if (persist) {
      AtsChangeSet.execute("Assignee - Prompt Change", awas);
    }
    return true;
  }
Exemple #12
0
  @Override
  public void run() {
    if (selectedCoverageEditorItem.getSelectedCoverageEditorItems().isEmpty()) {
      AWorkbench.popup("Select Coverage Item");
      return;
    }
    if (selectedCoverageEditorItem.getSelectedCoverageEditorItems().size() > 0) {
      ICoverage item =
          selectedCoverageEditorItem.getSelectedCoverageEditorItems().iterator().next();
      String highlightLine = null;

      try {
        if (item instanceof CoverageItem) {
          if (Strings.isValid(item.getName())) {
            highlightLine = item.getName();
          }
          item = item.getParent();
        }
        // If order number then parent has full file contents
        // attempt to find line in file that matches
        if (Strings.isValid(item.getOrderNumber())) {
          if (item.getParent() != null) {
            String itemLineText = item.getName();
            String parentFileContents = item.getParent().getFileContents();
            if (!Strings.isValid(parentFileContents)) {
              AWorkbench.popup("No File Contents Available");
              return;
            }
            String html = parentFileContents;
            // mark text for method
            if (Strings.isValid(itemLineText)) {
              html = html.replaceAll(itemLineText, "HEREBEGIN" + itemLineText + "HEREEND");
            }
            // mark text for executable line
            if (Strings.isValid(highlightLine)) {
              html = html.replaceAll(highlightLine, "HEREBEGIN" + highlightLine + "HEREEND");
            }
            html = AHTML.textToHtml(html);
            html = html.replaceAll(" ", "&nbsp;");
            html = html.replaceAll("HEREBEGIN", "<FONT style=\"BACKGROUND-COLOR: yellow\">");
            html = html.replaceAll("HEREEND", "</FONT>");
            ResultsEditor.open(
                "source",
                CoverageUtil.getFullPathWithName(item.getParent(), true)
                    + "["
                    + item.getName()
                    + "]",
                html);
          } else {
            AWorkbench.popup("No File Contents Available");
            return;
          }
        }
        // If no order number, just open full text
        else {
          String text = item.getFileContents();
          if (!Strings.isValid(text)) {
            AWorkbench.popup("No File Contents Available");
            return;
          }
          String html = AHTML.textToHtml(text);
          html = html.replaceAll(" ", "&nbsp;");
          ResultsEditor.open("source", CoverageUtil.getFullPathWithName(item, true), html);
        }

      } catch (OseeCoreException ex) {
        OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
      }
    }
  }