it.eng.spagobi.engines.qbe.crosstable
Class CrossTab

java.lang.Object
  extended by it.eng.spagobi.engines.qbe.crosstable.CrossTab

public class CrossTab
extends java.lang.Object

Author:
Alberto Ghedin This Class encapsulates the crossTab The publics methods are: - CrossTab(IDataStore dataStore, CrosstabDefinition crosstabDefinition) that builds the crossTab (headers structure and data) - getJSONCrossTab() that returns the JSON representation of the crosstab

Nested Class Summary
static class CrossTab.CellType
           
 class CrossTab.MeasureInfo
           
 
Field Summary
static java.lang.String CROSSTAB_JSON_COLUMNS_HEADERS
           
static java.lang.String CROSSTAB_JSON_CONFIG
           
static java.lang.String CROSSTAB_JSON_DATA
           
static java.lang.String CROSSTAB_JSON_MEASURES_METADATA
           
static java.lang.String CROSSTAB_JSON_ROWS_HEADERS
           
static java.lang.String CROSSTAB_JSON_ROWS_HEADERS_DESCRIPTION
           
static java.lang.String CROSSTAB_NODE_JSON_CHILDS
           
static java.lang.String CROSSTAB_NODE_JSON_KEY
           
static java.lang.String MEASURE_FORMAT
           
static java.lang.String MEASURE_NAME
           
static java.lang.String MEASURE_TYPE
           
static java.lang.String SUBTOTAL
           
static java.lang.String TOTAL
           
 
Constructor Summary
CrossTab()
           
CrossTab(it.eng.spagobi.tools.dataset.common.datastore.IDataStore dataStore, CrosstabDefinition crosstabDefinition)
          Builds the crossTab (headers structure and data)
CrossTab(it.eng.spagobi.tools.dataset.common.datastore.IDataStore dataStore, CrosstabDefinition crosstabDefinition, org.json.JSONArray calculateFields)
          Builds the crossTab (headers structure and data)
 
Method Summary
 void addCrosstabDataColumns(int startposition, java.util.List<java.lang.String[]> colums, CrossTab.CellType type)
          Inserts columns in the crosstab data matrix
 void addCrosstabDataLine(int startposition, java.util.List<java.lang.String[]> line, boolean horizontal, CrossTab.CellType type)
          Inserts lines in the crosstab data matrix
 void addCrosstabDataRow(int startposition, java.util.List<java.lang.String[]> rows, CrossTab.CellType type)
          Inserts rows in the crosstab data matrix
 void addSubtotals()
          SUBTOTALS
 void addSubtotalsToTheNode(Node n, boolean horizontal, int level, boolean measuresOnRow)
          Prepare and execute a CF for the subtotals
 CrossTab.CellType getCellType(int row, int column)
          Get the CellType of the cell
 Node getColumnsRoot()
           
 java.lang.String[][] getDataMatrix()
           
 org.json.JSONObject getJSONCrossTab()
          Get the JSON representation of the cross tab
 org.json.JSONArray getJSONDataMatrix()
          Serialize the matrix in a JSON format
 Node getRowsRoot()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CROSSTAB_NODE_JSON_KEY

public static final java.lang.String CROSSTAB_NODE_JSON_KEY
See Also:
Constant Field Values

CROSSTAB_NODE_JSON_CHILDS

public static final java.lang.String CROSSTAB_NODE_JSON_CHILDS
See Also:
Constant Field Values

CROSSTAB_JSON_ROWS_HEADERS

public static final java.lang.String CROSSTAB_JSON_ROWS_HEADERS
See Also:
Constant Field Values

CROSSTAB_JSON_ROWS_HEADERS_DESCRIPTION

public static final java.lang.String CROSSTAB_JSON_ROWS_HEADERS_DESCRIPTION
See Also:
Constant Field Values

CROSSTAB_JSON_COLUMNS_HEADERS

public static final java.lang.String CROSSTAB_JSON_COLUMNS_HEADERS
See Also:
Constant Field Values

CROSSTAB_JSON_DATA

public static final java.lang.String CROSSTAB_JSON_DATA
See Also:
Constant Field Values

CROSSTAB_JSON_CONFIG

public static final java.lang.String CROSSTAB_JSON_CONFIG
See Also:
Constant Field Values

CROSSTAB_JSON_MEASURES_METADATA

public static final java.lang.String CROSSTAB_JSON_MEASURES_METADATA
See Also:
Constant Field Values

MEASURE_NAME

public static final java.lang.String MEASURE_NAME
See Also:
Constant Field Values

MEASURE_TYPE

public static final java.lang.String MEASURE_TYPE
See Also:
Constant Field Values

MEASURE_FORMAT

public static final java.lang.String MEASURE_FORMAT
See Also:
Constant Field Values

TOTAL

public static final java.lang.String TOTAL
See Also:
Constant Field Values

SUBTOTAL

public static final java.lang.String SUBTOTAL
See Also:
Constant Field Values
Constructor Detail

CrossTab

public CrossTab()

CrossTab

public CrossTab(it.eng.spagobi.tools.dataset.common.datastore.IDataStore dataStore,
                CrosstabDefinition crosstabDefinition,
                org.json.JSONArray calculateFields)
         throws org.json.JSONException
Builds the crossTab (headers structure and data)

Parameters:
dataStore: - the source of the data
crosstabDefinition: - the definition of the crossTab
calculateFields: - array of JSONObjects the CF
Throws:
org.json.JSONException

CrossTab

public CrossTab(it.eng.spagobi.tools.dataset.common.datastore.IDataStore dataStore,
                CrosstabDefinition crosstabDefinition)
         throws org.json.JSONException
Builds the crossTab (headers structure and data)

Parameters:
dataStore: - the source of the data
crosstabDefinition: - the definition of the crossTab
Throws:
org.json.JSONException
Method Detail

getJSONCrossTab

public org.json.JSONObject getJSONCrossTab()
                                    throws org.json.JSONException
Get the JSON representation of the cross tab

Returns:
JSON representation of the cross tab
Throws:
org.json.JSONException

getJSONDataMatrix

public org.json.JSONArray getJSONDataMatrix()
Serialize the matrix in a JSON format

Returns:
the matrix in a JSON format

addSubtotals

public void addSubtotals()
SUBTOTALS


addSubtotalsToTheNode

public void addSubtotalsToTheNode(Node n,
                                  boolean horizontal,
                                  int level,
                                  boolean measuresOnRow)
Prepare and execute a CF for the subtotals

Parameters:
n -
horizontal -
level -
measuresOnRow -

addCrosstabDataLine

public void addCrosstabDataLine(int startposition,
                                java.util.List<java.lang.String[]> line,
                                boolean horizontal,
                                CrossTab.CellType type)
Inserts lines in the crosstab data matrix

Parameters:
startposition - the position where insert the rows/columns into the matrix
line - the lines to insert
horizontal - true to insert columns/false to insert rows
type - the type of the data

addCrosstabDataColumns

public void addCrosstabDataColumns(int startposition,
                                   java.util.List<java.lang.String[]> colums,
                                   CrossTab.CellType type)
Inserts columns in the crosstab data matrix

Parameters:
startposition - the position where insert the columns into the matrix
colums - the lines to insert
type - the type of the data

addCrosstabDataRow

public void addCrosstabDataRow(int startposition,
                               java.util.List<java.lang.String[]> rows,
                               CrossTab.CellType type)
Inserts rows in the crosstab data matrix

Parameters:
startposition - the position where insert the rows into the matrix
colums - the lines to insert
type - the type of the data

getCellType

public CrossTab.CellType getCellType(int row,
                                     int column)
Get the CellType of the cell

Parameters:
row - the row
column - the column
Returns:
the celltype of the cell

getColumnsRoot

public Node getColumnsRoot()

getRowsRoot

public Node getRowsRoot()

getDataMatrix

public java.lang.String[][] getDataMatrix()