Class Report

java.lang.Object
gov.nasa.pds.validate.report.Report
Direct Known Subclasses:
FullReport, JSONReport, XmlReport

public abstract class Report
extends Object
Abstract class that represents a Report for the Vtool command line API. This class handles basic utilities for reporting and calling customized portions of reports.
Author:
pramirez
  • Field Details

    • integrityCheckFlag

      protected boolean integrityCheckFlag
    • totalProducts

      protected int totalProducts
    • numProducts

      protected int numProducts
    • totalIntegrityChecks

      protected int totalIntegrityChecks
    • parameters

      protected final List<String> parameters
    • configurations

      protected final List<String> configurations
    • writer

      protected PrintWriter writer
    • messageSummary

      protected Map<String,​Long> messageSummary
  • Constructor Details

    • Report

      public Report()
      Default constructor to initialize report variables. Initializes default output to System.out if you wish to write the report to a different sourse use the appropriate setOutput method.
  • Method Details

    • setOutput

      public void setOutput​(Writer writer)
      Handles writing a Report to the writer interface. This is is useful if someone would like to put the contents of the Report to something such as StringWriter.
      Parameters:
      writer - which the report will be written to
    • setOutput

      public void setOutput​(OutputStream os)
      Handle writing a Report to an OutputStream. This is useful to get the report to print to something such as System.out
      Parameters:
      os - stream which the report will be written to
    • setOutput

      public void setOutput​(File file) throws IOException
      Handles writing a Report to a File.
      Parameters:
      file - which the report will output to
      Throws:
      IOException - if there is an issue in writing the report to the file
    • printHeader

      public void printHeader()
      This method will display the default header for the Vtool command line library reports. This is the standard header across all reports.
    • addParameter

      public void addParameter​(String parameter)
      Adds the string supplied to the parameter section in the heading of the report.
      Parameters:
      parameter - in a string form that represents something that was passed in when the tool was run
    • addConfiguration

      public void addConfiguration​(String configuration)
      Adds the string supplied to the configuration section in the heading of the report.
      Parameters:
      configuration - in a string form that represents a configuration that was used during parsing and validation
    • printHeader

      public void printHeader​(String title)
    • printHeader

      protected abstract void printHeader​(PrintWriter writer, String title)
      Allows a Report to customize the header portion of the Report if necessary.
      Parameters:
      writer - passed down to write header contents to
    • record

      public Status record​(URI sourceUri, ValidationProblem problem)
    • record

      public Status record​(URI sourceUri, List<ValidationProblem> problems)
      Allows a report to change how they manage reporting on a given file that has been parsed and validated. Also handles generating a status for a file and generating some summary statistics.
      Parameters:
      sourceUri - reference to the file that is being reported on
      problems - the set of issues found with the file. to be reported on
      Returns:
      status of the file (i.e. PASS, FAIL, or SKIP)
    • sortMessageSummary

      protected Map<String,​Long> sortMessageSummary​(Map<String,​Long> messageSummary)
    • recordSkip

      public Status recordSkip​(URI sourceUri, ValidationProblem problem)
    • printRecordSkip

      protected void printRecordSkip​(PrintWriter writer, URI sourceUri, ValidationProblem problem)
    • printRecordMessages

      protected abstract void printRecordMessages​(PrintWriter writer, Status status, URI sourceUri, List<ValidationProblem> problems)
      Allows a report to customize how it handles reporting on a particular label.
      Parameters:
      writer - passed on to write customized messages to
      sourceUri - reference to the file that is being reported on
      problems - which to report on for this source
    • printFooter

      public void printFooter()
      Prints out the footer or the report and calls the customized footer section.
    • printFooter

      protected abstract void printFooter​(PrintWriter writer)
      Allows customization of the footer section of the report
      Parameters:
      writer - passed on to writer customized footer contents
    • getNumPassed

      public int getNumPassed()
      Returns:
      number of labels that passed (had no errors)
    • getNumFailed

      public int getNumFailed()
      Returns:
      number of labels that failed (had one or more errors)
    • getNumSkipped

      public int getNumSkipped()
      Returns:
      number of files that were not recognized as a label
    • getTotalProducts

      public int getTotalProducts()
    • getTotalIntegrityChecks

      public int getTotalIntegrityChecks()
    • getTotalErrors

      public int getTotalErrors()
      Returns:
      total number of errors that were found across all labels inspected. Will not count errors generated from files that were considered skipped.
    • getTotalWarnings

      public int getTotalWarnings()
      Returns:
      total number of warning that were found across all labels inspected. Will not count warnings generated from files that were considered skipped.
    • getTotalInfos

      public int getTotalInfos()
      Returns:
      total number of info messages that were found across all labels inspected. Will not count info messages from files that were considered skipped.
    • hasErrors

      public boolean hasErrors()
      Returns:
      flag indicating if errors were found in the inspected files
    • hasWarnings

      public boolean hasWarnings()
      Returns:
      flag indicating if warnings were found in the inspected files
    • enableDeprecatedFlagWarning

      public void enableDeprecatedFlagWarning()
      Enables deprecation warning message when deprecated CLI flags are used
    • setLevel

      public void setLevel​(ExceptionType ExceptionType)
      Anything at or above the level will be reported. Default ExceptionType level is info and above
      Parameters:
      ExceptionType - level on which items will be reported
    • getLevel

      public ExceptionType getLevel()
      Returns:
      ExceptionType level of items that will be reported on. Anything at or above this level will be reported on
    • getType

      public String getType​(String systemId)