com.ibm.dse.tools.workbench.base
Interface Table

All Known Implementing Classes:
AbstractTable

public interface Table

This interface defines the behavior of any repository table object


Method Summary
 void add(TableRow row)
          This method adds a row to the list of rows.
 boolean areTriggersActive()
          This method returns the triggers state
 void cleanRollbackData()
          This method cleans the lists of inserted, modified and deleted rows, and marks them as commited.
 int count(Clause where)
          This method counts the rows that accomplish the conditions in the where clause
 void createRelations()
          This method creates the relationships for a table
 TableRow createTableRow()
          This method creates a new TableRow object for this table.
 TableRow createTableRow(boolean isNew, java.lang.String[] values)
          This method creates a TableRow object for this table with a list of values for the columns.
 void exportToFile(java.io.Writer w)
          This method sends the table data to a file writer.
 void flush()
          This method persists the modifications, creations or deletions of rows in this table
 java.lang.String getAlias()
          This method returns the table alias.
 CheckConstraint[] getChecks()
          Returns the list of check constraints for this table
 CheckConstraint[] getChecks(int column)
          Returns the list of check constraints for a column in this table
 int[] getColumnLengths()
          Returns the list of column lengths.
 java.lang.String[] getColumns()
          Returns the list of column names for this table
 java.lang.String getColumnsString(int[] columnsList, java.lang.String separator)
          This method constructs a String with column names to use in clauses like select, order by, insert, ...
 java.lang.String getColumnsString(java.lang.String separator)
          This method constructs a String with all column names to use in clauses like select...
 java.lang.String[] getCreateChecksStrings()
          This method returns the list of sentences to create the check constraints for the table.
 java.lang.String[] getCreateFksStrings()
          This method returns the list of sentences to create the foreign keys for the table.
 java.lang.String[] getCreateIndexesStrings()
          This method returns the list of sentences to create the indexes for the table.
 java.lang.String getCreatePkString()
          This method returns the sentence to create the primary key for the table.
 java.lang.String getCreateTableString()
          This method returns the sentence to create the table.
 java.util.Hashtable getFks()
          Returns the list of foreign keys that this table has with other tables
 Index[] getIndexes()
          Returns the list of indexes.
 java.lang.String getName()
          Returns the name of the table
 int[] getPk()
          Returns the list of column identifiers that are part of the primary key of this table
 java.lang.String getPkValue(TableRow row)
          Returns the Values in the primary key of a row in a String with separators
 TableRow[] getRelated(int relation, java.lang.String[] values, Clause where, int[] orderBy)
          Returns the rows of another table based on a relationship
 Relationship[] getRelations()
          Returns the list of relationships that this table has with other tables
 Repository getRepository()
          Returns repository in wich this table is created
 java.lang.String getTimestamp()
          Returns a unique value for generation of unique identifiers (primary keys) purpose
 java.lang.String getUniqueValue()
          Returns a unique value for generation of unique identifiers (primary keys) purpose
 boolean hasSelfGeneratedPk()
          This method indicates if the field in the primary key must be generated automatically
 void importFromString(java.lang.String s)
          This method inserts data into the table from a String that can be read from a stream
 boolean isInPk(int column)
          Checks if a column is part of the primary key
 boolean isRequired(int column)
          Checks if a column in the table is mandatory
 void postDelete(TableRow row)
          This method is called after a row is deleted
 void postInsert(TableRow row)
          This method is called after a row is inserted
 void postUpdate(TableRow row)
          This method is called after a row is updated
 void preDelete(TableRow row)
          This method is called before deleting a row
 void preInsert(TableRow row)
          This method is called before inserting a row
 void preUpdate(TableRow row)
          This method is called before modifying a row
 void registerDeletedRow(TableRow row)
          This method adds a row to the list of deleted rows
 void registerInsertedRow(TableRow row)
          This method adds a row to the list of inserted rows
 void registerModifiedRow(TableRow row)
          This method adds a row to the list of modified rows
 void removeFromList(TableRow row)
          This method removes a row from the list of rows
 void restoreRows()
          This method restores the mapped rows when doing a rollback
 TableRow[] retrieveAll(Clause where, int[] orderBy)
          Returns all the rows that accomplish the conditions in a where clause
 TableRow retrieveByPk(java.lang.String[] values)
          Returns the row corresponding to the values of the primary key
 java.lang.String[] retrieveDistinct(int column, Clause where)
          This method retrieve the distinct values in a column in the rows that accomplish the conditions in a where clause
 void setRepository(Repository repository)
          Sets the repository where this table is located
 void setTriggersState(boolean active)
          This method sets the triggers state
 java.lang.String[] validate(TableRow row)
          This method must validate the correctness of a row based on the rules of each object
 

Method Detail

add

public void add(TableRow row)
This method adds a row to the list of rows.
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow

areTriggersActive

public boolean areTriggersActive()
This method returns the triggers state
Returns:
boolean

cleanRollbackData

public void cleanRollbackData()
This method cleans the lists of inserted, modified and deleted rows, and marks them as commited.

count

public int count(Clause where)
          throws RepositoryException
This method counts the rows that accomplish the conditions in the where clause
Parameters:
where - com.ibm.dse.tools.workbench.base.Clause The where clause to apply
Returns:
int The number of conditions
Throws:
com.ibm.dse.workbench.base.RepositoryException - An error occurred when trying to do the query.

createRelations

public void createRelations()
                     throws WBInvalidArgumentException
This method creates the relationships for a table
Throws:
WBInvalidArgumentException - There is an error creating relationships.

createTableRow

public TableRow createTableRow()
                        throws WorkbenchException
This method creates a new TableRow object for this table.
Returns:
com.ibm.dse.tools.workbench.base.TableRow
Throws:
WorkbenchException -  

createTableRow

public TableRow createTableRow(boolean isNew,
                               java.lang.String[] values)
                        throws WorkbenchException
This method creates a TableRow object for this table with a list of values for the columns.

It can be new or retrieved

Parameters:
isNew - boolean
values - java.lang.String[]
Returns:
com.ibm.dse.tools.workbench.base.TableRow
Throws:
WorkbenchException -  

exportToFile

public void exportToFile(java.io.Writer w)
                  throws WorkbenchException,
                         java.io.IOException
This method sends the table data to a file writer.
Parameters:
w - java.io.Writer
Throws:
WorkbenchException -  
java.io.IOException -  

flush

public void flush()
           throws RepositoryException
This method persists the modifications, creations or deletions of rows in this table
Throws:
RepositoryException - An error ocurred saving the changes.

getAlias

public java.lang.String getAlias()
This method returns the table alias.
Returns:
java.lang.String

getChecks

public CheckConstraint[] getChecks()
Returns the list of check constraints for this table
Returns:
com.ibm.dse.tools.workbench.base.CheckConstraint[]

getChecks

public CheckConstraint[] getChecks(int column)
Returns the list of check constraints for a column in this table
Returns:
com.ibm.dse.tools.workbench.base.CheckConstraint[]

getColumnLengths

public int[] getColumnLengths()
Returns the list of column lengths.
Returns:
int[]

getColumns

public java.lang.String[] getColumns()
Returns the list of column names for this table
Returns:
java.lang.String[]

getColumnsString

public java.lang.String getColumnsString(int[] columnsList,
                                         java.lang.String separator)
This method constructs a String with column names to use in clauses like select, order by, insert, ...
Parameters:
columns - int[] The list of column identifiers to concat
separator - java.lang.String The separator between column names
Returns:
java.lang.String

getColumnsString

public java.lang.String getColumnsString(java.lang.String separator)
This method constructs a String with all column names to use in clauses like select...
Parameters:
separator - java.lang.String The separator between column names
Returns:
java.lang.String

getCreateChecksStrings

public java.lang.String[] getCreateChecksStrings()
This method returns the list of sentences to create the check constraints for the table.
Returns:
java.lang.String[]

getCreateFksStrings

public java.lang.String[] getCreateFksStrings()
This method returns the list of sentences to create the foreign keys for the table.
Returns:
java.lang.String[]

getCreateIndexesStrings

public java.lang.String[] getCreateIndexesStrings()
This method returns the list of sentences to create the indexes for the table.
Returns:
java.lang.String[]

getCreatePkString

public java.lang.String getCreatePkString()
This method returns the sentence to create the primary key for the table.
Returns:
java.lang.String

getCreateTableString

public java.lang.String getCreateTableString()
This method returns the sentence to create the table.
Returns:
java.lang.String

getFks

public java.util.Hashtable getFks()
Returns the list of foreign keys that this table has with other tables
Returns:
java.util.Hashtable

getIndexes

public Index[] getIndexes()
Returns the list of indexes.
Returns:
com.ibm.dse.tools.workbench.base.Index[]

getName

public java.lang.String getName()
Returns the name of the table
Returns:
java.lang.String

getPk

public int[] getPk()
Returns the list of column identifiers that are part of the primary key of this table
Returns:
int[]

getPkValue

public java.lang.String getPkValue(TableRow row)
Returns the Values in the primary key of a row in a String with separators
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Returns:
java.lang.String

getRelated

public TableRow[] getRelated(int relation,
                             java.lang.String[] values,
                             Clause where,
                             int[] orderBy)
                      throws WorkbenchException
Returns the rows of another table based on a relationship
Parameters:
relation - int The relationship identifier
values - java.lang.String[] The list of values to apply to the columns of the relationship
where - com.ibm.dse.tools.workbench.base.Clause The where clause to add to the conditions of relationship
orderBy - int[] The list of columns used to order the results
Returns:
com.ibm.dse.tools.workbench.base.TableRow[]
Throws:
WorkbenchException - An error ocurred doing the query.

getRelations

public Relationship[] getRelations()
Returns the list of relationships that this table has with other tables
Returns:
RelationShip[]

getRepository

public Repository getRepository()
Returns repository in wich this table is created
Returns:
com.ibm.dse.tools.workbench.base.Repository The repository of this table

getTimestamp

public java.lang.String getTimestamp()
Returns a unique value for generation of unique identifiers (primary keys) purpose
Returns:
java.lang.String

getUniqueValue

public java.lang.String getUniqueValue()
Returns a unique value for generation of unique identifiers (primary keys) purpose
Returns:
java.lang.String The unique value generated

hasSelfGeneratedPk

public boolean hasSelfGeneratedPk()
This method indicates if the field in the primary key must be generated automatically
Returns:
boolean

importFromString

public void importFromString(java.lang.String s)
                      throws WorkbenchException
This method inserts data into the table from a String that can be read from a stream
Parameters:
s - java.lang.String
Throws:
WorkbenchException -  

isInPk

public boolean isInPk(int column)
Checks if a column is part of the primary key
Parameters:
column - int The column to check
Returns:
boolean

isRequired

public boolean isRequired(int column)
Checks if a column in the table is mandatory
Parameters:
column - int The identifier of the column to check
Returns:
boolean True if column is mandatory

postDelete

public void postDelete(TableRow row)
                throws RepositoryException
This method is called after a row is deleted
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Throws:
RepositoryException -  

postInsert

public void postInsert(TableRow row)
                throws RepositoryException
This method is called after a row is inserted
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Throws:
RepositoryException -  

postUpdate

public void postUpdate(TableRow row)
                throws RepositoryException
This method is called after a row is updated
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Throws:
RepositoryException -  

preDelete

public void preDelete(TableRow row)
               throws RepositoryException
This method is called before deleting a row
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Throws:
RepositoryException -  

preInsert

public void preInsert(TableRow row)
               throws RepositoryException
This method is called before inserting a row
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Throws:
RepositoryException -  

preUpdate

public void preUpdate(TableRow row)
               throws RepositoryException
This method is called before modifying a row
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Throws:
RepositoryException -  

registerDeletedRow

public void registerDeletedRow(TableRow row)
This method adds a row to the list of deleted rows
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow

registerInsertedRow

public void registerInsertedRow(TableRow row)
This method adds a row to the list of inserted rows
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow

registerModifiedRow

public void registerModifiedRow(TableRow row)
This method adds a row to the list of modified rows
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow

removeFromList

public void removeFromList(TableRow row)
This method removes a row from the list of rows

(does not deletes the row from the repository)

Parameters:
com.ibm.dse.tools.workbench.base.TableRow - The row to be removed

restoreRows

public void restoreRows()
This method restores the mapped rows when doing a rollback

retrieveAll

public TableRow[] retrieveAll(Clause where,
                              int[] orderBy)
                       throws WorkbenchException
Returns all the rows that accomplish the conditions in a where clause
Parameters:
where - com.ibm.dse.tools.workbench.base.Clause The where clause to accomplish
orderBy - int[] The list of column identifiers used to order the results
Returns:
com.ibm.dse.tools.workbench.base.TableRow[] The list of rows retrieved
Throws:
WorkbenchException - An error ocurred doing the query.

retrieveByPk

public TableRow retrieveByPk(java.lang.String[] values)
                      throws WorkbenchException
Returns the row corresponding to the values of the primary key

The rows retrieved are added to the list, for cache purpose

Parameters:
values - String[] The values of the primary key components
Returns:
com.ibm.dse.tools.workbench.base.TableRow The row retrieved
Throws:
WorkbenchException - An error ocurred doing the query.

retrieveDistinct

public java.lang.String[] retrieveDistinct(int column,
                                           Clause where)
                                    throws WorkbenchException
This method retrieve the distinct values in a column in the rows that accomplish the conditions in a where clause
Parameters:
column - int
where - com.ibm.dse.tools.workbench.base.Clause
Returns:
java.lang.String[]
Throws:
WorkbenchException -  

setRepository

public void setRepository(Repository repository)
Sets the repository where this table is located
Parameters:
repository - com.ibm.dse.tools.workbench.base.Repository The repository to set

setTriggersState

public void setTriggersState(boolean active)
This method sets the triggers state
Parameters:
active - boolean

validate

public java.lang.String[] validate(TableRow row)
This method must validate the correctness of a row based on the rules of each object

It returns the list of error strings or null if there are no errors

Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow the row to validate
Returns:
java.lang.String[]