public abstract class SQLBaseComponent extends ComponentBase implements IDataComponent, IPreparedComponent, IParameterResolver
SQLExecute
,
SQLLookupRule
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected org.pentaho.commons.connection.IPentahoConnection |
connection
reference to connection object
|
protected boolean |
connectionOwner
is set to false if using another IPreparedComponents connection vs own
|
static String |
PREPARE_PARAMETER_PREFIX |
protected List |
preparedParameters
stores the prepared parameters for later use
|
protected String |
preparedQuery
stores the prepared query for later use
|
COMPONENT_EXECUTE_FAIL, debug, MISSING_SESSION, UNKNOWN_COMPONENT_ID
EMPTYLOGID, loggingLevel, LOGID_MASK1, LOGID_MASK2, LOGID_SEPARATOR
PREPARE_LATER_INTER_PREFIX, PREPARE_LATER_PLACEHOLDER, PREPARE_LATER_PREFIX, PREPARED_COMPONENT_NAME, PREPARED_OUTPUT_TYPE
ACTIVITY_LOG, DEBUG, ERROR, FATAL, INFO, INSTANCE_LOG, SESSION_LOG, SOLUTION_LOG, TRACE, UNKNOWN, WARN
Constructor and Description |
---|
SQLBaseComponent() |
Modifier and Type | Method and Description |
---|---|
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.
|
org.pentaho.commons.connection.IPentahoResultSet |
doQuery(SQLConnection sqlConnection,
String query,
boolean forwardOnlyResultset) |
protected boolean |
executeAction()
determines state of component, and executes accordingly.
|
org.pentaho.commons.connection.IPentahoResultSet |
executePrepared(Map preparedParams)
executes a prepared method that returns a result set executePrepared looks up any "PREPARELATER" params in the
preparedParams map.
|
protected org.pentaho.commons.connection.IPentahoConnection |
getConnection()
pass through to getConnection(defaultConnection)
|
protected org.pentaho.commons.connection.IPentahoConnection |
getConnection(org.pentaho.commons.connection.IPentahoConnection defaultConnection)
This method retrieves a connection based on the components inputs.
|
org.pentaho.commons.connection.IPentahoConnection |
getDatasourceConnection()
attempt to aquire a connection.
|
abstract org.apache.commons.logging.Log |
getLogger() |
int |
getMaxRows() |
protected org.pentaho.commons.connection.IPentahoMetaData |
getMetadata(org.pentaho.commons.connection.IPentahoResultSet resultSet,
boolean live)
returns metadata based on the result set.
|
String |
getQuery() |
int |
getQueryTimeout() |
boolean |
getReadOnly() |
abstract String |
getResultOutputName() |
org.pentaho.commons.connection.IPentahoResultSet |
getResultSet()
returns the result set object
|
boolean |
init()
nothing is done in the init function
|
protected boolean |
prepareQuery(String rawQuery)
called when in prepared-component mode, this method populates the preparedQuery string and preparedParameters
object.
|
int |
resolveParameter(String template,
String parameter,
Matcher parameterMatcher,
int copyStart,
StringBuffer results)
This method is called when TemplateUtil.applyTemplate() encounters a parameter.
|
protected boolean |
runQuery(String rawQuery,
boolean live)
executes the specified query template.
|
void |
setMaxRows(int value) |
void |
setQueryTimeout(int timeInSec) |
void |
setReadOnly(boolean value) |
org.pentaho.commons.connection.IPentahoConnection |
shareConnection()
return this class's connection.
|
boolean |
validateAction()
validates the action.
|
abstract boolean |
validateSystemSettings() |
protected void |
waitFor(int millis)
pause the thread a certain number of milliseconds
|
addTempParameter, addTempParameterObject, applyInputsToFormat, audit, createFeedbackParameter, createFeedbackParameter, createFeedbackParameter, createFeedbackParameter, createFeedbackParameter, createFeedbackParameter, createFeedbackParameter, createNewInstance, execute, feedbackAllowed, getActionDefinition, getActionName, getActionTitle, getComponentDefinition, getComponentDefinition, getContentOutputItem, getDefaultOutputStream, getFeedbackOutputStream, getId, getInitFailMessage, getInitOk, getInputBooleanValue, getInputLongValue, getInputNames, getInputParameter, getInputStream, getInputStringValue, getInputStringValue, getInputValue, getInstanceId, getLogId, getObjectName, getOutputContentItem, getOutputContentItem, getOutputItem, getOutputItem, getOutputNames, getOutputPreference, getProcessId, getResource, getResourceAsString, getResourceDataSource, getResourceInputStream, getResourceNames, getRuntimeContext, getSession, getSetting, getSolutionName, getSolutionPath, getStringSetting, inputMissingError, isDefinedInput, isDefinedOutput, isDefinedResource, isPromptPending, outputMissingError, promptNeeded, promptNow, resourceComponentSettingError, resourceMissingError, saveSetting, setActionDefinition, setActionName, setComponentDefinition, setComponentDefinitionMap, setFeedbackMimeType, setInstanceId, setOutputMimeType, setOutputMimeType, setOutputValue, setProcessId, setRuntimeContext, setSession, validate
debug, debug, error, error, error, fatal, fatal, getMessages, getUserString, info, info, setMessages, trace, trace, warn, warn
genLogIdFromInfo, genLogIdFromInfo, genLogIdFromSession, getLoggingLevel, setLoggingLevel, setLogId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute, getActionDefinition, getActionName, getComponentDefinition, getInstanceId, getMessages, getProcessId, getRuntimeContext, getSession, setActionDefinition, setActionName, setComponentDefinition, setComponentDefinitionMap, setInstanceId, setMessages, setProcessId, setRuntimeContext, setSession, validate
getId, getObjectName
public static final String PREPARE_PARAMETER_PREFIX
protected String preparedQuery
protected List preparedParameters
protected boolean connectionOwner
protected org.pentaho.commons.connection.IPentahoConnection connection
public abstract boolean validateSystemSettings()
validateSystemSettings
in class ComponentBase
public abstract String getResultOutputName()
public abstract org.apache.commons.logging.Log getLogger()
getLogger
in class PentahoBase
public org.pentaho.commons.connection.IPentahoResultSet getResultSet()
getResultSet
in interface IDataComponent
public boolean validateAction()
validateAction
in class ComponentBase
public void done()
done
in interface IComponent
done
in class ComponentBase
protected boolean executeAction()
executeAction
in class ComponentBase
protected org.pentaho.commons.connection.IPentahoMetaData getMetadata(org.pentaho.commons.connection.IPentahoResultSet resultSet, boolean live)
resultSet
- result set object to find metadatalive
- if false, create an in memory versionpublic org.pentaho.commons.connection.IPentahoResultSet executePrepared(Map preparedParams)
executePrepared
in interface IPreparedComponent
preparedParams
- a map of possible parameters.protected boolean prepareQuery(String rawQuery)
rawQuery
- protected boolean runQuery(String rawQuery, boolean live)
rawQuery
- query templatelive
- returns original result set if true, memory result set if falsepublic org.pentaho.commons.connection.IPentahoResultSet doQuery(SQLConnection sqlConnection, String query, boolean forwardOnlyResultset) throws Exception
Exception
public void dispose()
dispose
in interface org.pentaho.commons.connection.IDisposable
dispose
in interface IDataComponent
dispose
in interface IPreparedComponent
public int resolveParameter(String template, String parameter, Matcher parameterMatcher, int copyStart, StringBuffer results)
resolveParameter
in interface IParameterResolver
resolveParameter
in class ComponentBase
template
- the source stringparameter
- the parameter valueparameterMatcher
- the regex parameter matchercopyStart
- the start of the copyresults
- the output resultpublic org.pentaho.commons.connection.IPentahoConnection getDatasourceConnection()
protected void waitFor(int millis)
millis
- time to sleeppublic org.pentaho.commons.connection.IPentahoConnection shareConnection()
shareConnection
in interface IPreparedComponent
protected org.pentaho.commons.connection.IPentahoConnection getConnection()
protected org.pentaho.commons.connection.IPentahoConnection getConnection(org.pentaho.commons.connection.IPentahoConnection defaultConnection)
defaultConnection
- a default connection to use if no other is availablepublic boolean init()
init
in interface IComponent
init
in class ComponentBase
public int getQueryTimeout()
public void setQueryTimeout(int timeInSec)
public int getMaxRows()
public void setMaxRows(int value)
public String getQuery()
public void setReadOnly(boolean value)
public boolean getReadOnly()
Copyright © 2017 Hitachi Vantara. All rights reserved.