net.sf.farrago.session.mock
Class MockSessionStmtValidator

java.lang.Object
  extended by net.sf.farrago.session.mock.MockSessionStmtValidator
All Implemented Interfaces:
FarragoSessionStmtValidator, FarragoAllocation, FarragoAllocationOwner, ClosableAllocation, ClosableAllocationOwner

public class MockSessionStmtValidator
extends Object
implements FarragoSessionStmtValidator

MockSessionStmtValidator provides a bare-bones implementation of FarragoSessionStmtValidator. It primarily exists to support the retrieval of a MockReposTxnContext in the SQL parser.

Since:
Dec 8, 2006
Version:
$Id: //open/dev/farrago/src/net/sf/farrago/session/mock/MockSessionStmtValidator.java#5 $
Author:
stephan/jack

Field Summary
(package private)  FarragoSessionParser parser
           
(package private)  FarragoReposTxnContext reposTxnContext
           
 
Constructor Summary
MockSessionStmtValidator()
           
 
Method Summary
 void addAllocation(ClosableAllocation allocation)
          Assigns ownership of a ClosableAllocation to this owner.
 void closeAllocation()
          Closes this object.
 CwmCatalog findCatalog(String catalogName)
          Looks up a catalog by name, throwing a validation error if not found.
 CwmColumn findColumn(CwmNamedColumnSet namedColumnSet, String columnName)
          Looks up a table's column by name, throwing a validation error if not found.
 FemDataServer findDataServer(SqlIdentifier serverName)
          Looks up a data server by name, throwing a validation error if not found.
 FemDataWrapper findDataWrapper(SqlIdentifier wrapperName, boolean isForeign)
          Looks up a data wrapper by name, throwing a validation error if not found.
 FemJar findJarFromLiteralName(String jarName)
          Looks up a jar from a string literal representing its name (typically from a LIBRARY clause), throwing an exception if not found.
 List<FemRoutine> findRoutineOverloads(SqlIdentifier invocationName, ProcedureType routineType)
          Looks up all matching routine overloads by invocation name.
 FemLocalSchema findSchema(SqlIdentifier schemaName)
          Looks up a schema by name, throwing a validation error if not found.
<T extends CwmModelElement>
T
findSchemaObject(SqlIdentifier qualifiedName, Class<T> clazz)
          Looks up a schema object by name, throwing a validation error if not found.
 CwmSqldataType findSqldataType(SqlIdentifier typeName)
          Looks up a SQL datatype by name, throwing an exception if not found.
<T extends CwmModelElement>
T
findUnqualifiedObject(SqlIdentifier unqualifiedName, Class<T> clazz)
          Looks up a top-level object (e.g.
 List<SqlMoniker> getAllSchemaObjectNames(List<String> names)
          Gets schema object names as specified.
 FarragoObjectCache getCodeCache()
           
 FarragoDataWrapperCache getDataWrapperCache()
           
 FarragoDdlLockManager getDdlLockManager()
           
 CwmCatalog getDefaultCatalog()
          Gets the default catalog for unqualified schema names.
 FemDataServer getDefaultLocalDataServer()
           
 FennelDbHandle getFennelDbHandle()
           
 FarragoSessionIndexMap getIndexMap()
           
 FarragoSessionParser getParser()
           
 FarragoSessionPrivilegeChecker getPrivilegeChecker()
           
 FarragoRepos getRepos()
           
 FarragoReposTxnContext getReposTxnContext()
           
 CwmNamedColumnSet getSampleDataset(CwmNamedColumnSet columnSet, String datasetName)
          Looks up a sample dataset for a given schema object, or returns null if none is found.
 FarragoSession getSession()
           
 FarragoSessionVariables getSessionVariables()
           
 FarragoObjectCache getSharedDataWrapperCache()
           
 EigenbaseTimingTracer getTimingTracer()
           
 FarragoTypeFactory getTypeFactory()
           
 FarragoWarningQueue getWarningQueue()
          Gets the warning queue to be used by this validator
 void requestPrivilege(CwmModelElement obj, String action)
          Submits a request for access from the current user and/or role to a catalog object via this validator's privilege checker.
<T extends CwmModelElement>
FarragoSessionResolvedObject<T>
resolveSchemaObjectName(String[] names, Class<T> clazz)
          Resolve a (possibly qualified) name of a schema object.
 void setParser(FarragoSessionParser parser)
           
 void setParserPosition(SqlParserPos pos)
          Sets the parser position to use for context in error messages.
 void setReposTxnContext(FarragoReposTxnContext reposTxnContext)
          Sets the repository transaction context associated with this statement.
 void setTimingTracer(EigenbaseTimingTracer timingTracer)
          Sets the timing tracer associated with this statement
 void setWarningQueue(FarragoWarningQueue queue)
          Sets the warning queue to be used by this validator
 void validateDataType(SqlDataTypeSpec dataType)
          Validates a data type expression.
 void validateFeature(org.eigenbase.resgen.ResourceDefinition feature, SqlParserPos context)
          Validates that a particular feature is enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

FarragoSessionParser parser

reposTxnContext

FarragoReposTxnContext reposTxnContext
Constructor Detail

MockSessionStmtValidator

public MockSessionStmtValidator()
Method Detail

setParser

public void setParser(FarragoSessionParser parser)

getParser

public FarragoSessionParser getParser()
Specified by:
getParser in interface FarragoSessionStmtValidator
Returns:
the parser parsing the statement being validated

setReposTxnContext

public void setReposTxnContext(FarragoReposTxnContext reposTxnContext)
Description copied from interface: FarragoSessionStmtValidator
Sets the repository transaction context associated with this statement.

Specified by:
setReposTxnContext in interface FarragoSessionStmtValidator
Parameters:
reposTxnContext - repos txn context to use

getReposTxnContext

public FarragoReposTxnContext getReposTxnContext()
Specified by:
getReposTxnContext in interface FarragoSessionStmtValidator
Returns:
the repository transaction context associated with this statement.

getSession

public FarragoSession getSession()
Specified by:
getSession in interface FarragoSessionStmtValidator
Returns:
session invoking stmt to be validated

getRepos

public FarragoRepos getRepos()
Specified by:
getRepos in interface FarragoSessionStmtValidator
Returns:
repos to use for validating object references

getFennelDbHandle

public FennelDbHandle getFennelDbHandle()
Specified by:
getFennelDbHandle in interface FarragoSessionStmtValidator
Returns:
FennelDbHandle storing local data to be accessed by validated stmt

getTypeFactory

public FarragoTypeFactory getTypeFactory()
Specified by:
getTypeFactory in interface FarragoSessionStmtValidator
Returns:
type factory to use for validation

getSessionVariables

public FarragoSessionVariables getSessionVariables()
Specified by:
getSessionVariables in interface FarragoSessionStmtValidator
Returns:
connection defaults to use for validation

getCodeCache

public FarragoObjectCache getCodeCache()
Specified by:
getCodeCache in interface FarragoSessionStmtValidator
Returns:
cache to use for code lookups during validation

getDataWrapperCache

public FarragoDataWrapperCache getDataWrapperCache()
Specified by:
getDataWrapperCache in interface FarragoSessionStmtValidator
Returns:
private cache to use for validating references to data wrappers

getIndexMap

public FarragoSessionIndexMap getIndexMap()
Specified by:
getIndexMap in interface FarragoSessionStmtValidator
Returns:
index map to use for validation

getSharedDataWrapperCache

public FarragoObjectCache getSharedDataWrapperCache()
Specified by:
getSharedDataWrapperCache in interface FarragoSessionStmtValidator
Returns:
shared cache to use for validating references to data wrappers

getPrivilegeChecker

public FarragoSessionPrivilegeChecker getPrivilegeChecker()
Specified by:
getPrivilegeChecker in interface FarragoSessionStmtValidator
Returns:
the privilege checker for this validator

getDdlLockManager

public FarragoDdlLockManager getDdlLockManager()
Specified by:
getDdlLockManager in interface FarragoSessionStmtValidator
Returns:
the DDL lock manager for this validator

requestPrivilege

public void requestPrivilege(CwmModelElement obj,
                             String action)
Description copied from interface: FarragoSessionStmtValidator
Submits a request for access from the current user and/or role to a catalog object via this validator's privilege checker. Actual checking of the request may be deferred.

Specified by:
requestPrivilege in interface FarragoSessionStmtValidator
Parameters:
obj - object to be accessed
action - the action to be performed on obj (see PrivilegedActionEnum for base set)

findColumn

public CwmColumn findColumn(CwmNamedColumnSet namedColumnSet,
                            String columnName)
Description copied from interface: FarragoSessionStmtValidator
Looks up a table's column by name, throwing a validation error if not found.

Specified by:
findColumn in interface FarragoSessionStmtValidator
Parameters:
namedColumnSet - the table to search
columnName - name of column to find
Returns:
column found

findCatalog

public CwmCatalog findCatalog(String catalogName)
Description copied from interface: FarragoSessionStmtValidator
Looks up a catalog by name, throwing a validation error if not found.

Specified by:
findCatalog in interface FarragoSessionStmtValidator
Parameters:
catalogName - name of catalog to look up
Returns:
catalog found

getDefaultCatalog

public CwmCatalog getDefaultCatalog()
Description copied from interface: FarragoSessionStmtValidator
Gets the default catalog for unqualified schema names.

Specified by:
getDefaultCatalog in interface FarragoSessionStmtValidator
Returns:
default catalog

findSchema

public FemLocalSchema findSchema(SqlIdentifier schemaName)
Description copied from interface: FarragoSessionStmtValidator
Looks up a schema by name, throwing a validation error if not found.

Specified by:
findSchema in interface FarragoSessionStmtValidator
Parameters:
schemaName - name of schema to look up
Returns:
schema found

findDataWrapper

public FemDataWrapper findDataWrapper(SqlIdentifier wrapperName,
                                      boolean isForeign)
Description copied from interface: FarragoSessionStmtValidator
Looks up a data wrapper by name, throwing a validation error if not found.

Specified by:
findDataWrapper in interface FarragoSessionStmtValidator
Parameters:
wrapperName - name of wrapper to look up (must be simple)
isForeign - true for foreign data wrapper; false for local data wrapper
Returns:
wrapper found

findDataServer

public FemDataServer findDataServer(SqlIdentifier serverName)
Description copied from interface: FarragoSessionStmtValidator
Looks up a data server by name, throwing a validation error if not found.

Specified by:
findDataServer in interface FarragoSessionStmtValidator
Parameters:
serverName - name of server to look up (must be simple)
Returns:
server found

getDefaultLocalDataServer

public FemDataServer getDefaultLocalDataServer()
Specified by:
getDefaultLocalDataServer in interface FarragoSessionStmtValidator
Returns:
default data server to use if none specified in local table definition

findSchemaObject

public <T extends CwmModelElement> T findSchemaObject(SqlIdentifier qualifiedName,
                                                      Class<T> clazz)
Description copied from interface: FarragoSessionStmtValidator
Looks up a schema object by name, throwing a validation error if not found.

Specified by:
findSchemaObject in interface FarragoSessionStmtValidator
Parameters:
qualifiedName - name of object to look up
clazz - expected class of object; if the object exists with a different class, it will be treated as if it did not exist
Returns:
schema object found

findUnqualifiedObject

public <T extends CwmModelElement> T findUnqualifiedObject(SqlIdentifier unqualifiedName,
                                                           Class<T> clazz)
Description copied from interface: FarragoSessionStmtValidator
Looks up a top-level object (e.g. a catalog) by name, throwing a validation error if not found.

Specified by:
findUnqualifiedObject in interface FarragoSessionStmtValidator
Parameters:
unqualifiedName - SqlIdentifier which returns true for isSimple()
clazz - class of object to find
Returns:
object found

findRoutineOverloads

public List<FemRoutine> findRoutineOverloads(SqlIdentifier invocationName,
                                             ProcedureType routineType)
Description copied from interface: FarragoSessionStmtValidator
Looks up all matching routine overloads by invocation name.

Specified by:
findRoutineOverloads in interface FarragoSessionStmtValidator
Parameters:
invocationName - invocation name of routine to look up
routineType - type of routine to look up, or null for any type
Returns:
list of matching FemRoutine objects (empty if no matches)

findSqldataType

public CwmSqldataType findSqldataType(SqlIdentifier typeName)
Description copied from interface: FarragoSessionStmtValidator
Looks up a SQL datatype by name, throwing an exception if not found.

Specified by:
findSqldataType in interface FarragoSessionStmtValidator
Parameters:
typeName - name of type to find
Returns:
type definition

findJarFromLiteralName

public FemJar findJarFromLiteralName(String jarName)
Description copied from interface: FarragoSessionStmtValidator
Looks up a jar from a string literal representing its name (typically from a LIBRARY clause), throwing an exception if not found.

Specified by:
findJarFromLiteralName in interface FarragoSessionStmtValidator
Parameters:
jarName - string literal representing name of jar
Returns:
jar found

resolveSchemaObjectName

public <T extends CwmModelElement> FarragoSessionResolvedObject<T> resolveSchemaObjectName(String[] names,
                                                                                           Class<T> clazz)
Description copied from interface: FarragoSessionStmtValidator
Resolve a (possibly qualified) name of a schema object.

Specified by:
resolveSchemaObjectName in interface FarragoSessionStmtValidator
Parameters:
names - array of 1 or more name components, from most general to most specific
clazz - type of object to resolve
Returns:
FarragoSessionResolvedObject, or null if object definitely doesn't exist

getAllSchemaObjectNames

public List<SqlMoniker> getAllSchemaObjectNames(List<String> names)
Description copied from interface: FarragoSessionStmtValidator
Gets schema object names as specified. They can be schema or table object. If names array contain 1 element, return all schema names and all table names under the default schema (if that is set) If names array contain 2 elements, treat 1st element as schema name and return all table names in this schema

Specified by:
getAllSchemaObjectNames in interface FarragoSessionStmtValidator
Parameters:
names - the array contains either 2 elements representing a partially qualified object name in the format of 'schema.object', or an unqualified name in the format of 'object'
Returns:
the list of all SqlMoniker object (schema and table) names under the above criteria

setParserPosition

public void setParserPosition(SqlParserPos pos)
Description copied from interface: FarragoSessionStmtValidator
Sets the parser position to use for context in error messages.

Specified by:
setParserPosition in interface FarragoSessionStmtValidator
Parameters:
pos - new position to set, or null to clear

validateFeature

public void validateFeature(org.eigenbase.resgen.ResourceDefinition feature,
                            SqlParserPos context)
Description copied from interface: FarragoSessionStmtValidator
Validates that a particular feature is enabled.

Specified by:
validateFeature in interface FarragoSessionStmtValidator
Parameters:
feature - feature being used, represented as a resource definition from EigenbaseResource
context - parser position context for error reporting, or null if none available

setTimingTracer

public void setTimingTracer(EigenbaseTimingTracer timingTracer)
Description copied from interface: FarragoSessionStmtValidator
Sets the timing tracer associated with this statement

Specified by:
setTimingTracer in interface FarragoSessionStmtValidator
Parameters:
timingTracer - tracer to use

getTimingTracer

public EigenbaseTimingTracer getTimingTracer()
Specified by:
getTimingTracer in interface FarragoSessionStmtValidator
Returns:
the timing tracer associated with this statement

getSampleDataset

public CwmNamedColumnSet getSampleDataset(CwmNamedColumnSet columnSet,
                                          String datasetName)
Description copied from interface: FarragoSessionStmtValidator
Looks up a sample dataset for a given schema object, or returns null if none is found.

Specified by:
getSampleDataset in interface FarragoSessionStmtValidator
Parameters:
columnSet - Schema object
datasetName - Name of dataset, not null
Returns:
Sample dataset, or null if not found

validateDataType

public void validateDataType(SqlDataTypeSpec dataType)
                      throws SqlValidatorException
Description copied from interface: FarragoSessionStmtValidator
Validates a data type expression.

Specified by:
validateDataType in interface FarragoSessionStmtValidator
Throws:
SqlValidatorException

addAllocation

public void addAllocation(ClosableAllocation allocation)
Description copied from interface: ClosableAllocationOwner
Assigns ownership of a ClosableAllocation to this owner.

Specified by:
addAllocation in interface ClosableAllocationOwner
Parameters:
allocation - the ClosableAllocation to take over

closeAllocation

public void closeAllocation()
Description copied from interface: ClosableAllocation
Closes this object.

Specified by:
closeAllocation in interface ClosableAllocation

setWarningQueue

public void setWarningQueue(FarragoWarningQueue queue)
Description copied from interface: FarragoSessionStmtValidator
Sets the warning queue to be used by this validator

Specified by:
setWarningQueue in interface FarragoSessionStmtValidator
Parameters:
queue - target queue to use

getWarningQueue

public FarragoWarningQueue getWarningQueue()
Description copied from interface: FarragoSessionStmtValidator
Gets the warning queue to be used by this validator

Specified by:
getWarningQueue in interface FarragoSessionStmtValidator
Returns:
warning queue