Package org.motechproject.mots.service
Class JasperReportsExportService
- java.lang.Object
-
- org.motechproject.mots.service.JasperReportsExportService
-
@Service public class JasperReportsExportService extends java.lang.ObjectThis class is responsible for generating reports usingJasperTemplateandJasperTemplateParameters. After generation reports are added to a http response in demanded format.
-
-
Constructor Summary
Constructors Constructor Description JasperReportsExportService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgenerateJsonReport(JasperTemplate jasperTemplate, java.util.Map<java.lang.String,java.lang.Object> params)Uses given template to fill report with data from the db and exports it in JSON format.voidgenerateReport(java.util.UUID templateId, java.lang.String format, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Loads report template with given id and loads data from db to fill template and exports report toHttpServletResponseresponse.
-
-
-
Method Detail
-
generateReport
public void generateReport(java.util.UUID templateId, java.lang.String format, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.sql.SQLException, net.sf.jasperreports.engine.JRException, java.io.IOExceptionLoads report template with given id and loads data from db to fill template and exports report toHttpServletResponseresponse.- Parameters:
templateId- id of the template that will be used to generate the reportformat- format of the reportresponse- response object used to set proper headersrequest- request (to get the request parameters)- Throws:
java.sql.SQLException- if there is an error while connecting to dbjava.io.IOException- if there is an error while creatingExporternet.sf.jasperreports.engine.JRException- if there is an error while creatingJasperReport
-
generateJsonReport
public java.lang.String generateJsonReport(JasperTemplate jasperTemplate, java.util.Map<java.lang.String,java.lang.Object> params) throws net.sf.jasperreports.engine.JRException, java.sql.SQLException
Uses given template to fill report with data from the db and exports it in JSON format.- Parameters:
jasperTemplate- template that will be used to generate the reportparams- parameters to configure report- Returns:
- generated json
- Throws:
net.sf.jasperreports.engine.JRException- if there will be any problem with creating the report.java.sql.SQLException- if connection fails
-
-