Class CategoryReport

All Implemented Interfaces:
Selectable<Report>, Comparable<Report>

public class CategoryReport extends Report
The CategoryReport class creates reports that summarize groups of records found in the specified sourceDataTable. Each row in the report represents data summarized from a range of planning periods. Not all planning periods need be reported.

Column values are determined by searching the sourceDataTable for column names that match the columnPrefix. All matching values are used as column headings.

Row labels are specified in the categories array. There will be one row in the table for each String in the categories array.

Records from the sourceDataTable are classified by the categoryColumn to determine which row the record values should be summed into. Values for each database variable starting with columnPrefix are summed into the approprite column and row.

This class generates reports in three formats: HTML, PNG, and CSV. Each sub-report contains the same data, formatted appropriately for the output style. When specifying the filename parameter do not supply a filename extension. This report will automatically create the corresponding ".html", ".png", and ".csv" files. The default report provided by the ReportWriter is the HTML format report, which also provides links to the other two formats.

The CSV sub-report has the simplest formatting. The file contains comma separated text values, and can be read in a text editor or loaded into a spreadsheet. The first row contains the column headings. Subsequent rows contain values for each category. The first column in the table contains the period number, with a column heading of 'PERIOD'. Subsequent columns contain the range labels sorted in alphabetical order, and the final column contains row totals with a column heading of 'TOTAL'. The following shows a sample of a CSV format file:

PERIOD,1 - 20,21 - 40,41 - 60,61 - 80,81 - 100,101 - 120,121 - 140,140+,TOTAL

The HTML sub-report contains a table holding similar information to the CSV report. Column headings are based on the range label values.

Besides the table, the HTML report also contains a title, the name of the scenario, an embedding of a PNG version of the report, optional supplementary HTML data (additionalHTML), a link to the CSV sub-report, and a link to an index report.

The PNG sub-report shows a stacked-bar chart with one bar for each period, and one stack for each range. The Y-axis is automatically scaled to fit the data, and labeled with the units parameter. The X-axis displays period numbers.
Category report

See Also:
ReportWriter, RangeLabel
  • Field Details

    • TYPES

      public static final String[] TYPES
  • Constructor Details

    • CategoryReport

      public CategoryReport(String filename, String title, String units, AttributeStore sourceDataTable, String columnPattern, String categoryColumn, Comparable[] categories, int[] periods, String additionalHTML, boolean computePercent)
      The CategoryReport constructor
      filename - The basename to be used for output from this report. This name must be unique with respect to other reports added to the report writer. The name should not contain a filename extension. The report will add ".html", ".png", or ".csv" as appropriate.
      title - The title to be displayed in the HTML and PNG sub-reports. The report writer will automatically append the Scenario Name to the to the report title.
      units - The units of measure to be displayed on the Y-axis of the PNG sub-report.
      sourceDataTable - The table containing the data to be summarized.
      columnPattern - The pattern used to find database columns that will compose the columns of the report. All matching columns will be used.
      categoryColumn - The database column containing values to be summed into the rows of the table.
      categories - An array of String labels providing the row names to be used for this table.
      periods - An array of period numbers that will be used in composing the report. Only values from the specified periods will be used.
      additionalHTML - Artibrary HTML format text that can be added in to the HTML sub-report. This text can contain explanatory text, display a coporate logo, or provide a hyper-link to a related table.
      computePercent - A boolean value that indicates if the cell data should be converted to percent of the row total. Percent format data can assist in showing changed in relative composition over time.
  • Method Details

    • doReport

      public ca.spatial.reportwriter.Report.DataCache doReport(String filename, PrintStream out, Map<String,​Object> param, ca.spatial.reportwriter.Report.DataCache cache)
      Description copied from class: Report
      The method used by the report writer to format the requested report. This method is implemented in every custom report. Application programs generally do not need to call this method, but instead use the report writer methods to obtain reports.
      Specified by:
      doReport in class Report
      filename - The full name of the report to be printed, including the extension of the sub-report (if any).
      out - The output stream to print output on to.
      param - A HashMap containing parameters that modify the report (for example the scenario name).
    • getTypes

      public String[] getTypes()
      Description copied from class: Report
      An accessor function to retrieve the list of report types supported by this report. See the documentation for the TYPES variable for the list of sub-types.
      Specified by:
      getTypes in class Report
    • getUnits

      public String getUnits()
      Get the Units value.
      the Units value.
    • setUnits

      public void setUnits(String newUnits)
      Set the Units value.
      newUnits - The new Units value.
    • getAs

      public AttributeStore getAs()
      Get the As value.
      the As value.
    • setAs

      public void setAs(AttributeStore newAs)
      Set the As value.
      newAs - The new As value.
    • getPattern

      public String getPattern()
      Get the column pattern value.
    • setPattern

      public void setPattern(String newPattern)
      Set the column pattern value.
      newPattern - The new column prefix value.
    • getCategoryColumn

      public String getCategoryColumn()
      Get the CategoryColumn value.
      the CategoryColumn value.
    • setCategoryColumn

      public void setCategoryColumn(String newCategoryColumn)
      Set the CategoryColumn value.
      newCategoryColumn - The new CategoryColumn value.
    • getCategories

      public Comparable[] getCategories()
      Get the Categories value.
      the Categories value.
    • setCategories

      public void setCategories(Comparable[] newCategories)
      Set the Categories value.
      newCategories - The new Categories value.
    • getPeriods

      public int[] getPeriods()
      Get the Periods value.
      the Periods value.
    • setPeriods

      public void setPeriods(int[] newPeriods)
      Set the Periods value.
      newPeriods - The new Periods value.
    • getHTMLText

      public String getHTMLText()
      Get the Link value.
      the Link value.
    • setHTMLText

      public void setHTMLText(String newLink)
      Set the Link value.
      newLink - The new Link value.
    • isPercent

      public boolean isPercent()
      Get the Percent value.
      the Percent value.
    • setPercent

      public void setPercent(boolean newPercent)
      Set the Percent value.
      newPercent - The new Percent value.