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 CompilerDatabaseService

    java.lang.Object
      edu.udo.cs.miningmart.db.DB
          edu.udo.cs.miningmart.db.CompilerDatabaseService

All Implemented Interfaces:
  BusinessDbConnectionSource, java.io.Serializable

    public class CompilerDatabaseService

extends DB
implements BusinessDbConnectionSource

This class extends the class `DB` to serve as a collection of service and convenience methods for the M4 compiler.

Version:
  $Id: CompilerDatabaseService.java,v 1.14 2006/09/29 17:20:01 euler Exp $
Author:
  Timm Euler
See Also:
  `edu.udo.cs.miningmart.m4.core.utils.DB`, Serialized Form

Field Summary

Fields inherited from class edu.udo.cs.miningmart.db.DB
`busiDbc, C_BA, C_CONC, c_db, C_FEA, c_input, C_MCF, c_mining, c_no, c_output, C_REL, C_VAL, c_yes, cal, computeAllStat, dirtyObjectSets, m4Dbc, MYSQL, NO_DBMS, ORACLE, ORDER_FOR_WRITING, POSTGRES, READ_ONLY`

Constructor Summary
`CompilerDatabaseService(ConfigReader cr, boolean computeStatistics, M4InterfaceContext cal)`
`CompilerDatabaseService(DB db, M4InterfaceContext m4i)`
`CompilerDatabaseService(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)` Constructor for CompilerDatabaseService.

Method Summary
`void` | `addFkConstraintToTrash(java.lang.String tableName, java.lang.String constraintName, java.lang.String schemaName, long stepId)` If an operator adds a foreign key constraint to a database table, it must call this method so that this information can be kept.
`void` | `addFunctionToTrash(java.lang.String functionName, java.lang.String schemaName, long stepId)` If an operator creates a function in the Database, it must call this method so that this information can be kept.
`void` | `addIndexToTrash(java.lang.String indexName, java.lang.String schemaName, long stepId)` If an operator creates an index in the Database, it must call this method so that this information can be kept.
`void` | `addPkConstraintToTrash(java.lang.String tableName, java.lang.String constraintName, java.lang.String schemaName, long stepId)` If an operator adds a primary key constraint to a database table, it must call this method so that this information can be kept.
`void` | `addTableToTrash(java.lang.String tableName, java.lang.String schemaName, long stepId)` If an operator creates an actual table in the Database, it must call this method so that this information can be kept.
`void` | `addViewToTrash(java.lang.String viewName, java.lang.String schemaName, long stepId)` If an operator creates an actual view in the Database, it must call this method so that this information can be kept.
`java.lang.String` | `computeNumberOfDistinctElements(Column col)` Computes the number of distinct elements present in the column.
`java.lang.String` | `computeNumberOfElementsForValue(Column col, java.lang.String value)` Computes the number of entries in the given column which have the given value.
`java.lang.String` | `computeSum(Column col)` Computes the sum of the entries in the given column.
`boolean` | `createSQLView(Columnset cs, Step step)` Overwrites the superclass method to add the created view or table to the trash.
`void` | `executeDBProcedure(java.lang.String procedureName, java.lang.String[] parameters, boolean businessDb)` This method executes a Stored Procedure in the database.
`DbCore` | `getBusinessDbCore()`
`java.lang.String[]` | `getCountOfElements(Column col)` This method returns an array of Value objects whose value is a String of the form 'count, element' for each element in the column.
`java.lang.String[]` | `getCountOfElements(Column colCA, Column colTA)` This method returns an array of Value objects whose value is a String of the form 'count, elementTA, elementCA' for each element in the TA and CA column(s).
`java.lang.String[]` | `getCountOfElements(Column colCA, Column colTA, long sampleSize)` This method returns an array of String objects of the form 'count, elementTA, elementCA' for each element in the TA and CA column(s).
`java.sql.Connection` | `getDatabaseConnectionForData()` This method may be needed to provide wrappers with a database connection to the business database.
`java.util.Collection` | `getDeviatingValues(Column col, java.lang.String[] expectedValues)` Compares the distinct values that actually occur in the given column with the values given in the String array.
`java.lang.String[]` | `getDistinctElements(Column col)` Return the different values that occur in this column in the database in a String array.
`java.lang.String[]` | `getDistinctElements(long columnId)` Return the different values that occur in this column in the database in a String array.
`java.lang.String[]` | `getDistinctElementsWithoutNull(Column col)` Return the different non-null values that occur in this column in the database in a String array.
`java.lang.String[][]` | `getFrquencyTable(Column theClassAttribute, Feature[] theAttributes, java.lang.String[] classValues)`
`java.util.Collection` | `getInputConceptsFor(Step step)` This method should only be used by the compiler's control structure.
`java.lang.String` | `getSelectStringForColumnDataType(java.lang.String owner, java.lang.String tableName, java.lang.String columnName)` This method returns the DBMS-dependent SQL command that returns the name of the datatype of the given column in the given table or view (which is owned by the given owner).
`long` | `readCaseIdForStepId(long stepId)` Returns the case id for the given step.
`long` | `testSQLColumn(Column col)` This method checks if the generated sql-string for a new column is executable on the database.

Methods inherited from class edu.udo.cs.miningmart.db.DB
`areSomeStatisticsStored, attribPrefix, checkDouble, clearM4Cache, closeResultSet, commitBusinessTransactions, commitM4Transactions, createColumnsetFromTable, createNewInstance, createReverseStepTable, createSQLView, doPrint, doPrint, dropBusinessTable, dropM4Table, executeBusinessSingleValueSqlRead, executeBusinessSingleValueSqlReadL, executeBusinessSqlRead, executeBusinessSqlWrite, executeM4SingleValueSqlRead, executeM4SingleValueSqlReadL, executeM4SqlRead, executeM4SqlWrite, getAliasExpressionForInnerSelects, getAttributeForColumnNames, getAttributeForColumnTypes, getBusinessDbms, getBusinessSchemaName, getCasePrintObject, getColumnsetFromCase, getColumnTestQuery, getCompilerAccessLogic, getCrossTablesReferringTo, getDateComparisonAsSqlString, getDbNameOfM4Datatype, getDirtyObjectsForTable, getFloorExpression, getFreshM4Connection, getJdbcDriverClassName, getM4Dbms, getM4InstallationDirectory, getM4Object, getM4ObjectFromCache, getM4RelationalDatatypeName, getM4RelTypeForConceptualType, getMapOfForeignKeyReferences, getNameOfDateDatatype, getNameOfNumericDatatype, getNameOfVarcharDatatype, getNamesOfBusSchemaDbObjects, getNamesOfDbObjectsInTrash, getNextM4SequenceValue, getNumberOfMonthsBetween, getObjectsToBeDeletedForTable, getPowerExpression, getPrimaryKeysFromDbSchema, getRoundToDecimalPlacesExpression, getSelectStringAllBusDataTables, getSelectStringAllBusDataViews, getSelectStringAllColumnsForDbObject, getSelectStringDistribValuesTimeColumn, getUniqueRowIdentifier, isBusinessTable, isBusinessView, isCrossTable, isForeignKeyColumn, isM4Table, isM4View, isPrimaryKeyColumn, putM4ObjectToCache, quote, removeM4ObjectFromCache, rollbackOnM4, tableExistsInBusinessSchema, tableExistsInM4, updateDatabase`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface edu.udo.cs.miningmart.storedProcedures.BusinessDbConnectionSource
`getNameOfNumericDatatype`

Constructor Detail

### CompilerDatabaseService

    public CompilerDatabaseService(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

  Constructor for CompilerDatabaseService.

  Parameters:
    `m4Url` -
    `m4DbName` -
    `m4User` -
    `m4Passwd` -
    `dataUrl` -
    `dataDbName` -
    `dataUser` -
    `dataPasswd` -
    `computeStatistics` -
    `cal` -
  Throws:
    `java.sql.SQLException`
  See Also:
    `DB`

### CompilerDatabaseService

    public CompilerDatabaseService(ConfigReader cr,
                                   boolean computeStatistics,
                                   M4InterfaceContext cal)
                            throws java.sql.SQLException

Throws:
  `java.sql.SQLException`
See Also:
  `DB`

### CompilerDatabaseService

    public CompilerDatabaseService(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

### createSQLView

    public boolean createSQLView(Columnset cs,
                                 Step step)
                          throws M4CompilerError

  Overwrites the superclass method to add the created view or table to the trash.

  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:
    `M4CompilerError`

### addTableToTrash

    public void addTableToTrash(java.lang.String tableName,
                                java.lang.String schemaName,
                                long stepId)
                         throws M4CompilerError

  If an operator creates an actual table in the Database, it must call this method so that this information can be kept. The table will be deleted once all metadata created in the given step is deleted!

  Parameters:
    `tableName` - Name of the table.
    `schemaName` - Name of the db schema in which the table lives.
    `stepId` - M4 Id of the step in which the table was created.
  Throws:
    `M4CompilerError`

### addPkConstraintToTrash

    public void addPkConstraintToTrash(java.lang.String tableName,
                                       java.lang.String constraintName,
                                       java.lang.String schemaName,
                                       long stepId)
                                throws M4CompilerError

  If an operator adds a primary key constraint to a database table, it must call this method so that this information can be kept. The constraint will be deleted once all metadata created in the given step are deleted!

  Parameters:
    `tableName` - Name of the altered table.
    `constraintName` - Name of the database constraint
    `schemaName` - Name of the db schema in which the table lives.
    `stepId` - M4 Id of the step in which the table was created.
  Throws:
    `M4CompilerError`

### addFkConstraintToTrash

    public void addFkConstraintToTrash(java.lang.String tableName,
                                       java.lang.String constraintName,
                                       java.lang.String schemaName,
                                       long stepId)
                                throws M4CompilerError

  If an operator adds a foreign key constraint to a database table, it must call this method so that this information can be kept. The constraint will be deleted once all metadata created in the given step are deleted!

  Parameters:
    `tableName` - Name of the altered table.
    `constraintName` - Name of the database constraint
    `schemaName` - Name of the db schema in which the table lives.
    `stepId` - M4 Id of the step in which the table was created.
  Throws:
    `M4CompilerError`

### addFunctionToTrash

    public void addFunctionToTrash(java.lang.String functionName,
                                   java.lang.String schemaName,
                                   long stepId)
                            throws M4CompilerError

  If an operator creates a function in the Database, it must call this method so that this information can be kept. The function will be deleted once all metadata created in the given step is deleted!

  Parameters:
    `functionName` - Name of the function.
    `schemaName` - Name of the db schema in which the function lives.
    `stepId` - M4 Id of the step in which the function was created.
  Throws:
    `M4CompilerError`

### addIndexToTrash

    public void addIndexToTrash(java.lang.String indexName,
                                java.lang.String schemaName,
                                long stepId)
                         throws M4CompilerError

  If an operator creates an index in the Database, it must call this method so that this information can be kept. The index will be deleted once all metadata created in the given step is deleted!

  Parameters:
    `indexName` - Name of the index.
    `schemaName` - Name of the db schema in which the index lives.
    `stepId` - M4 Id of the step in which the index was created.
  Throws:
    `M4CompilerError`

### addViewToTrash

    public void addViewToTrash(java.lang.String viewName,
                               java.lang.String schemaName,
                               long stepId)
                        throws M4CompilerError

  If an operator creates an actual view in the Database, it must call this method so that this information can be kept. The view will be deleted once all metadata created in the given step is deleted!

  Parameters:
    `viewName` - Name of the view.
    `schemaName` - Name of the db schema in which the view lives.
    `stepId` - M4 Id of the step in which the view was created.
  Throws:
    `M4CompilerError`

### getDatabaseConnectionForData

    public java.sql.Connection getDatabaseConnectionForData()
                                                     throws M4CompilerError

  This method may be needed to provide wrappers with a database connection to the business database. Using this method should be avoided, because the database accesses are not controlled by the control structure, if it is used. For these external accesses a separate business data Connection is set up, which has to be closed by the calling operator!

  Specified by:
    `getDatabaseConnectionForData` in interface `BusinessDbConnectionSource`
  Returns:
    a `java.sql.Connection` to the business database
  Throws:
    `M4CompilerError`

### readCaseIdForStepId

    public long readCaseIdForStepId(long stepId)
                             throws M4CompilerError

  Returns the case id for the given step.

  Parameters:
    `stepId` - An M4 step Id.
  Returns:
    The case Id that is entered in the database for the step with the given Id.
  Throws:
    `M4CompilerError`

### computeSum

    public java.lang.String computeSum(Column col)
                                throws M4CompilerError

  Computes the sum of the entries in the given column.

  Parameters:
    `col` - the column
  Returns:
    the sum of all values in the column as a String
  Throws:
    `M4CompilerError`

### computeNumberOfDistinctElements

    public java.lang.String computeNumberOfDistinctElements(Column col)
                                                     throws M4CompilerError

  Computes the number of distinct elements present in the column.

  Parameters:
    `col` - the column
  Returns:
    the number of different values in the column as a String
  Throws:
    `M4CompilerError`

### testSQLColumn

    public long testSQLColumn(Column col)
                       throws M4CompilerError

  This method checks if the generated sql-string for a new column is executable on the database. It is only a select-statement, no database object is created. It returns the DB datatype of the column as provided by the query.

  Parameters:
    `Column` - to be tested
  Returns:
    Return the number of the database type of the Column, as specified in table COL_DATATYPE_T in the M4.
  Throws:
    `M4CompilerError`

### getCountOfElements

    public java.lang.String[] getCountOfElements(Column col)
                                          throws M4CompilerError

  This method returns an array of Value objects whose value is a String of the form 'count, element' for each element in the column.

  Parameters:
    `col` - The column
  Returns:
    An array of value objects whose value is a String
  Throws:
    `M4CompilerError`

### getCountOfElements

    public java.lang.String[] getCountOfElements(Column colCA,
                                                 Column colTA)
                                          throws M4CompilerError

  This method returns an array of Value objects whose value is a String of the form 'count, elementTA, elementCA' for each element in the TA and CA column(s). TA means target attribute, CA means class attribute.

  Parameters:
    `colTA` - the target column
    `colCA` - the class column
  Returns:
    An array of value objects whose value is a String
  Throws:
    `M4CompilerError`

### getCountOfElements

    public java.lang.String[] getCountOfElements(Column colCA,
                                                 Column colTA,
                                                 long sampleSize)
                                          throws DbConnectionClosed,
                                                 M4CompilerError

  This method returns an array of String objects of the form 'count, elementTA, elementCA' for each element in the TA and CA column(s). TA means target attribute, CA means class attribute.

  Parameters:
    `colTA` - the target column
    `colCA` - the class column
    `sampleSize` - a maximum sample size
  Returns:
    An array of String objects
  Throws:
    `DbConnectionClosed`
    `M4CompilerError`

### getFrquencyTable

    public java.lang.String[][] getFrquencyTable(Column theClassAttribute,
                                                 Feature[] theAttributes,
                                                 java.lang.String[] classValues)
                                          throws M4CompilerError

  Throws:
    `M4CompilerError`

### computeNumberOfElementsForValue

    public java.lang.String computeNumberOfElementsForValue(Column col,
                                                            java.lang.String value)
                                                     throws M4CompilerError

  Computes the number of entries in the given column which have the given value. Optionally, a Group-By-Expression is used.

  Parameters:
    `col` - the column
    `value` - the value
  Returns:
    the number of occurrences of the value in the column as a String
  Throws:
    `M4CompilerError`

### executeDBProcedure

    public void executeDBProcedure(java.lang.String procedureName,
                                   java.lang.String[] parameters,
                                   boolean businessDb)
                            throws M4CompilerError

  This method executes a Stored Procedure in the database.

  Parameters:
    `procedureName` - The name of the stored procedure.
    `parameters` - The parameters of the stored procedure. Note that table names and similar parameters should be quoted like this: 'tablename'. The static method String quote(String) of this class can be used to quote such strings.
    `businessDb` - `true` indicates that the stored procedure is located in the schema of the business data, `false` executes a stored procedure in the M4 schema.
  Throws:
    `M4CompilerError`

### getDistinctElements

    public java.lang.String[] getDistinctElements(Column col)
                                           throws M4CompilerError

  Return the different values that occur in this column in the database in a String array. If the Column contains NULL values, there will be a String object in the returned array which is `null`. If you want to avoid that, use the method `getDistinctElementsWithoutNull(Column)`.

  Parameters:
    `col` - The Column
  Returns:
    A String array
  Throws:
    `M4CompilerError`

### getDistinctElements

    public java.lang.String[] getDistinctElements(long columnId)
                                           throws M4CompilerError

  Return the different values that occur in this column in the database in a String array.

  Parameters:
    `columnId` - The Column id
  Returns:
    A String array
  Throws:
    `M4CompilerError`

### getDistinctElementsWithoutNull

    public java.lang.String[] getDistinctElementsWithoutNull(Column col)
                                                      throws M4CompilerError

  Return the different non-null values that occur in this column in the database in a String array. If the Column contains NULL values, this will not lead to an entry for null in the returned array.

  Parameters:
    `col` - The Column
  Returns:
    A String array
  Throws:
    `M4CompilerError`

### getDeviatingValues

    public java.util.Collection getDeviatingValues(Column col,
                                                   java.lang.String[] expectedValues)
                                            throws M4CompilerError

  Compares the distinct values that actually occur in the given column with the values given in the String array. Any actual values that the given column contains, but are not in the given array, are returned in a Collection of Strings.

  Parameters:
    `col` - the column, some of whose actual values may be returned
    `expectedValues` - the values expected in that column
  Returns:
    all unexpected values occurring in the given column
  Throws:
    `M4CompilerError`

### getInputConceptsFor

    public java.util.Collection getInputConceptsFor(Step step)
                                             throws M4Exception

  This method should only be used by the compiler's control structure.

  Parameters:
    `step` - a `Step` to find all input Concepts for
  Returns:
    A `Collection` of `Concept`s
  Throws:
    `M4Exception`

### getBusinessDbCore

    public DbCore getBusinessDbCore()
                             throws DbConnectionClosed

  Overrides:
    `getBusinessDbCore` in class `DB`
  Throws:
    `DbConnectionClosed`

### getSelectStringForColumnDataType

    public java.lang.String getSelectStringForColumnDataType(java.lang.String owner,
                                                             java.lang.String tableName,
                                                             java.lang.String columnName)

  This method returns the DBMS-dependent SQL command that returns the name of the datatype of the given column in the given table or view (which is owned by the given owner).

  Specified by:
    `getSelectStringForColumnDataType` in interface `BusinessDbConnectionSource`
  Parameters:
    `owner` - Name of the owner of the table or view
    `tableName` - Name of a table or view in the business schema
    `columnName` - Name of the column whose datatype is returned
  Returns:
    the DBMS-dependent name of the datatype of the column with the given name

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