proper.relaggs
Class RelaggsStructure

java.lang.Object
  extended by proper.core.ProperObject
      extended by proper.database.ConnectorObject
          extended by proper.relaggs.RelaggsStructure
All Implemented Interfaces:
ProperInterface

public class RelaggsStructure
extends ConnectorObject

Title: RelaggsStructure Description: Stores the information about the attributes of an aggregated table.
ChangeLog:

Version:
$Revision: 1.2 $
Author:
Susanne Streuer, FracPete

Field Summary
static java.lang.String KEY_DATE_Y
          Hashtable key for the year-month-day objects.
static java.lang.String KEY_DATE_YM
          Hashtable key for the year-month-day objects.
static java.lang.String KEY_DATE_YMD
          Hashtable key for the year-month-day objects.
static java.lang.String KEY_INT_AVG
          Hashtable key for the average (for Double).
static java.lang.String KEY_INT_CNTALL
          Hashtable key for the number of all records (for Integer).
static java.lang.String KEY_INT_CNTVAL
          Hashtable key for the number of distinct values (for Integer).
static java.lang.String KEY_INT_MAX
          Hashtable key for the maximum (for Integer).
static java.lang.String KEY_INT_MED
          Hashtable key for the median (for Integer).
static java.lang.String KEY_INT_MIN
          Hashtable key for the minimum (for Integer).
static java.lang.String KEY_INT_Q1
          Hashtable key for the 1-quartil (for Integer).
static java.lang.String KEY_INT_Q3
          Hashtable key for the 3-quartil (for Integer).
static java.lang.String KEY_INT_RNG
          Hashtable key for the range (for Integer).
static java.lang.String KEY_INT_STDDEV
          Hashtable key for the standard deviation (for Double).
static java.lang.String KEY_INT_SUM
          Hashtable key for the sum (for Integer).
static java.lang.String KEY_INT_VALUES
          Hashtable key for the values (for Vector).
 
Fields inherited from interface proper.core.ProperInterface
VERSION
 
Constructor Summary
RelaggsStructure(Connector conn)
          Creates a new RelaggsStructure.
 
Method Summary
 void addAttribute(RelaggsAttribute attr)
          Adds an attribute that should be aggregated to the structure.
 void addAttributeValue(RelaggsAttribute attr, java.sql.Date value, int key)
          Adds a date attribute value to the structure.
 void addAttributeValue(RelaggsAttribute attr, int value, int key)
          Adds an integer attribute value to the structure.
 void addAttributeValue(RelaggsAttribute attr, java.lang.String value, int key)
          Adds a string attribute value to the structure.
 void addAttributeValueGroupBy(RelaggsAttribute attr, RelaggsAttribute gb_attr, java.lang.Object gb_value, java.sql.Date value, int key)
          Adds a date attribute value for a condition attribute value to the structure.
 void addAttributeValueGroupBy(RelaggsAttribute attr, RelaggsAttribute gb_attr, java.lang.Object gb_value, java.lang.Object value, java.lang.String value_type, int key)
          Adds an integer attribute value or an aggregated integer value for a condition attribute value to the structure.
 void addAttributeValueGroupBy(RelaggsAttribute attr, RelaggsAttribute gb_attr, java.lang.Object gb_value, java.lang.String value, int key)
          Adds a string attribute value for a condition attribute value to the structure.
 void addRecord()
          Increments the record counter.
 java.lang.String getAlterTableColumns(RelaggsTable source_table)
          Returns the columns part for an ALTER TABLE statement containing the new columns for the aggregated values.
FracPete:
changed sql from type String to StringBuffer for performance reasons introduced a HashSet to identify duplicate columns changed data types to ANSI types: INT, DOUBLE PRECISION
 java.util.HashSet getColumns()
          returns the columns used as basis for creating a new unique one
 java.util.Hashtable getGroupByAttributes()
          Returns a hashtable containing the condition attributes as key.
 java.util.Enumeration getKeyValues()
          Returns an Enumeration containing the key attribute values.
 java.sql.PreparedStatement getUpdateQuery(java.lang.Object key, RelaggsTable source, RelaggsTable dest, Join join)
          Returns an PreparedStatement containing the UPDATE query with the aggregated values for a key value.
 boolean isAggregationValid(RelaggsAttribute attr)
          Returns whether the attribute should be aggregated according to the max_aggr_values parameter.
 boolean isAggregationValid(RelaggsAttribute attr, java.lang.String attr_param)
          Returns whether the attribute should be aggregated according to the max_aggr_values parameter.
 void printReport()
          Prints information about the collected data.
 void processAttributes()
          Calculates the aggregation values median, 1-quart, 3-quart and range for integer attributes.
 
Methods inherited from class proper.database.ConnectorObject
getConnector
 
Methods inherited from class proper.core.ProperObject
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_DATE_YMD

public static final java.lang.String KEY_DATE_YMD
Hashtable key for the year-month-day objects.

See Also:
Constant Field Values

KEY_DATE_YM

public static final java.lang.String KEY_DATE_YM
Hashtable key for the year-month-day objects.

See Also:
Constant Field Values

KEY_DATE_Y

public static final java.lang.String KEY_DATE_Y
Hashtable key for the year-month-day objects.

See Also:
Constant Field Values

KEY_INT_CNTALL

public static final java.lang.String KEY_INT_CNTALL
Hashtable key for the number of all records (for Integer).

See Also:
Constant Field Values

KEY_INT_CNTVAL

public static final java.lang.String KEY_INT_CNTVAL
Hashtable key for the number of distinct values (for Integer).

See Also:
Constant Field Values

KEY_INT_SUM

public static final java.lang.String KEY_INT_SUM
Hashtable key for the sum (for Integer).

See Also:
Constant Field Values

KEY_INT_AVG

public static final java.lang.String KEY_INT_AVG
Hashtable key for the average (for Double).

See Also:
Constant Field Values

KEY_INT_MIN

public static final java.lang.String KEY_INT_MIN
Hashtable key for the minimum (for Integer).

See Also:
Constant Field Values

KEY_INT_MAX

public static final java.lang.String KEY_INT_MAX
Hashtable key for the maximum (for Integer).

See Also:
Constant Field Values

KEY_INT_STDDEV

public static final java.lang.String KEY_INT_STDDEV
Hashtable key for the standard deviation (for Double).

See Also:
Constant Field Values

KEY_INT_Q1

public static final java.lang.String KEY_INT_Q1
Hashtable key for the 1-quartil (for Integer).

See Also:
Constant Field Values

KEY_INT_Q3

public static final java.lang.String KEY_INT_Q3
Hashtable key for the 3-quartil (for Integer).

See Also:
Constant Field Values

KEY_INT_MED

public static final java.lang.String KEY_INT_MED
Hashtable key for the median (for Integer).

See Also:
Constant Field Values

KEY_INT_RNG

public static final java.lang.String KEY_INT_RNG
Hashtable key for the range (for Integer).

See Also:
Constant Field Values

KEY_INT_VALUES

public static final java.lang.String KEY_INT_VALUES
Hashtable key for the values (for Vector).

See Also:
Constant Field Values
Constructor Detail

RelaggsStructure

public RelaggsStructure(Connector conn)
Creates a new RelaggsStructure.

Parameters:
conn - the Connector instance
Method Detail

getColumns

public java.util.HashSet getColumns()
returns the columns used as basis for creating a new unique one


addRecord

public void addRecord()
Increments the record counter.


addAttribute

public void addAttribute(RelaggsAttribute attr)
Adds an attribute that should be aggregated to the structure.

Parameters:
attr - the attribute that should be added

addAttributeValue

public void addAttributeValue(RelaggsAttribute attr,
                              int value,
                              int key)
Adds an integer attribute value to the structure.

Parameters:
attr - the integer attribute
value - the integer value
key - the integer aggregation key

addAttributeValue

public void addAttributeValue(RelaggsAttribute attr,
                              java.sql.Date value,
                              int key)
Adds a date attribute value to the structure.

Parameters:
attr - the date attribute
value - the date value
key - the integer aggregation key

addAttributeValueGroupBy

public void addAttributeValueGroupBy(RelaggsAttribute attr,
                                     RelaggsAttribute gb_attr,
                                     java.lang.Object gb_value,
                                     java.sql.Date value,
                                     int key)
Adds a date attribute value for a condition attribute value to the structure.

Parameters:
attr - the date attribute
gb_attr - the condition attribute
gb_value - the condition attribute value
value - the date attribute value
key - the integer aggregation key

addAttributeValueGroupBy

public void addAttributeValueGroupBy(RelaggsAttribute attr,
                                     RelaggsAttribute gb_attr,
                                     java.lang.Object gb_value,
                                     java.lang.Object value,
                                     java.lang.String value_type,
                                     int key)
Adds an integer attribute value or an aggregated integer value for a condition attribute value to the structure.

Parameters:
attr - the integer attribute
gb_attr - the condition attribute
gb_value - the condition attribute value
value - the integer value or the aggregated value (type Integer or Double)
value_type - the type of the inserted value: - KEY_INT_VALUES for a single integer value - KEY_INT_[Aggr.-function] for an aggregated value
key - the integer aggregation key

addAttributeValue

public void addAttributeValue(RelaggsAttribute attr,
                              java.lang.String value,
                              int key)
Adds a string attribute value to the structure.

Parameters:
attr - the string attribute
value - the string attribute value
key - the integer aggregation key

addAttributeValueGroupBy

public void addAttributeValueGroupBy(RelaggsAttribute attr,
                                     RelaggsAttribute gb_attr,
                                     java.lang.Object gb_value,
                                     java.lang.String value,
                                     int key)
Adds a string attribute value for a condition attribute value to the structure.

Parameters:
attr - the string attribute
gb_attr - the condition attribute
gb_value - the condition attribute value
value - the string attribute value
key - the integer aggregation key

processAttributes

public void processAttributes()
Calculates the aggregation values median, 1-quart, 3-quart and range for integer attributes. Processes the one argument and the two argument aggregation values.


printReport

public void printReport()
Prints information about the collected data. For test purpose.


getGroupByAttributes

public java.util.Hashtable getGroupByAttributes()
Returns a hashtable containing the condition attributes as key. For Date attributes object is Vector with String - Keys for format type.


getAlterTableColumns

public java.lang.String getAlterTableColumns(RelaggsTable source_table)
Returns the columns part for an ALTER TABLE statement containing the new columns for the aggregated values.
FracPete:

Parameters:
source_table - the attribute table that contained the original data for the aggregation

isAggregationValid

public boolean isAggregationValid(RelaggsAttribute attr,
                                  java.lang.String attr_param)
Returns whether the attribute should be aggregated according to the max_aggr_values parameter.

Parameters:
attr - the attribute to check
attr_param - only for date attributes: the type of the date attribute (KEY_DATE_*)

isAggregationValid

public boolean isAggregationValid(RelaggsAttribute attr)
Returns whether the attribute should be aggregated according to the max_aggr_values parameter. For date attributes returns true if one of the format types is valid for aggregation.

Parameters:
attr - the attribute to check

getKeyValues

public java.util.Enumeration getKeyValues()
Returns an Enumeration containing the key attribute values.


getUpdateQuery

public java.sql.PreparedStatement getUpdateQuery(java.lang.Object key,
                                                 RelaggsTable source,
                                                 RelaggsTable dest,
                                                 Join join)
                                          throws java.sql.SQLException
Returns an PreparedStatement containing the UPDATE query with the aggregated values for a key value.

Parameters:
key - the key attribute value
source - the attribute table that contained the original data for the aggregation
dest - the result table that will contain the aggregated data
join - the foreign key relation
Throws:
java.sql.SQLException