Class BaseReportActionHandler

    • Constructor Detail

      • BaseReportActionHandler

        public BaseReportActionHandler()
    • Method Detail

      • execute

        public void execute()
        execute() method overridden to add the logic to download or display the report file stored in the temporary folder.
        Specified by:
        execute in interface ActionHandler
        Overrides:
        execute in class BaseActionHandler
      • getReportTemplatePath

        protected String getReportTemplatePath​(ReportingUtils.ExportType expType,
                                               ReportDefinition report,
                                               org.codehaus.jettison.json.JSONObject jsonContent)
                                        throws org.codehaus.jettison.json.JSONException,
                                               OBException
        Get the PDF, XLS or HTML template path from the Report Definition. Override this method to add custom logic to get report template paths.
        Parameters:
        expType - The export type.
        report - The Report Definition.
        jsonContent - JSONObject with the values set in the filter parameters, used by the classes extending this one when generating reports which use more than one template. In that case, the selection of the template can be done based on the values of the parameters present in this JSONObject.
        Returns:
        The template path.
        Throws:
        org.codehaus.jettison.json.JSONException
        OBException
      • doGenerateReport

        protected void doGenerateReport​(org.codehaus.jettison.json.JSONObject result,
                                        Map<String,​Object> parameters,
                                        org.codehaus.jettison.json.JSONObject jsonContent,
                                        String action)
                                 throws org.codehaus.jettison.json.JSONException,
                                        OBException
        Manages the report generation. It sets the proper response actions to download the generated file or to open it in a new Openbravo tab.
        Parameters:
        result - JSONObject with the response that is returned to the client.
        parameters - Map including the parameters of the call.
        jsonContent - JSONObject with the values set in the filter parameters.
        action - String with the output type of the report.
        Throws:
        org.codehaus.jettison.json.JSONException
        OBException - Exception thrown when a validation fails.
      • doValidations

        protected void doValidations​(ReportDefinition report,
                                     Map<String,​Object> parameters,
                                     org.codehaus.jettison.json.JSONObject jsonContent)
                              throws OBException
        Override this method to add validations to the report before it is generated.
        Parameters:
        report - the Report Definition
        parameters - Map including the parameters of the call.
        jsonContent - JSONObject with the values set in the filter parameters.
        Throws:
        OBException
      • addAdditionalParameters

        protected void addAdditionalParameters​(ReportDefinition process,
                                               org.codehaus.jettison.json.JSONObject jsonContent,
                                               Map<String,​Object> parameters)
        Override this method to put additional parameters to send to the Jasper Report template. Process Definition filter parameters are automatically added.
        Parameters:
        process - the Process Definition of the Report
        jsonContent - values set in the filter parameters
        parameters - the current Parameter Map that it is send to the Jasper Report.
      • getReportData

        protected net.sf.jasperreports.engine.JRDataSource getReportData​(Map<String,​Object> parameters)
        Get the data to pass to the report generation method. Override this method to put logic for getting the data. The map received as argument contains parameters that can be used to create some logic to build the report data
        Parameters:
        parameters - map that contains the parameters of the HTTP request and the parameters that will be sent to the jasper report
        Returns:
        a JRDataSource object containing the report data
      • getReportConnectionProvider

        protected ConnectionProvider getReportConnectionProvider()
        Get the connection provider to use in report generation. Override this method to put logic for getting the connection provider
        Returns:
        the ConnectionProvider to use during the report generation
      • isCompilingSubreports

        @Deprecated
        protected boolean isCompilingSubreports()
        Deprecated.
        This method has no effect
        This method has no effect. Classes extending BaseReportActionHandler will always try to compile the sub-reports (if any). Note that the sub-reports to be compiled will be the .jrxml files placed in the same folder as the main report and whose related parameter name starts with SUBREP_.
        Returns:
        true