コード例 #1
0
ファイル: V0_9_2Transformer.java プロジェクト: eclipse/osee
  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);
      }
    }
  }
 public void clear() {
   attributes.clear();
 }