public Set<String> getAttributeTypeNames() {
   Set<String> typeNames = new HashSet<String>();
   for (CharSequence attrTypeName : attributes.keySet()) {
     typeNames.add(attrTypeName.toString());
   }
   return typeNames;
 }
 @Override
 public List<Object[]> getInsertData(SqlOrderEnum key) {
   List<Object[]> toReturn = null;
   if (dataItemInserts != null) {
     toReturn = (List<Object[]>) dataItemInserts.getValues(key);
   }
   return toReturn != null ? toReturn : Collections.<Object[]>emptyList();
 }
 public Collection<URI> getURIAttributes() {
   Collection<RoughAttribute> roughAttributes = attributes.getValues();
   Collection<URI> values = new ArrayList<URI>();
   for (RoughAttribute attribute : roughAttributes) {
     if (attribute.hasURI()) {
       values.add(attribute.getURI());
     }
   }
   return values;
 }
 public Collection<String> getAttributeValueList(String attributeTypeName) {
   Collection<RoughAttribute> roughAttributes =
       attributes.getValues(new CaseInsensitiveString(attributeTypeName));
   Collection<String> values = new ArrayList<String>();
   for (RoughAttribute attribute : roughAttributes) {
     if (!attribute.hasURI()) {
       values.add(attribute.getValue());
     }
   }
   return values;
 }
Exemplo n.º 5
0
  @Override
  public Version applyTransform(ExchangeDataProcessor processor, Log logger)
      throws OseeCoreException {
    List<Long> branchUuids = convertBranchTable(processor);

    Map<Long, Long> artifactGammaToNetGammaId = convertArtifactAndConflicts(processor);
    consolidateTxsAddressing(
        processor, ExportItem.OSEE_TXS_DATA, branchUuids, artifactGammaToNetGammaId);

    HashCollection<String, String> tableToColumns = new HashCollection<>();
    tableToColumns.put("osee_artifact", "<column id=\"gamma_id\" type=\"NUMERIC\" />\n");
    tableToColumns.put(
        "osee_branch", "<column id=\"baseline_transaction_id\" type=\"INTEGER\" />\n");
    processor.transform(ExportItem.EXPORT_DB_SCHEMA, new DbSchemaRuleAddColumn(tableToColumns));

    processor.transform(
        ExportItem.EXPORT_MANIFEST,
        new ReplaceAll("<entry id=\"osee.artifact.version.data.xml[^<]+", ""));
    processor.deleteExportItem("osee.artifact.version.data.xml");
    return getMaxVersion();
  }
Exemplo n.º 6
0
  private void consolidateTxsAddressing(
      ExchangeDataProcessor processor,
      ExportItem exportItem,
      List<Long> branchUuids,
      Map<Long, Long> artifactGammaToNetGammaId)
      throws OseeCoreException {
    File targetFile = processor.getDataProvider().getFile(exportItem);
    File tempFile = new File(Lib.changeExtension(targetFile.getPath(), "temp"));
    Writer fileWriter = null;
    HashCollection<Long, Address> addressMap = new HashCollection<>(false, TreeSet.class);
    V0_9_2TxsConsolidateParser transformer =
        new V0_9_2TxsConsolidateParser(artifactGammaToNetGammaId, addressMap);
    try {
      fileWriter = processor.startTransform(targetFile, tempFile, transformer);
      ExchangeUtil.readExchange(tempFile, transformer);

      for (long branchUuid : branchUuids) {
        transformer.setBranchId(branchUuid);
        ExchangeUtil.readExchange(tempFile, transformer);

        for (Long gammaId : addressMap.keySet()) {
          Collection<Address> addresses = addressMap.getValues(gammaId);
          fixAddressing(addresses);
          writeAddresses(transformer.getWriter(), addresses);
        }
        addressMap.clear();
      }
      tempFile.delete();
    } catch (Exception ex) {
      OseeExceptions.wrapAndThrow(ex);
    } finally {
      try {
        transformer.finish();
      } catch (Exception ex) {
        OseeExceptions.wrapAndThrow(ex);
      } finally {
        Lib.close(fileWriter);
      }
    }
  }
 @Override
 public Iterator<Entry<CaseInsensitiveString, Collection<RoughAttribute>>> iterator() {
   return attributes.entrySet().iterator();
 }
 public void addAttribute(String name, URI... uris) {
   for (URI uri : uris) {
     attributes.put(new CaseInsensitiveString(name), new RoughAttribute(uri));
   }
 }
 public void addAttribute(String name, String... values) {
   for (String value : values) {
     attributes.put(new CaseInsensitiveString(name), new RoughAttribute(value));
   }
 }
 public void clear() {
   attributes.clear();
 }
 @Override
 public String toString() {
   return attributes.toString();
 }
 @Override
 public int hashCode() {
   return attributes.hashCode();
 }
Exemplo n.º 13
0
  public List<CpaDecision> load() {
    List<CpaDecision> decisions = new ArrayList<CpaDecision>();
    QueryBuilder queryBuilder =
        atsServer
            .getQuery()
            .andTypeEquals(AtsArtifactTypes.TeamWorkflow)
            .and(AtsAttributeTypes.ApplicabilityWorkflow, "true");
    if (Strings.isValid(programUuid)) {
      queryBuilder.and(AtsAttributeTypes.ProgramUuid, programUuid);
    }
    if (Conditions.hasValues(uuids)) {
      queryBuilder.and(AtsAttributeTypes.AtsId, uuids);
    }
    if (open != null) {
      queryBuilder.and(
          AtsAttributeTypes.CurrentStateType,
          (open ? StateType.Working.name() : StateType.Completed.name()));
    }
    HashCollection<String, CpaDecision> origPcrIdToDecision =
        new HashCollection<String, CpaDecision>();
    String pcrToolId = null;
    ElapsedTime time = new ElapsedTime("load cpa workflows");
    ResultSet<ArtifactReadable> results = queryBuilder.getResults();
    time.end(Units.SEC);
    time = new ElapsedTime("process cpa workflows");
    for (ArtifactReadable art : results) {
      IAtsTeamWorkflow teamWf = atsServer.getWorkItemFactory().getTeamWf(art);
      CpaDecision decision = CpaFactory.getDecision(teamWf, null);
      decision.setApplicability(
          art.getSoleAttributeValue(AtsAttributeTypes.ApplicableToProgram, ""));
      decision.setRationale(art.getSoleAttributeValue(AtsAttributeTypes.Rationale, ""));
      String pcrToolIdValue = art.getSoleAttributeValue(AtsAttributeTypes.PcrToolId, "");
      if (pcrToolId == null) {
        pcrToolId = pcrToolIdValue;
      }
      decision.setPcrSystem(pcrToolIdValue);
      boolean completed =
          art.getSoleAttributeValue(AtsAttributeTypes.CurrentStateType, "")
              .equals(StateType.Completed.name());
      decision.setComplete(completed);
      decision.setAssignees(teamWf.getStateMgr().getAssigneesStr());
      if (completed) {
        decision.setCompletedBy(teamWf.getCompletedBy().getName());
        decision.setCompletedDate(DateUtil.getMMDDYY(teamWf.getCompletedDate()));
      }

      // set location of decision workflow
      decision.setDecisionLocation(
          CpaUtil.getCpaPath(atsServer).path(teamWf.getAtsId()).build().toString());

      // set location of originating pcr
      String origPcrId = art.getSoleAttributeValue(AtsAttributeTypes.OriginatingPcrId);
      origPcrIdToDecision.put(origPcrId, decision);
      decision.setOrigPcrLocation(
          CpaUtil.getCpaPath(atsServer)
              .path(origPcrId)
              .queryParam("pcrSystem", decision.getPcrSystem())
              .build()
              .toString());

      // set location of duplicated pcr (if any)
      String duplicatedPcrId = art.getSoleAttributeValue(AtsAttributeTypes.DuplicatedPcrId, null);
      if (Strings.isValid(duplicatedPcrId)) {
        String duplicatedLocation =
            CpaUtil.getCpaPath(atsServer)
                .path(duplicatedPcrId)
                .queryParam("pcrSystem", decision.getPcrSystem())
                .build()
                .toString();
        decision.setDuplicatedPcrLocation(duplicatedLocation);
        decision.setDuplicatedPcrId(duplicatedPcrId);
      }

      decisions.add(decision);
    }
    time.end();

    time = new ElapsedTime("load issues");
    IAtsCpaService service = cpaRegistry.getServiceById(pcrToolId);
    for (Entry<String, CpaPcr> entry :
        service.getPcrsByIds(origPcrIdToDecision.keySet()).entrySet()) {
      for (CpaDecision decision : origPcrIdToDecision.getValues(entry.getKey())) {
        decision.setOriginatingPcr(entry.getValue());
      }
    }
    time.end();

    return decisions;
  }
 private void addRow(SqlOrderEnum sqlKey, Object... data) {
   dataItemInserts.put(sqlKey, data);
 }