org.opensubsystems.core.persist.db
Class VersionedDatabaseSchema

java.lang.Object
  extended by org.opensubsystems.core.persist.db.DatabaseSchemaImpl
      extended by org.opensubsystems.core.persist.db.VersionedDatabaseSchema
All Implemented Interfaces:
DatabaseOperations, DatabaseSchema
Direct Known Subclasses:
MSSQLVersionedDatabaseSchema, MySQLVersionedDatabaseSchema, PostgreSQLVersionedDatabaseSchema, SybaseVersionedDatabaseSchema

public class VersionedDatabaseSchema
extends DatabaseSchemaImpl

Versioned database schema provide functionality of creating and upgrading of individual database schemas in the database based on their versions. This class keeps track of existing and current versiones of database schemas and upgrades them as necesary

Version:
$Id: VersionedDatabaseSchema.java,v 1.21 2007/01/10 05:16:58 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.14 2006/04/05 05:00:52 bastafidli

Field Summary
static java.lang.String SCHEMA_TABLE_NAME
          Full name of the table used by this schema.
static java.lang.String VERSIONED_SCHEMA_NAME
          Name identifies this schema in the database.
static int VERSIONED_SCHEMA_VERSION
          Version of this schema in the database.
 
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
VersionedDatabaseSchema()
          Default constructor.
 
Method Summary
 void add(DatabaseSchema dsSchema)
          Add new database schema to be managed by versioned schema.
 void create(java.sql.Connection cntDBConnection, java.lang.String strUserName)
          Create the schema.
protected  void createOrUpgradeSchemas(java.sql.Connection cntDBConnection, java.lang.String strUserName, java.util.Map mpSchemasToAdd, java.util.Map mpSchemasToUpgrade)
          Creating or upgrading schemas, which needs to be added or changes.
 void init(java.sql.Connection cntDBConnection, java.lang.String strUserName)
          Initialize the schema.
protected  void loadExistingSchemas(java.sql.Connection cntDBConnection, java.util.Map mpSchemasToAdd, java.util.Map mpSchemasToUpgrade)
          Check what schemas already exists in the repository.
 
Methods inherited from class org.opensubsystems.core.persist.db.DatabaseSchemaImpl
getDependentSchemas, getJoinFromWhere, getName, getOwnerColumnNames, getSchemaPrefix, getVersion, handleSQLException, isExistingIndex, isInDomain, upgrade, upgradeView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSIONED_SCHEMA_NAME

public static final java.lang.String VERSIONED_SCHEMA_NAME
Name identifies this schema in the database.

See Also:
Constant Field Values

VERSIONED_SCHEMA_VERSION

public static final int VERSIONED_SCHEMA_VERSION
Version of this schema in the database. Version 1 - original Version 2 - PostgreSQL added user defined type

See Also:
Constant Field Values

SCHEMA_TABLE_NAME

public static final java.lang.String SCHEMA_TABLE_NAME
Full name of the table used by this schema.

Constructor Detail

VersionedDatabaseSchema

public VersionedDatabaseSchema()
                        throws OSSException
Default constructor.

Throws:
OSSException - - database cannot be started.
Method Detail

add

public void add(DatabaseSchema dsSchema)
         throws OSSException
Add new database schema to be managed by versioned schema.

Parameters:
dsSchema - - new database schema to be managed
Throws:
OSSException - - database cannot be started.

init

public void init(java.sql.Connection cntDBConnection,
                 java.lang.String strUserName)
          throws OSSException,
                 java.sql.SQLException
Initialize the schema. This function should make sure that the schema in the database is up to date, perform any upgrades if necessary, etc.

Parameters:
cntDBConnection - - valid connection to database
strUserName - - name of user who will be accessing this table
Throws:
OSSException - - problem initializing the schema
java.sql.SQLException - - problem initializing the schema

create

public void create(java.sql.Connection cntDBConnection,
                   java.lang.String strUserName)
            throws java.sql.SQLException,
                   OSSException
Create the schema.

Parameters:
cntDBConnection - - valid connection to database
strUserName - - name of user who will be accessing this table
Throws:
java.sql.SQLException - - problem creating the schema
OSSException - - problem creating the schema

loadExistingSchemas

protected void loadExistingSchemas(java.sql.Connection cntDBConnection,
                                   java.util.Map mpSchemasToAdd,
                                   java.util.Map mpSchemasToUpgrade)
                            throws OSSException
Check what schemas already exists in the repository.

Parameters:
cntDBConnection - - valid connection to database
mpSchemasToAdd - - current schemas will at the end contains schemas, which must be added
mpSchemasToUpgrade - - schemas to upgrade will contain schemas, which must be upgraded
Throws:
OSSException - - problem initializing the schema

createOrUpgradeSchemas

protected void createOrUpgradeSchemas(java.sql.Connection cntDBConnection,
                                      java.lang.String strUserName,
                                      java.util.Map mpSchemasToAdd,
                                      java.util.Map mpSchemasToUpgrade)
                               throws OSSException,
                                      java.sql.SQLException
Creating or upgrading schemas, which needs to be added or changes.

Parameters:
cntDBConnection - - valid connection to database
strUserName - - name of user who will be accessing this table
mpSchemasToAdd - - current schemas will at the end contains schemas which must be added
mpSchemasToUpgrade - - schemas to upgrade will contain schemas which must be upgraded
Throws:
OSSException - - problem initializing the schema
java.sql.SQLException - - problem initializing the schema


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