Quotero Wiki » Development » Reporting

Reporting

Last modified by XWikiGuest on 2011/01/19 13:11

How to create a new Quotero Report using Reporting features.

Common information to server and client-side

The Report Object

Basically, a report contains a name, a date, a header and a body.

  • name is a simple String,
  • date is a simple Date,
  • header ia s Header object,
  • body is a Body object.

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.

reportdiag.PNG

Server-Side

ReportImpl Abstract Class

New Report implementations have to inherit ReportImpl abstract class and override getData() method.

For example with DocumentHits implementation.

reportdiag2.PNG

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 Class

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).

xmlreport.PNG

  • getReport() method generate new Report XML stream by using reflection to instantiate new ReportImpl from the Class Name and the parameters XML stream.
  • getReportsList() method just return a reports list XML stream containing all the available report implementations (each implementation should be put in the package org.coretechs.quotero.reporting.impl).
  • getReportAttributes() method return a parameters XML stream containing all parameters from a specified report Class Name.

Client-Side

ReportGenerator Class

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.

reportgen.PNG

The Web Service call is make in the generate() method.

Created by Jérôme Ludmann on 2010/10/11 11:12

This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 2.6.1.33884 - Documentation