edu.udo.cs.miningmart.operator
Class ExecutableOperator

java.lang.Object
  extended byedu.udo.cs.miningmart.operator.ExecutableOperator
Direct Known Subclasses:
ConceptOperator, EvaluateAdvantageOfTFIDFTransformation, EvaluateResults, FeatureConstruction, PrepareForYale

public abstract class ExecutableOperator
extends java.lang.Object

Abstract superclass of all executable operators in MiningMart. It provides, among others, the methods load(), execute() and get(Single)Parameter(). Its direct subclasses are ConceptOperator and FeatureConstruction.

Version:
$Id: ExecutableOperator.java,v 1.12 2006/04/11 14:10:10 euler Exp $
Author:
Timm Euler, Martin Scholz

Field Summary
protected  java.lang.String[] generatedSQLDefinitions
           
 
Constructor Summary
ExecutableOperator()
           
 
Method Summary
 void autoPrint()
          Prints all the parameters of this operator for the current Step in the order given by the table OP_PARAMS_T.
protected  void checkConditions()
           
abstract  void compileStatement()
          Abstract method for compiling the generated sql-statement.
abstract  void createStatement(boolean lazy)
          Abstract method for generating an sql-statement.
 void doPrint(java.lang.Exception ex)
          Method to be used by all subclasses to print exception messages to the screen or log file.
 void doPrint(java.util.logging.Level verbosity, java.lang.String printString)
          Method to be used by all subclasses to print messages to the screen or log file.
abstract  EstimatedStatistics estimateStatistics(Step theStep)
          Abstract method for estimating statistics for a concept.
 void execute(boolean lazy)
          Execute everything to be done to compile an operator.
 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.
protected  java.lang.String getArtificalColumnName(java.lang.String otherColumns)
          Service method for subclasses.
protected  short getBusinessDbms()
           
protected  int getHighestLoopNr()
          Gets the numberOfLoops from the table STEP_T.
 CompilerDatabaseService getM4Db()
          This method returns the instance of CompilerDatabaseService that is used in this Case.
protected  short getM4Dbms()
           
 M4Object getM4ObjectFromCache(long Id)
          This method returns the object with the given Id if it is in the Cache.
 java.lang.String getName()
           
 long getNextM4SequenceValue()
           
 int getNumberOfLoops()
          Get the number of loops that this operator is to be applied in in a way that the return value can be used as the loop number of getParameter.
 Operator getOperator()
           
 java.util.Iterator getOpParamsIterator()
           
 ParameterObject[] getParameter(java.lang.String name)
          This method is the same as getParameter(String,int), but for parameters that are not looped.
 ParameterObject[] getParameter(java.lang.String name, int loopNr)
          For loopable parameters.
 M4Object getSingleParameter(java.lang.String name)
          This method is similar to Step.getParameter, but it returns a single M4Object.
 M4Object getSingleParameter(java.lang.String name, int loopNr)
          Same as getSingleParameter(String), but with loop number
 Step getStep()
           
protected  void handleAssertions()
           
protected  boolean isDeselectedParameter(M4Object m4o)
          Check if an M4Object has been deselected by an automatic FeatureSelection operator.
 boolean isLoopable()
           
 boolean isManual()
           
 boolean isStepable()
           
 void load(Step step)
          Loads all parameters for this operator.
 void print()
          Print-method for all operator parameters.
 void putM4ObjectToCache(M4Object m4o)
          This method stores an M4 object in the Cache, using its ID as the key for the underlying data structure.
 void showCreateStatement()
          Print-method for the generated sql-statement.
protected  boolean storedProceduresAvailable()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

generatedSQLDefinitions

protected java.lang.String[] generatedSQLDefinitions
Constructor Detail

ExecutableOperator

public ExecutableOperator()
Method Detail

load

public void load(Step step)
          throws ParameterDeselectedError,
                 M4CompilerError
Loads all parameters for this operator.

Parameters:
step - This executable operator's step
Throws:
ParameterDeselectedError
M4CompilerError

getParameter

public ParameterObject[] getParameter(java.lang.String name,
                                      int loopNr)
                               throws M4CompilerError
For loopable parameters.

Parameters:
name - the name of a parameter to be looked up
loopNr - the loop for which the parameter should be returned
Returns:
an array of ParameterObjects. A return value of null indicates, that the parameter was not found.
Throws:
M4CompilerError

getParameter

public ParameterObject[] getParameter(java.lang.String name)
                               throws M4CompilerError
This method is the same as getParameter(String,int), but for parameters that are not looped.

Parameters:
name - name of the parameter
Returns:
an array of ParameterObjects. A return value of null indicates, that the parameter was not found.
Throws:
M4CompilerError

getSingleParameter

public M4Object getSingleParameter(java.lang.String name)
                            throws M4CompilerError
This method is similar to Step.getParameter, but it returns a single M4Object. This is more comfortable if it is known, that a parameter is no array. If a parameter is not found null is returned. If the parameter is an array, the first value is returned.

Parameters:
name - the name of the parameter
Returns:
the parameter value, null if not present
Throws:
M4CompilerError

getSingleParameter

public M4Object getSingleParameter(java.lang.String name,
                                   int loopNr)
                            throws M4CompilerError
Same as getSingleParameter(String), but with loop number

Throws:
M4CompilerError
See Also:
getSingleParameter(String)

getM4Db

public CompilerDatabaseService getM4Db()
                                throws M4CompilerError
This method returns the instance of CompilerDatabaseService that is used in this Case. It provides a number of service methods to access M4.

Returns:
the CompilerDatabaseService object of this Case
Throws:
M4CompilerError

getOperator

public Operator getOperator()
Returns:
an object representing the M4 operator.

getName

public java.lang.String getName()
Returns:
the operator name

getStep

public Step getStep()
Returns:
the Step object associated to this object.

isLoopable

public boolean isLoopable()
Returns:
true iff this operator is loopable.

isManual

public boolean isManual()
Returns:
true iff this is a manual operator

isStepable

public boolean isStepable()
Returns:
true iff this operator is multistepable.

getHighestLoopNr

protected final int getHighestLoopNr()
Gets the numberOfLoops from the table STEP_T. This number is not interpreted for further usage.

Returns:
Returns an int, 0 if loops are not activated for the Step; otherwise the number of loops is returned.
See Also:
getNumberOfLoops()

getNumberOfLoops

public int getNumberOfLoops()
Get the number of loops that this operator is to be applied in in a way that the return value can be used as the loop number of getParameter. Example:
for (int loop=0; loop < getNumberOfLoops() ; loop++)

Returns:
the number of loops as found in table STEP_T, but a value of 0 (loops not activated) results in a return value of 1.
See Also:
getHighestLoopNr()

getOpParamsIterator

public java.util.Iterator getOpParamsIterator()
                                       throws M4CompilerError
Returns:
an Iterator for the parameters stored in table OP_PARAM_T, represented as objects of type OpParam.
Throws:
M4CompilerError

isDeselectedParameter

protected final boolean isDeselectedParameter(M4Object m4o)
                                       throws M4CompilerError
Check if an M4Object has been deselected by an automatic FeatureSelection operator. Only Features can be deselected.

Parameters:
m4o - the M4Object
Returns:
true, iff deselected
Throws:
M4CompilerError

doPrint

public void doPrint(java.util.logging.Level verbosity,
                    java.lang.String printString)
Method to be used by all subclasses to print messages to the screen or log file.

Parameters:
verbosity - A verbosity level. Use one of the public static variables of the class Print.
printString - The string with the message.
See Also:
edu.udo.cs.miningmart.m4.core.utils.Print

doPrint

public void doPrint(java.lang.Exception ex)
Method to be used by all subclasses to print exception messages to the screen or log file.

Parameters:
ex - An exception object. Its message string will be printed.

print

public final void print()
Print-method for all operator parameters. If you do not use the autoLoad() mechanism, this method must be defined at all levels of abstraction and has to print out all parameters read at this level. In this case the first statement must always be super.showParameters().
If you use the autoLoad() mechanism (recommended), then just override the method with a call to this.autoPrint() (without calling super.print()!).


autoPrint

public final void autoPrint()
Prints all the parameters of this operator for the current Step in the order given by the table OP_PARAMS_T. Note that you have to call the method autoLoad() before being able to apply autoPrint. In subclasses you can override the print() method by just calling this method, without calling super.print().


execute

public void execute(boolean lazy)
             throws java.sql.SQLException,
                    M4CompilerWarning,
                    M4CompilerError,
                    UserError,
                    M4Exception
Execute everything to be done to compile an operator. This method consists of the actual execution phase of an operator. Every implementation needs the functions createStatement, compileStatement and writeResults. All functions called here are abstract and must be implemented differently at lower levels, e.g. by the abstract classes ConceptOperator and FeatureConstruction.

Parameters:
lazy - If TRUE, run the operator in lazy mode
Returns:
errorCode
Throws:
UserError
M4Exception
java.sql.SQLException
M4CompilerWarning
M4CompilerError

handleAssertions

protected void handleAssertions()
                         throws M4CompilerError,
                                M4CompilerWarning
Throws:
M4CompilerError
M4CompilerWarning

checkConditions

protected void checkConditions()
                        throws UserError,
                               M4CompilerError
Throws:
UserError
M4CompilerError

createStatement

public abstract void createStatement(boolean lazy)
                              throws java.sql.SQLException,
                                     M4CompilerWarning,
                                     M4CompilerError
Abstract method for generating an sql-statement. This method handles the process of generating an sql-statement for an operator. The implementation is done individually by every operator.

Parameters:
lazy - If TRUE, run in lazy mode: create atmost one output ColumnSet
Throws:
java.sql.SQLException
M4CompilerWarning
M4CompilerError

showCreateStatement

public void showCreateStatement()
Print-method for the generated sql-statement. This method prints out the generated sql-statement.


compileStatement

public abstract void compileStatement()
                               throws java.sql.SQLException,
                                      M4CompilerWarning,
                                      M4CompilerError
Abstract method for compiling the generated sql-statement. This method tests if the generated sql-statement is executable in the database. The implementation is done individually by every operator.

Throws:
java.sql.SQLException
M4CompilerWarning
M4CompilerError

estimateStatistics

public abstract EstimatedStatistics estimateStatistics(Step theStep)
                                                throws M4Exception
Abstract method for estimating statistics for a concept. The realisation of this method depends on the type of operator that is connected to the step that creates the concept whose statistics are to be estimated. Therefore the implementation is done in this class and its subclasses.

Parameters:
theStep - the step that creates the output concept whose statistics are to be estimated
Returns:
an EstimatedStatistics object, some of whose values may or may not be available, depending on whether they could be guessed or inferred.
Throws:
M4Exception

getM4Dbms

protected short getM4Dbms()
                   throws M4CompilerError,
                          DbConnectionClosed
Returns:
a constant indicating which DBMS holds the M4 schema
Throws:
M4CompilerError
DbConnectionClosed

getBusinessDbms

protected short getBusinessDbms()
                         throws M4CompilerError,
                                DbConnectionClosed
Returns:
a constant indicating which DBMS holds the business data schema
Throws:
M4CompilerError
DbConnectionClosed

storedProceduresAvailable

protected boolean storedProceduresAvailable()
                                     throws DbConnectionClosed,
                                            M4CompilerError
Returns:
true iff the DBMS holding the business data schema supports Java Stored Procedures. This information is necessary to decide, whether according operator parts should be executed inside or outside the database.
Throws:
DbConnectionClosed
M4CompilerError

getM4ObjectFromCache

public M4Object getM4ObjectFromCache(long Id)
                              throws M4CompilerError
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.
Throws:
M4CompilerError

putM4ObjectToCache

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

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

executeM4SqlWrite

public void executeM4SqlWrite(java.lang.String query)
                       throws java.sql.SQLException,
                              M4CompilerError,
                              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
M4CompilerError
DbConnectionClosed

executeBusinessSqlWrite

public void executeBusinessSqlWrite(java.lang.String query)
                             throws java.sql.SQLException,
                                    M4CompilerError,
                                    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
M4CompilerError
DbConnectionClosed

executeM4SqlRead

public java.sql.ResultSet executeM4SqlRead(java.lang.String query)
                                    throws java.sql.SQLException,
                                           M4CompilerError,
                                           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
M4CompilerError
DbConnectionClosed

executeBusinessSqlRead

public java.sql.ResultSet executeBusinessSqlRead(java.lang.String query)
                                          throws java.sql.SQLException,
                                                 M4CompilerError,
                                                 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
M4CompilerError
DbConnectionClosed

executeM4SingleValueSqlReadL

public java.lang.Long executeM4SingleValueSqlReadL(java.lang.String query)
                                            throws java.sql.SQLException,
                                                   M4CompilerError,
                                                   DbConnectionClosed
Throws:
java.sql.SQLException
M4CompilerError
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,
                                                         M4CompilerError,
                                                         DbConnectionClosed
Throws:
java.sql.SQLException
M4CompilerError
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,
                                                    M4CompilerError,
                                                    DbConnectionClosed
Throws:
java.sql.SQLException
M4CompilerError
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,
                                                          M4CompilerError,
                                                          DbConnectionClosed
Throws:
java.sql.SQLException
M4CompilerError
DbConnectionClosed
See Also:
In contrast to that method, this method creates and then closes its own Statement.

getNextM4SequenceValue

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

getArtificalColumnName

protected java.lang.String getArtificalColumnName(java.lang.String otherColumns)
Service method for subclasses. If an extra column name is needed (an SQL variable), this method returns one that is different from all String tokens that occur in the given String.

Parameters:
otherColumns - The other column names
Returns:
A String that is no substring of otherColumns


Copyright © 2001-2005