edu.udo.cs.miningmart.db
Class DB

java.lang.Object
  extended byedu.udo.cs.miningmart.db.DB
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CompilerDatabaseService

public class DB
extends java.lang.Object
implements java.io.Serializable

The class DB handles all actions which have to be executed on the database: it makes the connect to a DB on construction and disconnect from the database on finalization, it reads from the metaschema and writes into it. The read data from the database is stored in the corresponding class structure. On writing the information has to be available in the corresponding class structure For each compiler run exactly one object of this class exists. It provides the cache for all M4 objects (ie for their Java representation objects).

Version:
$Id: DB.java,v 1.16 2006/04/11 14:10:16 euler Exp $
Author:
Timm Euler, Martin Scholz
See Also:
Serialized Form

Field Summary
protected  DbCore busiDbc
           
static java.lang.String C_BA
          The String for type "BaseAttribute" used in the M4 schema.
static java.lang.String C_CONC
          The String for type "Concept" used in the M4 schema.
static java.lang.String c_db
           
static java.lang.String C_FEA
          The String for type "Feature" used in the M4 schema.
static java.lang.String c_input
           
static java.lang.String C_MCF
          The String for type "MultiColumnFeature" used in the M4 schema.
static java.lang.String c_mining
           
static java.lang.String c_no
           
static java.lang.String c_output
           
static java.lang.String C_REL
          The String for type "Relation" used in the M4 schema.
static java.lang.String C_VAL
          The String for type "Value" used in the M4 schema.
static java.lang.String c_yes
           
protected  M4InterfaceContext cal
           
protected  boolean computeAllStat
           
static java.util.HashMap dirtyObjectSets
          The data structure for dirty objects.
protected  DbCore m4Dbc
           
static short NO_DBMS
          Constant to indicate no (or an unsupported) DBMS.
static short ORACLE
          Constant to indicate an Oracle DBMS.
static java.lang.String[] ORDER_FOR_WRITING
          Writing the objects in this order prevents us from violating all dependencies except for those between objects in the same table.
static short POSTGRES
          Constant to indicate a Postgres DBMS.
static boolean READ_ONLY
          Currently for debugging only, although we should provide a read-only mode.
 
Constructor Summary
DB(ConfigReader cr, boolean computeStatistics, M4InterfaceContext cal)
          This constructor uses the M4 and Business data connection information that is available from the given ConfigReader object.
DB(DB db, M4InterfaceContext m4i)
           
DB(java.lang.String m4Url, java.lang.String m4DbName, java.lang.String m4User, java.lang.String m4Passwd, java.lang.String dataUrl, java.lang.String dataDbName, java.lang.String dataUser, java.lang.String dataPasswd, boolean computeStatistics, M4InterfaceContext cal)
          The constructor of this class establishes two new database connections.
 
Method Summary
static java.lang.String attribPrefix(java.lang.String attributeName, java.lang.String prefix)
          This method returns a String which can be used to query the database for the given attribute, which should be of type VARCHAR, with the given prefix.
static java.lang.String checkDouble(java.lang.String test)
          Tests if the given String contains a double, and changes funny oracle-formats to java convention.
 void clearM4Cache()
          Emtpies the Cache of M4 objects.
static java.lang.String closeResultSet(java.sql.ResultSet rs)
          This is a service method to comfortably close ResultSets.
 void commitBusinessTransactions()
          Commit the last transactions in the business database.
 void commitM4Transactions()
          Commit the last transactions in the M4 database.
 Columnset createColumnsetFromTable(java.lang.String tableName)
           
 M4Object createNewInstance(java.lang.Class c)
          This method creates actual instances of M4Object classes.
 boolean createSQLView(Columnset cs)
          Create the generated sql definition for a new view or table within the database.
protected  void doPrint(java.lang.Exception ex)
           
protected  void doPrint(java.util.logging.Level verbosity, java.lang.String message)
           
 boolean dropBusinessTable(java.lang.String tableName)
          Try to drop the table with the given name in the business schema, if it exists there.
 boolean dropM4Table(java.lang.String tableName)
          Try to drop the table with the given name in the M4 schema, if it exists there.
 java.lang.String executeBusinessSingleValueSqlRead(java.lang.String query)
           
 java.lang.Long executeBusinessSingleValueSqlReadL(java.lang.String query)
           
 java.sql.ResultSet executeBusinessSqlRead(java.lang.String query)
          Method to comfortably read from the business database.
 void executeBusinessSqlWrite(java.lang.String query)
          Method to comfortably write to the business database.
 java.lang.String executeM4SingleValueSqlRead(java.lang.String query)
           
 java.lang.Long executeM4SingleValueSqlReadL(java.lang.String query)
           
 java.sql.ResultSet executeM4SqlRead(java.lang.String query)
          Method to comfortably read from the M4 database.
 void executeM4SqlWrite(java.lang.String query)
          Method to comfortably write to the M4 database.
 java.lang.String getAttributeForColumnNames()
          Returns the name of the column that contains the column names.
 java.lang.String getAttributeForColumnTypes()
          Returns the name of the column that contains the column types.
 DbCore getBusinessDbCore()
           
 short getBusinessDbms()
           
 java.lang.String getBusinessSchemaName()
          Returns the name of the business data schema.
 Print getCasePrintObject()
           
 Columnset getColumnsetFromCase(java.lang.String nameOfCs, Case theCase)
           
 M4InterfaceContext getCompilerAccessLogic()
           
static java.util.HashSet getDirtyObjectsForTable(java.lang.String dbTableName)
           
 void getFreshM4Connection()
          Closes and re-opens the connection to the M4 database.
 short getM4Dbms()
           
 M4Object getM4Object(long Id, java.lang.Class m4ClassObject)
          This method tries to find an object with the given Id in the Cache.
 M4Object getM4ObjectFromCache(long Id)
          This method returns the object with the given Id if it is in the Cache.
 java.lang.String getM4RelationalDatatypeName(java.lang.String dbTypeName, boolean useBusinessDBMS)
          This method returns the M4-Relational Datatype that corresponds to the given DBMS-dependent name of a datatype.
 java.util.Map getMapOfForeignKeyReferences(Columnset cs, Case currentCase)
          Returns a Map that maps every column of the given Columnset to a Columnset whose primary key it references, or to null if no such Columnset exists.
 java.util.Collection getNamesOfBusSchemaDbObjects()
          Returns the names of all Views and Tables in the business data schema that have not been created by the compiler for the current Case.
 java.util.Collection getNamesOfDbObjectsInTrash()
          Returns the names of all Views and Tables (in the business schema) that have been created by the compiler for the current Case.
 long getNextM4SequenceValue()
           
static java.util.Collection getObjectsToBeDeletedForTable(java.lang.String dbTableName)
           
 java.util.Collection getPrimaryKeysFromDbSchema(Columnset cs)
          Returns all Columns of the given Columnset that form the primary key of that Columnset according to the SQL constraints in the DB.
 java.lang.String getSelectStringAllBusDataTables()
          Returns the SQL String that selects all table names from the business data schema.
 java.lang.String getSelectStringAllBusDataViews()
          Returns the SQL String that selects all view names from the business data schema.
 java.lang.String getSelectStringAllColumnsForDbObject(java.lang.String dbObjectName)
          Returns the SQL String that selects all column names for the given Table or View name from the business data schema.
 boolean isBusinessTable(java.lang.String dbObjectName)
           
 boolean isBusinessView(java.lang.String dbObjectName)
           
 boolean isCrossTable(java.lang.String dbObjectName)
           
 boolean isForeignKeyColumn(Column theColumn)
          Returns true iff the given column is declared to refer as a foreign key to a different DB table in the business database.
 boolean isM4Table(java.lang.String dbObjectName)
           
 boolean isM4View(java.lang.String dbObjectName)
           
 boolean isPrimaryKeyColumn(Column theColumn)
          Returns true iff the given column is declared to act as a primary key of its DB table in the business database.
 void putM4ObjectToCache(M4Object m4o)
          This method stores an M4 object in the Cache, using its ID as the key for the underlying data structure.
static java.lang.String quote(java.lang.String sql)
          Put "'" around the string and replace all "'" occuring inside by "''".
 void removeM4ObjectFromCache(M4Object m4o)
          This method should only be called from the generic delete method in M4Data.
 void rollbackOnM4()
          Roll back the last transactions (since the last commit) in the M4 database.
 boolean tableExistsInBusinessSchema(java.lang.String tableName)
           
 boolean tableExistsInM4(java.lang.String tableName)
           
 void updateDatabase()
          This is the main method for writing updates back to the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m4Dbc

protected final transient DbCore m4Dbc

busiDbc

protected final transient DbCore busiDbc

NO_DBMS

public static final short NO_DBMS
Constant to indicate no (or an unsupported) DBMS.

See Also:
Constant Field Values

ORACLE

public static final short ORACLE
Constant to indicate an Oracle DBMS.

See Also:
Constant Field Values

POSTGRES

public static final short POSTGRES
Constant to indicate a Postgres DBMS.

See Also:
Constant Field Values

c_yes

public static final java.lang.String c_yes
See Also:
Constant Field Values

c_no

public static final java.lang.String c_no
See Also:
Constant Field Values

c_output

public static final java.lang.String c_output
See Also:
Constant Field Values

c_input

public static final java.lang.String c_input
See Also:
Constant Field Values

c_db

public static final java.lang.String c_db
See Also:
Constant Field Values

c_mining

public static final java.lang.String c_mining
See Also:
Constant Field Values

C_VAL

public static java.lang.String C_VAL
The String for type "Value" used in the M4 schema.


C_CONC

public static java.lang.String C_CONC
The String for type "Concept" used in the M4 schema.


C_REL

public static java.lang.String C_REL
The String for type "Relation" used in the M4 schema.


C_BA

public static java.lang.String C_BA
The String for type "BaseAttribute" used in the M4 schema.


C_MCF

public static java.lang.String C_MCF
The String for type "MultiColumnFeature" used in the M4 schema.


C_FEA

public static java.lang.String C_FEA
The String for type "Feature" used in the M4 schema.


computeAllStat

protected boolean computeAllStat

cal

protected transient M4InterfaceContext cal

READ_ONLY

public static final boolean READ_ONLY
Currently for debugging only, although we should provide a read-only mode.

See Also:
Constant Field Values

ORDER_FOR_WRITING

public static final java.lang.String[] ORDER_FOR_WRITING
Writing the objects in this order prevents us from violating all dependencies except for those between objects in the same table.


dirtyObjectSets

public static final java.util.HashMap dirtyObjectSets
The data structure for dirty objects. The keys are table names, the values are HashSets of dirty M4Data objects residing in these tables. This data structure should only be manipulated directly by the methods getDirtyObjectsForTable(String) and clearDirtyObjectSets()!

Constructor Detail

DB

public DB(java.lang.String m4Url,
          java.lang.String m4DbName,
          java.lang.String m4User,
          java.lang.String m4Passwd,
          java.lang.String dataUrl,
          java.lang.String dataDbName,
          java.lang.String dataUser,
          java.lang.String dataPasswd,
          boolean computeStatistics,
          M4InterfaceContext cal)
   throws java.sql.SQLException
The constructor of this class establishes two new database connections. Autocommit is set to false, so transaction management must be done individually by the database functions. The first database connection is for the metadata and can be accessed with "getDatabaseConnectionForM4()"; the second is used for business data and can be accessed with "getDatabaseConnectionForData()". If the second set of connection parameters given to this constructor is null, the two connections are the same.

Parameters:
m4Url - Prefix of the M4 database url
m4DbName - name of the M4 database
m4User - name of the M4 database user
m4Passwd - password for the M4 database user
dataUrl - Prefix of the business database url
dataDbName - name of the business database
dataUser - name of the business database user
dataPasswd - password for the business database user
computeStatistics - If FALSE, never compute statistics for a column; if TRUE, do it always. (deprecated)
cal - the CompilerAccessLogic object of the Thread.

DB

public DB(ConfigReader cr,
          boolean computeStatistics,
          M4InterfaceContext cal)
   throws java.sql.SQLException
This constructor uses the M4 and Business data connection information that is available from the given ConfigReader object.

Parameters:
cr - A ConfigReader object to get the data connection information from.
computeStatistics - If FALSE, never compute statistics for a column; if TRUE, do it always. (deprecated)
cal - the CompilerAccessLogic object of the Thread.
Throws:
java.sql.SQLException

DB

public DB(DB db,
          M4InterfaceContext m4i)
Parameters:
db - an existing DB connection to copy the connection data from and to share the cache with.
m4i - the M4InterfaceContext to use
Method Detail

getCasePrintObject

public Print getCasePrintObject()

getFreshM4Connection

public void getFreshM4Connection()
                          throws java.sql.SQLException,
                                 DbConnectionClosed
Closes and re-opens the connection to the M4 database. This may be necessary to reduce the number of open database cursors.

Throws:
java.sql.SQLException
DbConnectionClosed

getM4Dbms

public short getM4Dbms()
                throws DbConnectionClosed
Throws:
DbConnectionClosed

getBusinessDbms

public short getBusinessDbms()
                      throws DbConnectionClosed
Throws:
DbConnectionClosed

getBusinessSchemaName

public java.lang.String getBusinessSchemaName()
Returns the name of the business data schema.

Returns:
a String (name of business data schema)

commitM4Transactions

public void commitM4Transactions()
                          throws java.sql.SQLException,
                                 DbConnectionClosed
Commit the last transactions in the M4 database.

Throws:
java.sql.SQLException
DbConnectionClosed

commitBusinessTransactions

public void commitBusinessTransactions()
                                throws java.sql.SQLException,
                                       DbConnectionClosed
Commit the last transactions in the business database.

Throws:
java.sql.SQLException
DbConnectionClosed

rollbackOnM4

public void rollbackOnM4()
                  throws java.sql.SQLException,
                         DbConnectionClosed
Roll back the last transactions (since the last commit) in the M4 database.

Throws:
java.sql.SQLException
DbConnectionClosed

getM4Object

public M4Object getM4Object(long Id,
                            java.lang.Class m4ClassObject)
                     throws M4Exception
This method tries to find an object with the given Id in the Cache. If it is there, the cached object is returned. Otherwise the given object is loaded (filled with information from the database) and returned.

Parameters:
Id - The unique M4 Id of the object to be looked up.
m4ClassObject - This class will be instiated and filled if no object with the given Id is in the Cache. The class specified has to be a subclass of M4Object!
Returns:
A complete M4Object.
Throws:
M4Exception

clearM4Cache

public void clearM4Cache()
Emtpies the Cache of M4 objects. Do not use this method unless you know what you are doing.


getM4ObjectFromCache

public M4Object getM4ObjectFromCache(long Id)
This method returns the object with the given Id if it is in the Cache.

Parameters:
Id - The unique M4 Id of the object to be loaded.
Returns:
An M4Object if an object with the given Id is in the Cache; null otherwise.

putM4ObjectToCache

public void putM4ObjectToCache(M4Object m4o)
                        throws M4Exception
This method stores an M4 object in the Cache, using its ID as the key for the underlying data structure.

Throws:
M4Exception - if the object is null or has an ID of 0.

removeM4ObjectFromCache

public void removeM4ObjectFromCache(M4Object m4o)
This method should only be called from the generic delete method in M4Data.

Parameters:
m4o - the M4Object to remove from the cache because it has been deleted on M4 intervace level.

attribPrefix

public static java.lang.String attribPrefix(java.lang.String attributeName,
                                            java.lang.String prefix)
This method returns a String which can be used to query the database for the given attribute, which should be of type VARCHAR, with the given prefix.

Parameters:
attributeName - Name of the attribute
prefix - The prefix String
Returns:
A string for a database query

quote

public static java.lang.String quote(java.lang.String sql)
Put "'" around the string and replace all "'" occuring inside by "''".

Parameters:
sql - The String to be quoted
Returns:
the quoted String

checkDouble

public static java.lang.String checkDouble(java.lang.String test)
                                    throws M4Exception
Tests if the given String contains a double, and changes funny oracle-formats to java convention.

Throws:
M4Exception

getSelectStringAllBusDataTables

public java.lang.String getSelectStringAllBusDataTables()
Returns the SQL String that selects all table names from the business data schema.

Returns:
An SQL String

getSelectStringAllBusDataViews

public java.lang.String getSelectStringAllBusDataViews()
Returns the SQL String that selects all view names from the business data schema.

Returns:
An SQL String

getSelectStringAllColumnsForDbObject

public java.lang.String getSelectStringAllColumnsForDbObject(java.lang.String dbObjectName)
Returns the SQL String that selects all column names for the given Table or View name from the business data schema.

Parameters:
dbObjectName - Name of a table or view in the business data schema
Returns:
An SQL String

getAttributeForColumnNames

public java.lang.String getAttributeForColumnNames()
Returns the name of the column that contains the column names.

Returns:
the name of the column that contains the column names

getAttributeForColumnTypes

public java.lang.String getAttributeForColumnTypes()
Returns the name of the column that contains the column types.

Returns:
the name of the column that contains the column types

getNamesOfBusSchemaDbObjects

public java.util.Collection getNamesOfBusSchemaDbObjects()
                                                  throws M4Exception
Returns the names of all Views and Tables in the business data schema that have not been created by the compiler for the current Case.

Returns:
a collection of names of views and tables
Throws:
M4Exception

getNamesOfDbObjectsInTrash

public java.util.Collection getNamesOfDbObjectsInTrash()
                                                throws M4Exception
Returns the names of all Views and Tables (in the business schema) that have been created by the compiler for the current Case.

Returns:
a collection of names of views and tables
Throws:
M4Exception

getPrimaryKeysFromDbSchema

public java.util.Collection getPrimaryKeysFromDbSchema(Columnset cs)
                                                throws M4Exception
Returns all Columns of the given Columnset that form the primary key of that Columnset according to the SQL constraints in the DB.

Parameters:
cs - the given Columnset
Returns:
a Collection of Columns
Throws:
M4Exception

getMapOfForeignKeyReferences

public java.util.Map getMapOfForeignKeyReferences(Columnset cs,
                                                  Case currentCase)
                                           throws M4Exception
Returns a Map that maps every column of the given Columnset to a Columnset whose primary key it references, or to null if no such Columnset exists. On Java M4 level the returned Columnsets are created if they do not exist yet.

Parameters:
cs - the given Columnset
currentCase - the Case to which the given Columnset belongs/should belong
Returns:
a Map mapping Columns to Columnsets
Throws:
M4Exception

createColumnsetFromTable

public Columnset createColumnsetFromTable(java.lang.String tableName)
                                   throws M4Exception
Throws:
M4Exception

getColumnsetFromCase

public Columnset getColumnsetFromCase(java.lang.String nameOfCs,
                                      Case theCase)
                               throws M4Exception
Throws:
M4Exception

isCrossTable

public boolean isCrossTable(java.lang.String dbObjectName)
                     throws java.sql.SQLException,
                            DbConnectionClosed
Throws:
java.sql.SQLException
DbConnectionClosed

dropBusinessTable

public boolean dropBusinessTable(java.lang.String tableName)
                          throws M4Exception
Try to drop the table with the given name in the business schema, if it exists there. Returns TRUE iff the table had existed, FALSE otherwise.

Parameters:
tableName - the name of the table to be dropped
Returns:
TRUE iff the table had existed before it was removed, FALSE if nothing was done.
Throws:
M4Exception

dropM4Table

public boolean dropM4Table(java.lang.String tableName)
                    throws M4Exception
Try to drop the table with the given name in the M4 schema, if it exists there. Returns TRUE iff the table had existed, FALSE otherwise.

Parameters:
tableName - the name of the table to be dropped
Returns:
TRUE iff the table had existed before it was removed, FALSE if nothing was done.
Throws:
M4Exception

isBusinessTable

public boolean isBusinessTable(java.lang.String dbObjectName)
                        throws java.sql.SQLException,
                               DbConnectionClosed
Throws:
java.sql.SQLException
DbConnectionClosed

isBusinessView

public boolean isBusinessView(java.lang.String dbObjectName)
                       throws java.sql.SQLException,
                              DbConnectionClosed
Throws:
java.sql.SQLException
DbConnectionClosed

isM4Table

public boolean isM4Table(java.lang.String dbObjectName)
                  throws java.sql.SQLException,
                         DbConnectionClosed
Throws:
java.sql.SQLException
DbConnectionClosed

isM4View

public boolean isM4View(java.lang.String dbObjectName)
                 throws java.sql.SQLException,
                        DbConnectionClosed
Throws:
java.sql.SQLException
DbConnectionClosed

tableExistsInM4

public boolean tableExistsInM4(java.lang.String tableName)
                        throws M4Exception
Throws:
M4Exception

tableExistsInBusinessSchema

public boolean tableExistsInBusinessSchema(java.lang.String tableName)
                                    throws M4Exception
Throws:
M4Exception

executeM4SqlWrite

public void executeM4SqlWrite(java.lang.String query)
                       throws java.sql.SQLException,
                              DbConnectionClosed
Method to comfortably write to the M4 database.

Parameters:
query - an SQL query to be executed. This has to be a write operation to the M4 database, or an SQL string to execute a procedure in the M4 schema.
Throws:
java.sql.SQLException
DbConnectionClosed

executeBusinessSqlWrite

public void executeBusinessSqlWrite(java.lang.String query)
                             throws java.sql.SQLException,
                                    DbConnectionClosed
Method to comfortably write to the business database.

Parameters:
query - an SQL query to be executed. This has to be a write operation to the business database, or an SQL string to execute a procedure in the business schema.
Throws:
java.sql.SQLException
DbConnectionClosed

executeM4SqlRead

public java.sql.ResultSet executeM4SqlRead(java.lang.String query)
                                    throws java.sql.SQLException,
                                           DbConnectionClosed
Method to comfortably read from the M4 database. The caller has to close the returned ResultSet after usage!

Parameters:
query - an SQL query to be executed. This has to be a read operation on the M4 database.
Returns:
the corresponding ResultSet
Throws:
java.sql.SQLException
DbConnectionClosed

executeBusinessSqlRead

public java.sql.ResultSet executeBusinessSqlRead(java.lang.String query)
                                          throws java.sql.SQLException,
                                                 DbConnectionClosed
Method to comfortably read from the business database. The caller has to close the returned ResultSet after usage!

Parameters:
query - an SQL query to be executed. This has to be a read operation on the business database.
Returns:
the corresponding ResultSet
Throws:
java.sql.SQLException
DbConnectionClosed

executeM4SingleValueSqlReadL

public java.lang.Long executeM4SingleValueSqlReadL(java.lang.String query)
                                            throws java.sql.SQLException,
                                                   DbConnectionClosed
Throws:
java.sql.SQLException
DbConnectionClosed
See Also:
In contrast to that method, this method creates and then closes its own Statement.

executeBusinessSingleValueSqlReadL

public java.lang.Long executeBusinessSingleValueSqlReadL(java.lang.String query)
                                                  throws java.sql.SQLException,
                                                         DbConnectionClosed
Throws:
java.sql.SQLException
DbConnectionClosed
See Also:
In contrast to that method, this method creates and then closes its own Statement.

executeM4SingleValueSqlRead

public java.lang.String executeM4SingleValueSqlRead(java.lang.String query)
                                             throws java.sql.SQLException,
                                                    DbConnectionClosed
Throws:
java.sql.SQLException
DbConnectionClosed
See Also:
In contrast to that method, this method creates and then closes its own Statement.

executeBusinessSingleValueSqlRead

public java.lang.String executeBusinessSingleValueSqlRead(java.lang.String query)
                                                   throws java.sql.SQLException,
                                                          DbConnectionClosed
Throws:
java.sql.SQLException
DbConnectionClosed
See Also:
In contrast to that method, this method creates and then closes its own Statement.

isForeignKeyColumn

public boolean isForeignKeyColumn(Column theColumn)
                           throws M4Exception
Returns true iff the given column is declared to refer as a foreign key to a different DB table in the business database.

Parameters:
theColumn - the column for which to decide if it contains a foreign key
Returns:
true if it is a foreign key column in its columnset
Throws:
M4Exception

isPrimaryKeyColumn

public boolean isPrimaryKeyColumn(Column theColumn)
                           throws M4Exception
Returns true iff the given column is declared to act as a primary key of its DB table in the business database.

Parameters:
theColumn - the column for which to decide if it contains a primary key
Returns:
true if it is a primary key column in its columnset
Throws:
M4Exception

getM4RelationalDatatypeName

public java.lang.String getM4RelationalDatatypeName(java.lang.String dbTypeName,
                                                    boolean useBusinessDBMS)
                                             throws M4Exception
This method returns the M4-Relational Datatype that corresponds to the given DBMS-dependent name of a datatype.

Parameters:
dbTypeName - name of the DBMS-dependent datatype
useBusinessDBMS - Set this parameter to TRUE if the datatype should be looked up in the DB that holds the business data schema. Set it to FALSE if it should be looked up in the M4 schema DB.
Returns:
An M4 relational datatype name.
Throws:
M4Exception

getNextM4SequenceValue

public long getNextM4SequenceValue()
                            throws DbConnectionClosed,
                                   M4Exception
Returns:
the value returned by the sequence installed in the M4 schema.
Throws:
M4Exception - if for some reason the sequence does not return a value
DbConnectionClosed

doPrint

protected void doPrint(java.util.logging.Level verbosity,
                       java.lang.String message)

doPrint

protected void doPrint(java.lang.Exception ex)

getCompilerAccessLogic

public M4InterfaceContext getCompilerAccessLogic()

getBusinessDbCore

public DbCore getBusinessDbCore()
                         throws DbConnectionClosed
Throws:
DbConnectionClosed

createNewInstance

public M4Object createNewInstance(java.lang.Class c)
                           throws M4Exception
This method creates actual instances of M4Object classes. Therefore it cannot be implemented against the abstract interface, but deals with the concrete implementation, in this case the classes from edu.udo.cs.miningmart.m4.core. Therefore it must always be called with core classes!

Returns:
a new object of this class.
Throws:
M4Exception

createSQLView

public boolean createSQLView(Columnset cs)
                      throws M4Exception
Create the generated sql definition for a new view or table within the database. Returns TRUE if the table had to be materialised.

Returns:
TRUE if a table was created, FALSE if a view was created
Throws:
M4Exception

closeResultSet

public static java.lang.String closeResultSet(java.sql.ResultSet rs)
This is a service method to comfortably close ResultSets.

Parameters:
rs - a ResultSet to be closed or null to do nothing.
Returns:
the message of an SQLException or null if no error occured (or if rs was null).

getDirtyObjectsForTable

public static java.util.HashSet getDirtyObjectsForTable(java.lang.String dbTableName)
Returns:
the HashSet of dirty objects for the given M4 database table name. Should only be used by the methods for setting objects dirty and clean!

getObjectsToBeDeletedForTable

public static java.util.Collection getObjectsToBeDeletedForTable(java.lang.String dbTableName)
                                                          throws M4Exception
Throws:
M4Exception

updateDatabase

public void updateDatabase()
                    throws M4Exception
This is the main method for writing updates back to the database. First all objects changed in a way relevant to their database representation will be updated, new objects will be inserted. This happens table by table, so that all dependencies are respected. Finally all objects to be deleted will be removed from the database. Storing and deleting are done by generic methods. Objects that need to update additional information like cross-tables should override the method storeLocal().

Throws:
M4Exception


Copyright © 2001-2005