com.ibm.dse.tools.workbench.base
Class DefaultTableRow

java.lang.Object
  |
  +--com.ibm.dse.tools.workbench.base.DefaultTableRow

public class DefaultTableRow
extends java.lang.Object
implements TableRow, java.io.Serializable

This class implements a generic repository table row

See Also:
Serialized Form

Field Summary
protected  java.lang.String[] commitedVal
          The columns values of this row after last commit or rollback
protected  boolean deleted
          Flag of row deleted
protected  java.lang.String[] errorList
          List of errors for this row
protected  boolean inError
          Flag of row with validation errors
protected  java.lang.String[] lastValues
          The columns values of this row
protected  boolean modified
          Flag of row modified but changes not persisted
protected  boolean newRow
          Flag of row created but not persisted
protected  int referencesCount
          The number of registered uses of this row
protected  Table table
          The table containing this row
protected  java.lang.String[] values
          The columns values of this row
 
Constructor Summary
DefaultTableRow(Table table)
          This constructor creates a DefaultTableRow object for a table
DefaultTableRow(Table table, boolean isNew, java.lang.String[] values)
          This constructor creates a DefaultTableRow object for a table
 
Method Summary
 void copyCascade(Repository paramRepository, boolean exactGroup)
          This method copies a row from a repository to another.
 void copyCascadeForImporting(Repository paramRepository, boolean exactGroup)
          This method copies a row from a repository to another.
 void copyParentGroupsTree(Repository destinationRep, boolean exactGroup)
          Copies all the parent groups tree (the groups containing the row) of a row to a destination repository
 TableRow copyTo(Repository paramRepository)
          This method copies a row from a repository to another.
 TableRow createOpenEdition()
          This method creates an Open Edition of a row.
 void delete()
          This method deletes this row
 void deleteCascade()
          Deletes a row and all its related rows from the repository
 void deregisterRefence()
          This method discounts a use reference.
 TableRow duplicate()
          This method creates a new row with the same values as the actual row
 void flush()
          Flushes all changes made in the row to the database
 TableRow getContainerGroup()
          Returns the row representing the group that contains this object
 TableRow getDestinationRowByName(Workspace destRepository)
          This method returns the row with the same name as the actual from a Workspace.
 int getDestinationRowStatus(Workspace destRepository)
          This method checks for the existence of any version of this row in a Workspace
 java.lang.String[] getErrorList()
          Returns the list of error messages for a row after validate has been called.
 java.lang.String getLastCommitedValueAt(int column)
          Returns the value contained in a column of this row
 java.lang.String getLastValueAt(int column)
          Returns the value contained in a column of this row
 java.lang.String getNextVersion(Repository repository)
          Proposes a new version code based on the last version code of the object stored in the repository
 TableRow[] getRelated(int relation, Clause where, int[] orderBy)
          Returns the rows of another table based on a relationship and the values of this row
 Table getTable()
          Returns the table of the row
 java.lang.String getValueAt(int column)
          Returns the value contained in a column of this row
 void importToWorkspace(Workspace ws)
          This method copies a row from a repository to a workspace
protected  void insert()
          This method inserts the current row in a database
 boolean isDeleted()
          Indicates if row has been deleted from the database
 boolean isInError()
          Indicates if last validation has caused errors
 boolean isModified()
          Indicates if the row has been changed since last flush
 boolean isNew()
          Returns the insertion status of this row (true if it has not been inserted yet)
 boolean isVersioned()
          Indicates if this row is versioned or an open edition
 void markCommited()
          This method marks the row stated as committed
 void registerReference()
          This method increments the count of use references.
 void restoreInserted()
          This method restores the status of an inserted row since the last commit or rollback
 void restoreModified()
          This method restores the status of a modified or deleted row since the last commit or rollback
 void setContainerGroup(java.lang.String grpCode)
          This method sets the Container group of a row
 void setOtherVersionsInactive()
          This method searches for other editions of the row in the Repository where it is stored and marks them as inactive
 void setTable(Table table)
          Sets the table of the row
 void setValueAt(int column, java.lang.String value)
          Sets the value in a column of this row
 void setValues(java.lang.String[] values)
          Sets the values of all columns of this row
protected  void storeRollbackData()
          This method stores the actual values for a possible rollback
 java.lang.String toString()
          Returns a string representation of this row
protected  void update()
          This method updates the current row to the database
 java.lang.String[] validate()
          Evaluates and returns the list of validation error messages for this row and marks it as inError if there are errors
 TableRow version(java.lang.String newVersion, Repository repository)
          Versions this row, copying it to a repository, based on the version process for its table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

referencesCount

protected int referencesCount
The number of registered uses of this row

values

protected java.lang.String[] values
The columns values of this row

lastValues

protected java.lang.String[] lastValues
The columns values of this row

commitedVal

protected java.lang.String[] commitedVal
The columns values of this row after last commit or rollback

table

protected Table table
The table containing this row

newRow

protected boolean newRow
Flag of row created but not persisted

modified

protected boolean modified
Flag of row modified but changes not persisted

deleted

protected boolean deleted
Flag of row deleted

inError

protected boolean inError
Flag of row with validation errors

errorList

protected java.lang.String[] errorList
List of errors for this row
Constructor Detail

DefaultTableRow

public DefaultTableRow(Table table)
                throws WorkbenchException
This constructor creates a DefaultTableRow object for a table
Parameters:
table - com.ibm.dse.tools.workbench.base.Table The table on wich create the row
Throws:
WorkbenchException - When the table can not be created

DefaultTableRow

public DefaultTableRow(Table table,
                       boolean isNew,
                       java.lang.String[] values)
                throws WorkbenchException
This constructor creates a DefaultTableRow object for a table
Parameters:
table - com.ibm.dse.tools.workbench.base.Table The table on wich create the row
isNew - boolean indicates whether the row is new or not
values - java.lang.String[] the row values
Throws:
WorkbenchException - the table row can not be created
Method Detail

copyCascade

public void copyCascade(Repository paramRepository,
                        boolean exactGroup)
                 throws WorkbenchException
This method copies a row from a repository to another.

It also copies all the needed data such as parent rows, related rows and container group.

Specified by:
copyCascade in interface TableRow
Parameters:
paramRepository - com.ibm.dse.tools.workbench.base.Repository The repository to where copy the row
exactGroup - boolean Indicator of whether the row has to be attached to the container group by CODE (true) or by NAME (false)
Throws:
WorkbenchException - an error ocurred while copying the row

copyCascadeForImporting

public void copyCascadeForImporting(Repository paramRepository,
                                    boolean exactGroup)
                             throws WorkbenchException
This method copies a row from a repository to another.

It also copies all the needed data such as parent rows, related rows and container group.

Specified by:
copyCascadeForImporting in interface TableRow
Parameters:
paramRepository - com.ibm.dse.tools.workbench.base.Repository The repository to where copy the row
exactGroup - boolean Indicator of whether the row has to be attached to the container group by CODE (true) or by NAME (false)
Throws:
WorkbenchException - an error ocurred while copying the row

copyParentGroupsTree

public void copyParentGroupsTree(Repository destinationRep,
                                 boolean exactGroup)
                          throws WorkbenchException
Copies all the parent groups tree (the groups containing the row) of a row to a destination repository
Specified by:
copyParentGroupsTree in interface TableRow
Parameters:
destinationRep - com.ibm.dse.tools.workbench.base.Repository The destination repository
exactGroup - boolean Indicator of whether the row has to be attached to the container group by CODE (true) or by NAME (false)
Throws:
WorkbenchException -  

copyTo

public TableRow copyTo(Repository paramRepository)
                throws WorkbenchException
This method copies a row from a repository to another.
Specified by:
copyTo in interface TableRow
Parameters:
paramRepository - com.ibm.dse.tools.workbench.base.Repository The repository to where copy the row
Returns:
com.ibm.dse.tools.workbench.base.TableRow The copy of the row in the destination repository
Throws:
WorkbenchException - When the row can not be copied

createOpenEdition

public TableRow createOpenEdition()
                           throws WorkbenchException
This method creates an Open Edition of a row.

It duplicates the row and makes all its childs to point to this new version.

Specified by:
createOpenEdition in interface TableRow
Returns:
com.ibm.dse.tools.workbench.base.TableRow The open edition
Throws:
WorkbenchException -  

delete

public void delete()
            throws RepositoryException
This method deletes this row
Specified by:
delete in interface TableRow
Throws:
RepositoryException -  

deleteCascade

public void deleteCascade()
                   throws WorkbenchException
Deletes a row and all its related rows from the repository
Specified by:
deleteCascade in interface TableRow
Throws:
WorkbenchException -  

deregisterRefence

public void deregisterRefence()
This method discounts a use reference.

If there is no more uses, the row must be removed from the list in table

Specified by:
deregisterRefence in interface TableRow

duplicate

public TableRow duplicate()
                   throws WorkbenchException
This method creates a new row with the same values as the actual row
Specified by:
duplicate in interface TableRow
Returns:
com.ibm.dse.tools.workbench.base.TableRow
Throws:
WorkbenchException -  

flush

public void flush()
           throws RepositoryException
Flushes all changes made in the row to the database
Specified by:
flush in interface TableRow
Throws:
RepositoryException -  

getContainerGroup

public TableRow getContainerGroup()
                           throws WorkbenchException
Returns the row representing the group that contains this object
Specified by:
getContainerGroup in interface TableRow
Returns:
com.ibm.dse.tools.workbench.base.TableRow The row representing the container group
Throws:
WorkbenchException -  

getDestinationRowByName

public TableRow getDestinationRowByName(Workspace destRepository)
                                 throws WorkbenchException
This method returns the row with the same name as the actual from a Workspace.
The row must be owned by a table implementing the Versionable interface, otherwise a RpNonVersionableTableException will be thrown


The table owning the row must be in a Workspace, this way is garanteed that only one row will be returned, because only a unique edition of a versionable object can exist in a Workspace.
Specified by:
getDestinationRowByName in interface TableRow
Parameters:
destRepository - com.ibm.dse.tools.workbench.base.Workspace
Returns:
com.ibm.dse.tools.workbench.base.TableRow
Throws:
WorkbenchException -  

getDestinationRowStatus

public int getDestinationRowStatus(Workspace destRepository)
                            throws WorkbenchException
This method checks for the existence of any version of this row in a Workspace
Specified by:
getDestinationRowStatus in interface TableRow
Parameters:
destRepository - com.ibm.dse.tools.workbench.base.Workspace
Returns:
int

It retuns a number between 0 and 3: 0: the row doesn´t exist in the destination repository 1: the row exists in the destination repository with a different edition and it is an open edition 2: the row exists in the destination repository with a different edition and it is version 3: the row exists in the destination repository with the same version

Throws:
WorkbenchException -  

getErrorList

public java.lang.String[] getErrorList()
Returns the list of error messages for a row after validate has been called.
Specified by:
getErrorList in interface TableRow
Returns:
java.lang.String[]

getLastCommitedValueAt

public java.lang.String getLastCommitedValueAt(int column)
Returns the value contained in a column of this row
Specified by:
getLastCommitedValueAt in interface TableRow
Parameters:
column - int The identifier of the column to evaluate
Returns:
java.lang.String

getLastValueAt

public java.lang.String getLastValueAt(int column)
Returns the value contained in a column of this row
Specified by:
getLastValueAt in interface TableRow
Parameters:
column - int The identifier of the column to evaluate
Returns:
java.lang.String

getNextVersion

public java.lang.String getNextVersion(Repository repository)
                                throws RpNonVersionableTableException,
                                       WorkbenchException
Proposes a new version code based on the last version code of the object stored in the repository
Specified by:
getNextVersion in interface TableRow
Parameters:
repository - com.ibm.dse.tools.workbench.base.Repository The repository
Returns:
java.lang.String The version code
Throws:
RpNonVersionableTableException - The row which version code is been asked isn't owned by a Versionable table
WorkbenchException -  

getRelated

public TableRow[] getRelated(int relation,
                             Clause where,
                             int[] orderBy)
                      throws WorkbenchException
Returns the rows of another table based on a relationship and the values of this row
Specified by:
getRelated in interface TableRow
Parameters:
relation - int The relationship identifier
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 -  

getTable

public Table getTable()
Returns the table of the row
Specified by:
getTable in interface TableRow
Returns:
com.ibm.dse.tools.workbench.base.Table

getValueAt

public java.lang.String getValueAt(int column)
Returns the value contained in a column of this row
Specified by:
getValueAt in interface TableRow
Parameters:
column - int The identifier of the column to evaluate
Returns:
java.lang.String

importToWorkspace

public void importToWorkspace(Workspace ws)
                       throws WorkbenchException
This method copies a row from a repository to a workspace
Specified by:
importToWorkspace in interface TableRow
Parameters:
ws - com.ibm.dse.tools.workbench.base.Workspace
Throws:
WorkbenchException -  

insert

protected void insert()
               throws RepositoryException
This method inserts the current row in a database
Throws:
RepositoryException -  

isDeleted

public boolean isDeleted()
Indicates if row has been deleted from the database
Specified by:
isDeleted in interface TableRow
Returns:
boolean

isInError

public boolean isInError()
Indicates if last validation has caused errors
Specified by:
isInError in interface TableRow
Returns:
boolean

isModified

public boolean isModified()
Indicates if the row has been changed since last flush
Specified by:
isModified in interface TableRow
Returns:
boolean

isNew

public boolean isNew()
Returns the insertion status of this row (true if it has not been inserted yet)
Specified by:
isNew in interface TableRow
Returns:
boolean

isVersioned

public boolean isVersioned()
                    throws RpNonVersionableTableException
Indicates if this row is versioned or an open edition
Specified by:
isVersioned in interface TableRow
Returns:
boolean
Throws:
RpNonVersionableTableException - The row isn't owned by a Versionable table

markCommited

public void markCommited()
This method marks the row stated as committed
Specified by:
markCommited in interface TableRow

registerReference

public void registerReference()
This method increments the count of use references.
Specified by:
registerReference in interface TableRow

restoreInserted

public void restoreInserted()
This method restores the status of an inserted row since the last commit or rollback
Specified by:
restoreInserted in interface TableRow

restoreModified

public void restoreModified()
This method restores the status of a modified or deleted row since the last commit or rollback
Specified by:
restoreModified in interface TableRow

setContainerGroup

public void setContainerGroup(java.lang.String grpCode)
                       throws WorkbenchException
This method sets the Container group of a row
Specified by:
setContainerGroup in interface TableRow
Parameters:
grpCode - java.lang.String the code of the group to be set as container
Throws:
WorkbenchException -  

setOtherVersionsInactive

public void setOtherVersionsInactive()
                              throws WorkbenchException
This method searches for other editions of the row in the Repository where it is stored and marks them as inactive
Specified by:
setOtherVersionsInactive in interface TableRow
Throws:
WorkbenchException -  

setTable

public void setTable(Table table)
Sets the table of the row
Specified by:
setTable in interface TableRow
Parameters:
table - com.ibm.dse.tools.workbench.base.Table The table to set

setValueAt

public void setValueAt(int column,
                       java.lang.String value)
                throws RepositoryException
Sets the value in a column of this row
Specified by:
setValueAt in interface TableRow
Parameters:
column - int The identifier of the column to modify
value - java.lang.String The value to be assigned
Throws:
RepositoryException -  

setValues

public void setValues(java.lang.String[] values)
               throws RepositoryException
Sets the values of all columns of this row
Specified by:
setValues in interface TableRow
Parameters:
values - java.lang.String[] The value to be assigned
Throws:
RepositoryException -  

storeRollbackData

protected void storeRollbackData()
This method stores the actual values for a possible rollback

toString

public java.lang.String toString()
Returns a string representation of this row
Overrides:
toString in class java.lang.Object
Returns:
java.lang.String

update

protected void update()
               throws RepositoryException
This method updates the current row to the database
Throws:
RepositoryException -  

validate

public java.lang.String[] validate()
Evaluates and returns the list of validation error messages for this row and marks it as inError if there are errors
Specified by:
validate in interface TableRow
Returns:
java.lang.String[] the errors list

version

public TableRow version(java.lang.String newVersion,
                        Repository repository)
                 throws WorkbenchException
Versions this row, copying it to a repository, based on the version process for its table
Specified by:
version in interface TableRow
Parameters:
newVersion - java.lang.String the new version code
repository - com.ibm.dse.tools.workbench.base.Repository the repository where to copy the versioned row
Returns:
com.ibm.dse.tools.workbench.base.TableRow the versioned row
Throws:
WorkbenchException - The row can not be versioned