edu.udo.cs.miningmart.m4.core
Class M4InterfaceImpl

java.lang.Object
  extended byedu.udo.cs.miningmart.m4.M4Interface
      extended byedu.udo.cs.miningmart.m4.core.M4InterfaceImpl
All Implemented Interfaces:
M4InterfaceContext, java.io.Serializable

public class M4InterfaceImpl
extends M4Interface
implements M4InterfaceContext, java.io.Serializable

Version:
$Id: M4InterfaceImpl.java,v 1.12 2006/04/11 14:10:14 euler Exp $
Author:
Martin Scholz
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class edu.udo.cs.miningmart.m4.M4Interface
M4Interface.CaseLockedException
 
Field Summary
 
Fields inherited from class edu.udo.cs.miningmart.m4.M4Interface
AVAILABLE_MATCHERS, currentCase, currentCompilerAccess, MATCHER_EDITDISTANCE, MATCHER_NGRAM, MATCHER_SIMPLE, MATCHER_SOUNDEX, print, SYSTEM_PROP_DB_CONFIG_PATH, SYSTEM_PROP_PRINT_VERBOSITY
 
Constructor Summary
M4InterfaceImpl()
          Constructor Will set up the database connections and the Print object for log outputs
 
Method Summary
 boolean canRemoveM4Access(java.lang.String caseName)
          Check if the M4Access for the specified Case can be removed.
 Case createCase(java.lang.String name, boolean setAsCurrentCase)
          Creates a new Case.
 Operator createOperator(java.lang.String name)
          Creates a new Operator.
 boolean existsCase(java.lang.String name)
          Checks wether a case with this name exists.
 Case findCase(java.lang.String name, boolean setAsCurrent)
           
 Case findCaseForReadOnlyAccess(java.lang.String name, boolean setAsCurrent)
          Returns a Case for read-only access.
 Case findCaseForUpdate(java.lang.String name, boolean setAsCurrent)
          Returns a Case and locks it so it may be modified.
 java.util.Collection findConnection(Concept theConcept, java.util.Collection namesOfDbObjects, java.lang.String matcher)
          Connects the given concept with one of the Db Objects (tables or views) whose names are given in the second parameter.
 Operator findOperator(java.lang.String name)
          Returns an Operator that may be changed.
 java.util.Collection getAllCaseNames()
          Current implementation: Reads case names directly from the database, so it has to be taken care for writing back the cache in time!
 java.util.Collection getAllOperatorNames()
          Current implementation: Reads operator names directly from the database, so it has to be taken care for writing back the cache in time!
 Case getCase()
           
 DB getM4db()
           
 java.util.Collection getNamesOfBusinessTablesAndViews()
           
 void getNewDbConnection()
           
 OperatorGroup getOperatorGroup()
           
 Print getPrintObject()
           
 boolean getStopRequest()
           
 boolean isBusinessTable(java.lang.String name)
          Checks wether a table in the business schema with this name exists.
 boolean isBusinessView(java.lang.String name)
          Checks wether a view in the business schema with this name exists.
 boolean isCaseLockedForReading(java.lang.String caseName)
          Check if case can be locked for reading.
 boolean isCaseLockedForWriting(java.lang.String caseName)
          Check if case can be locked for writing.
 void releaseCase(java.lang.String name)
          Release a Case for access.
 void releaseCaseWithoutStoring(java.lang.String name)
          Release a Case from access lock, but do not store it to the DB even if it has been changed.
 
Methods inherited from class edu.udo.cs.miningmart.m4.M4Interface
getCurrentCase, getCurrentCompilerAccess, getInstance, removeCurrentCase, setCurrentCase, setCurrentCompilerAccess, setInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

M4InterfaceImpl

public M4InterfaceImpl()
Constructor Will set up the database connections and the Print object for log outputs

Method Detail

getNewDbConnection

public void getNewDbConnection()

getStopRequest

public boolean getStopRequest()
Specified by:
getStopRequest in interface M4InterfaceContext

getCase

public Case getCase()
Specified by:
getCase in interface M4InterfaceContext

getM4db

public DB getM4db()
Specified by:
getM4db in interface M4InterfaceContext
Specified by:
getM4db in class M4Interface

getPrintObject

public Print getPrintObject()
Specified by:
getPrintObject in interface M4InterfaceContext

createCase

public Case createCase(java.lang.String name,
                       boolean setAsCurrentCase)
                throws M4Exception
Description copied from class: M4Interface
Creates a new Case. The name of the Case must be unique within the M4 Schema.

Specified by:
createCase in class M4Interface
Parameters:
name - The name of the Case that should be created.
setAsCurrentCase - If this parameter is set to TRUE, the newly created case is set as the current case, and can be retrieved using getCurrentCase(). Otherwise the only handle to the new case is the returned object.
Returns:
Case the Case that is created.
Throws:
M4Exception
See Also:
M4Interface.createCase(String, boolean)

createOperator

public Operator createOperator(java.lang.String name)
                        throws M4Exception
Description copied from class: M4Interface
Creates a new Operator. The name of the Operator must be unique within the M4 Schema.

Specified by:
createOperator in class M4Interface
Parameters:
name - The name of the Operator that should be created.
Returns:
Operator the Operator that is created.
Throws:
M4Exception
See Also:
M4Interface.createOperator(String)

getAllCaseNames

public java.util.Collection getAllCaseNames()
Current implementation: Reads case names directly from the database, so it has to be taken care for writing back the cache in time!

Specified by:
getAllCaseNames in class M4Interface
Returns:
Collection of Case names.
See Also:
M4Interface.getAllCaseNames()

getNamesOfBusinessTablesAndViews

public java.util.Collection getNamesOfBusinessTablesAndViews()
                                                      throws M4Exception
Specified by:
getNamesOfBusinessTablesAndViews in class M4Interface
Returns:
a Collection of Strings, namely the names of all tables and views in the business data schema except those that were created by the compiler (ie, are listed in the trash table).
Throws:
M4Exception
See Also:
M4Interface.getNamesOfBusinessTablesAndViews()

isBusinessTable

public boolean isBusinessTable(java.lang.String name)
                        throws M4Exception
Description copied from class: M4Interface
Checks wether a table in the business schema with this name exists.

Specified by:
isBusinessTable in class M4Interface
Parameters:
name - the name of the table
Returns:
true if the table exists, false otherwise
Throws:
M4Exception
See Also:
M4Interface.isBusinessTable(java.lang.String)

isBusinessView

public boolean isBusinessView(java.lang.String name)
                       throws M4Exception
Description copied from class: M4Interface
Checks wether a view in the business schema with this name exists.

Specified by:
isBusinessView in class M4Interface
Parameters:
name - the name of the view
Returns:
true if the view exists, false otherwise
Throws:
M4Exception
See Also:
M4Interface.isBusinessView(java.lang.String)

existsCase

public boolean existsCase(java.lang.String name)
Description copied from class: M4Interface
Checks wether a case with this name exists.

Specified by:
existsCase in class M4Interface
Returns:
true if the case exists, false otherwise.
See Also:
M4Interface.existsCase(String)

findOperator

public Operator findOperator(java.lang.String name)
Description copied from class: M4Interface
Returns an Operator that may be changed. As Operators are much less frequently added or changed by users than Cases a findOperatorForUpdate() method is not provided here.

Specified by:
findOperator in class M4Interface
Parameters:
name - The name of the Operator that should be retrieved.
Returns:
Operator the Operator that is found or null if it is not found.
See Also:
M4Interface.findOperator(String)

findCase

public Case findCase(java.lang.String name,
                     boolean setAsCurrent)

getAllOperatorNames

public java.util.Collection getAllOperatorNames()
Current implementation: Reads operator names directly from the database, so it has to be taken care for writing back the cache in time!

Specified by:
getAllOperatorNames in class M4Interface
Returns:
Collection of Operator names.
See Also:
M4Interface.getAllOperatorNames()

findConnection

public java.util.Collection findConnection(Concept theConcept,
                                           java.util.Collection namesOfDbObjects,
                                           java.lang.String matcher)
                                    throws M4Exception
Description copied from class: M4Interface
Connects the given concept with one of the Db Objects (tables or views) whose names are given in the second parameter. If the given concept already has a connection to a Columnset, that connection is removed. A new Columnset is created that represents one of the tables or views, or a join result (see below), and is connected to the concept given in the first parameter. The Db Object is chosen by schema matching. The third parameter determines which matcher is used; its value must be one of the public constants defined in this class. The returned Collection will be empty in many cases. However, if it contains two columnsets, this means that these two columnsets were joined and the result matched the given Concept better than any of the single tables/views. In this case the given Concept is connected to a Columnset that represents a view of the join result.

Specified by:
findConnection in class M4Interface
Parameters:
theConcept - Concept to be connected
namesOfDbObjects - Names of business schema tables and views among which to select the best-matching one
matcher - The type of schema matching algorithm to be used (must be one of the corresponding public constants of this class)
Returns:
A Collection that is NULL iff the given Concept was matched directly to one of the given Db Objects, and that contains two Columnsets iff two of the given Db Objects were joined (following existing foreign key relationships in the database schema) and the resulting view matched the given concept better than any single table/view.
Throws:
M4Exception
See Also:
edu.udo.miningmart.m4.M4Interface#findConnection(Concept, Collection, String)

canRemoveM4Access

public boolean canRemoveM4Access(java.lang.String caseName)
Description copied from class: M4Interface
Check if the M4Access for the specified Case can be removed.

Specified by:
canRemoveM4Access in class M4Interface
See Also:
M4Interface.canRemoveM4Access(String)

isCaseLockedForReading

public boolean isCaseLockedForReading(java.lang.String caseName)
Description copied from class: M4Interface
Check if case can be locked for reading.

Specified by:
isCaseLockedForReading in class M4Interface
See Also:
M4Interface.isCaseLockedForReading(String)

isCaseLockedForWriting

public boolean isCaseLockedForWriting(java.lang.String caseName)
Description copied from class: M4Interface
Check if case can be locked for writing.

Specified by:
isCaseLockedForWriting in class M4Interface
See Also:
M4Interface.isCaseLockedForWriting(String)

findCaseForReadOnlyAccess

public Case findCaseForReadOnlyAccess(java.lang.String name,
                                      boolean setAsCurrent)
                               throws M4Interface.CaseLockedException
Description copied from class: M4Interface
Returns a Case for read-only access. Read-only access administration is done in a database table; it is not enforced by the M4Interface however! This means it is left to the programmer to disallow changes. Many users are allowed to read a Case as long as nobody else is writing to the Case. No writer to a Case is allowed if there is at least one reader.

Specified by:
findCaseForReadOnlyAccess in class M4Interface
Parameters:
name - The name of the Case that should be retrieved.
setAsCurrent - Boolean indicating retrieved case should be set as current. The current Case is used as the context for M4Interface methods that depend on the Case. Normally this value should be set to true. Note that the current Case context can also be set using the setCurrentCase method.
Returns:
Case the Case that is found or null if it is not found.
Throws:
M4Interface.CaseLockedException - when a Case is already locked for reading.
See Also:
M4Interface.findCaseForReadOnlyAccess(String, boolean)

findCaseForUpdate

public Case findCaseForUpdate(java.lang.String name,
                              boolean setAsCurrent)
                       throws M4Interface.CaseLockedException
Description copied from class: M4Interface
Returns a Case and locks it so it may be modified. Many users are allowed to read a Case as long as nobody else is writing to the Case. No writer to a Case is allowed if there is at least one reader.

Specified by:
findCaseForUpdate in class M4Interface
Parameters:
name - The name of the Case that should be retrieved.
setAsCurrent - If the retrieved Case should be set as the current Case context for M4Interface methods that depend on the Case. Normally this value should be set to true. Note that the current Case context can also be set using the setCurrentCase method.
Returns:
Case the Case that is found or null if it is not found.
Throws:
M4Interface.CaseLockedException - when a Case is already locked for writing.
See Also:
M4Interface.findCaseForUpdate(String, boolean)

releaseCase

public void releaseCase(java.lang.String name)
Description copied from class: M4Interface
Release a Case for access. The Case is stored to the DB.

Specified by:
releaseCase in class M4Interface
Parameters:
name - the name of the case to be released
See Also:
M4Interface.releaseCase(String)

releaseCaseWithoutStoring

public void releaseCaseWithoutStoring(java.lang.String name)
Description copied from class: M4Interface
Release a Case from access lock, but do not store it to the DB even if it has been changed.

Specified by:
releaseCaseWithoutStoring in class M4Interface
Parameters:
name - the name of the case to be released
See Also:
M4Interface.releaseCaseWithoutStoring(String)

getOperatorGroup

public OperatorGroup getOperatorGroup()
Specified by:
getOperatorGroup in class M4Interface
Returns:
an object of class OperatorGroup


Copyright © 2001-2005