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
           
static class CrossTab.MeasureInfo
           
 
Field Summary
static java.lang.String CROSSTAB_CELLTYPEOFCOLUMNS
           
static java.lang.String CROSSTAB_CELLTYPEOFROWS
           
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_HEADER_TITLE
           
static java.lang.String CROSSTAB_JSON_ROWS_HEADERS
           
static java.lang.String CROSSTAB_JSON_ROWS_HEADERS_DESCRIPTION
           
static java.lang.String CROSSTAB_JSON_VALUE_DESCRIPTION_MAP
           
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_POSITION
           
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 valuesDataStore, CrosstabDefinition crosstabDefinition)
          Builds the crossTab (headers structure and data)
CrossTab(it.eng.spagobi.tools.dataset.common.datastore.IDataStore dataStore, CrosstabDefinition crosstabDefinition, org.json.JSONArray fieldOptions, 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
 int addSubtotalsToTheNodeFirstLevel(Node node, boolean horizontal, int positionToAddNode)
           
 int addSubtotalsToTheNodeUpLevel(Node node, boolean horizontal, int startingPosition)
           
 void addSubtotalsToTheTree(Node node, boolean horizontal, int startingPosition)
           
 int addSubtotalsToTheTreeNoMeasure(Node node, boolean horizontal, int startingPosition)
           
 Node buildSubtotalNode(int totalHeadersNumber, boolean withMeasures)
           
 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
 java.util.List<CrossTab.MeasureInfo> getMeasures()
           
 java.lang.String getMeasureScaleFactor(java.lang.String name)
           
 java.util.List<java.lang.String> getRowHeadersTitles()
           
 Node getRowsRoot()
           
 boolean isMeasureOnRow()
           
 
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

CROSSTAB_JSON_ROWS_HEADER_TITLE

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

CROSSTAB_CELLTYPEOFCOLUMNS

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

CROSSTAB_CELLTYPEOFROWS

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

CROSSTAB_JSON_VALUE_DESCRIPTION_MAP

public static final java.lang.String CROSSTAB_JSON_VALUE_DESCRIPTION_MAP
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

MEASURE_POSITION

public static final java.lang.String MEASURE_POSITION
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 fieldOptions,
                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
fieldOptions: - fieldOptions
calculateFields: - array of JSONObjects the CF
Throws:
org.json.JSONException

CrossTab

public CrossTab(it.eng.spagobi.tools.dataset.common.datastore.IDataStore valuesDataStore,
                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

getMeasureScaleFactor

public java.lang.String getMeasureScaleFactor(java.lang.String name)

addSubtotals

public void addSubtotals()
SUBTOTALS


addSubtotalsToTheTreeNoMeasure

public int addSubtotalsToTheTreeNoMeasure(Node node,
                                          boolean horizontal,
                                          int startingPosition)

addSubtotalsToTheTree

public void addSubtotalsToTheTree(Node node,
                                  boolean horizontal,
                                  int startingPosition)

addSubtotalsToTheNodeUpLevel

public int addSubtotalsToTheNodeUpLevel(Node node,
                                        boolean horizontal,
                                        int startingPosition)

addSubtotalsToTheNodeFirstLevel

public int addSubtotalsToTheNodeFirstLevel(Node node,
                                           boolean horizontal,
                                           int positionToAddNode)

buildSubtotalNode

public Node buildSubtotalNode(int totalHeadersNumber,
                              boolean withMeasures)

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()

getRowHeadersTitles

public java.util.List<java.lang.String> getRowHeadersTitles()

getMeasures

public java.util.List<CrossTab.MeasureInfo> getMeasures()

isMeasureOnRow

public boolean isMeasureOnRow()