org.opensubsystems.core.persist.db
Class ModifiableDatabaseSchemaImpl

java.lang.Object
  extended by org.opensubsystems.core.persist.db.DatabaseSchemaImpl
      extended by org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl
All Implemented Interfaces:
DatabaseOperations, DatabaseSchema, ModifiableDatabaseSchema

public abstract class ModifiableDatabaseSchemaImpl
extends DatabaseSchemaImpl
implements ModifiableDatabaseSchema

Base class implementation for database schemas that provide queries or operations that allow to modify data in tables managed by this schema.

Version:
$Id: ModifiableDatabaseSchemaImpl.java,v 1.1 2007/01/10 05:09:38 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
Initial revision.

Field Summary
protected  java.util.Map m_mapModifiableTableNames
          Map of all tables belonging to this schema that can be modified by the operations provided by the schema (e.g.
 
Fields inherited from class org.opensubsystems.core.persist.db.DatabaseSchemaImpl
DATABASE_SCHEMA_PREFIX, DATABASE_SCHEMA_PREFIX_DEFAULT, m_arrDependentSchemas, m_bIsInDomain, m_iSchemaVersion, m_strSchemaName, NL
 
Fields inherited from interface org.opensubsystems.core.persist.db.DatabaseOperations
DBOP_DELETE, DBOP_INSERT, DBOP_SELECT, DBOP_UPDATE
 
Constructor Summary
ModifiableDatabaseSchemaImpl(DatabaseSchema[] arrDependentSchemas, java.lang.String strSchemaName, int iSchemaVersion, boolean bIsInDomain, java.lang.Integer iModifiableDataType, java.lang.String strModifiableTableName)
          Constructor allowing to specify attributes for database schema that support only single data object type and therefore have most likely only one table name that can be modified and single columns sets.
ModifiableDatabaseSchemaImpl(DatabaseSchema[] arrDependentSchemas, java.lang.String strSchemaName, int iSchemaVersion, boolean bIsInDomain, java.util.Map mapModifiableTableNames)
          Constructor allowing to specify attributes for database schema that support multiple data object types and therefore have multiple sets of tables that can be modified and columns sets.
 
Method Summary
 int deleteRelatedData(java.sql.Connection cntDBConnection, int iDataType, int iId)
          Method deletes related child data when main data object is being deleted.
 java.util.Map getModifiableTableNames()
          Get the names of all tables that can be modified by the operations provided by this database schema (e.g.
 void handleSQLException(java.sql.SQLException exc, java.sql.Connection dbConnection, int iOperationType, int iDataType, java.lang.Object data)
          Handle SQL Exception caused by some database operations.
 
Methods inherited from class org.opensubsystems.core.persist.db.DatabaseSchemaImpl
getDependentSchemas, getJoinFromWhere, getName, getOwnerColumnNames, getSchemaPrefix, getVersion, isExistingIndex, isInDomain, upgrade, upgradeView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opensubsystems.core.persist.db.DatabaseSchema
create, getDependentSchemas, getName, getVersion, isInDomain, upgrade
 

Field Detail

m_mapModifiableTableNames

protected java.util.Map m_mapModifiableTableNames
Map of all tables belonging to this schema that can be modified by the operations provided by the schema (e.g. schema allows insert, update or delete on this table). Key is the data type, value is the string with the table name.

Constructor Detail

ModifiableDatabaseSchemaImpl

public ModifiableDatabaseSchemaImpl(DatabaseSchema[] arrDependentSchemas,
                                    java.lang.String strSchemaName,
                                    int iSchemaVersion,
                                    boolean bIsInDomain,
                                    java.util.Map mapModifiableTableNames)
                             throws OSSException
Constructor allowing to specify attributes for database schema that support multiple data object types and therefore have multiple sets of tables that can be modified and columns sets.

Parameters:
arrDependentSchemas - - array of dependent schemas
strSchemaName - - name of the schema
iSchemaVersion - - version of the schema
bIsInDomain - - flag signaling if object is in domain
mapModifiableTableNames - - map of all tables belonging to this schema that can be modified by the schema (e.g. schema allows insert, update or delete on this table)
Throws:
OSSException - - an error has occured

ModifiableDatabaseSchemaImpl

public ModifiableDatabaseSchemaImpl(DatabaseSchema[] arrDependentSchemas,
                                    java.lang.String strSchemaName,
                                    int iSchemaVersion,
                                    boolean bIsInDomain,
                                    java.lang.Integer iModifiableDataType,
                                    java.lang.String strModifiableTableName)
                             throws OSSException
Constructor allowing to specify attributes for database schema that support only single data object type and therefore have most likely only one table name that can be modified and single columns sets.

Parameters:
arrDependentSchemas - - array of dependent schemas
strSchemaName - - name of the schema
iSchemaVersion - - version of the schema
iModifiableDataType - - data type that can be modified using operations in this schema
strModifiableTableName - - table belonging to this schema that can be modified by the schema (e.g. schema allows insert, update or delete on this table)
bIsInDomain - - flag signaling if object is in domain
Throws:
OSSException - - an error has occured
Method Detail

deleteRelatedData

public int deleteRelatedData(java.sql.Connection cntDBConnection,
                             int iDataType,
                             int iId)
                      throws OSSException,
                             java.sql.SQLException
Method deletes related child data when main data object is being deleted. This method has to be overriden for databases that don't support cascade delete (eg. Sybase ASE).

Specified by:
deleteRelatedData in interface ModifiableDatabaseSchema
Parameters:
cntDBConnection - - valid connection to database
iDataType - - data type identifying what to delete
iId - - ID of the record that has to be deleted
Returns:
int - number of deleted records
Throws:
OSSException - - problem deleting related data
java.sql.SQLException - - problem deleting related data

getModifiableTableNames

public java.util.Map getModifiableTableNames()
Get the names of all tables that can be modified by the operations provided by this database schema (e.g. schema allows insert, update or delete on this table).

Specified by:
getModifiableTableNames in interface ModifiableDatabaseSchema
Returns:
Map - map of table names for particular schema. key = object data type value = table name null if the schema doesn't allow to modify any of the tables

handleSQLException

public void handleSQLException(java.sql.SQLException exc,
                               java.sql.Connection dbConnection,
                               int iOperationType,
                               int iDataType,
                               java.lang.Object data)
                        throws OSSException
Handle SQL Exception caused by some database operations.

Specified by:
handleSQLException in interface DatabaseSchema
Overrides:
handleSQLException in class DatabaseSchemaImpl
Parameters:
exc - - sql exception to be handled
dbConnection - - database connection used when the exception occured
iOperationType - - type of the operation that caused the exception, see DatabaseOperations for possible values
iDataType - - data type the data object represents (e.g if this is type user and data is Integer, that means it is id of user object). This is one of the DataConstant constants.
data - - data object the exception is handled for
Throws:
OSSException - - problem handling exception


Copyright © 2003 - 2006 OpenSubsystems s.r.o.