Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.udo.cs.miningmart.db
Class DB

    java.lang.Object
      edu.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.31 2006/10/02 08:58:56 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` | `MYSQL` Constant to indicate a MySql DBMS.
`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
`boolean` | `areSomeStatisticsStored(Columnset cs)` This method checks if any statistics for the given columnset are available in the database, so that they do not have to be computed.
`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 `ResultSet`s.
`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.
`void` | `createReverseStepTable()` Creates a table called REVSTEP_T in the M4 schema which is used to link steps that reverse a feature construction to the step that constructed the feature.
`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` | `getAliasExpressionForInnerSelects(java.lang.String aliasName)` Returns a String that can be used to in a SQL statement that involves a SELECT inside a FROM, to alias this inner view definition.
`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)` Returns a Columnset that is attached to one of the concepts of the given case and has the given name.
`java.lang.String` | `getColumnTestQuery(Column col)` Returns a string that can be used as a query.
`M4InterfaceContext` | `getCompilerAccessLogic()`
`java.util.Collection` | `getCrossTablesReferringTo(java.lang.String dbObjectName)` Returns a collection of strings with all the names of DB tables/views that refer to the given table/view and seem to be a cross table.
`java.lang.String` | `getDateComparisonAsSqlString(boolean useBusinessDBMS, java.lang.String dateOrTimeColumnName, java.lang.String dateExpression, boolean greater, boolean orEqual, java.lang.String timeFormat)` Returns an SQL string that can be used in a query.
`java.lang.String` | `getDbNameOfM4Datatype(java.lang.String m4RelDatatypeName, int length, boolean useBusinessDBMS)` This method returns the DBMS-dependent name of the datatype which the current DBMS uses to realize the given M4-Relational Datatype.
`static java.util.HashSet` | `getDirtyObjectsForTable(java.lang.String dbTableName)`
`java.lang.String` | `getFloorExpression()` Returns a String that can be used in a SQL statement and that computes the floor of some expression.
`void` | `getFreshM4Connection()` Closes and re-opens the connection to the M4 database.
`java.lang.String` | `getJdbcDriverClassName(boolean useBusinessDBMS)` Returns the Java class name of the JDBC driver used to access the database.
`short` | `getM4Dbms()`
`java.lang.String` | `getM4InstallationDirectory(boolean useBusinessDBMS)` Returns the Java class name of the JDBC driver used to access the database.
`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.lang.String` | `getM4RelTypeForConceptualType(java.lang.String conceptualType)` Returns the most suitable relational datatype for the given conceptual data type.
`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.lang.String` | `getNameOfDateDatatype()`
`java.lang.String` | `getNameOfNumericDatatype()`
`java.lang.String` | `getNameOfVarcharDatatype(int size)`
`java.util.Collection` | `getNamesOfBusSchemaDbObjects(boolean includeMmTables)` 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()`
`long` | `getNumberOfMonthsBetween(java.lang.String dbObjectName, java.lang.String firstValue, java.lang.String secondValue)`
`static java.util.Collection` | `getObjectsToBeDeletedForTable(java.lang.String dbTableName)`
`java.lang.String` | `getPowerExpression(java.lang.String base, java.lang.String exponent)` Returns a String that can be used in a SQL statement and that computes the power of the base to the exponent.
`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` | `getRoundToDecimalPlacesExpression()` Returns a String that can be used in a SQL statement and that rounds some expression to n decimal places.
`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.
`java.lang.String` | `getSelectStringDistribValuesTimeColumn(java.lang.String colSql, java.lang.String tableName, java.lang.String distribBase)` Returns the SQL string that selects distribution values from the given column (given by its name and the name of its table or view).
`java.lang.String` | `getUniqueRowIdentifier(boolean useBusinessDBMS)` Return the DBMS-dependent string which can be used in a SELECT-Statement in SQL to uniquely identify table rows by an integer.
`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

### MYSQL

    public static final short MYSQL

  Constant to indicate a MySql 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 `HashSet`s 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.
  Throws:
    `java.sql.SQLException`

### 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 M4Exception

  Commit the last transactions in the M4 database.

  Throws:
    `M4Exception`

### 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.

  Parameters:
    `An` - M4Object to be stored in the Cache.
  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

### getSelectStringDistribValuesTimeColumn

    public java.lang.String getSelectStringDistribValuesTimeColumn(java.lang.String colSql,
                                                                   java.lang.String tableName,
                                                                   java.lang.String distribBase)

  Returns the SQL string that selects distribution values from the given column (given by its name and the name of its table or view). The given distribution base determines the granularity of aggregation. In this way daywise or monthwise values can be selected, for example.

  Parameters:
    `colSql` - string that determines the column in the given table or view
    `tableName` - name of a table or view
    `distribBase` - granularity of values to be returned by the query
  Returns:
    a query

### areSomeStatisticsStored

    public boolean areSomeStatisticsStored(Columnset cs)
                                    throws M4Exception

  This method checks if any statistics for the given columnset are available in the database, so that they do not have to be computed.

  Parameters:
    `cs` - the columnset
  Returns:
  Throws:
    `M4Exception`

### 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

### getNameOfNumericDatatype

    public java.lang.String getNameOfNumericDatatype()

### getNameOfVarcharDatatype

    public java.lang.String getNameOfVarcharDatatype(int size)

### getNameOfDateDatatype

    public java.lang.String getNameOfDateDatatype()

### getDbNameOfM4Datatype

    public java.lang.String getDbNameOfM4Datatype(java.lang.String m4RelDatatypeName,
                                                  int length,
                                                  boolean useBusinessDBMS)
                                           throws M4CompilerError

  This method returns the DBMS-dependent name of the datatype which the current DBMS uses to realize the given M4-Relational Datatype.

  Parameters:
    `m4RelDatatypeName` - name of the M4 Relational Datatype
    `length` - Gives a size for the datatype. For example, if the M4 Relational Datatype is NUMBER and length is 10, then the return value will be the String "NUMBER(10)" if the DBMS is Oracle. If this length is not positive, the datatype will be returned without a size, in the example: "NUMBER" The DBMS may not allow lengths at all, in which case also the datatype without a size is returned.
    `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:
    A DBMS-dependent string that contains a datatype name.
  Throws:
    `M4CompilerError`

### getUniqueRowIdentifier

    public java.lang.String getUniqueRowIdentifier(boolean useBusinessDBMS)
                                            throws M4CompilerError

  Return the DBMS-dependent string which can be used in a SELECT-Statement in SQL to uniquely identify table rows by an integer.

  Parameters:
    `useBusinessDBMS` - Set this parameter to TRUE if the unique row identifier will be used in the business data schema. (This is probably the case.) Set it to FALSE if the identifier will be used in the M4 data schema.
  Returns:
    A DBMS-dependent string which identifies table rows by integers in SQL-Statements.
  Throws:
    `M4CompilerError`

### getJdbcDriverClassName

    public java.lang.String getJdbcDriverClassName(boolean useBusinessDBMS)
                                            throws M4CompilerError

  Returns the Java class name of the JDBC driver used to access the database.

  Parameters:
    `useBusinessDBMS` - Set this to TRUE if the JDBC driver for accessing the business data is meant; if FALSE, the driver for the M4 database is used
  Returns:
    a String which is a fully qualified Java class name
  Throws:
    `M4CompilerError`

### getM4InstallationDirectory

    public java.lang.String getM4InstallationDirectory(boolean useBusinessDBMS)
                                                throws M4Exception

  Returns the Java class name of the JDBC driver used to access the database.

  Parameters:
    `useBusinessDBMS` - Set this to TRUE if the JDBC driver for accessing the business data is meant; if FALSE, the driver for the M4 database is used
  Returns:
    a String which is a fully qualified Java class name
  Throws:
    `M4CompilerError`
    `M4Exception`

### getDateComparisonAsSqlString

    public java.lang.String getDateComparisonAsSqlString(boolean useBusinessDBMS,
                                                         java.lang.String dateOrTimeColumnName,
                                                         java.lang.String dateExpression,
                                                         boolean greater,
                                                         boolean orEqual,
                                                         java.lang.String timeFormat)
                                                  throws M4CompilerError

  Returns an SQL string that can be used in a query. The expression returned will evaluate to true if the given firstDate is after the given secondDate and greater is true; or if firstDate is before secondDate and greater is false. The parameter orEqual allows equality of the dates in each case.

  Parameters:
    `useBusinessDBMS` - set it to TRUE if the business DBMS should determine the format of the returned String; set it to FALSE if the M4 DBMS should be used
    `dateOrTimeColumnName` - one date expression (MUST be a column name)
    `dateExpression` - another date expression (can NOT be a column name)
    `greater` - If TRUE, firstDate `>` secondDate is asked for in the returned query; if FALSE, firstDate `<` secondDate is asked for
    `orEqual` - if TRUE, `>=` or `<=` are used for comparison instead of `<` or `>`
    `timeFormat` - a time format to be used for comparison
  Returns:
    an SQL query
  Throws:
    `M4CompilerError`

### getColumnTestQuery

    public java.lang.String getColumnTestQuery(Column col)
                                        throws DbConnectionClosed

  Returns a string that can be used as a query. If the query can be executed without errors, it means that the given Column has a well-formed SQL definition.

  Returns:
    a query string
  Throws:
    `DbConnectionClosed`

### 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(boolean includeMmTables)
                                                      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

  Returns a Columnset that is attached to one of the concepts of the given case and has the given name. If no such Columnset exists, NULL is returned.

  Parameters:
    `nameOfCs` -
    `theCase` -
  Returns:
  Throws:
    `M4Exception`

### isCrossTable

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

  Throws:
    `java.sql.SQLException`
    `DbConnectionClosed`

### getCrossTablesReferringTo

    public java.util.Collection getCrossTablesReferringTo(java.lang.String dbObjectName)
                                                   throws java.sql.SQLException,
                                                          DbConnectionClosed

  Returns a collection of strings with all the names of DB tables/views that refer to the given table/view and seem to be a cross table.

  Parameters:
    `dbObjectName` -
  Returns:
  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`

### getPowerExpression

    public java.lang.String getPowerExpression(java.lang.String base,
                                               java.lang.String exponent)
                                        throws M4Exception

  Returns a String that can be used in a SQL statement and that computes the power of the base to the exponent.

  Parameters:
    `base` -
    `exponent` -
  Returns:
    a string with the power expression
  Throws:
    `M4Exception`

### getFloorExpression

    public java.lang.String getFloorExpression()
                                        throws M4Exception

  Returns a String that can be used in a SQL statement and that computes the floor of some expression. The floor is the largest integer that is smaller than or equal to the value of the expression.

  Returns:
    a string with the floor function name
  Throws:
    `M4Exception`

### getRoundToDecimalPlacesExpression

    public java.lang.String getRoundToDecimalPlacesExpression()
                                                       throws M4Exception

  Returns a String that can be used in a SQL statement and that rounds some expression to n decimal places.

  Returns:
    a string with the rounding function name
  Throws:
    `M4Exception`

### getNumberOfMonthsBetween

    public long getNumberOfMonthsBetween(java.lang.String dbObjectName,
                                         java.lang.String firstValue,
                                         java.lang.String secondValue)
                                  throws M4Exception

  Throws:
    `M4Exception`

### getAliasExpressionForInnerSelects

    public java.lang.String getAliasExpressionForInnerSelects(java.lang.String aliasName)
                                                       throws M4Exception

  Returns a String that can be used to in a SQL statement that involves a SELECT inside a FROM, to alias this inner view definition.

  Parameters:
    `aliasName` -
  Returns:
    a string with the alias expression
  Throws:
    `M4Exception`

### createReverseStepTable

    public void createReverseStepTable()
                                throws M4Exception

  Creates a table called REVSTEP_T in the M4 schema which is used to link steps that reverse a feature construction to the step that constructed the feature.

  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`

### getM4RelTypeForConceptualType

    public java.lang.String getM4RelTypeForConceptualType(java.lang.String conceptualType)

  Returns the most suitable relational datatype for the given conceptual data type.

  Parameters:
    `conceptualType` -
  Returns:

### 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!

  Parameters:
    `a` - `Class` object, subclass of M4Object.
  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.

  Parameters:
    `Columnset` - to be tested
    `step` - the step in which this Columnset was created
  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 `ResultSet`s.

  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`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005