How to create a new Quotero Report using Reporting features.
Basically, a report contains a name, a date, a header and a body.
Header contains a list of columns which have names which refer to cells.
Body contains a list of rows. Each row contains a list of cells and each cell has a name and a value.
New Report implementations have to inherit ReportImpl abstract class and override getData() method.
For example with DocumentHits implementation.
public class DocumentHitsReport extends ReportImpl {
private Long dateFrom;
private Long dateTo;
private String order;
private Boolean asc;
public String getData() throws ConfigException, DataSourceException {
return new DocumentHitsReportFactory(this).getReport();
}
// and attributes getters to used in factory
}
Your getData() method have to call the adequate factory method to build an return the new report XML stream. The factory method is generally a database access over Hibernate.
XMLReportHelper is used by ReportingController to make Report XML stream from parameters XML stream and to get related information about reports (attributes, list of reports).
This class allows clients to generate Report. It take Class Name to determinate the ReportGenerator server implementation. When all parameters are set, generate() call Web Service and get XML stream about report. This XML stream is converted into Report object.
Here is a example of use with DocumentHits:
ReportGenerator reportGen = new ReportGenerator(sessionUid,
"org.coretechs.quotero.reporting.impl.DocumentHitsReport");
reportGen.addParameter("dateFrom",String.valueOf(sdf.parse(dateFrom).getTime()));
reportGen.addParameter("dateTo",String.valueOf(sdf.parse(dateTo).getTime()));
reportGen.addParameter("order", order);
reportGen.addParameter("asc", asc.toString());
Report report = reportGen.generate();
First, it is necessary to instantiate ReportGenerator with the Class Name corresponding to the Report server implementation. The addParameter() method is used to add new parameter to this report.
Note: if the parameter is unknown for the implementation, or if the parameter has already been set, an exception will be thrown.
The Web Service call is make in the generate() method.