// resulting information to display
  private static enum InventoryStatsItem implements StatsItemEnum {
    Bib_ID(StatsItem.makeStringStatsItem("Bib IDs", 100)),
    Hash_Code(StatsItem.makeStringStatsItem("Hash Code (MD5)", 500));

    StatsItem si;

    InventoryStatsItem(StatsItem si) {
      this.si = si;
    }

    public StatsItem si() {
      return si;
    }
  }
Пример #2
0
  public static enum CounterStatsItems implements StatsItemEnum {
    File_Cell(StatsItem.makeStringStatsItem("File [cell row, cell col]", 100)),
    Filename(StatsItem.makeStringStatsItem("File", 150)),
    Cell(StatsItem.makeStringStatsItem("Cell", 50)),
    Rec(StatsItem.makeEnumStatsItem(CounterRec.class, "Record").setWidth(60)),
    Stat(StatsItem.makeEnumStatsItem(CounterStat.class, "Compliance").setWidth(170)),
    Fixable(StatsItem.makeEnumStatsItem(FIXABLE.class, "Fixable").setWidth(40)),
    Report(StatsItem.makeStringStatsItem("Counter Report", 150)),
    Version(StatsItem.makeEnumStatsItem(REV.class, "Rev").setWidth(40)),
    Message(StatsItem.makeStringStatsItem("Message", 400)),
    CellValue(StatsItem.makeStringStatsItem("Cell Value", 250)),
    Replacement(StatsItem.makeStringStatsItem("Replacement", 250)),
    ;
    StatsItem si;

    CounterStatsItems(StatsItem si) {
      this.si = si;
    }

    public StatsItem si() {
      return si;
    }
  }
  public ActionResult importFile(File selectedFile) throws IOException {
    Separator fileSeparator = (Separator) getProperty(DELIM);
    Timer timer = new Timer();
    forceKey = dt.getImporterForceKey();

    int colcount = 0;
    TreeMap<String, Stats> types = new TreeMap<String, Stats>();
    StatsItemConfig details = new StatsItemConfig();
    if (forceKey) {
      details.addStatsItem(KEY, StatsItem.makeStringStatsItem("Auto Num").setExport(false));
    }

    int colset = 0;

    DelimitedFileReader dfr = new DelimitedFileReader(selectedFile, fileSeparator.separator);
    boolean firstRow = (YN) getProperty(HEADROW) == YN.Y;

    for (Vector<String> cols = dfr.getRow(); cols != null; cols = dfr.getRow()) {
      colcount = Math.max(colcount, cols.size());
      for (int i = colset; i < colcount; i++) {
        String colkey = "Col" + (i + 1);
        details.addStatsItem(
            colkey, StatsItem.makeStringStatsItem(firstRow ? cols.get(i) : colkey));
        colset++;
      }
      firstRow = false;
    }

    firstRow = (YN) getProperty(HEADROW) == YN.Y;
    dfr = new DelimitedFileReader(selectedFile, fileSeparator.separator);
    for (Vector<String> cols = dfr.getRow(); cols != null; cols = dfr.getRow()) {
      if (firstRow) {
        firstRow = false;
        continue;
      }
      String key = cols.get(0);
      if (forceKey) {
        key = "" + (rowKey++);
      }
      Stats stats = Stats.Generator.INSTANCE.create(key);
      stats.init(details);
      int start = 1;
      if (forceKey) {
        stats.setKeyVal(details.getByKey(KEY), cols.get(0));
        start = 0;
      }
      for (int i = start; i < cols.size(); i++) {
        String colkey = "Col" + (i + 1);
        stats.setKeyVal(details.getByKey(colkey), cols.get(i));
      }
      types.put(key, stats);
    }

    return new ActionResult(
        selectedFile,
        selectedFile.getName(),
        this.toString(),
        details,
        types,
        true,
        timer.getDuration());
  }