org.pentaho.platform.plugin.action.sql
Class SQLBaseComponent

java.lang.Object
  extended by org.pentaho.platform.engine.core.system.PentahoBase
      extended by org.pentaho.platform.engine.services.PentahoMessenger
          extended by org.pentaho.platform.engine.services.solution.ComponentBase
              extended by org.pentaho.platform.plugin.action.sql.SQLBaseComponent
All Implemented Interfaces:
Serializable, IDataComponent, IPreparedComponent, IAuditable, IComponent, ILogger, IParameterResolver
Direct Known Subclasses:
SQLLookupRule

public abstract class SQLBaseComponent
extends ComponentBase
implements IDataComponent, IPreparedComponent, IParameterResolver

SQLBaseComponent is the base class for SQLExecute and SQLLookupRule. it does the majority of work when interacting with Pentaho's BI Platform, including implementing the necessary component features. It also implements IDataComponent and IPreparedComponent.

See Also:
SQLExecute, SQLLookupRule, Serialized Form

Field Summary
static String PREPARE_PARAMETER_PREFIX
           
 
Fields inherited from class org.pentaho.platform.engine.services.solution.ComponentBase
COMPONENT_EXECUTE_FAIL, MISSING_SESSION
 
Fields inherited from class org.pentaho.platform.engine.core.system.PentahoBase
EMPTYLOGID, LOGID_MASK1, LOGID_MASK2, LOGID_SEPARATOR
 
Fields inherited from interface org.pentaho.platform.api.engine.ILogger
ACTIVITY_LOG, DEBUG, ERROR, FATAL, INFO, INSTANCE_LOG, SESSION_LOG, SOLUTION_LOG, TRACE, UNKNOWN, WARN
 
Fields inherited from interface org.pentaho.platform.api.data.IPreparedComponent
PREPARE_LATER_INTER_PREFIX, PREPARE_LATER_PLACEHOLDER, PREPARE_LATER_PREFIX, PREPARED_COMPONENT_NAME, PREPARED_OUTPUT_TYPE
 
Fields inherited from interface org.pentaho.platform.api.engine.ILogger
ACTIVITY_LOG, DEBUG, ERROR, FATAL, INFO, INSTANCE_LOG, SESSION_LOG, SOLUTION_LOG, TRACE, UNKNOWN, WARN
 
Constructor Summary
SQLBaseComponent()
           
 
Method Summary
 void dispose()
          dispose of the resultset, and if the owner, dispose of the connection.
 void done()
          nothing to do in done call from runtime context.
 IPentahoResultSet doQuery(SQLConnection sqlConnection, String query, boolean forwardOnlyResultset)
           
 IPentahoResultSet executePrepared(Map preparedParams)
          executes a prepared method that returns a result set executePrepared looks up any "PREPARELATER" params in the preparedParams map.
 IPentahoConnection getDatasourceConnection()
          attempt to aquire a connection.
abstract  Log getLogger()
           
 String getQuery()
           
 int getQueryTimeout()
           
abstract  String getResultOutputName()
           
 IPentahoResultSet getResultSet()
          returns the result set object
 boolean init()
          nothing is done in the init function
 int resolveParameter(String template, String parameter, Matcher parameterMatcher, int copyStart, StringBuffer results)
          This method is called when TemplateUtil.applyTemplate() encounters a parameter.
 void setQueryTimeout(int timeInSec)
           
 IPentahoConnection shareConnection()
          return this class's connection.
 boolean validateAction()
          validates the action.
abstract  boolean validateSystemSettings()
           
 
Methods inherited from class org.pentaho.platform.engine.services.solution.ComponentBase
createFeedbackParameter, createFeedbackParameter, createNewInstance, execute, getActionDefinition, getActionName, getActionTitle, getComponentDefinition, getComponentDefinition, getId, getInitFailMessage, getInitOk, getInstanceId, getLogId, getObjectName, getProcessId, getResourceAsString, getRuntimeContext, getSession, inputMissingError, outputMissingError, promptNeeded, promptNow, resourceComponentSettingError, resourceMissingError, setActionDefinition, setActionName, setComponentDefinition, setComponentDefinitionMap, setInstanceId, setProcessId, setRuntimeContext, setSession, validate
 
Methods inherited from class org.pentaho.platform.engine.services.PentahoMessenger
debug, debug, error, error, fatal, fatal, getMessages, getUserString, info, info, setMessages, trace, trace, warn, warn
 
Methods inherited from class org.pentaho.platform.engine.core.system.PentahoBase
genLogIdFromInfo, genLogIdFromInfo, genLogIdFromSession, getLoggingLevel, setLoggingLevel, setLogId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pentaho.platform.api.engine.IComponent
execute, getActionDefinition, getActionName, getComponentDefinition, getInstanceId, getMessages, getProcessId, getRuntimeContext, getSession, setActionDefinition, setActionName, setComponentDefinition, setComponentDefinitionMap, setInstanceId, setMessages, setProcessId, setRuntimeContext, setSession, validate
 
Methods inherited from interface org.pentaho.platform.api.engine.IAuditable
getId, getObjectName
 
Methods inherited from interface org.pentaho.platform.api.engine.ILogger
debug, debug, error, error, fatal, fatal, getLoggingLevel, info, info, setLoggingLevel, trace, trace, warn, warn
 
Methods inherited from interface org.pentaho.platform.api.engine.IComponent
execute, getActionDefinition, getActionName, getComponentDefinition, getInstanceId, getMessages, getProcessId, getRuntimeContext, getSession, setActionDefinition, setActionName, setComponentDefinition, setComponentDefinitionMap, setInstanceId, setMessages, setProcessId, setRuntimeContext, setSession, validate
 
Methods inherited from interface org.pentaho.platform.api.engine.IAuditable
getId, getObjectName
 
Methods inherited from interface org.pentaho.platform.api.engine.ILogger
debug, debug, error, error, fatal, fatal, getLoggingLevel, info, info, setLoggingLevel, trace, trace, warn, warn
 

Field Detail

PREPARE_PARAMETER_PREFIX

public static final String PREPARE_PARAMETER_PREFIX
See Also:
Constant Field Values
Constructor Detail

SQLBaseComponent

public SQLBaseComponent()
Method Detail

validateSystemSettings

public abstract boolean validateSystemSettings()

getResultOutputName

public abstract String getResultOutputName()

getLogger

public abstract Log getLogger()
Specified by:
getLogger in class PentahoBase

getResultSet

public IPentahoResultSet getResultSet()
returns the result set object

Specified by:
getResultSet in interface IDataComponent
Returns:
pentaho result set

validateAction

public boolean validateAction()
validates the action. checks to verify inputs are available to execute - verify query is available - verify connection is available, via jndi, connection string, or prepared component - verify output is specified


done

public void done()
nothing to do in done call from runtime context.

Specified by:
done in interface IComponent
Specified by:
done in class ComponentBase

executePrepared

public IPentahoResultSet executePrepared(Map preparedParams)
executes a prepared method that returns a result set executePrepared looks up any "PREPARELATER" params in the preparedParams map.

Specified by:
executePrepared in interface IPreparedComponent
Parameters:
preparedParams - a map of possible parameters.
Returns:
result set

doQuery

public IPentahoResultSet doQuery(SQLConnection sqlConnection,
                                 String query,
                                 boolean forwardOnlyResultset)
                          throws Exception
Throws:
Exception

dispose

public void dispose()
dispose of the resultset, and if the owner, dispose of the connection.

Specified by:
dispose in interface IDataComponent
Specified by:
dispose in interface IPreparedComponent

resolveParameter

public int resolveParameter(String template,
                            String parameter,
                            Matcher parameterMatcher,
                            int copyStart,
                            StringBuffer results)
This method is called when TemplateUtil.applyTemplate() encounters a parameter. TemplateUtil.applyTemplate is called when someone makes a call to applyInputsToFormat() In this class it is called in the above "runQuery()" method.

Specified by:
resolveParameter in interface IParameterResolver
Overrides:
resolveParameter in class ComponentBase
Parameters:
template - the source string
parameter - the parameter value
parameterMatcher - the regex parameter matcher
copyStart - the start of the copy
results - the output result
Returns:
the next copystart

getDatasourceConnection

public IPentahoConnection getDatasourceConnection()
attempt to aquire a connection. if connection isn't available, wait a certain period of time before trying again.

Returns:
connection

shareConnection

public IPentahoConnection shareConnection()
return this class's connection. This implements the IPreparedComponent interface, which may share its connection with others.

Specified by:
shareConnection in interface IPreparedComponent
Returns:
connection object

init

public boolean init()
nothing is done in the init function

Specified by:
init in interface IComponent
Specified by:
init in class ComponentBase
Returns:
true always

getQueryTimeout

public int getQueryTimeout()

setQueryTimeout

public void setQueryTimeout(int timeInSec)

getQuery

public String getQuery()