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

java.lang.Object
  |
  +--com.ibm.dse.tools.workbench.base.AbstractTable
        |
        +--com.ibm.dse.tools.workbench.base.VersionableTable
              |
              +--com.ibm.dse.tools.workbench.base.InstancesTable

public class InstancesTable
extends VersionableTable
implements Errorable

This class represents a table of instances


Field Summary
static int ACTIVE
          The identifier for the ACTIVE column
static int BASE_GROUP
          The identifier for the BASE_GROUP column
static int CK_ACTIVE
          The identifiers for the check constraint CK_ACTIVE
static int CK_IN_ERROR
          The identifier for the check constraint CK_IN_ERROR
static int CK_RELEASED
          The identifiers for the check constraint CK_RELEASED
static int CK_VERSIONED
          The identifiers for the check constraint CK_VERSIONED
static int CODE
          The identifier for the CODE column
static int COMMENT
          The identifier for the COMMENT column
static int ENTITY
          The identifier for the ENTITY column
static int ICON
          The identifier for the ICON column
static int IN_ERROR
          The identifier for the IN_ERROR column
static int NAME
          The identifier for the NAME column
static int OWNER
          The identifier for the OWNER column
static int PARENT
          The identifier for the PARENT column
static int PATH
          The identifier for the PATH column
static int POSITION
          The identifier for the POSITION column
static int REL_CHILD_INSTANCES
          The identifiers for the relationship INSINSFK
static int REL_ERRORS
          The identifier for the relationship ERRINSFK
static int REL_GROUPS_ASSIGNED
          The identifiers for the relationship GRPINSIF
static int REL_OWNED_PROPERTIES
          The identifiers for the relationship PRPINSFK
static int RELEASED
          The identifier for the RELEASED column
static int TAG
          The identifier for the TAG column
static int TIMESTAMP
          The identifier for the TIMESTAMP column
static int VERSION
          The identifier for the VERSION column
static int VERSIONED
          The identifier for the VERSIONED column
 
Fields inherited from class com.ibm.dse.tools.workbench.base.AbstractTable
alias, checks, columnLengths, columns, DATA_DELIMITER, DATA_SEPARATOR, deletedRows, ESCAPE_SEQUENCE, fks, indexes, insertedRows, modifiedRows, name, pk, relations, repository, required, rows, triggers
 
Constructor Summary
InstancesTable(Repository rpstry)
          This constructor creates an InstancesTable object in a repository
 
Method Summary
 void copyParentGroupsTree(TableRow tableRow, Repository destinationRep, boolean exactGroup)
          Copies all the parent groups hierarchy of an instance to a repository
 TableRow createOpenEdition(TableRow row)
          Creates an open edition of an instance row
 void createRelations()
          This method creates the relationships for a table
 TableRow findReference(TableRow instance, java.lang.String attName)
          Returns the instance referred by a property that corresponds to a cross reference
 int getActiveColumn()
          Returns the Active column identifier
 TableRow[] getChildInstances(TableRow instance, int[] orderBy)
          This method returns the children for the given instance.
 int getCodeColumn()
          Returns the Code column identifier
 java.lang.String getCompletePath(TableRow instance)
          Returns a string with the concatenation of all parent names separated by dots
 TableRow getContainerGroup(TableRow versionableRow)
          This method returns the group containing the versionableRow passed as parameter
 TableRow getEntity(TableRow instance)
          Returns the row representing the entity defining an instance
 java.lang.String[] getErrorMessage(TableRow instance)
          Returns the string containing the error message
 Table getErrorsTable()
          Returns related errors table
 java.lang.String getErrorsTableName()
          Returns related errors table name
 TableRow getGroup(TableRow instance)
          This method returns the group where the instance belongs.
 int getInErrorColumn()
          This method returns the column identifier for the InError field
 TableRow getInstanceParent(TableRow instance)
          This method returns the instance parent for the given instance.
 int getNameColumn()
          Returns the Name column identifier
 int getOwnerColumn()
          Returns the Owner column identifier
 TableRow[] getParentInstanceTree(TableRow instance)
          Returns all the hierarchy parents of an instance including it
 java.lang.String getPathByAttributes(TableRow instance, java.lang.String[] attNameList)
          Returns a string with the concatenation of all parent property values separated by dots
 TableRow[] getProperties(TableRow instance)
          Returns the properties of an instance
 int getReleasedColumn()
          Returns the Released column identifier
 int getTimeStampColumn()
          Returns the TimeStamp column identifier
 int getVersionColumn()
          Returns the Version column identifier
 int getVersionedColumn()
          Returns the Versioned column identifier
 boolean hasSelfGeneratedPk()
          This method indicates if the field in the primary key must be generated automatically
 void importToWorkspace(Workspace ws, TableRow row)
          Copies a row of this VersionableTable from a repository to a workspace.
 void postDelete(TableRow row)
          This method validates the composition of the parent of the specified instance
 void preInsert(TableRow row)
          Before inserting a row, the path must be calculated
 void preUpdate(TableRow row)
          When updating a row, the path must be recalculated, because the name can be changed
 TableRow[] retrieveAll(Clause where, int[] orderBy)
          This method overwrites the AbstractTable retrieveAll behaviour, adding the needed error handling code
 TableRow retrieveByPk(java.lang.String[] values)
          This method overwrites the AbstractTable retrieveByPk behaviour, adding the needed error handling code
 java.lang.String[] retrieveDistinct(int column, Clause where)
          This method overwrites the AbstractTable retrieveDistinct behaviour, adding the needed error handling code
 TableRow[] rowsToBeRemoved(TableRow[] rows)
          Returns the rows that a remove process performed on a set of rows will remove.
protected  void rowsToBeRemoved(TableRow row, java.util.Hashtable rowList)
          Adds to a Hashtable the related rows that a remove process performed on a row will remove.
 void setContainerGroup(TableRow versionableRow, java.lang.String grpCode)
          This method sets the Container group of an entity row
static void setValidationActive(boolean activate)
          Sets the validation active flag
 java.lang.String[] validate(TableRow instance)
          This method checks the correctness of an instance row based on application rules
 void validateInstanceHierarchy(TableRow instance)
          This method validates an instance and his children
 java.lang.String[] validateInstancesComposition(TableRow instance)
          This method checks the correctness of an instance row based on application rules
 java.lang.String[] validateMandatoryProperties(TableRow instance)
          This method validates the mandatory properties of a table row
 java.lang.String[] validateProperties(TableRow instance)
          This method checks the correctness of the properties of a table row
 TableRow version(TableRow versionableRow, java.lang.String newVersion, Repository repository)
          This method versions an instance.
 
Methods inherited from class com.ibm.dse.tools.workbench.base.VersionableTable
alterFkFields, alterRelatedRows, copyOwner, copyParentGroupsTree, getContainerGroup, getContainerGroup, getDistinctNames, getVersions, getWorkspaceContainerGroup, isAValidVersionNumber, isVersioned, setContainerGroup, updateOpenEditionFields, updateVersionFields
 
Methods inherited from class com.ibm.dse.tools.workbench.base.AbstractTable
add, areTriggersActive, cleanRollbackData, count, createTableRow, createTableRow, exportToFile, flush, getAlias, getChecks, getChecks, getColumnLengths, getColumns, getColumnsString, getColumnsString, getConnection, getCreateChecksStrings, getCreateFksStrings, getCreateIndexesStrings, getCreatePkString, getCreateTableString, getDefaultVersion, getFks, getIndexes, getName, getPk, getPkValue, getRelated, getRelations, getRepository, getTimestamp, getUniqueValue, importFromString, isInPk, isRequired, postInsert, postUpdate, preDelete, registerDeletedRow, registerInsertedRow, registerModifiedRow, removeFromList, restoreRows, setAlias, setRepository, setTriggersState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CODE

public static final int CODE
The identifier for the CODE column

NAME

public static final int NAME
The identifier for the NAME column

TAG

public static final int TAG
The identifier for the TAG column

ICON

public static final int ICON
The identifier for the ICON column

COMMENT

public static final int COMMENT
The identifier for the COMMENT column

VERSION

public static final int VERSION
The identifier for the VERSION column

ENTITY

public static final int ENTITY
The identifier for the ENTITY column

PARENT

public static final int PARENT
The identifier for the PARENT column

POSITION

public static final int POSITION
The identifier for the POSITION column

OWNER

public static final int OWNER
The identifier for the OWNER column

RELEASED

public static final int RELEASED
The identifier for the RELEASED column

TIMESTAMP

public static final int TIMESTAMP
The identifier for the TIMESTAMP column

VERSIONED

public static final int VERSIONED
The identifier for the VERSIONED column

ACTIVE

public static final int ACTIVE
The identifier for the ACTIVE column

BASE_GROUP

public static final int BASE_GROUP
The identifier for the BASE_GROUP column

PATH

public static final int PATH
The identifier for the PATH column

IN_ERROR

public static final int IN_ERROR
The identifier for the IN_ERROR column

REL_GROUPS_ASSIGNED

public static final int REL_GROUPS_ASSIGNED
The identifiers for the relationship GRPINSIF

REL_CHILD_INSTANCES

public static final int REL_CHILD_INSTANCES
The identifiers for the relationship INSINSFK

REL_OWNED_PROPERTIES

public static final int REL_OWNED_PROPERTIES
The identifiers for the relationship PRPINSFK

REL_ERRORS

public static final int REL_ERRORS
The identifier for the relationship ERRINSFK

CK_RELEASED

public static final int CK_RELEASED
The identifiers for the check constraint CK_RELEASED

CK_VERSIONED

public static final int CK_VERSIONED
The identifiers for the check constraint CK_VERSIONED

CK_ACTIVE

public static final int CK_ACTIVE
The identifiers for the check constraint CK_ACTIVE

CK_IN_ERROR

public static final int CK_IN_ERROR
The identifier for the check constraint CK_IN_ERROR
Constructor Detail

InstancesTable

public InstancesTable(Repository rpstry)
This constructor creates an InstancesTable object in a repository
Parameters:
rpstry - com.ibm.dse.tools.workbench.base.DefaultRepository The repository in wich create the table
Method Detail

copyParentGroupsTree

public void copyParentGroupsTree(TableRow tableRow,
                                 Repository destinationRep,
                                 boolean exactGroup)
                          throws WorkbenchException
Copies all the parent groups hierarchy of an instance to a repository
Overrides:
copyParentGroupsTree in class VersionableTable
Parameters:
tableRow - com.ibm.dse.tools.workbench.base.TableRow The entity to copy
destinationRep - com.ibm.dse.tools.workbench.base.Repository The repository where to copy
exactGroup - boolean Indicator of whether the row has to be attached to the container group by CODE (true) or by NAME (false)
Throws:
WorkbenchException -  

createOpenEdition

public TableRow createOpenEdition(TableRow row)
                           throws WorkbenchException
Creates an open edition of an instance row
Overrides:
createOpenEdition in class VersionableTable
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow the original row
Returns:
com.ibm.dse.tools.workbench.base.TableRow The open edition row It can be the open edition of the given row or the open edition of the top most parent instance
Throws:
WorkbenchException -  

createRelations

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

findReference

public TableRow findReference(TableRow instance,
                              java.lang.String attName)
                       throws WorkbenchException
Returns the instance referred by a property that corresponds to a cross reference
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow The instance that has the reference
attName - java.lang.String The name of the attribute that has the reference
Returns:
com.ibm.dse.tools.workbench.base.TableRow The instance referred
Throws:
WorkbenchException -  

getActiveColumn

public int getActiveColumn()
Returns the Active column identifier
Overrides:
getActiveColumn in class VersionableTable
Returns:
int

getChildInstances

public TableRow[] getChildInstances(TableRow instance,
                                    int[] orderBy)
                             throws WorkbenchException
This method returns the children for the given instance.
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow
orderBy - int
Returns:
com.ibm.dse.tools.workbench.base.TableRow[]
Throws:
WorkbenchException -  

getCodeColumn

public int getCodeColumn()
Returns the Code column identifier
Returns:
int

getCompletePath

public java.lang.String getCompletePath(TableRow instance)
                                 throws WorkbenchException
Returns a string with the concatenation of all parent names separated by dots
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow
Returns:
java.lang.String
Throws:
WorkbenchException - An error occurred while retrieving the complete path.

getContainerGroup

public TableRow getContainerGroup(TableRow versionableRow)
                           throws WorkbenchException
This method returns the group containing the versionableRow passed as parameter
Overrides:
getContainerGroup in class VersionableTable
Parameters:
versionableRow - com.ibm.dse.tools.workbench.base.TableRow The row whose group must be returned
Returns:
com.ibm.dse.tools.workbench.base.TableRow The group containing the versionableRow
Throws:
WorkbenchException -  

getEntity

public TableRow getEntity(TableRow instance)
                   throws WorkbenchException
Returns the row representing the entity defining an instance
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow The row representing the instance
Returns:
com.ibm.dse.tools.workbench.base.TableRow
Throws:
WorkbenchException -  

getErrorMessage

public java.lang.String[] getErrorMessage(TableRow instance)
                                   throws WorkbenchException
Returns the string containing the error message
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow The row representing the instance
Returns:
java.lang.String[]
Throws:
WorkbenchException -  

getErrorsTable

public Table getErrorsTable()
Returns related errors table
Specified by:
getErrorsTable in interface Errorable
Returns:
com.ibm.dse.tools.workbench.base.Table

getErrorsTableName

public java.lang.String getErrorsTableName()
Returns related errors table name
Specified by:
getErrorsTableName in interface Errorable
Returns:
java.lang.String

getGroup

public TableRow getGroup(TableRow instance)
This method returns the group where the instance belongs. If it's not a root instance, then the inherited group is returned
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow
Returns:
com.ibm.dse.tools.workbench.base.TableRow

getInErrorColumn

public int getInErrorColumn()
This method returns the column identifier for the InError field
Specified by:
getInErrorColumn in interface Errorable
Returns:
int The InError column identifier

getInstanceParent

public TableRow getInstanceParent(TableRow instance)
                           throws WorkbenchException
This method returns the instance parent for the given instance.
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow
Returns:
com.ibm.dse.tools.workbench.base.TableRow
Throws:
WorkbenchException -  

getNameColumn

public int getNameColumn()
Returns the Name column identifier
Overrides:
getNameColumn in class VersionableTable
Returns:
int

getOwnerColumn

public int getOwnerColumn()
Returns the Owner column identifier
Overrides:
getOwnerColumn in class VersionableTable
Returns:
int

getParentInstanceTree

public TableRow[] getParentInstanceTree(TableRow instance)
                                 throws WorkbenchException
Returns all the hierarchy parents of an instance including it
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow The row representing the instance
Returns:
com.ibm.dse.tools.workbench.base.TableRow[]
Throws:
WorkbenchException -  

getPathByAttributes

public java.lang.String getPathByAttributes(TableRow instance,
                                            java.lang.String[] attNameList)
                                     throws WorkbenchException
Returns a string with the concatenation of all parent property values separated by dots

A list of attributes names is provided, so these attributes are searched, in the same order of preference that they are provided, between the properties of the current instance. When a property for one of this attributes is found, its value is concatenated to the complete path, separated by a dot

Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow
attNameList - java.lang.String[] The list of attribute names to use in properties search
Returns:
java.lang.String
Throws:
WorkbenchException -  

getProperties

public TableRow[] getProperties(TableRow instance)
                         throws WorkbenchException
Returns the properties of an instance
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow The row representing the instance
Returns:
com.ibm.dse.tools.workbench.base.TableRow[]
Throws:
WorkbenchException -  

getReleasedColumn

public int getReleasedColumn()
Returns the Released column identifier
Overrides:
getReleasedColumn in class VersionableTable
Returns:
int

getTimeStampColumn

public int getTimeStampColumn()
Returns the TimeStamp column identifier
Overrides:
getTimeStampColumn in class VersionableTable
Returns:
int

getVersionColumn

public int getVersionColumn()
Returns the Version column identifier
Overrides:
getVersionColumn in class VersionableTable
Returns:
int

getVersionedColumn

public int getVersionedColumn()
Returns the Versioned column identifier
Overrides:
getVersionedColumn in class VersionableTable
Returns:
int

hasSelfGeneratedPk

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

importToWorkspace

public void importToWorkspace(Workspace ws,
                              TableRow row)
                       throws WorkbenchException
Copies a row of this VersionableTable from a repository to a workspace.

Rows in VersionableTable objects contained in a Workspace object can not be imported to a Workspace.

This method also copies the parent groups tree if needed.

Overrides:
importToWorkspace in class VersionableTable
Parameters:
ws - com.ibm.dse.tools.workbench.base.Workspace The destination repository.
row - com.ibm.dse.tools.workbench.base.TableRow The row to be copied.
Throws:
WorkbenchException - An error ocurred while importing to workspace.

postDelete

public void postDelete(TableRow row)
                throws RepositoryException
This method validates the composition of the parent of the specified instance
Overrides:
postDelete in class AbstractTable
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Throws:
RepositoryException - An error occurred while calculating the path.

preInsert

public void preInsert(TableRow row)
               throws RepositoryException
Before inserting a row, the path must be calculated
Overrides:
preInsert in class AbstractTable
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Throws:
RepositoryException - An error occurred while calculating the path.

preUpdate

public void preUpdate(TableRow row)
               throws RepositoryException
When updating a row, the path must be recalculated, because the name can be changed
Overrides:
preUpdate in class AbstractTable
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
Throws:
RepositoryException -  

retrieveAll

public TableRow[] retrieveAll(Clause where,
                              int[] orderBy)
                       throws WorkbenchException
This method overwrites the AbstractTable retrieveAll behaviour, adding the needed error handling code
Overrides:
retrieveAll in class AbstractTable
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
This method overwrites the AbstractTable retrieveByPk behaviour, adding the needed error handling code
Overrides:
retrieveByPk in class AbstractTable
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 overwrites the AbstractTable retrieveDistinct behaviour, adding the needed error handling code
Overrides:
retrieveDistinct in class AbstractTable
Parameters:
column - int
where - com.ibm.dse.tools.workbench.base.Clause
Returns:
java.lang.String[]
Throws:
WorkbenchException -  

rowsToBeRemoved

public TableRow[] rowsToBeRemoved(TableRow[] rows)
                           throws WorkbenchException
Returns the rows that a remove process performed on a set of rows will remove.
Overrides:
rowsToBeRemoved in class VersionableTable
Parameters:
rows - com.ibm.dse.tools.workbench.base.TableRow[] the rows
Returns:
com.ibm.dse.tools.workbench.base.TableRow[] the rows that would de removed
Throws:
WorkbenchException - An error ocurred while retrieving the rows to be removed.

rowsToBeRemoved

protected void rowsToBeRemoved(TableRow row,
                               java.util.Hashtable rowList)
                        throws WorkbenchException
Adds to a Hashtable the related rows that a remove process performed on a row will remove.
Overrides:
rowsToBeRemoved in class VersionableTable
Parameters:
row - com.ibm.dse.tools.workbench.base.TableRow
rowList - java.util.Hashtable
Throws:
WorkbenchException - An error ocurred while retrieving the rows to be removed.

setContainerGroup

public void setContainerGroup(TableRow versionableRow,
                              java.lang.String grpCode)
                       throws WorkbenchException
This method sets the Container group of an entity row
Overrides:
setContainerGroup in class VersionableTable
Parameters:
versionableRow - com.ibm.dse.tools.workbench.base.TableRow The entity row
grpCode - java.lang.String The code of the group to be set as container
Throws:
WorkbenchException -  

setValidationActive

public static void setValidationActive(boolean activate)
Sets the validation active flag
Parameters:
activate - boolean

validate

public java.lang.String[] validate(TableRow instance)
This method checks the correctness of an instance row based on application rules

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

Overrides:
validate in class AbstractTable
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow The row to validate
Returns:
java.lang.String[]

validateInstanceHierarchy

public void validateInstanceHierarchy(TableRow instance)
                               throws WorkbenchException
This method validates an instance and his children
Parameters:
instance - com.ibm.dse.tools.workbench.base.TableRow
Throws:
WorkbenchException -  

validateInstancesComposition

public java.lang.String[] validateInstancesComposition(TableRow instance)
This method checks the correctness of an instance row based on application rules

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

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

validateMandatoryProperties

public java.lang.String[] validateMandatoryProperties(TableRow instance)
This method validates the mandatory properties of a table row

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

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

validateProperties

public java.lang.String[] validateProperties(TableRow instance)
This method checks the correctness of the properties of a table row

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

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

version

public TableRow version(TableRow versionableRow,
                        java.lang.String newVersion,
                        Repository repository)
                 throws WorkbenchException
This method versions an instance.

Only Root Instances can be versioned

Overrides:
version in class VersionableTable
Parameters:
versionableRow - com.ibm.dse.tools.workbench.base.TableRow the instance row to be versioned
newVersion - java.lang.String the 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 instance row
Throws:
WorkbenchException -