Package adams.flow.source
Class WekaDatabaseReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.core.AbstractActor
-
- adams.flow.source.AbstractSource
-
- adams.flow.source.WekaDatabaseReader
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler
,adams.core.CleanUpHandler
,adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.PasswordSupporter
,adams.core.QuickInfoSupporter
,adams.core.ShallowCopySupporter<adams.flow.core.Actor>
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.core.StoppableWithFeedback
,adams.core.VariablesInspectionHandler
,adams.db.DatabaseConnectionParameterHandler
,adams.event.VariableChangeListener
,adams.flow.core.Actor
,adams.flow.core.ErrorHandler
,adams.flow.core.OutputProducer
,Serializable
,Comparable
public class WekaDatabaseReader extends adams.flow.source.AbstractSource implements adams.db.DatabaseConnectionParameterHandler
Executes a query and returns the data either in batch or incremental mode.
Input/output:
- generates:
weka.core.Instance
weka.core.Instances
Valid options are:
-D <int> (property: debugLevel) The greater the number the more additional info the scheme may output to the console (0 = off). default: 0 minimum: 0
-name <java.lang.String> (property: name) The name of the actor. default: WekaDatabaseReader
-annotation <adams.core.base.BaseText> (property: annotations) The annotations to attach to this actor. default:
-skip (property: skip) If set to true, transformation is skipped and the input token is just forwarded as it is.
-stop-flow-on-error (property: stopFlowOnError) If set to true, the flow gets stopped in case this actor encounters an error; useful for critical actors.
-url <java.lang.String> (property: URL) The JDBC URL of the database to query.
-user <java.lang.String> (property: user) The user for connecting to the database.
-password <adams.core.base.BasePassword> (property: password) The password for the database user.
-query <java.lang.String> (property: query) The SQL query to execute. default: select * from result0
-keys <java.lang.String> (property: keys) The keys to use for identifying a single row (comma-separated list of column names). default:
-incremental (property: incremental) If set to true, then single Instance objects are output, otherwise just one Instances object.
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.core.io.PlaceholderFile
m_CustomPropsFile
a custom properties file to use instead of default one.protected weka.core.Instances
m_Data
the full data.protected boolean
m_Incremental
whether to output the data row-by-row.protected String
m_Keys
the keys that uniquely identify a single row.protected weka.core.Instance
m_NextInstance
the next instance to output.protected adams.core.base.BasePassword
m_Password
the password for the user used for connecting.protected adams.db.SQLStatement
m_Query
the query to execute.protected weka.core.converters.DatabaseLoader
m_Source
the actual loader for loading the data.protected boolean
m_SparseFormat
whether to output data in sparse format.protected weka.core.Instances
m_Structure
the structure.protected String
m_URL
the database URL to query.protected String
m_User
the database user to use for connecting.-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
-
Constructor Summary
Constructors Constructor Description WekaDatabaseReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
customPropsFileTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected String
doExecute()
Executes the flow item.Class[]
generates()
Returns the class of objects that it generates.adams.core.io.PlaceholderFile
getCustomPropsFile()
Returns the custom properties file to use for initializing the database setup instead of WEKA's default one.boolean
getIncremental()
Returns whether to output single Instance objects or just one Instances object.String
getKeys()
Returns the keys to use for identifying a single row (comma-separated list).adams.core.base.BasePassword
getPassword()
Returns the database password.adams.db.SQLStatement
getQuery()
Returns the query to execute.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.boolean
getSparseFormat()
Returns whether data is output in sparse format.String
getURL()
Returns the query to execute.String
getUser()
Returns the database user.String
globalInfo()
Returns a string describing the object.boolean
hasPendingOutput()
Checks whether there is pending output to be collected after executing the flow item.String
incrementalTipText()
Returns the tip text for this property.String
keysTipText()
Returns the tip text for this property.adams.flow.core.Token
output()
Returns the generated token.String
passwordTipText()
Returns the tip text for this property.String
queryTipText()
Returns the tip text for this property.protected void
reset()
Resets the scheme.void
setCustomPropsFile(adams.core.io.PlaceholderFile value)
Sets the custom properties file to use for initializing the database setup instead of WEKA's default one.void
setIncremental(boolean value)
Sets whether to output single Instance objects or just one Instances object.void
setKeys(String value)
Sets the keys to use for identifying a single row (comma-separated list).void
setPassword(adams.core.base.BasePassword value)
Sets the database password.void
setQuery(adams.db.SQLStatement value)
Sets the query to execute.void
setSparseFormat(boolean value)
Sets whether to output the data in sparse format.void
setURL(String value)
Sets the database URL to query.void
setUser(String value)
Sets the database user.String
sparseFormatTipText()
Returns the tip text for this property.String
URLTipText()
Returns the tip text for this property.String
userTipText()
Returns the tip text for this property.void
wrapUp()
Cleans up after the execution has finished.-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, equals, execute, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, preExecute, pruneBackup, pruneBackup, restoreState, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
cleanUp, compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, stopExecution, toCommandLine, variableChanged
-
-
-
-
Field Detail
-
m_URL
protected String m_URL
the database URL to query.
-
m_User
protected String m_User
the database user to use for connecting.
-
m_Password
protected adams.core.base.BasePassword m_Password
the password for the user used for connecting.
-
m_Query
protected adams.db.SQLStatement m_Query
the query to execute.
-
m_Keys
protected String m_Keys
the keys that uniquely identify a single row.
-
m_Incremental
protected boolean m_Incremental
whether to output the data row-by-row.
-
m_SparseFormat
protected boolean m_SparseFormat
whether to output data in sparse format.
-
m_CustomPropsFile
protected adams.core.io.PlaceholderFile m_CustomPropsFile
a custom properties file to use instead of default one.
-
m_Structure
protected weka.core.Instances m_Structure
the structure.
-
m_Source
protected weka.core.converters.DatabaseLoader m_Source
the actual loader for loading the data.
-
m_NextInstance
protected weka.core.Instance m_NextInstance
the next instance to output.
-
m_Data
protected weka.core.Instances m_Data
the full data.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.core.option.AbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.flow.core.AbstractActor
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceadams.flow.core.Actor
- Specified by:
getQuickInfo
in interfaceadams.core.QuickInfoSupporter
- Overrides:
getQuickInfo
in classadams.flow.core.AbstractActor
- Returns:
- null if no info available, otherwise short string
-
setURL
public void setURL(String value)
Sets the database URL to query.- Specified by:
setURL
in interfaceadams.db.DatabaseConnectionParameterHandler
- Parameters:
value
- the JDBC URL
-
getURL
public String getURL()
Returns the query to execute.- Specified by:
getURL
in interfaceadams.db.DatabaseConnectionParameterHandler
- Returns:
- the query
-
URLTipText
public String URLTipText()
Returns the tip text for this property.- Specified by:
URLTipText
in interfaceadams.db.DatabaseConnectionParameterHandler
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUser
public void setUser(String value)
Sets the database user.- Specified by:
setUser
in interfaceadams.db.DatabaseConnectionParameterHandler
- Parameters:
value
- the user
-
getUser
public String getUser()
Returns the database user.- Specified by:
getUser
in interfaceadams.db.DatabaseConnectionParameterHandler
- Returns:
- the user
-
userTipText
public String userTipText()
Returns the tip text for this property.- Specified by:
userTipText
in interfaceadams.db.DatabaseConnectionParameterHandler
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPassword
public void setPassword(adams.core.base.BasePassword value)
Sets the database password.- Specified by:
setPassword
in interfaceadams.db.DatabaseConnectionParameterHandler
- Specified by:
setPassword
in interfaceadams.core.PasswordSupporter
- Parameters:
value
- the password
-
getPassword
public adams.core.base.BasePassword getPassword()
Returns the database password.- Specified by:
getPassword
in interfaceadams.db.DatabaseConnectionParameterHandler
- Specified by:
getPassword
in interfaceadams.core.PasswordSupporter
- Returns:
- the password
-
passwordTipText
public String passwordTipText()
Returns the tip text for this property.- Specified by:
passwordTipText
in interfaceadams.db.DatabaseConnectionParameterHandler
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setQuery
public void setQuery(adams.db.SQLStatement value)
Sets the query to execute.- Parameters:
value
- the query
-
getQuery
public adams.db.SQLStatement getQuery()
Returns the query to execute.- Returns:
- the query
-
queryTipText
public String queryTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setKeys
public void setKeys(String value)
Sets the keys to use for identifying a single row (comma-separated list).- Parameters:
value
- the keys
-
getKeys
public String getKeys()
Returns the keys to use for identifying a single row (comma-separated list).- Returns:
- the keys
-
keysTipText
public String keysTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setIncremental
public void setIncremental(boolean value)
Sets whether to output single Instance objects or just one Instances object.- Parameters:
value
- if true then a single Instance objects are output
-
getIncremental
public boolean getIncremental()
Returns whether to output single Instance objects or just one Instances object.- Returns:
- true if single Instance objects are output
-
incrementalTipText
public String incrementalTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setSparseFormat
public void setSparseFormat(boolean value)
Sets whether to output the data in sparse format.- Parameters:
value
- if true then sparse format is used
-
getSparseFormat
public boolean getSparseFormat()
Returns whether data is output in sparse format.- Returns:
- true if sparse format is used
-
sparseFormatTipText
public String sparseFormatTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setCustomPropsFile
public void setCustomPropsFile(adams.core.io.PlaceholderFile value)
Sets the custom properties file to use for initializing the database setup instead of WEKA's default one.- Parameters:
value
- the custom props file, ignored if a directory
-
getCustomPropsFile
public adams.core.io.PlaceholderFile getCustomPropsFile()
Returns the custom properties file to use for initializing the database setup instead of WEKA's default one.- Returns:
- the custom props file, ignored if a directory
-
customPropsFileTipText
public String customPropsFileTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
generates
public Class[] generates()
Returns the class of objects that it generates.- Specified by:
generates
in interfaceadams.flow.core.OutputProducer
- Returns:
- weka.core.Instance.class, weka.core.Instances.class
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classadams.flow.core.AbstractActor
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecute
in classadams.flow.core.AbstractActor
- Returns:
- null if everything is fine, otherwise error message
-
output
public adams.flow.core.Token output()
Returns the generated token.- Specified by:
output
in interfaceadams.flow.core.OutputProducer
- Returns:
- the generated token
-
hasPendingOutput
public boolean hasPendingOutput()
Checks whether there is pending output to be collected after executing the flow item.- Specified by:
hasPendingOutput
in interfaceadams.flow.core.OutputProducer
- Returns:
- true if there is pending output
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished.- Specified by:
wrapUp
in interfaceadams.flow.core.Actor
- Overrides:
wrapUp
in classadams.flow.core.AbstractActor
-
-