com.ibm.commerce.payments.configurator
Interface IDBMS

All Superinterfaces:
com.ibm.commerce.payments.configurator.IDatabase

public interface IDBMS
extends com.ibm.commerce.payments.configurator.IDatabase

It represents a Database Management System. This is an internal interface meant to be used by the configurator classes. This class is NOT externalized or documented for 3rd party cassettes. Extends IDatabase, so instances of this class can be used in ICassetteConfigurator.addToInstance(IDatabase database, Properties properties) and in ICassetteConfigurator.removeFromInstance(IDatabase database).


Method Summary
 void addCassetteCfg(java.lang.String name, java.lang.String vendor, java.lang.String version)
          Adds a cassette configuration for a Payments Instance.
 boolean checkETillConfigTable()
          Checks for the existence of the ETILLCONFIG table.
 boolean commit()
          Commits pending changes in current transaction.
 void createPMSchema()
          Creates the database to be used by a Payments instance.
 void createPMTables()
          Creates the database tables to be used by a Payments Instance.
 void deletePMSchema()
          Deletes a schema been used by the tables of a Payments Instance.
 void deletePMTables()
          Deletes the database tables used by a Payments Instance.
 java.sql.Connection getConnection()
          Obtains a new connection to the the Database Management System.
 java.lang.String getDbName()
          Gets the name of the Payments instance database.
 java.lang.String getDbOwnerId()
          Gets the owner of the Payments instance tables in the database.
 java.lang.String getDbUserId()
          Gets the user currently connected to the Payments instance database.
 java.lang.String getJdbcDriver()
          Gets the full JDBC Driver
 java.lang.String getJdbcUrl()
          Gets the full JDBC URL
 com.ibm.commerce.payments.configurator.IDatabase getPublicDatabase()
          Gets a reference to the database interface published to 3rd party cassettes.
 java.sql.Connection getSameConnection()
          Obtains the connection been used by this Database Management System.
 java.lang.String getType()
          Gets the type of the database implementation.
 java.util.List queryCassetteCfg()
          Gets the configuration for all the cassettes in a Payments Instance.
 void removeCassetteCfg(java.lang.String cassetteId)
          Removes a cassette configuration for a Payments Instance.
 boolean requiresSchema()
          Checks if the IDBMS implementation requires a database schema before the creation of the tables.
 boolean rollback()
          Cancels pending changes in current transaction.
 void runSQLScript(java.sql.Statement statement, java.lang.String filename)
          Executes an SQL script in the target Database Management System.
 void runSQLScript(java.lang.String filename)
          Executes an SQL script in the target Database Management System.
 java.util.List runSQLScriptInRobustMode(java.lang.String filename)
          Executes an SQL script in the target Database Management System.
 boolean supportsDatabaseCreation()
          Checks if the IDBMS implementation supports the creation of the Payments instance database.
 boolean supportsDatabaseDeletion()
          Checks if the IDBMS implementation supports the deletion of the Payments instance database.
 void updateCassetteVersion(java.lang.String name, java.lang.String version)
          Update the version number for the cassette
 void updateETillConfig(java.lang.String fieldValuePair)
          Updates the ETILLCONFIG table with the field-value pair passed in.
 
Methods inherited from interface com.ibm.commerce.payments.configurator.IDatabase
executeSQLUpdate
 

Method Detail

supportsDatabaseCreation

public boolean supportsDatabaseCreation()
Checks if the IDBMS implementation supports the creation of the Payments instance database.
Returns:
true if the Payments instance database can be created by the IDBMS implementation; false if the database must be created manually

supportsDatabaseDeletion

public boolean supportsDatabaseDeletion()
Checks if the IDBMS implementation supports the deletion of the Payments instance database.
Returns:
true if the Payments instance database can be deleted by the IDBMS implementation; false if the database must be deleted manually

requiresSchema

public boolean requiresSchema()
Checks if the IDBMS implementation requires a database schema before the creation of the tables.
Returns:
true if a database schema needs to be created before the tables are created

createPMSchema

public void createPMSchema()
                    throws com.ibm.commerce.payments.configurator.SchemaCannotBeCreatedException
Creates the database to be used by a Payments instance. Executes successfully when the database is created by this method call or when the database already existed before the method invocation.
Throws:
DatabaseCannotBeCreatedException - Thrown if the database does not exist and cannot be created

deletePMSchema

public void deletePMSchema()
                    throws com.ibm.commerce.payments.configurator.SchemaCannotBeDeletedException
Deletes a schema been used by the tables of a Payments Instance. Executes succesfully when the schema is deleted by this method call or when the schema didn't existed before the method invocation.
Throws:
com.ibm.commerce.payments.configurator.SchemaCannotBeDeletedException - Thrown if the schema exists and cannot be deleted

createPMTables

public void createPMTables()
                    throws com.ibm.commerce.payments.configurator.TablesCannotBeCreatedException
Creates the database tables to be used by a Payments Instance. Executes succesfully when the tables are created by this method call or when the tables already existed before the method invocation.
Throws:
com.ibm.commerce.payments.configurator.TablesCannotBeCreatedException - Thrown if the tables does not exist and cannot be created

deletePMTables

public void deletePMTables()
                    throws com.ibm.commerce.payments.configurator.TablesCannotBeDeletedException
Deletes the database tables used by a Payments Instance. Executes succesfully when the tables are deleted by this method call or when the tables didn't existed before the method invocation.
Throws:
com.ibm.commerce.payments.configurator.TablesCannotBeDeletedException - Thrown if the tables exist and cannot be deleted

getSameConnection

public java.sql.Connection getSameConnection()
Obtains the connection been used by this Database Management System. This method is externalized for the special case where multiple changes to the same set of tables would cause a deadlock if multiple connections are used. The caller should NOT close this connection. The caller SHOULD close any statements that it has created from the connection. Every call to this method will return the same connection.
Returns:
The internal connection to the Database Management System; null if the inner connection has not been initialized

getConnection

public java.sql.Connection getConnection()
Obtains a new connection to the the Database Management System. The caller is responsible to close the connection and any created statements from the connection. Every call to this method will create a new connection.
Specified by:
getConnection in interface com.ibm.commerce.payments.configurator.IDatabase
Returns:
A new connection to the Database Management System; null if a connection cannot be created

queryCassetteCfg

public java.util.List queryCassetteCfg()
Gets the configuration for all the cassettes in a Payments Instance. Queries the CassetteCfg table and returns an ArrayList of cassettes added to this instance.
Returns:
The list of cassettes configuration for the target database system

checkETillConfigTable

public boolean checkETillConfigTable()
Checks for the existence of the ETILLCONFIG table.
Returns:
true if ETILLCONFIG exists; false otherwise

updateETillConfig

public void updateETillConfig(java.lang.String fieldValuePair)
                       throws DatabaseOperationFailedException
Updates the ETILLCONFIG table with the field-value pair passed in. The field_value_pair parm should be a string like: "FIELDNAME=filedValue"
Parameters:
fieldValuePair -  
Throws:
DatabaseOperationFailedException - Thrown if the database operation failed

addCassetteCfg

public void addCassetteCfg(java.lang.String name,
                           java.lang.String vendor,
                           java.lang.String version)
                    throws DatabaseOperationFailedException
Adds a cassette configuration for a Payments Instance. Updates the ETCASSETTECFG table with the new cassette info. The rest of the fields are default.
Parameters:
name - the name of the cassette (shortname - full package is not included)
vendor - the implementor of the cassette
version - the version of the cassette
Throws:
DatabaseOperationFailedException - Thrown if the database operation failed

removeCassetteCfg

public void removeCassetteCfg(java.lang.String cassetteId)
                       throws DatabaseOperationFailedException
Removes a cassette configuration for a Payments Instance. Removes the cassette info from etCassetteCofig table.
Parameters:
name - The name of the cassette
Throws:
DatabaseOperationFailedException - Thrown if the database operation fails

getType

public java.lang.String getType()
Gets the type of the database implementation.
Specified by:
getType in interface com.ibm.commerce.payments.configurator.IDatabase
Returns:
The type of the database (DB2 or Oracle)

getDbOwnerId

public java.lang.String getDbOwnerId()
Gets the owner of the Payments instance tables in the database.
Specified by:
getDbOwnerId in interface com.ibm.commerce.payments.configurator.IDatabase
Returns:
The owner id of the Payments instance tables

getDbUserId

public java.lang.String getDbUserId()
Gets the user currently connected to the Payments instance database.
Specified by:
getDbUserId in interface com.ibm.commerce.payments.configurator.IDatabase
Returns:
The user currently connected to the Payments instance database

getDbName

public java.lang.String getDbName()
Gets the name of the Payments instance database.
Specified by:
getDbName in interface com.ibm.commerce.payments.configurator.IDatabase
Returns:
The name of the Payments instance database

getJdbcUrl

public java.lang.String getJdbcUrl()
Gets the full JDBC URL
Returns:
JDBC URL

getJdbcDriver

public java.lang.String getJdbcDriver()
Gets the full JDBC Driver
Returns:
JDBC Driver

commit

public boolean commit()
Commits pending changes in current transaction.
Returns:
true if operation was completed successfully; false otherwise

rollback

public boolean rollback()
Cancels pending changes in current transaction.
Returns:
true if operation was completed successfully; false otherwise

runSQLScriptInRobustMode

public java.util.List runSQLScriptInRobustMode(java.lang.String filename)
Executes an SQL script in the target Database Management System. This is the code that reads the SQL script file and executes the commands in the file. I'm not sure that File is really the parameter we want here, or something that will pass the contents of the file in a StringBuffer. The ArrayList returned is a list of all the errors encountered while running the script. This method needs to be public so that the PMCassettes class can access it to run the cassette create and delete scripts. The TableManager class (from old framework code) has code in it that runs SQL scripts, but the AS/400 ported that code to make it more robust. I would suggest comparing the two and trying to use the new feautures from the AS/400 code. I think the biggest difference was a boolean parameter that was passed in that told whether to run the script in robust mode or not. On create robust=false. On Delete robust=true. This was so the code would not fail if one table was missing while dropping tables. I believe the execute script code has always replaced the variables in the SQLScript, too. I think we should have different method that does this and is virtual so that each database type that extends DBMS can rewrite this method and replace the variables in its scripts. Maybe this work belongs to DBInfo before DBMS gets the scripts.
Parameters:
fileName - the SQL script to be executed
robust - a flag indicating the operation mode; true means that the script will be executed until the end, even if some errors occur; false means that the script will execute until the first error occur, or the end of the script is reached
Returns:
the list of potential error messages returned by the execution of the script

runSQLScript

public void runSQLScript(java.lang.String filename)
                  throws DatabaseOperationFailedException
Executes an SQL script in the target Database Management System.
Parameters:
filename -  
Throws:
DatabaseOperationFailedException -  

runSQLScript

public void runSQLScript(java.sql.Statement statement,
                         java.lang.String filename)
                  throws DatabaseOperationFailedException
Executes an SQL script in the target Database Management System.
Parameters:
statement -  
filename -  
Throws:
DatabaseOperationFailedException -  

getPublicDatabase

public com.ibm.commerce.payments.configurator.IDatabase getPublicDatabase()
Gets a reference to the database interface published to 3rd party cassettes.
Returns:
the reference of the published interface to 3rd party cassettes

updateCassetteVersion

public void updateCassetteVersion(java.lang.String name,
                                  java.lang.String version)
                           throws DatabaseOperationFailedException
Update the version number for the cassette
Parameters:
name - The cassette name
version - The new version number
Throws:
DatabaseOperationFailedException -