adams.flow.source
Class WekaDatabaseReader

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.core.AbstractActor
              extended by adams.flow.source.AbstractSource
                  extended by adams.flow.source.WekaDatabaseReader
All Implemented Interfaces:
AdditionalInformationHandler, CleanUpHandler, Debuggable, DebugOutputHandler, Destroyable, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<AbstractActor>, SizeOfHandler, Stoppable, DatabaseConnectionParameterHandler, VariableChangeListener, ErrorHandler, OutputProducer, ProvenanceSupporter, Serializable, Comparable

public class WekaDatabaseReader
extends AbstractSource
implements ProvenanceSupporter, 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.
 

Version:
$Revision: 4584 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  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  BasePassword m_Password
          the password for the user used for connecting.
protected  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
FILE_EXTENSION, FILE_EXTENSION_GZ, m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_FullName, m_Headless, m_Name, m_Parent, m_Root, m_Self, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
WekaDatabaseReader()
           
 
Method Summary
 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.
 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).
 BasePassword getPassword()
          Returns the database password.
 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.
 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(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(BasePassword value)
          Sets the database password.
 void setQuery(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.
 void updateProvenance(ProvenanceContainer cont)
          Updates the provenance information in the provided container.
 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, debug, destroy, equals, execute, findVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFullName, getName, getNextSibling, getParent, getPreviousSibling, getRoot, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, postExecute, preExecute, pruneBackup, pruneBackup, restoreState, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debugLevelTipText, finishInit, getDebugLevel, getOptionManager, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 BasePassword m_Password
the password for the user used for connecting.


m_Query

protected 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 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.

Constructor Detail

WekaDatabaseReader

public WekaDatabaseReader()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class 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 interface OptionHandler
Overrides:
defineOptions in class AbstractActor

getQuickInfo

public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.

Specified by:
getQuickInfo in interface QuickInfoSupporter
Overrides:
getQuickInfo in class 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 interface DatabaseConnectionParameterHandler
Parameters:
value - the JDBC URL

getURL

public String getURL()
Returns the query to execute.

Specified by:
getURL in interface DatabaseConnectionParameterHandler
Returns:
the query

URLTipText

public String URLTipText()
Returns the tip text for this property.

Specified by:
URLTipText in interface 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 interface DatabaseConnectionParameterHandler
Parameters:
value - the user

getUser

public String getUser()
Returns the database user.

Specified by:
getUser in interface DatabaseConnectionParameterHandler
Returns:
the user

userTipText

public String userTipText()
Returns the tip text for this property.

Specified by:
userTipText in interface DatabaseConnectionParameterHandler
Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setPassword

public void setPassword(BasePassword value)
Sets the database password.

Specified by:
setPassword in interface DatabaseConnectionParameterHandler
Parameters:
value - the password

getPassword

public BasePassword getPassword()
Returns the database password.

Specified by:
getPassword in interface DatabaseConnectionParameterHandler
Returns:
the password

passwordTipText

public String passwordTipText()
Returns the tip text for this property.

Specified by:
passwordTipText in interface DatabaseConnectionParameterHandler
Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setQuery

public void setQuery(SQLStatement value)
Sets the query to execute.

Parameters:
value - the query

getQuery

public 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(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 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 interface OutputProducer
Returns:
weka.core.Instance.class, weka.core.Instances.class

reset

protected void reset()
Resets the scheme.

Overrides:
reset in class AbstractActor

doExecute

protected String doExecute()
Executes the flow item.

Specified by:
doExecute in class AbstractActor
Returns:
null if everything is fine, otherwise error message

output

public Token output()
Returns the generated token.

Specified by:
output in interface 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 interface OutputProducer
Returns:
true if there is pending output

updateProvenance

public void updateProvenance(ProvenanceContainer cont)
Updates the provenance information in the provided container.

Specified by:
updateProvenance in interface ProvenanceSupporter
Parameters:
cont - the provenance container to update

wrapUp

public void wrapUp()
Cleans up after the execution has finished.

Overrides:
wrapUp in class AbstractActor


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.