org.opensubsystems.inventory.persist.db
Class UnitDatabaseSchema

java.lang.Object
  extended by org.opensubsystems.core.persist.db.DatabaseSchemaImpl
      extended by org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl
          extended by org.opensubsystems.patterns.listdata.persist.db.impl.ModifiableListDatabaseSchemaImpl
              extended by org.opensubsystems.inventory.persist.db.UnitDatabaseSchema
All Implemented Interfaces:
org.opensubsystems.core.persist.db.DatabaseOperations, org.opensubsystems.core.persist.db.DatabaseSchema, org.opensubsystems.core.persist.db.ModifiableDatabaseSchema, org.opensubsystems.patterns.listdata.persist.db.ListDatabaseSchema
Direct Known Subclasses:
DB2UnitDatabaseSchema, HsqlDBUnitDatabaseSchema, MSSQLUnitDatabaseSchema, MySQLUnitDatabaseSchema, OracleUnitDatabaseSchema, PostgreSQLUnitDatabaseSchema, SapDBUnitDatabaseSchema, SybaseUnitDatabaseSchema

public abstract class UnitDatabaseSchema
extends org.opensubsystems.patterns.listdata.persist.db.impl.ModifiableListDatabaseSchemaImpl

Database specific operations related to persistence of units.

Version:
$Id: UnitDatabaseSchema.java,v 1.19 2007/01/12 06:19:45 bastafidli Exp $
Author:
Martin Cerba
Code reviewer:
TODO: Review this code
Code reviewed:

Field Summary
static int[] UNIT_MANDATORY_RETRIEVE_COLUMNS
          Columns which always have to be retrieved from the database
static java.lang.String UNIT_SCHEMA_NAME
          Name identifies this schema in the database.
static int UNIT_SCHEMA_VERSION
          Version of this schema in the database.
static int[] UNIT_SORT_COLUMNS
          Static variable for array of all columns codes that can be used for sorting.
 
Fields inherited from class org.opensubsystems.patterns.listdata.persist.db.impl.ModifiableListDatabaseSchemaImpl
m_mapFilterableColumns, m_mapListableTableNames, m_mapMandatoryRetrieveColumns, m_mapSortableColumns
 
Fields inherited from class org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl
m_mapModifiableTableNames
 
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
UnitDatabaseSchema()
          Default constructor.
 
Method Summary
 void createListIndexes(java.sql.Connection cntDBConnection)
          Method creates specified LST indexes used for speeding up retrieving data into the list.
 java.lang.String getChangeAvailableCountSQL()
          Get SQL statement to change available count.
protected abstract  java.lang.String getChangeShippedAndAvailableCountSecureSQL()
          Return sql statemnet string for change shipped and availbale in regular item, In regular item both available and shiped have to by nonnegative
protected abstract  java.lang.String getChangeShippedAndAvailableCountSecureSQLFoundHolder()
          Return sql statemnet string for chnage shipped and availbale in found holder.
 java.lang.String getChangeShippedAndAvailableCountSQL()
          Get SQL statement to change shipped and available count.
 java.lang.StringBuffer getColumns(boolean specific, int[] columns, java.lang.Object[] prefixes, java.lang.Object[] postfixes, java.lang.StringBuffer buffer)
          
 java.lang.String getDeleteUnitById()
          Get query to delete particular unit.
 java.lang.String getInsertUnit()
          Method returns simple insert unit query.
abstract  java.lang.String getInsertUnitAndFetchGeneratedValues()
          Get query that inserts a Unit to the database and fetches database generated values such as the generated id and creation timestamp
 java.lang.String getResetCounts()
          Method to get sql for reset counts
 java.lang.String getSelectAvailableItems()
          Method returning sql command for getting available items.
 java.lang.String getSelectByItemAndCost()
          Method returning unit for specific item and cost.
 java.lang.String getSelectFoundHolder()
          Method returning unit used as found holder for specific item
 java.lang.String getSelectUnitById(int[] columns)
          Get query to select unit by ID.
 java.lang.String getSelectUnitsWithoutFoundHolder()
          Method returning sql command for getting units without found holder.
 java.lang.String getUpdateUnit()
          Method returns simple update unit query.
abstract  java.lang.String getUpdateUnitAndFetchGeneratedValues()
          Get query that updates Unit in the database and fetches database generated values such as the updated modification timestamp
 void handleSQLException(java.sql.SQLException exc, java.sql.Connection dbConnection, int iOperationType, int iDataType, java.lang.Object data)
          
 
Methods inherited from class org.opensubsystems.patterns.listdata.persist.db.impl.ModifiableListDatabaseSchemaImpl
getFilterbleColumns, getMandatoryRetrieveColumns, getSelectList, getSortableColumns
 
Methods inherited from class org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl
deleteRelatedData, getModifiableTableNames
 
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.patterns.listdata.persist.db.ListDatabaseSchema
getJoinFromWhere, isExistingIndex
 
Methods inherited from interface org.opensubsystems.core.persist.db.DatabaseSchema
create, getDependentSchemas, getName, getVersion, isInDomain, upgrade
 

Field Detail

UNIT_SCHEMA_NAME

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

See Also:
Constant Field Values

UNIT_SCHEMA_VERSION

public static final int UNIT_SCHEMA_VERSION
Version of this schema in the database.

See Also:
Constant Field Values

UNIT_MANDATORY_RETRIEVE_COLUMNS

public static final int[] UNIT_MANDATORY_RETRIEVE_COLUMNS
Columns which always have to be retrieved from the database


UNIT_SORT_COLUMNS

public static final int[] UNIT_SORT_COLUMNS
Static variable for array of all columns codes that can be used for sorting.

Constructor Detail

UnitDatabaseSchema

public UnitDatabaseSchema()
                   throws org.opensubsystems.core.error.OSSException
Default constructor.

Throws:
org.opensubsystems.core.error.OSSException - - error occured.
Method Detail

getInsertUnitAndFetchGeneratedValues

public abstract java.lang.String getInsertUnitAndFetchGeneratedValues()
                                                               throws org.opensubsystems.core.error.OSSException
Get query that inserts a Unit to the database and fetches database generated values such as the generated id and creation timestamp

Returns:
String - query for simple insert or stored procedure call
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getUpdateUnitAndFetchGeneratedValues

public abstract java.lang.String getUpdateUnitAndFetchGeneratedValues()
                                                               throws org.opensubsystems.core.error.OSSException
Get query that updates Unit in the database and fetches database generated values such as the updated modification timestamp

Returns:
String - query for simple update or stored procedure call
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getInsertUnit

public java.lang.String getInsertUnit()
                               throws org.opensubsystems.core.error.OSSException
Method returns simple insert unit query. This method is common for all databases and can be overwritten for each specific database schema.

Returns:
String - simple insert unit query
Throws:
org.opensubsystems.core.error.OSSException - - exception during getting query

getUpdateUnit

public java.lang.String getUpdateUnit()
                               throws org.opensubsystems.core.error.OSSException
Method returns simple update unit query. This method is common for all databases and can be overwritten for each specific database schema.

Returns:
String - simple update unit query
Throws:
org.opensubsystems.core.error.OSSException - - exception during getting query

createListIndexes

public void createListIndexes(java.sql.Connection cntDBConnection)
                       throws java.sql.SQLException,
                              org.opensubsystems.core.error.OSSException
Method creates specified LST indexes used for speeding up retrieving data into the list.

Parameters:
cntDBConnection - - valid connection to database
Throws:
java.sql.SQLException - - problem creating the database schema
org.opensubsystems.core.error.OSSException - - problem creating the database schema

getChangeShippedAndAvailableCountSecureSQL

protected abstract java.lang.String getChangeShippedAndAvailableCountSecureSQL()
                                                                        throws org.opensubsystems.core.error.OSSException
Return sql statemnet string for change shipped and availbale in regular item, In regular item both available and shiped have to by nonnegative

Returns:
String - sql statement
Throws:
org.opensubsystems.core.error.OSSException - - error in function

getChangeShippedAndAvailableCountSecureSQLFoundHolder

protected abstract java.lang.String getChangeShippedAndAvailableCountSecureSQLFoundHolder()
                                                                                   throws org.opensubsystems.core.error.OSSException
Return sql statemnet string for chnage shipped and availbale in found holder. In found holder item only shiped have to by nonnegative. Available can be negative.

Returns:
String - sql statement
Throws:
org.opensubsystems.core.error.OSSException - - error in function

getColumns

public java.lang.StringBuffer getColumns(boolean specific,
                                         int[] columns,
                                         java.lang.Object[] prefixes,
                                         java.lang.Object[] postfixes,
                                         java.lang.StringBuffer buffer)
                                  throws org.opensubsystems.core.error.OSSException

Throws:
org.opensubsystems.core.error.OSSException

getSelectUnitById

public java.lang.String getSelectUnitById(int[] columns)
                                   throws org.opensubsystems.core.error.OSSException
Get query to select unit by ID.

Parameters:
columns - - columns to retrieve
Returns:
String - query
Throws:
org.opensubsystems.core.error.OSSException - - and error has occured

getSelectByItemAndCost

public java.lang.String getSelectByItemAndCost()
                                        throws org.opensubsystems.core.error.OSSException
Method returning unit for specific item and cost.

Returns:
String - select by ID query
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getSelectAvailableItems

public java.lang.String getSelectAvailableItems()
                                         throws org.opensubsystems.core.error.OSSException
Method returning sql command for getting available items.

Returns:
String - sql select query
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getSelectUnitsWithoutFoundHolder

public java.lang.String getSelectUnitsWithoutFoundHolder()
                                                  throws org.opensubsystems.core.error.OSSException
Method returning sql command for getting units without found holder.

Returns:
String - sql select query
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getSelectFoundHolder

public java.lang.String getSelectFoundHolder()
                                      throws org.opensubsystems.core.error.OSSException
Method returning unit used as found holder for specific item

Returns:
String - select query
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getDeleteUnitById

public java.lang.String getDeleteUnitById()
Get query to delete particular unit.

Returns:
String - query

getChangeAvailableCountSQL

public java.lang.String getChangeAvailableCountSQL()
                                            throws org.opensubsystems.core.error.OSSException
Get SQL statement to change available count.

Returns:
String - select query
Throws:
org.opensubsystems.core.error.OSSException - - an error accessing database

getChangeShippedAndAvailableCountSQL

public java.lang.String getChangeShippedAndAvailableCountSQL()
                                                      throws org.opensubsystems.core.error.OSSException
Get SQL statement to change shipped and available count.

Returns:
String
Throws:
org.opensubsystems.core.error.OSSException - - an error accessing database

getResetCounts

public java.lang.String getResetCounts()
                                throws org.opensubsystems.core.error.OSSException
Method to get sql for reset counts

Returns:
String - sql for reset counts
Throws:
org.opensubsystems.core.error.OSSException - - an error accessing database

handleSQLException

public void handleSQLException(java.sql.SQLException exc,
                               java.sql.Connection dbConnection,
                               int iOperationType,
                               int iDataType,
                               java.lang.Object data)
                        throws org.opensubsystems.core.error.OSSException

Specified by:
handleSQLException in interface org.opensubsystems.core.persist.db.DatabaseSchema
Overrides:
handleSQLException in class org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl
Throws:
org.opensubsystems.core.error.OSSException


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