IDEMPIERE-146 Performance: Report Engine always read all data into memory. Make print element serializable to prepare for future virtualization of report data.

This commit is contained in:
Heng Sin Low 2012-06-20 16:11:27 +08:00
parent f16c6291db
commit a6e7659595
2 changed files with 16 additions and 9 deletions

View File

@ -75,7 +75,7 @@ public class PrintData implements Serializable
* @param name data element name * @param name data element name
* @param nodes ArrayList with nodes (content not checked) * @param nodes ArrayList with nodes (content not checked)
*/ */
public PrintData (Properties ctx, String name, ArrayList<Object> nodes) public PrintData (Properties ctx, String name, ArrayList<Serializable> nodes)
{ {
if (name == null) if (name == null)
throw new IllegalArgumentException("Name cannot be null"); throw new IllegalArgumentException("Name cannot be null");
@ -90,9 +90,9 @@ public class PrintData implements Serializable
/** Data Structure Name */ /** Data Structure Name */
private String m_name; private String m_name;
/** Data Structure rows */ /** Data Structure rows */
private ArrayList<ArrayList<Object>> m_rows = new ArrayList<ArrayList<Object>>(); private ArrayList<ArrayList<Serializable>> m_rows = new ArrayList<ArrayList<Serializable>>();
/** Current Row Data Structure elements */ /** Current Row Data Structure elements */
private ArrayList<Object> m_nodes = null; private ArrayList<Serializable> m_nodes = null;
/** Current Row */ /** Current Row */
private int m_row = -1; private int m_row = -1;
/** List of Function Rows */ /** List of Function Rows */
@ -246,7 +246,7 @@ public class PrintData implements Serializable
*/ */
public void addRow (boolean functionRow, int levelNo) public void addRow (boolean functionRow, int levelNo)
{ {
m_nodes = new ArrayList<Object>(); m_nodes = new ArrayList<Serializable>();
m_row = m_rows.size(); m_row = m_rows.size();
m_rows.add (m_nodes); m_rows.add (m_nodes);
if (functionRow) if (functionRow)
@ -265,7 +265,7 @@ public class PrintData implements Serializable
if (row < 0 || row >= m_rows.size()) if (row < 0 || row >= m_rows.size())
return false; return false;
m_row = row; m_row = row;
m_nodes = (ArrayList<Object>)m_rows.get(m_row); m_nodes = m_rows.get(m_row);
return true; return true;
} }

View File

@ -16,6 +16,7 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.print; package org.compiere.print;
import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -32,8 +33,14 @@ import org.compiere.util.NamePair;
* @author Jorg Janke * @author Jorg Janke
* @version $Id: PrintDataElement.java,v 1.2 2006/07/30 00:53:02 jjanke Exp $ * @version $Id: PrintDataElement.java,v 1.2 2006/07/30 00:53:02 jjanke Exp $
*/ */
public class PrintDataElement public class PrintDataElement implements Serializable
{ {
/**
* generated serialize id
*/
private static final long serialVersionUID = -4823568539698752659L;
/** /**
* Print Data Element Constructor * Print Data Element Constructor
* @param columnName name * @param columnName name
@ -42,7 +49,7 @@ public class PrintDataElement
* @param isPKey is primary key * @param isPKey is primary key
* @param isPageBreak if true force page break * @param isPageBreak if true force page break
*/ */
public PrintDataElement (String columnName, Object value, int displayType, boolean isPKey, boolean isPageBreak, String format) public PrintDataElement (String columnName, Serializable value, int displayType, boolean isPKey, boolean isPageBreak, String format)
{ {
if (columnName == null) if (columnName == null)
throw new IllegalArgumentException("PrintDataElement - Name cannot be null"); throw new IllegalArgumentException("PrintDataElement - Name cannot be null");
@ -61,7 +68,7 @@ public class PrintDataElement
* @param pattern Number/date format pattern * @param pattern Number/date format pattern
* @param displayType optional displayType * @param displayType optional displayType
*/ */
public PrintDataElement(String columnName, Object value, int displayType, String pattern) public PrintDataElement(String columnName, Serializable value, int displayType, String pattern)
{ {
this (columnName, value, displayType, false, false, pattern); this (columnName, value, displayType, false, false, pattern);
} // PrintDataElement } // PrintDataElement
@ -69,7 +76,7 @@ public class PrintDataElement
/** Data Name */ /** Data Name */
private String m_columnName; private String m_columnName;
/** Data Value */ /** Data Value */
private Object m_value; private Serializable m_value;
/** Display Type */ /** Display Type */
private int m_displayType; private int m_displayType;
/** Is Primary Key */ /** Is Primary Key */