protected void resetContext() {
   URI testURI = testCampaign.getURI();
   context =
       new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
   context.setSourceURI(testURI);
   context.setExtractURI(testURI);
   fd = new FactSetDefinition();
 }
Exemple #2
0
  @Override
  public void unloadLstFiles(LoadContext lc, Collection<CampaignSourceEntry> files) {
    HashMapToList<Class<?>, CDOMSubLineLoader<?>> loaderMap =
        new HashMapToList<Class<?>, CDOMSubLineLoader<?>>();
    for (CDOMSubLineLoader<?> loader : loadMap.values()) {
      loaderMap.addToListFor(loader.getLoadedClass(), loader);
    }
    for (CampaignSourceEntry cse : files) {
      lc.setExtractURI(cse.getURI());
      URI writeURI = cse.getWriteURI();
      File f = new File(writeURI);
      ensureCreated(f.getParentFile());
      try {
        TreeSet<String> set = new TreeSet<String>();
        for (Kit k : lc.getReferenceContext().getConstructedCDOMObjects(Kit.class)) {
          if (cse.getURI().equals(k.getSourceURI())) {
            StringBuilder sb = new StringBuilder();
            String[] unparse = lc.unparseSubtoken(k, "*KITTOKEN");
            sb.append("STARTPACK:");
            sb.append(k.getDisplayName());
            if (unparse != null) {
              sb.append('\t').append(StringUtil.join(unparse, "\t"));
            }
            sb.append('\n');

            Changes<BaseKit> changes = lc.getObjectContext().getListChanges(k, ListKey.KIT_TASKS);
            Collection<BaseKit> tasks = changes.getAdded();
            if (tasks == null) {
              continue;
            }
            for (BaseKit kt : tasks) {
              List<CDOMSubLineLoader<?>> loaders = loaderMap.getListFor(kt.getClass());
              for (CDOMSubLineLoader loader : loaders) {
                processTask(lc, kt, loader, sb);
              }
            }
            sb.append('\n');
            set.add(sb.toString());
          }
        }
        PrintWriter pw = new PrintWriter(f);
        pw.println("#~PARAGRAPH");
        for (String s : set) {
          pw.print(s);
        }
        pw.close();
      } catch (IOException e) {
        Logging.errorPrint("Exception in Load: ", e);
      }
    }
  }