ajax.catalog
Class Table

java.lang.Object
  |
  +--ajax.catalog.Table
All Implemented Interfaces:
CatalogObject

public class Table
extends java.lang.Object
implements CatalogObject


Constructor Summary
Table(java.lang.String tableName, java.util.LinkedList tableFields, java.util.LinkedList keyFields)
          Constructor of a table representing a base data flow supplied by the user.
Table(java.lang.String name, java.util.List schema, java.util.List key, Output output, Transformation transf)
          Constructor for a table that is the result of a outer join.
Table(java.lang.String name, Output output, Transformation transf)
          Constructor for a table that is the result of a transformation.
 
Method Summary
 java.lang.String[][] DepConstraintToSQL()
          Generates SQL code to execute the DEP constraint
 java.util.Iterator getExplainingAttributes()
          Returns an Iterator through a list containg all the FieldType objects which correspond to the explaining attributes from this table
 java.util.Iterator getExplainingAttributes(java.lang.String tableName)
          Returns an Iterator through a list containg those FieldType objects which correspond to the explaining attributes from this table which go back to the table given as parameter into String tableName argument
 java.util.Iterator getExplainingTables()
          Returns an Iterator through the list of the table names that could explain this table
 java.util.Iterator getFields()
          Returns an Iterator through all the fields that compose the schema of this table.
 java.util.Iterator getFields(java.lang.String name)
          Returns an enumeration of all the fields that compose the schema of this table.
 FieldType getFieldType(java.lang.String fieldName, java.lang.String tableName)
          Given a field name, looks for the desired field and returns its type.
 int getIndexAttribute(java.lang.String tableName, java.lang.String attribute)
          Gets the index of an attribute Indexes start at 1
 java.util.List getKey()
          Returns the list of key attributes of this table.
 java.util.List getKey(java.lang.String name)
          Returns the list of key attributes if the table´s name is equal to the specified name.
 java.util.Iterator getKeys()
          Returns an Iterator through the list of key attributes of this table.
 java.lang.String getName()
          Returns the name of this table.
 int getNbDepConstraints()
          Returns the number of Dep constraints
 boolean hasExplainingTables()
          Returns true if this table can be explained by going back to other tables.
 boolean hasKey(java.lang.String keyName)
          Returns true if it is the name of a key attribute of this table
 boolean isToMaterialize()
          Says if this table is the result of an output of a transformation or corresponds to a table defined by the user and supplied as input of the cleaning program. returns true in the first case and false in the second case.
 boolean isTransformation()
          Returns false, since this catalog object is not a transformation.
 Output output()
          returns the Output object associated to this table.
 void setWeaveRunTimePolicy(java.io.BufferedWriter bfw)
          Generates and writes the specification runtime policy, needed by Weave to implement the Explainer, for this table.
 void setWeaveSchema(java.io.BufferedWriter bfw)
          Generates and writes the specification schema, needed by Weave to implement the Explainer, for this table.
 java.lang.String toFile()
          Generates code for materializing the result of a transformation in a file.
 java.lang.String toString()
          Converts the table into a human read-able object.
 java.lang.String toTable()
          toTable() Generates code to create a table in SQL that materializes the result of the transformation
 void toXML(java.lang.String XMLfileName)
          Converts this CatalogObject into an XML document
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

public Table(java.lang.String name,
             Output output,
             Transformation transf)
Constructor for a table that is the result of a transformation.

Table

public Table(java.lang.String name,
             java.util.List schema,
             java.util.List key,
             Output output,
             Transformation transf)
Constructor for a table that is the result of a outer join. This table corresponds to an implicit output of the transformation.
Parameters:
name - is the name of the table to materialize
schema - is the schema of this table (a list of FieldType objects).
key - is the key of this table (a list of FieldType objects).
transf - is the transformation which will fill out this table

Table

public Table(java.lang.String tableName,
             java.util.LinkedList tableFields,
             java.util.LinkedList keyFields)
      throws CatalogException
Constructor of a table representing a base data flow supplied by the user. In this case there is not a transformation associated to the table. A CatalogException is thrown if a field belonging to the key of this table is not present in the schema of the table.
Parameters:
tableName - is the name of the table.
tableFields - is a list of FieldTypes objects that define the table´s schema.
keyFields - is a list containing the names of the key fileds of this table.
Method Detail

isToMaterialize

public final boolean isToMaterialize()
Says if this table is the result of an output of a transformation or corresponds to a table defined by the user and supplied as input of the cleaning program. returns true in the first case and false in the second case.

output

public final Output output()
returns the Output object associated to this table.

isTransformation

public final boolean isTransformation()
Returns false, since this catalog object is not a transformation. The tables corresponding to base data flows are also stored in the catalog.
Specified by:
isTransformation in interface CatalogObject
See Also:
ajax.catalog.CatalogObject

getFieldType

public FieldType getFieldType(java.lang.String fieldName,
                              java.lang.String tableName)
                       throws CatalogException
Given a field name, looks for the desired field and returns its type. The argument tableName is always the name of the table
Specified by:
getFieldType in interface CatalogObject

getFields

public java.util.Iterator getFields(java.lang.String name)
                             throws CatalogException
Returns an enumeration of all the fields that compose the schema of this table. Each field is represented by a Fieldtype object.
Specified by:
getFields in interface CatalogObject

getFields

public java.util.Iterator getFields()
                             throws CatalogException
Returns an Iterator through all the fields that compose the schema of this table. Each field is represented by a Fieldtype object.
Returns:
the Iterator

getIndexAttribute

public int getIndexAttribute(java.lang.String tableName,
                             java.lang.String attribute)
                      throws CatalogException
Gets the index of an attribute Indexes start at 1
Specified by:
getIndexAttribute in interface CatalogObject

toXML

public void toXML(java.lang.String XMLfileName)
Converts this CatalogObject into an XML document
Specified by:
toXML in interface CatalogObject

getName

public java.lang.String getName()
Returns the name of this table. The name may corresponds to an output of a transformation or to the name of a table in the case of a base data flow.
Specified by:
getName in interface CatalogObject

getNbDepConstraints

public int getNbDepConstraints()
Returns the number of Dep constraints

DepConstraintToSQL

public java.lang.String[][] DepConstraintToSQL()
                                        throws CatalogException,
                                               AjaxTypeException
Generates SQL code to execute the DEP constraint

toTable

public java.lang.String toTable()
                         throws ajax.catalog.TransfException
toTable() Generates code to create a table in SQL that materializes the result of the transformation

toFile

public java.lang.String toFile()
Generates code for materializing the result of a transformation in a file. In fact we create the file header with the names of the attributes MISSING TEST CONSTRAINTS: primary key, not null, unique, check, foreign key

getKey

public java.util.List getKey()
Returns the list of key attributes of this table.

getKey

public java.util.List getKey(java.lang.String name)
                      throws CatalogException
Returns the list of key attributes if the table´s name is equal to the specified name. Otherwise it throws a catalog exception.
Specified by:
getKey in interface CatalogObject
See Also:
CatalogObject

getExplainingTables

public java.util.Iterator getExplainingTables()
                                       throws CatalogException
Returns an Iterator through the list of the table names that could explain this table
Returns:
an Iterator through a String table names list

hasExplainingTables

public boolean hasExplainingTables()
                            throws CatalogException
Returns true if this table can be explained by going back to other tables. To put in other words, this method returns true if this table is generated as a result of an Ajax transformation.
Returns:
boolean value

getExplainingAttributes

public java.util.Iterator getExplainingAttributes(java.lang.String tableName)
                                           throws CatalogException
Returns an Iterator through a list containg those FieldType objects which correspond to the explaining attributes from this table which go back to the table given as parameter into String tableName argument
Parameters:
tableName - the name of the desired explaining table
Returns:
an Iterator through a list of FieldType objects

getExplainingAttributes

public java.util.Iterator getExplainingAttributes()
                                           throws CatalogException
Returns an Iterator through a list containg all the FieldType objects which correspond to the explaining attributes from this table
Returns:
an Iterator through a list of FieldType objects

getKeys

public java.util.Iterator getKeys()
Returns an Iterator through the list of key attributes of this table. Each key is represented by a FieldType object

hasKey

public boolean hasKey(java.lang.String keyName)
Returns true if it is the name of a key attribute of this table
Parameters:
keyName - the attribute's name

toString

public java.lang.String toString()
Converts the table into a human read-able object.
Overrides:
toString in class java.lang.Object

setWeaveSchema

public void setWeaveSchema(java.io.BufferedWriter bfw)
                    throws CatalogException,
                           java.io.IOException
Generates and writes the specification schema, needed by Weave to implement the Explainer, for this table. This code will be part of the Weave's schemas file .sch
Parameters:
bfw - a BufferedWriter object where to write the generated sch code

setWeaveRunTimePolicy

public void setWeaveRunTimePolicy(java.io.BufferedWriter bfw)
                           throws CatalogException,
                                  java.io.IOException
Generates and writes the specification runtime policy, needed by Weave to implement the Explainer, for this table. This code will be part of the Weave's runtime policy file .rtp
Parameters:
bfw - a BufferedWriter object where to write the generated rtp code