Пример #1
0
 private static void preview(ReportOutput output) {
   String[] columns = output.getColumnArray();
   ReportRow[] rows = output.getRowArray();
   for (ReportRow row : rows) {
     for (String column : columns) {
       System.out.print(clean(row.getColumnValue(column)));
     }
     System.out.println();
   }
 }
  protected AbstractReport parseResultSet(
      ReportParams params,
      ResultSet rs,
      SqlEnums.DimensionSelectTerm dimensionSelectTerm,
      AbstractReport abstractReport)
      throws SQLException {
    ReportRow reportRow = new ReportRow();
    DepartmentScreenReport report = new DepartmentScreenReport(params.getDatePart());
    report.setCombineDepartments(params.isCombineDepartments());
    Location currentLocation;
    Location previousLocation = null;
    boolean isFirstRow = true;
    while (rs.next()) {
      ReportDate date = params.getDatePart().parseResultSet(rs);
      currentLocation = LocationUtils.createNewLocation(rs, dimensionSelectTerm);
      List<Double> treatmentClasses = parseOpcValues(rs);
      ValueSet opnr = new ValueSet(treatmentClasses, currentLocation);

      if (isNewLocation(previousLocation, currentLocation)) {
        if (!isFirstRow) report.add(reportRow);
        reportRow = new ReportRow();

        if (params.getDatePart() instanceof ShiftStrategy)
          reportRow.setShiftList(date, date.getShiftCode(), opnr);
        else reportRow.addOpcValues(date, opnr);

      } else {

        if (params.getDatePart() instanceof ShiftStrategy)
          reportRow.setShiftList(date, date.getShiftCode(), opnr);
        else reportRow.addOpcValues(date, opnr);
      }
      reportRow.setLocation(currentLocation);
      previousLocation = currentLocation;
      isFirstRow = false;
    }
    report.add(reportRow);
    return report;
  }