Class BaseReportActionHandler
- java.lang.Object
-
- org.openbravo.client.kernel.BaseActionHandler
-
- org.openbravo.client.application.process.BaseProcessActionHandler
-
- org.openbravo.client.application.process.FileExportActionHandler
-
- org.openbravo.client.application.report.BaseReportActionHandler
-
- All Implemented Interfaces:
ActionHandler
- Direct Known Subclasses:
AgingBalanceReportActionHandler
,CashflowForecastReportActionHandler
public class BaseReportActionHandler extends FileExportActionHandler
Action Handler used as base for jasper reports generated from process definition. This handler can be extended to customize its behavior.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openbravo.client.application.process.FileExportActionHandler
FileExportActionHandler.FileAction
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
JASPER_REPORT_PARAMETERS
-
Fields inherited from class org.openbravo.client.application.process.BaseProcessActionHandler
PARAM_FILE_CONTENT, PARAM_FILE_NAME, PARAM_FILE_SIZE, PARAM_MULTIPART_VALUES
-
-
Constructor Summary
Constructors Constructor Description BaseReportActionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.protected void
addAditionalParameters(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject processParams)
Allows to include additional process parameters in the result built withFileExportActionHandler.createResponseForDownload(java.util.Map<java.lang.String, java.lang.Object>, org.codehaus.jettison.json.JSONObject, java.nio.file.Path)
protected void
addAditionalRecordInfo(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject recordInfo)
Allows to include additional record information in the result built withFileExportActionHandler.createResponseForDownload(java.util.Map<java.lang.String, java.lang.Object>, org.codehaus.jettison.json.JSONObject, java.nio.file.Path)
protected Path
doGenerateFile(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject data)
protected Path
doGenerateReport(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject jsonContent)
Manages the report generation.protected void
doGenerateReport(org.codehaus.jettison.json.JSONObject result, Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject jsonContent, String action)
Deprecated, for removal: This API element is subject to removal in a future version.doGenerateReport(Map, JSONObject)
is used insteadprotected void
doValidations(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject data)
Allows to do verifications in the dataprotected void
doValidations(ReportDefinition report, Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject jsonContent)
Override this method to add validations to the report before it is generated.protected Path
generateFileToDownload(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject data)
This method that allows possible verifications in the dataprotected org.codehaus.jettison.json.JSONObject
getAdditionalResponseActions()
protected FileExportActionHandler.FileAction
getDownloadAction(org.codehaus.jettison.json.JSONObject data)
Allows to define the action to be done with the file when it is downloaded.protected String
getDownloadFileName(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject data)
Retrieves the name of the file to be downloadedprotected ConnectionProvider
getReportConnectionProvider()
Get the connection provider to use in report generation.protected net.sf.jasperreports.engine.JRDataSource
getReportData(Map<String,Object> parameters)
Get the data to pass to the report generation method.protected String
getReportTemplatePath(ReportingUtils.ExportType expType, ReportDefinition report, org.codehaus.jettison.json.JSONObject jsonContent)
Get the PDF, XLS or HTML template path from the Report Definition.protected boolean
isCompilingSubreports()
Deprecated.This method has no effectprotected boolean
isValidDownloadFileType(ReportingUtils.ExportType exportType)
-
Methods inherited from class org.openbravo.client.application.process.FileExportActionHandler
doExecute, execute, uploadAttachment
-
Methods inherited from class org.openbravo.client.application.process.BaseProcessActionHandler
execute, extractParametersFromRequest, extractRequestContent, fixRequestMap, getResponseBuilder, hasAccess
-
Methods inherited from class org.openbravo.client.kernel.BaseActionHandler
fixRequestMap, writeResponse
-
-
-
-
Field Detail
-
JASPER_REPORT_PARAMETERS
protected static final String JASPER_REPORT_PARAMETERS
- See Also:
- Constant Field Values
-
-
Method Detail
-
doGenerateFile
protected Path doGenerateFile(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject data) throws IOException, org.codehaus.jettison.json.JSONException
- Overrides:
doGenerateFile
in classFileExportActionHandler
- Throws:
IOException
org.codehaus.jettison.json.JSONException
-
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.doGenerateReport(Map, JSONObject)
is used instead- 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 ReportjsonContent
- values set in the filter parametersparameters
- 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 effectThis method has no effect. Classes extendingBaseReportActionHandler
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
-
getDownloadAction
protected FileExportActionHandler.FileAction getDownloadAction(org.codehaus.jettison.json.JSONObject data) throws org.codehaus.jettison.json.JSONException
Description copied from class:FileExportActionHandler
Allows to define the action to be done with the file when it is downloaded. It returnsFileExportActionHandler.FileAction.DOWNLOAD
by default.- Overrides:
getDownloadAction
in classFileExportActionHandler
- Parameters:
data
- JSONObject with the request content- Returns:
- the action to be done when the file is downloaded
- Throws:
org.codehaus.jettison.json.JSONException
-
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 classFileExportActionHandler
- Parameters:
parameters
- The map of parameters extracted from the requestdata
- 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 Definitionparameters
- 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 classFileExportActionHandler
- Parameters:
parameters
- The map of parameters extracted from the requestdata
- 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 classFileExportActionHandler
- Parameters:
parameters
- The map of parameters extracted from the requestdata
- JSONObject with the request content- Returns:
- the name of the file to be downloaded
- Throws:
org.codehaus.jettison.json.JSONException
-
isValidDownloadFileType
protected boolean isValidDownloadFileType(ReportingUtils.ExportType exportType)
- Overrides:
isValidDownloadFileType
in classFileExportActionHandler
- Returns:
- true if the handler supports downloading files with the give type. Otherwise false is returned.
-
getAdditionalResponseActions
protected org.codehaus.jettison.json.JSONObject getAdditionalResponseActions()
- Overrides:
getAdditionalResponseActions
in classFileExportActionHandler
- Returns:
- a JSONObject containing the additional response actions to be done together with the file action defined by the process
-
addAditionalParameters
protected void addAditionalParameters(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject processParams) throws org.codehaus.jettison.json.JSONException
Description copied from class:FileExportActionHandler
Allows to include additional process parameters in the result built withFileExportActionHandler.createResponseForDownload(java.util.Map<java.lang.String, java.lang.Object>, org.codehaus.jettison.json.JSONObject, java.nio.file.Path)
- Overrides:
addAditionalParameters
in classFileExportActionHandler
- Parameters:
parameters
- The map of parameters extracted from the requestprocessParams
- JSONObject with information of the process itself. This method is allowed to mutate this object by adding properties into it.- Throws:
org.codehaus.jettison.json.JSONException
-
addAditionalRecordInfo
protected void addAditionalRecordInfo(Map<String,Object> parameters, org.codehaus.jettison.json.JSONObject recordInfo) throws org.codehaus.jettison.json.JSONException
Description copied from class:FileExportActionHandler
Allows to include additional record information in the result built withFileExportActionHandler.createResponseForDownload(java.util.Map<java.lang.String, java.lang.Object>, org.codehaus.jettison.json.JSONObject, java.nio.file.Path)
- Overrides:
addAditionalRecordInfo
in classFileExportActionHandler
- Parameters:
parameters
- The map of parameters extracted from the requestrecordInfo
- JSONObject with the record information. This method is allowed to mutate this object by adding properties into it.- Throws:
org.codehaus.jettison.json.JSONException
-
-