@Override
 public String getTaskEditorLabel(SearchType searchType) throws OseeCoreException {
   StringBuffer sb = new StringBuffer();
   Collection<IAtsTeamDefinition> teamDefs = getSelectedTeamDefinitions();
   if (teamDefs.size() > 0) {
     sb.append(" - Teams: ");
     sb.append(org.eclipse.osee.framework.jdk.core.util.Collections.toString(",", teamDefs));
   }
   if (getSelectedVersionArtifact() != null) {
     sb.append(" - Version: ");
     sb.append(getSelectedVersionArtifact());
   }
   if (getSelectedGroups().size() > 0) {
     sb.append(" - Groups: ");
     sb.append(Collections.toString(",", getSelectedGroups()));
   }
   if (getSelectedUser() != null) {
     sb.append(" - Assignee: ");
     sb.append(getSelectedUser());
   }
   if (getSelectedState() != null) {
     sb.append(" - State: ");
     sb.append(getSelectedState());
   }
   if (isIncludeCompletedCheckbox() && isIncludeCancelledCheckbox()) {
     sb.append(" - Include Completed/Cancelled");
   }
   if (isIncludeCompletedCheckbox()) {
     sb.append(" - Include Completed");
   }
   if (isIncludeCancelledCheckbox()) {
     sb.append(" - Include Cancelled");
   }
   return Strings.truncate("Tasks" + sb.toString(), TaskEditor.TITLE_MAX_LENGTH, true);
 }
  private void processSoftwareRequirement(ArtifactReadable softwareRequirement, String criticality)
      throws IOException {
    writer.writeCell(
        softwareRequirement.getName(), SafetyReportGenerator.SOFTWARE_REQUIREMENT_INDEX);
    String softwareRequirementDAL =
        writeCriticalityWithDesignCheck(
            softwareRequirement,
            criticality,
            CoreRelationTypes.Requirement_Trace__Higher_Level,
            CoreAttributeTypes.DevelopmentAssuranceLevel);

    writer.writeCell(
        calculateBoeingEquivalentSWQualLevel(
            softwareRequirementDAL,
            softwareRequirement.getAttributeCount(CoreAttributeTypes.Partition)));
    writer.writeCell(functionalCategory);

    writer.writeCell(
        Collections.toString(
            ",", getAttributesToStringList(softwareRequirement, CoreAttributeTypes.Partition)));

    writer.writeCell(
        safetyReport.getComponentUtil().getQualifiedComponentNames(softwareRequirement));
    Collection<String> codeUnits =
        safetyReport.getRequirementToCodeUnitsValues(softwareRequirement);

    if (Conditions.hasValues(codeUnits)) {
      for (String codeUnit : codeUnits) {
        writer.writeCell(codeUnit, SafetyReportGenerator.CODE_UNIT_INDEX);
        writer.endRow();
      }
    } else {
      writer.endRow();
    }
  }
  @Test
  public void testSetAttributeValuesAddOneRemoveOne() throws Exception {
    artifact.setAttributeValues(CoreAttributeTypes.StaticId, ADD_ONE_REMOVE_ONE);

    List<String> actual = artifact.getAttributesToStringList(CoreAttributeTypes.StaticId);

    assertTrue(Collections.isEqual(ADD_ONE_REMOVE_ONE, actual));
  }
  @Test
  public void testSetAttributeValuesWithDuplicates() throws Exception {
    artifact.setAttributeValues(CoreAttributeTypes.StaticId, ADD_DUPLICATES);

    List<String> actual = artifact.getAttributesToStringList(CoreAttributeTypes.StaticId);

    assertTrue(Collections.isEqual(ADD_DUPLICATES_EXPECTED, actual));
  }
  @Test
  public void testSetAttributeValues() throws Exception {
    List<String> actual = artifact.getAttributesToStringList(CoreAttributeTypes.StaticId);

    assertTrue(Collections.isEqual(START_VALUE, actual));
  }
  @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);
    }
  }
示例#7
0
  @Override
  public String getColumnText(Object element, XViewerColumn xCol, int columnIndex)
      throws OseeCoreException {
    ICoverage coverage = (ICoverage) element;
    if (xCol.equals(CoverageXViewerFactory.Name)) {
      return coverage.getName();
    }
    if (element instanceof MessageCoverageItem) {
      return "";
    }
    if (xCol.equals(CoverageXViewerFactory.Assignees_Col)) {
      if (element instanceof CoverageUnit) {
        return Artifacts.toString(
            "; ", OseeCoverageUnitStore.getAssignees((CoverageUnit) coverage));
      }
      return "";
    }
    if (xCol.equals(CoverageXViewerFactory.Notes_Col)) {
      return coverage.getNotes();
    }
    if (xCol.equals(CoverageXViewerFactory.Coverage_Percent)) {
      return coverage.getCoveragePercentStr();
    }
    if (xCol.equals(CoverageXViewerFactory.Location)) {
      return coverage.getLocation();
    }
    if (xCol.equals(CoverageXViewerFactory.Full_Path)) {
      return CoverageUtil.getFullPath(coverage);
    }
    if (xCol.equals(CoverageXViewerFactory.Namespace)) {
      return coverage.getNamespace();
    }
    if (xCol.equals(CoverageXViewerFactory.Work_Product_Task)) {
      return coverage.getWorkProductTaskStr();
    }
    if (xCol.equals(CoverageXViewerFactory.Guid)) {
      return coverage.getGuid();
    }
    if (xCol.equals(CoverageXViewerFactory.Unit)) {
      String unit = "";
      if (element instanceof CoverageUnit) {
        unit = coverage.getName();
      } else {
        unit = coverage.getParent().getName();
      }

      return unit;
    }
    if (xCol.equals(CoverageXViewerFactory.Lines_Covered)) {
      if (element instanceof CoverageUnit) {
        return String.valueOf(((CoverageUnit) coverage).getCoverageItemsCoveredCount(true));
      }
    }
    if (xCol.equals(CoverageXViewerFactory.Total_Lines)) {
      if (element instanceof CoverageUnit) {
        return String.valueOf(((CoverageUnit) coverage).getCoverageItems(true).size());
      }
    }

    if (coverage instanceof CoverageItem
        || (coverage instanceof MergeItem
            && ((MergeItem) coverage).getImportItem() instanceof CoverageItem)) {
      CoverageItem coverageItem = null;
      if (coverage instanceof CoverageItem) {
        coverageItem = (CoverageItem) coverage;
      } else {
        coverageItem = (CoverageItem) ((MergeItem) coverage).getImportItem();
      }
      if (xCol.equals(CoverageXViewerFactory.Coverage_Rationale)) {
        return coverageItem.getRationale();
      }
      if (xCol.equals(CoverageXViewerFactory.Method_Number)) {
        return coverageItem.getParent().getOrderNumber();
      }
      if (xCol.equals(CoverageXViewerFactory.Execution_Number)) {
        return coverageItem.getOrderNumber();
      }
      if (xCol.equals(CoverageXViewerFactory.Line_Number)) {
        return coverageItem.getLineNumber();
      }
      if (xCol.equals(CoverageXViewerFactory.Coverage_Method)) {
        return coverageItem.getCoverageMethod().getName();
      }
      if (xCol.equals(CoverageXViewerFactory.Parent_Coverage_Unit)) {
        return coverageItem.getCoverageUnit().getName();
      }
      if (xCol.equals(CoverageXViewerFactory.Coverage_Test_Units)) {
        Collection<String> testUnits = coverageItem.getTestUnits();
        if (testUnits == null) {
          return "";
        }
        return Collections.toString(", ", testUnits);
      }
      return "";
    }
    if (coverage instanceof CoverageUnit
        || (coverage instanceof MergeItem
            && ((MergeItem) coverage).getImportItem() instanceof CoverageUnit)) {
      CoverageUnit coverageUnit = null;
      if (coverage instanceof CoverageUnit) {
        coverageUnit = (CoverageUnit) coverage;
      } else if (coverage instanceof MergeItem) {
        coverageUnit = (CoverageUnit) ((MergeItem) coverage).getImportItem();
      }
      if (xCol.equals(CoverageXViewerFactory.Parent_Coverage_Unit)) {
        return coverageUnit.getParentCoverageUnit() == null
            ? ""
            : coverageUnit.getParentCoverageUnit().getName();
      }
      if (xCol.equals(CoverageXViewerFactory.Method_Number)) {
        return coverageUnit.getOrderNumber();
      }
    }
    if (coverage instanceof CoverageItem) {
      CoverageItem coverageItem = (CoverageItem) coverage;
      if (xCol.equals(CoverageXViewerFactory.Parent_Coverage_Unit)) {
        return coverageItem.getParent() == null ? "" : coverageItem.getParent().getName();
      }
      if (xCol.equals(CoverageXViewerFactory.Method_Number)) {
        return coverageItem.getParent() == null ? "" : coverageItem.getParent().getOrderNumber();
      }
      if (xCol.equals(CoverageXViewerFactory.Execution_Number)) {
        return coverageItem.getOrderNumber();
      }
      if (xCol.equals(CoverageXViewerFactory.Coverage_Method)) {
        return coverageItem.getCoverageMethod().getName();
      }
    }
    if (coverage instanceof MergeItem
        && (((MergeItem) coverage).getImportItem() instanceof CoverageItem
            || ((MergeItem) coverage).getPackageItem() instanceof CoverageItem)) {
      MergeItem mergeItem = (MergeItem) coverage;
      ICoverage importItem = mergeItem.getImportItem();
      ICoverage packageItem = mergeItem.getPackageItem();
      if (xCol.equals(CoverageXViewerFactory.Parent_Coverage_Unit)) {
        if (importItem != null && importItem.getParent() != null) {
          return importItem.getParent().getName();
        } else if (packageItem != null && packageItem.getParent() != null) {
          return packageItem.getParent().getName();
        }
        return "";
      }
      if (xCol.equals(CoverageXViewerFactory.Method_Number)) {
        if (importItem != null && importItem.getParent() != null) {
          return importItem.getParent().getOrderNumber();
        } else if (packageItem != null && packageItem.getParent() != null) {
          return packageItem.getParent().getOrderNumber();
        }
        return "";
      }
      if (xCol.equals(CoverageXViewerFactory.Execution_Number)) {
        if (importItem != null) {
          return importItem.getOrderNumber();
        } else if (packageItem != null) {
          return packageItem.getOrderNumber();
        }
        return "";
      }
      if (xCol.equals(CoverageXViewerFactory.Coverage_Method)) {
        if (importItem != null) {
          return ((CoverageItem) importItem).getCoverageMethod().getName();
        } else if (packageItem != null) {
          return ((CoverageItem) packageItem).getCoverageMethod().getName();
        }
        return "";
      }
    }
    return "";
  }
  @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;
  }
 private String asCertString(List<String> certs) {
   return certs != null
       ? org.eclipse.osee.framework.jdk.core.util.Collections.toString(";", certs)
       : null;
 }