コード例 #1
0
ファイル: ArtifactImportPage.java プロジェクト: eclipse/osee
  @Override
  protected void restoreWidgetValues() {
    super.restoreWidgetValues();
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
      if (getDefaultSourceFile() == null) {
        directoryFileSelector.setDirectorySelected(settings.getBoolean("isDirectory"));
        String file = settings.get("source.file");
        if (Strings.isValid(file)) {
          directoryFileSelector.setText(file);
        }
      }

      String parser = settings.get("selected.parser");
      if (Strings.isValid(parser)) {
        for (IArtifactExtractor item : importContributionManager.getExtractors()) {
          if (parser.equals(item.getClass().getSimpleName())) {
            parserSelectPanel.setArtifactExtractor(item);
          }
        }
      }
      if (getDefaultDestinationArtifact() == null) {
        String guid = settings.get("destination.artifact.guid");
        String branchUuidStr = settings.get("destination.branch.uuid");

        if (GUID.isValid(guid) && Strings.isNumeric(branchUuidStr)) {
          try {
            Long bramchUuid = Long.valueOf(branchUuidStr);
            Artifact artifact =
                ArtifactQuery.getArtifactFromId(guid, BranchManager.getBranchByUuid(bramchUuid));
            artifactSelectPanel.setDefaultItem(artifact);
          } catch (OseeCoreException ex) {
            OseeLog.logf(
                Activator.class,
                Level.SEVERE,
                "Unable to restore destination artifact- guid:[%s] branch uuid:[%d]",
                guid,
                branchUuidStr);
          }
        }
      }

      boolean toUpdate = settings.getBoolean("is.update.existing.selected");
      updateExistingArtifacts.setSelection(toUpdate);
      deleteUnmatchedArtifacts.setEnabled(toUpdate);
      if (toUpdate) {
        try {
          ArtifactType artType = ArtifactTypeManager.getType(getArtifactType());
          attributeTypeSelectPanel.setAllowedAttributeTypes(
              artType.getAttributeTypes(getDestinationArtifact().getFullBranch()));
        } catch (OseeCoreException ex) {
          OseeLog.log(Activator.class, Level.SEVERE, ex);
        }
      } else {
        attributeTypeSelectPanel.setAllowedAttributeTypes(new ArrayList<IAttributeType>());
      }
    }
  }
コード例 #2
0
 @Override
 public byte[] find(String path) throws IOException {
   try {
     File bundleFile = new File(rootFolder, path);
     if (bundleFile.exists()) {
       return Lib.inputStreamToBytes(new FileInputStream(bundleFile));
     }
   } catch (Exception ex) {
     OseeLog.logf(getClass(), Level.SEVERE, "Error trying to read: [%s]", path);
   }
   return null;
 }
コード例 #3
0
  @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);
    }
  }
  /**
   * Create a new decision review configured and transitioned to handle action validation
   *
   * @param force will force the creation of the review without checking that a review should be
   *     created
   */
  public static DecisionReviewArtifact createValidateReview(
      TeamWorkFlowArtifact teamArt,
      boolean force,
      Date createdDate,
      IAtsUser createdBy,
      SkynetTransaction transaction)
      throws OseeCoreException {
    // If not validate page, don't do anything
    if (!force && !isValidatePage(teamArt.getStateDefinition())) {
      return null;
    }
    // If validate review already created for this state, return
    if (!force && ReviewManager.getReviewsFromCurrentState(teamArt).size() > 0) {
      for (AbstractReviewArtifact rev : ReviewManager.getReviewsFromCurrentState(teamArt)) {
        if (rev.getName().equals(VALIDATE_REVIEW_TITLE)) {
          return null;
        }
      }
    }
    // Create validate review
    try {

      DecisionReviewArtifact decRev =
          DecisionReviewManager.createNewDecisionReview(
              teamArt,
              isValidateReviewBlocking(teamArt.getStateDefinition())
                  ? ReviewBlockType.Transition
                  : ReviewBlockType.None,
              true,
              createdDate,
              createdBy);
      decRev.setName(VALIDATE_REVIEW_TITLE);
      decRev.setSoleAttributeValue(
          AtsAttributeTypes.DecisionReviewOptions,
          "No;Followup;" + getValidateReviewFollowupUsersStr(teamArt) + "\n" + "Yes;Completed;");

      TransitionHelper helper =
          new TransitionHelper(
              "Transition to Decision",
              Arrays.asList(decRev),
              DecisionReviewState.Decision.getName(),
              Arrays.asList(teamArt.getCreatedBy()),
              null,
              TransitionOption.None);
      TransitionManager transitionMgr = new TransitionManager(helper, transaction);
      TransitionResults results = transitionMgr.handleAll();
      if (!results.isEmpty()) {
        OseeLog.logf(
            Activator.class,
            OseeLevel.SEVERE_POPUP,
            "Error transitioning Decision review [%s] to Decision %s",
            decRev.toStringWithId(),
            results);
      }

      return decRev;

    } catch (Exception ex) {
      OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
    }
    return null;
  }