Class BaseReportActionHandler

    • Constructor Detail

      • BaseReportActionHandler

        public BaseReportActionHandler()
    • Method Detail

      • 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

        @Deprecated(forRemoval=true)
        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
        Deprecated, for removal: This API element is subject to removal in a future version.
        Throws:
        org.codehaus.jettison.json.JSONException
        OBException
      • doGenerateReport

        protected Path doGenerateReport​(Map<String,​Object> parameters,
                                        org.codehaus.jettison.json.JSONObject jsonContent)
                                 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:
        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.
        Returns:
        JSONObject with the content of response that is returned to the client
        Throws:
        org.codehaus.jettison.json.JSONException
        OBException - Exception thrown when a validation fails.
      • 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
      • doValidations

        protected void doValidations​(Map<String,​Object> parameters,
                                     org.codehaus.jettison.json.JSONObject data)
        Description copied from class: FileExportActionHandler
        Allows to do verifications in the data
        Overrides:
        doValidations in class FileExportActionHandler
        Parameters:
        parameters - The map of parameters extracted from the request
        data - JSONObject with the request content
      • 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
      • generateFileToDownload

        protected Path generateFileToDownload​(Map<String,​Object> parameters,
                                              org.codehaus.jettison.json.JSONObject data)
                                       throws IOException,
                                              org.codehaus.jettison.json.JSONException
        Description copied from class: FileExportActionHandler
        This method that allows possible verifications in the data
        Specified by:
        generateFileToDownload in class FileExportActionHandler
        Parameters:
        parameters - The map of parameters extracted from the request
        data - JSONObject with the request content
        Throws:
        IOException
        org.codehaus.jettison.json.JSONException
      • getDownloadFileName

        protected String getDownloadFileName​(Map<String,​Object> parameters,
                                             org.codehaus.jettison.json.JSONObject data)
                                      throws org.codehaus.jettison.json.JSONException
        Description copied from class: FileExportActionHandler
        Retrieves the name of the file to be downloaded
        Specified by:
        getDownloadFileName in class FileExportActionHandler
        Parameters:
        parameters - The map of parameters extracted from the request
        data - JSONObject with the request content
        Returns:
        the name of the file to be downloaded
        Throws:
        org.codehaus.jettison.json.JSONException
      • getAdditionalResponseActions

        protected org.codehaus.jettison.json.JSONObject getAdditionalResponseActions()
        Overrides:
        getAdditionalResponseActions in class FileExportActionHandler
        Returns:
        a JSONObject containing the additional response actions to be done together with the file action defined by the process