The generator defines a schema named Basic HTML report schema which is used internally by the generator to serialize the output of an operation to a XML file. The schema defines the namespace http://pineapple.dev.java.net/ns/report/basic_html_1_0.
The schema can be found at these locations:
During the site phase (of the Maven build) the schema is copied to the main site in the pineapple-project. The schema is copied to the directory /ns/report. The copy operation is implemented in the pom.xml for the pineapple-basic-html-report-generator project
The project uses JAXB through the Maven plugin cxf-xjc-plugin to generate classes from XML schema.
The report generator uses log4j for logging. Each pineapple client must provide a Log4j configuration which is accessible at runtime as a result of the build process.
The report generator does not provide a Log4j configuration as part of its production build. A log4j configuration file is defined in the project in the directory src/test/resources/log4.properties for testing.
The test configuration configures Log4j to write to the log file to ${user.home}/.pineapple/logs/pineapple.log.
The report generator uses a XSLT file which to transform the generated XML report file into a HTML file. The XLST file is located in src/main/resources/com.alpha.pineapple.report.basichtml.xsl.
The report generator contains a configuration file which defines a Spring application context. The Spring application context defines dependency injection of objects as part of initialization of the report generator. The file is located in src/main/resources/com.alpha.pineapple.report.basichtml-config.xml.
The package com.alpha.pineapple.report.basichtml is the root package of the report generator and contains the report generator class named BasicHtmlReportGeneratorImpl.
The class implements the com.alpha.pineapple.execution.ResultListener interface which listens to events from execution results during execution of an Pineapple operation. When the state of root execution result is changed from running to some completed state, the generator creates the report.
The generator implements the com.alpha.pineapple.report.basichtml.ReportGeneratorInfo interface which provides info how the report generation process whent.
The algorithm for generating a reports is:
Instances are created by using the factory methods:
The location of reports is configurable as an argument to the factory method BasicHtmlReportGeneratorImpl.getInstance(File reportDirectory). The reportDirectory parameter defines a the root directory where the generator will generate reports.
Alternatively, the report generator implements the interface ReportGeneratorInfo which contains the method setReportDirectory(..) which can be used to set the root directory.
At runtime the the generator will add a new sub directory each time the generator is invoked. The created directory is named report-TIMESTAMP where TIMESTAMP is a time stamp with the format YYYY-MM-DD-HHMMSS. The time stamp marks the time when the generator starts to create the report. The two report files named basic-report.xml and basic-report.html are created in the directory.
If no location is defined, i.e. the no-arg factory method BasicHtmlReportGeneratorImpl.getInstance() is used, or the generator is looked up from the Spring context, the generator will generate reports in the root directory: ${user.home}/.pineapple/reports/
The class ReportNamespaceMapper implements the com.sun.xml.bind.marshaller.NamespacePrefixMapper interface. The class maps entities from Basic HTML report schema namespace with a prefix during JAXB marshalling. The class defines the mapping:
The XLST transformer can't handle invalid XML chars.
To removed all invalid XML chars then then all text is escaped to XML 1.0 and then unescaped again mediately. The purpose of the unescaping is to let JAXB and the XSLT transformer handling the escaping of XML.
The class com.alpha.pineapple.report.basichtml.model.MapperImpl which implements the interface Mapper implements mapping between ExecutionResult objects and schema generated classes. The class is used by the generator to produce the object graph which is marshalled into the XML file.
The execution results which is mapped by the mapper object is processed differently based on their position in the result object graph: