--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/report/ReportingUtils.java Wed May 20 10:26:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/report/ReportingUtils.java Wed May 20 19:06:43 2015 +0200
@@ -19,7 +19,6 @@
package org.openbravo.client.application.report;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
@@ -73,7 +72,6 @@
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBDal;
import org.openbravo.database.ConnectionProvider;
-import org.openbravo.erpCommon.utility.JRFieldProviderDataSource;
import org.openbravo.erpCommon.utility.JRFormatFactory;
import org.openbravo.erpCommon.utility.OBMessageUtils;
import org.openbravo.model.ad.utility.FileType;
@@ -85,25 +83,25 @@
/** Utilities to generate jasper reports */
public class ReportingUtils {
+ /**
+ * Used to set a report parameter with a org.openbravo.dal.core.OBContext which contains the
+ * OBContext that has launched the report.
+ */
public static final String JASPER_PARAM_OBCONTEXT = "jasper_obContext";
+ /**
+ * Used to set a report parameter with an org.hibernate.Session object with the current hibernate.
+ * session.
+ */
public static final String JASPER_PARAM_HBSESSION = "jasper_hbSession";
+ /**
+ * Used to set the parameter with the URI to retrieve images in HTML reports.
+ */
+ public static final String IMAGES_URI = "Images URI";
private static final Logger log = LoggerFactory.getLogger(ReportingUtils.class);
/**
- * Exports the report to a file in a temporary folder. This method adds automatically the
- * parameters needed to print a report from a Process Definition.
- *
- * @param jasperFilePath
- * The path to the JR template of the report.
- * @param expType
- * The desired output type of the report.
- * @param parameters
- * The parameters to be sent to Jasper Report.
- * @param strFileName
- * The name to be used on the generated file.
- * @throws OBException
- * In case there is any error generating the file an exception is thrown with the error
- * message.
+ * @see ReportingUtils#exportJR(String, ExportType, Map, File, boolean, ConnectionProvider,
+ * JRDataSource, Map)
*/
public static void exportJR(String jasperFilePath, ExportType expType,
Map<String, Object> parameters, String strFileName) throws OBException {
@@ -112,22 +110,8 @@
}
/**
- * Exports the report to a file in a temporary folder.
- *
- * @param jasperFilePath
- * The path to the JR template of the report.
- * @param expType
- * The desired output type of the report.
- * @param parameters
- * The parameters to be sent to Jasper Report.
- * @param strFileName
- * The name to be used on the generated file.
- * @param addProcessDefinitionParameters
- * A flag to indicate if the parameters needed to print a report from a Process
- * Definition should be added.
- * @throws OBException
- * In case there is any error generating the file an exception is thrown with the error
- * message.
+ * @see ReportingUtils#exportJR(String, ExportType, Map, File, boolean, ConnectionProvider,
+ * JRDataSource, Map)
*/
public static void exportJR(String jasperFilePath, ExportType expType,
Map<String, Object> parameters, String strFileName, boolean addProcessDefinitionParameters)
@@ -138,28 +122,8 @@
}
/**
- * Exports the report to a file in a temporary folder.
- *
- * @param jasperFilePath
- * The path to the JR template of the report.
- * @param expType
- * The desired output type of the report.
- * @param parameters
- * The parameters to be sent to Jasper Report.
- * @param strFileName
- * The name to be used on the generated file.
- * @param addProcessDefinitionParameters
- * A flag to indicate if the parameters needed to print a report from a Process
- * Definition should be added.
- * @param connectionProvider
- * A connection provider in case the report needs it.
- * @param data
- * The data to be used in the report, if required.
- * @param additionalExportParameters
- * Additional export parameters than can be added to configure the resulting report.
- * @throws OBException
- * In case there is any error generating the report an exception is thrown with the
- * error message.
+ * @see ReportingUtils#exportJR(String, ExportType, Map, File, boolean, ConnectionProvider,
+ * JRDataSource, Map)
*/
public static void exportJR(String jasperFilePath, ExportType expType,
Map<String, Object> parameters, String strFileName, boolean addProcessDefinitionParameters,
@@ -171,28 +135,8 @@
}
/**
- * Exports the report to a file, without compiling any sub-report.
- *
- * @param jasperFilePath
- * The path to the JR template of the report.
- * @param expType
- * The desired output type of the report.
- * @param parameters
- * The parameters to be sent to Jasper Report.
- * @param target
- * The file used to return the report.
- * @param addProcessDefinitionParameters
- * A flag to indicate if the parameters needed to print a report from a Process
- * Definition should be added.
- * @param connectionProvider
- * A connection provider in case the report needs it.
- * @param data
- * The data to be used in the report, if required.
- * @param additionalExportParameters
- * Additional export parameters than can be added to configure the resulting report.
- * @throws OBException
- * In case there is any error generating the file an exception is thrown with the error
- * message.
+ * @see ReportingUtils#exportJR(String, ExportType, Map, File, boolean, ConnectionProvider,
+ * JRDataSource, Map, boolean)
*/
public static void exportJR(String jasperFilePath, ExportType expType,
Map<String, Object> parameters, File target, boolean addProcessDefinitionParameters,
@@ -203,28 +147,8 @@
}
/**
- * Exports the report to an output stream, without compiling any sub-report.
- *
- * @param jasperFilePath
- * The path to the JR template of the report.
- * @param expType
- * The desired output type of the report.
- * @param parameters
- * The parameters to be sent to Jasper Report.
- * @param outputStream
- * An output stream used to return the report.
- * @param addProcessDefinitionParameters
- * A flag to indicate if the parameters needed to print a report from a Process
- * Definition should be added.
- * @param connectionProvider
- * A connection provider in case the report needs it.
- * @param data
- * The data to be used in the report, if required.
- * @param additionalExportParameters
- * Additional export parameters than can be added to configure the resulting report.
- * @throws OBException
- * In case there is any error generating the report an exception is thrown with the
- * error message.
+ * @see ReportingUtils#exportJR(String, ExportType, Map, OutputStream, boolean,
+ * ConnectionProvider, JRDataSource, Map, boolean)
*/
public static void exportJR(String jasperFilePath, ExportType expType,
Map<String, Object> parameters, OutputStream outputStream,
@@ -721,6 +645,10 @@
/**
* Generates a SimpleXlsReportConfiguration from a parameter map.
*
+ * This method allows backwards compatibility when generating XLS reports by using a parameter map
+ * to define the export configuration. The usage of this parameter map is deprecated in the Jasper
+ * Reports library to use the SimpleXlsReportConfiguration class instead.
+ *
* @param params
* A parameter map with the export parameters.
* @return A SimpleXlsReportConfiguration object with the resulting configuration.
@@ -730,10 +658,7 @@
private static SimpleXlsReportConfiguration getXlsConfigurationFromExportParameters(
Map<Object, Object> params) {
SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
- Iterator<Entry<Object, Object>> it = params.entrySet().iterator();
- while (it.hasNext()) {
- @SuppressWarnings("rawtypes")
- Map.Entry pair = (Map.Entry) it.next();
+ for (Entry<Object, Object> pair : params.entrySet()) {
String parameter = ((net.sf.jasperreports.engine.JRExporterParameter) pair.getKey())
.toString();
if (parameter.equals("Is One Page per Sheet")) {
@@ -762,6 +687,8 @@
configuration.setMaxRowsPerSheet((Integer) pair.getValue());
} else if (parameter.equals("Ignore page margins")) {
configuration.setIgnorePageMargins((Boolean) pair.getValue());
+ } else {
+ log.warn("Unknown XLS export configuration parameter: " + parameter);
}
}
return configuration;
@@ -770,8 +697,17 @@
/**
* Configures a SimpleHtmlReportConfiguration and a SimpleHtmlExporterOutput from a parameter map.
*
+ * This method allows backwards compatibility when generating HTML reports by using a parameter
+ * map to define the export configuration. The usage of this parameter map is deprecated in the
+ * Jasper Reports library to use the SimpleHtmlReportConfiguration and SimpleHtmlExporterOutput
+ * classes instead.
+ *
* @param params
* A parameter map with the export parameters.
+ * @param configuration
+ * The SimpleHtmlReportConfiguration object generated based on the parameter map.
+ * @param exporterOutput
+ * The SimpleHtmlExporterOutput object generated based on the parameter map.
*
*/
@SuppressWarnings("deprecation")
@@ -780,10 +716,7 @@
// Add configuration defaults
// This is needed just in case the params map only contains the Images URI parameter
configuration.setSizeUnit(HtmlSizeUnitEnum.POINT);
- Iterator<Entry<Object, Object>> it = params.entrySet().iterator();
- while (it.hasNext()) {
- @SuppressWarnings("rawtypes")
- Map.Entry pair = (Map.Entry) it.next();
+ for (Entry<Object, Object> pair : params.entrySet()) {
String parameter = ((net.sf.jasperreports.engine.JRExporterParameter) pair.getKey())
.toString();
if (parameter.equals("Images URI")) {
@@ -805,6 +738,8 @@
configuration.setWrapBreakWord((Boolean) pair.getValue());
} else if (parameter.equals("Zoom Ratio")) {
configuration.setZoomRatio((Float) pair.getValue());
+ } else {
+ log.warn("Unknown HTML export configuration parameter: " + parameter);
}
}
}
@@ -942,10 +877,9 @@
}
}
- } catch (final JRException exception) {
- log.error(exception.getMessage());
- exception.printStackTrace();
- throw new OBException(exception);
+ } catch (final JRException e) {
+ log.error("Error processing subreports for template: " + templateFile, e);
+ throw new OBException(e.getMessage(), e);
}
}
@@ -970,9 +904,8 @@
try {
jasperReportLines = getTranslatedJasperReport(connectionProvider, templateLocation
+ subReportFileName, language, baseDesignPath);
- } catch (final JRException e1) {
- log.error(e1.getMessage());
- e1.printStackTrace();
+ } catch (final JRException e) {
+ log.error("Error generating subreport: " + subReportFileName, e);
}
return jasperReportLines;
}
@@ -1042,7 +975,7 @@
*
* @param jasperPrintList
* A list of JasperPrint objects.
- * @param createBoomkmarks
+ * @param createBookmarks
* A flag to indicate if the document should contain bookmarks, to mark the beginning of
* each individual document that was part of the initial document list.
* @param outputStream
@@ -1073,7 +1006,7 @@
*
* @param jasperPrintList
* A list of JasperPrint objects.
- * @param createBoomkmarks
+ * @param createBookmarks
* A flag to indicate if the document should contain bookmarks, to mark the beginning of
* each individual document that was part of the initial document list.
* @param userPassword
@@ -1177,57 +1110,14 @@
}
/**
- * Creates a JasperPrint from a grid report.
- *
- * @deprecated
- *
- * @param reportFile
- * An input stream containing the report file.
- * @param gridReportVO
- * A grid report.
- * @return A JasperPrint object with the compiled report.
- * @throws JRException
- * In case there is any error generating the file an exception is thrown with the error
- * message.
- * @throws IOException
- * In case there is any error generating the JasperPrint an exception is thrown with the
- * error message.
- */
- public static JasperPrint createJasperPrint(InputStream reportFile,
- org.openbravo.erpCommon.utility.GridReportVO gridReportVO) throws JRException, IOException {
- JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
- if (log.isDebugEnabled())
- log.debug("Create JasperDesign");
- org.openbravo.erpCommon.utility.ReportDesignBO designBO = new org.openbravo.erpCommon.utility.ReportDesignBO(
- jasperDesign, gridReportVO);
- designBO.define();
- if (log.isDebugEnabled())
- log.debug("JasperDesign created, pageWidth: " + jasperDesign.getPageWidth()
- + " left margin: " + jasperDesign.getLeftMargin() + " right margin: "
- + jasperDesign.getRightMargin());
- JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
- Map<String, Object> parameters = new HashMap<String, Object>();
- parameters.put("BaseDir", gridReportVO.getContext());
- parameters.put("IS_IGNORE_PAGINATION", gridReportVO.getPagination());
-
- JasperPrint jasperPrint = JasperFillManager
- .fillReport(
- jasperReport,
- parameters,
- new JRFieldProviderDataSource(gridReportVO.getFieldProvider(), gridReportVO
- .getDateFormat()));
- return jasperPrint;
- }
-
- /**
* Changes the mask to use "." as Decimal Symbol and "," as grouping symbol.
*
* @param mask
- * the current mask
+ * the current mask.
* @param decimalSymbol
- * the current decimal symbol
+ * the current decimal symbol.
* @param groupingSymbol
- * the current grouping symbol
+ * the current grouping symbol.
* @return the mask with the updated decimal and grouping symbols.
*/
private static String correctMaskForGrouping(String mask, String decimalSymbol,
@@ -1243,30 +1133,51 @@
* is generated.
*/
public enum ExportType {
+ // When IS_IGNORE_PAGINATION is set to true, the report-filling engine will generate the
+ // document on a single, very long page. Running the generated report to any output format, a
+ // single page document will be visualized. This is the desired behavior for some document
+ // types, such as HTML, XML or XLS.
+ // This flag should be false for documents with page-oriented layout, like PDF, to allow the
+ // possibility to navigate between pages.
+ /**
+ * CSV export type
+ */
@SuppressWarnings("serial")
CSV("csv", "", new HashMap<String, Object>() {
{
put("IS_IGNORE_PAGINATION", true);
}
}), //
+ /**
+ * HTML export type
+ */
@SuppressWarnings("serial")
HTML("html", "", new HashMap<String, Object>() {
{
put("IS_IGNORE_PAGINATION", true);
}
}), //
+ /**
+ * PDF export type
+ */
@SuppressWarnings("serial")
PDF("pdf", "103", new HashMap<String, Object>() {
{
put("IS_IGNORE_PAGINATION", false);
}
}), //
+ /**
+ * XLS export type
+ */
@SuppressWarnings("serial")
XLS("xls", "101", new HashMap<String, Object>() {
{
put("IS_IGNORE_PAGINATION", true);
}
}), //
+ /**
+ * XML export type
+ */
@SuppressWarnings("serial")
XML("xml", "800004", new HashMap<String, Object>() {
{
@@ -1297,14 +1208,23 @@
this.params = params;
}
+ /**
+ * @return a String with the extension type.
+ */
public String getExtension() {
return this.extension;
}
+ /**
+ * @return a String with the content type.
+ */
public String getContentType() {
return fileType;
}
+ /**
+ * @return a map with the configuration parameters.
+ */
public Map<String, Object> getExportParameters() {
// An instance of the Map is done for making sure
// that if this method is called, it is only accessing
@@ -1314,6 +1234,13 @@
/**
* Returns the corresponding ExportType item based on the action.
+ *
+ * @param action
+ * a String that defines the export type.
+ * @return the ExportType associated to the input String parameter.
+ * @throws OBException
+ * In case the input String parameter does not correspond with any valid ExportType,
+ * an exception is thrown with the error message.
*/
public static ExportType getExportType(String action) throws OBException {
if ("CSV".equals(action)) {
@@ -1331,7 +1258,14 @@
}
}
- /** Checks if temporary file name is a valid one: has extension and the name is a uuid */
+ /**
+ * Checks if temporary file name is a valid one: has extension and the name is a uuid.
+ *
+ * @param tmpFileName
+ * a String with the file name.
+ *
+ * @return true if the the temporary file name is valid, false otherwise.
+ */
public boolean isValidTemporaryFileName(String tmpFileName) {
if (!tmpFileName.endsWith("." + getExtension())) {
// file name should end with the extension
@@ -1345,7 +1279,11 @@
}
}
- /** Returns temporary directory to save generated reports */
+ /**
+ * Returns temporary directory to save generated reports.
+ *
+ * @return a String with the temporary directory location.
+ */
public static String getTempFolder() {
final String tmpFolder = System.getProperty("java.io.tmpdir");
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java Wed May 20 10:26:36 2015 +0200
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java Wed May 20 19:06:43 2015 +0200
@@ -1225,7 +1225,6 @@
exportParameters, false);
}
- @SuppressWarnings("deprecation")
private void renderJR(VariablesSecureApp variables, HttpServletResponse response,
String strReportName, String strFileName, String strOutputType,
HashMap<String, Object> designParameters, JRDataSource data,
@@ -1283,8 +1282,7 @@
+ strOutputType);
HttpServletRequest request = RequestContext.get().getRequest();
String localAddress = HttpBaseUtils.getLocalAddress(request);
- exportParameters.put(net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI,
- localAddress + "/servlets/image?image={0}");
+ exportParameters.put(ReportingUtils.IMAGES_URI, localAddress + "/servlets/image?image={0}");
ReportingUtils.exportJR(strReportName, expType, designParameters, os, false, this, data,
exportParameters);
} else if (strOutputType.equals("pdf") || strOutputType.equalsIgnoreCase("xls")) {
--- a/src/org/openbravo/erpCommon/ad_process/JasperProcess.java Wed May 20 10:26:36 2015 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/JasperProcess.java Wed May 20 19:06:43 2015 +0200
@@ -1,3 +1,21 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2008-2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
package org.openbravo.erpCommon.ad_process;
import java.text.DecimalFormat;
@@ -20,19 +38,15 @@
import org.openbravo.erpCommon.utility.Utility;
import org.openbravo.scheduling.Process;
import org.openbravo.scheduling.ProcessBundle;
-import org.openbravo.scheduling.ProcessLogger;
import org.openbravo.utils.Replace;
public class JasperProcess implements Process {
static Logger log4j = Logger.getLogger(JasperProcess.class);
- private ProcessLogger logger;
-
private ConnectionProvider connection;
public void initialize(ProcessBundle bundle) {
- logger = bundle.getLogger();
connection = bundle.getConnection();
}
@@ -67,7 +81,6 @@
strReportName = Replace.replace(Replace.replace(strReportName, "@basedesign@", strBaseDesign),
"@attach@", strAttach);
- String strFileName = strReportName.substring(strReportName.lastIndexOf("/") + 1);
// FIXME: os is never assigned, but used leading to an NPE
ServletOutputStream os = null;
--- a/src/org/openbravo/erpCommon/utility/ExportGrid.java Wed May 20 10:26:36 2015 +0200
+++ b/src/org/openbravo/erpCommon/utility/ExportGrid.java Wed May 20 19:06:43 2015 +0200
@@ -43,9 +43,6 @@
// text length multiplied by a factor (character width)
private static final int CHAR_WIDTH = 10;
- /**
- * @deprecated
- */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException {
VariablesSecureApp vars = new VariablesSecureApp(request);
@@ -106,9 +103,6 @@
}
}
- /**
- * @deprecated
- */
private GridReportVO createGridReport(VariablesSecureApp vars, String strTabId,
String strWindowId, String strAccessLevel, boolean useFieldLength) throws ServletException {
if (log4j.isDebugEnabled())
--- a/src/org/openbravo/erpCommon/utility/GridBO.java Wed May 20 10:26:36 2015 +0200
+++ b/src/org/openbravo/erpCommon/utility/GridBO.java Wed May 20 19:06:43 2015 +0200
@@ -22,61 +22,82 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
import net.sf.jasperreports.engine.JRException;
+import net.sf.jasperreports.engine.JasperCompileManager;
+import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
+import net.sf.jasperreports.engine.JasperReport;
+import net.sf.jasperreports.engine.design.JasperDesign;
+import net.sf.jasperreports.engine.xml.JRXmlLoader;
+import org.apache.log4j.Logger;
import org.openbravo.client.application.report.ReportingUtils;
import org.openbravo.client.application.report.ReportingUtils.ExportType;
class GridBO {
- /**
- * @deprecated
- */
+ private static Logger log4j = Logger.getLogger("org.openbravo.erpCommon.utility.GridBO");
+
public static void createHTMLReport(InputStream reportFile, GridReportVO gridReportVO,
String path, String fileName) throws JRException, IOException {
gridReportVO.setPagination(false);
- JasperPrint jasperPrint = ReportingUtils.createJasperPrint(reportFile, gridReportVO);
+ JasperPrint jasperPrint = createJasperPrint(reportFile, gridReportVO);
ReportingUtils.saveReport(jasperPrint, ExportType.HTML, null, new File(path + "/" + fileName));
}
- /**
- * @deprecated
- */
public static void createPDFReport(InputStream reportFile, GridReportVO gridReportVO,
String path, String fileName) throws JRException, IOException {
gridReportVO.setPagination(false);
- JasperPrint jasperPrint = ReportingUtils.createJasperPrint(reportFile, gridReportVO);
+ JasperPrint jasperPrint = createJasperPrint(reportFile, gridReportVO);
ReportingUtils.saveReport(jasperPrint, ExportType.PDF, null, new File(path + "/" + fileName));
}
- /**
- * @deprecated
- */
public static void createXLSReport(InputStream reportFile, GridReportVO gridReportVO,
String path, String fileName) throws JRException, IOException {
gridReportVO.setPagination(true);
- JasperPrint jasperPrint = ReportingUtils.createJasperPrint(reportFile, gridReportVO);
+ JasperPrint jasperPrint = createJasperPrint(reportFile, gridReportVO);
ReportingUtils.saveReport(jasperPrint, ExportType.XLS, null, new File(path + "/" + fileName));
}
- /**
- * @deprecated
- */
public static void createCSVReport(InputStream reportFile, GridReportVO gridReportVO,
String path, String fileName) throws JRException, IOException {
gridReportVO.setPagination(true);
- JasperPrint jasperPrint = ReportingUtils.createJasperPrint(reportFile, gridReportVO);
+ JasperPrint jasperPrint = createJasperPrint(reportFile, gridReportVO);
ReportingUtils.saveReport(jasperPrint, ExportType.CSV, null, new File(path + "/" + fileName));
}
- /**
- * @deprecated
- */
public static void createXMLReport(InputStream reportFile, GridReportVO gridReportVO,
OutputStream os) throws JRException, IOException {
gridReportVO.setPagination(true);
- JasperPrint jasperPrint = ReportingUtils.createJasperPrint(reportFile, gridReportVO);
+ JasperPrint jasperPrint = createJasperPrint(reportFile, gridReportVO);
ReportingUtils.saveReport(jasperPrint, ExportType.XML, null, os);
}
+
+ private static JasperPrint createJasperPrint(InputStream reportFile,
+ org.openbravo.erpCommon.utility.GridReportVO gridReportVO) throws JRException, IOException {
+ JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
+ if (log4j.isDebugEnabled())
+ log4j.debug("Create JasperDesign");
+ org.openbravo.erpCommon.utility.ReportDesignBO designBO = new org.openbravo.erpCommon.utility.ReportDesignBO(
+ jasperDesign, gridReportVO);
+ designBO.define();
+ if (log4j.isDebugEnabled())
+ log4j.debug("JasperDesign created, pageWidth: " + jasperDesign.getPageWidth()
+ + " left margin: " + jasperDesign.getLeftMargin() + " right margin: "
+ + jasperDesign.getRightMargin());
+ JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
+ Map<String, Object> parameters = new HashMap<String, Object>();
+ parameters.put("BaseDir", gridReportVO.getContext());
+ parameters.put("IS_IGNORE_PAGINATION", gridReportVO.getPagination());
+
+ JasperPrint jasperPrint = JasperFillManager
+ .fillReport(
+ jasperReport,
+ parameters,
+ new JRFieldProviderDataSource(gridReportVO.getFieldProvider(), gridReportVO
+ .getDateFormat()));
+ return jasperPrint;
+ }
}
--- a/src/org/openbravo/erpCommon/utility/GridReportVO.java Wed May 20 10:26:36 2015 +0200
+++ b/src/org/openbravo/erpCommon/utility/GridReportVO.java Wed May 20 19:06:43 2015 +0200
@@ -23,8 +23,7 @@
import org.openbravo.data.FieldProvider;
-@Deprecated
-public class GridReportVO {
+class GridReportVO {
private String jrxmlTemplate;
private String sql;
private String title;
--- a/src/org/openbravo/erpCommon/utility/ReportDesignBO.java Wed May 20 10:26:36 2015 +0200
+++ b/src/org/openbravo/erpCommon/utility/ReportDesignBO.java Wed May 20 19:06:43 2015 +0200
@@ -33,8 +33,7 @@
import org.apache.log4j.Logger;
-@Deprecated
-public class ReportDesignBO {
+class ReportDesignBO {
public static Logger log4j = Logger.getLogger("org.openbravo.erpCommon.utility.GridBO");
private int px = 0;
@@ -44,9 +43,6 @@
private GridReportVO gridReportVO;
- /**
- * @deprecated
- */
public ReportDesignBO(JasperDesign jasperDesign, GridReportVO gridReportVO) {
super();
this.jasperDesign = jasperDesign;
@@ -65,6 +61,7 @@
px += columnVO.getWidth();
}
+ @SuppressWarnings("deprecation")
private void addFieldHeader(GridColumnVO columnVO) {
JRDesignBand bHeader = (JRDesignBand) jasperDesign.getColumnHeader();
JRDesignStaticText text = new JRDesignStaticText();
@@ -85,6 +82,7 @@
bHeader.addElement(text);
}
+ @SuppressWarnings("deprecation")
private void addFieldValue(GridColumnVO columnVO) throws JRException {
JRDesignBand bDetalle = (JRDesignBand) jasperDesign.getDetailSection().getBands()[0];
--- a/src/org/openbravo/erpCommon/utility/Utility.java Wed May 20 10:26:36 2015 +0200
+++ b/src/org/openbravo/erpCommon/utility/Utility.java Wed May 20 19:06:43 2015 +0200
@@ -1786,6 +1786,11 @@
return OBDateUtils.isBiggerDate(strDate1, strDate2, DateFormatter);
}
+ /**
+ * @deprecated Use
+ * {@link org.openbravo.client.application.report.ReportingUtils#getTranslatedJasperReport(ConnectionProvider, String, String, String)}
+ * instead.
+ */
public static JasperReport getTranslatedJasperReport(ConnectionProvider conn, String reportName,
String language, String baseDesignPath) throws JRException {
return ReportingUtils.getTranslatedJasperReport(conn, reportName, language, baseDesignPath);
--- a/src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java Wed May 20 10:26:36 2015 +0200
+++ b/src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java Wed May 20 19:06:43 2015 +0200
@@ -497,14 +497,6 @@
default:
break;
}
- if (report.outputType.equals(OutputTypeEnum.ARCHIVE)) {
- // Delete temporal reports generated for the returned report in case they have been
- // attached also
- File file = new File(report.getTargetLocation());
- if (file.exists() && !file.isDirectory()) {
- file.delete();
- }
- }
}
} catch (IOException e) {
log4j.error(e.getMessage());
@@ -514,6 +506,17 @@
e.printStackTrace();
} finally {
try {
+ for (Iterator<Report> iterator = reports.iterator(); iterator.hasNext();) {
+ Report report = iterator.next();
+ if (report.outputType.equals(OutputTypeEnum.ARCHIVE)) {
+ // Delete temporal reports generated for the returned report in case they have been
+ // attached also
+ File file = new File(report.getTargetLocation());
+ if (file.exists() && !file.isDirectory()) {
+ file.delete();
+ }
+ }
+ }
os.close();
response.flushBuffer();
} catch (IOException e) {