adams.flow.sink
Class WekaDatabaseWriter

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.core.AbstractActor
              extended by adams.flow.sink.AbstractSink
                  extended by adams.flow.sink.WekaDatabaseWriter
All Implemented Interfaces:
AdditionalInformationHandler, CleanUpHandler, Debuggable, DebugOutputHandler, Destroyable, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<AbstractActor>, SizeOfHandler, Stoppable, VariableChangeListener, ErrorHandler, InputConsumer, Serializable, Comparable

public class WekaDatabaseWriter
extends AbstractSink

Actor for saving a weka.core.Instances object in a database.
The relation name of the incoming dataset can be used to replace the current filename (path and extension are kept).

Input/output:
- accepts:
   weka.core.Instances
   weka.core.Instance

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: WekaDatabaseWriter
 
-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.
 
-table <java.lang.String> (property: tableName)
    The name of the table to store the data in.
    default: weka
 
-auto-key-generation (property: autoKeyGeneration)
    If set to true, a primary key is automatically generated.
 
-use-relation-as-table (property: useRelationNameAsTable)
    If set to true, the relation name is used as table name.
 
-custom-props <adams.core.io.PlaceholderFile> (property: customPropsFile)
    Custom properties file to override the default database settings, eg, for
    accessing a different type of database; ignored if pointing to a directory.
    default: .
 

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

Field Summary
static String BACKUP_SAVER
          the key for storing the current incremental clusterer in the backup.
protected  boolean m_AutoKeyGeneration
          whether to automatically generate a primary key.
protected  PlaceholderFile m_CustomPropsFile
          a custom properties file to use instead of default one.
protected  BasePassword m_Password
          the password for the user used for connecting.
protected  weka.core.converters.DatabaseSaver m_Saver
          the database saver.
protected  String m_TableName
          protected the name of the table to store the data in.
protected  String m_URL
          the database URL to query.
protected  String m_User
          the database user to use for connecting.
protected  boolean m_UseRelationNameAsTable
          whether to use the relation as table name.
 
Fields inherited from class adams.flow.sink.AbstractSink
BACKUP_INPUT, m_InputToken
 
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
WekaDatabaseWriter()
           
 
Method Summary
 Class[] accepts()
          Returns the class that the consumer accepts.
 String autoKeyGenerationTipText()
          Returns the tip text for this property.
protected  Hashtable<String,Object> backupState()
          Backs up the current state of the actor before update the variables.
 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.
 boolean getAutoKeyGeneration()
          Returns whether a primary key is automatically generated.
 PlaceholderFile getCustomPropsFile()
          Returns the custom properties file to use for initializing the database setup instead of WEKA's default one.
 BasePassword getPassword()
          Returns the database password.
 String getQuickInfo()
          Returns a quick info about the actor, which will be displayed in the GUI.
 String getTableName()
          Returns the table name to store the data in.
 String getURL()
          Returns the query to execute.
 String getUser()
          Returns the database user.
 boolean getUseRelationNameAsTable()
          Returns whether to output single Instance objects or just one Instances object.
 String globalInfo()
          Returns a string describing the object.
 String passwordTipText()
          Returns the tip text for this property.
protected  void pruneBackup()
          Removes entries from the backup.
protected  void reset()
          Resets the actor.
protected  void restoreState(Hashtable<String,Object> state)
          Restores the state of the actor before the variables got updated.
 void setAutoKeyGeneration(boolean value)
          Sets whether to automatically generate a primary key.
 void setCustomPropsFile(PlaceholderFile value)
          Sets the custom properties file to use for initializing the database setup instead of WEKA's default one.
 void setPassword(BasePassword value)
          Sets the database password.
 void setTableName(String value)
          Sets the table name to store the data in.
 void setURL(String value)
          Sets the database URL to query.
 void setUser(String value)
          Sets the database user.
 void setUseRelationNameAsTable(boolean value)
          Sets whether to output single Instance objects or just one Instances object.
 String tableNameTipText()
          Returns the tip text for this property.
 String URLTipText()
          Returns the tip text for this property.
 String useRelationNameAsTableTipText()
          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.sink.AbstractSink
input
 
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, 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, 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

BACKUP_SAVER

public static final String BACKUP_SAVER
the key for storing the current incremental clusterer in the backup.

See Also:
Constant Field Values

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_TableName

protected String m_TableName
protected the name of the table to store the data in.


m_AutoKeyGeneration

protected boolean m_AutoKeyGeneration
whether to automatically generate a primary key.


m_UseRelationNameAsTable

protected boolean m_UseRelationNameAsTable
whether to use the relation as table name.


m_CustomPropsFile

protected PlaceholderFile m_CustomPropsFile
a custom properties file to use instead of default one.


m_Saver

protected weka.core.converters.DatabaseSaver m_Saver
the database saver.

Constructor Detail

WekaDatabaseWriter

public WekaDatabaseWriter()
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

reset

protected void reset()
Resets the actor.

Overrides:
reset 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

pruneBackup

protected void pruneBackup()
Removes entries from the backup.

Overrides:
pruneBackup in class AbstractActor

backupState

protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.

Overrides:
backupState in class AbstractSink
Returns:
the backup

restoreState

protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.

Overrides:
restoreState in class AbstractSink
Parameters:
state - the backup of the state to restore from

setURL

public void setURL(String value)
Sets the database URL to query.

Parameters:
value - the JDBC URL

getURL

public String getURL()
Returns the query to execute.

Returns:
the query

URLTipText

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

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.

Parameters:
value - the user

getUser

public String getUser()
Returns the database user.

Returns:
the user

userTipText

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

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.

Parameters:
value - the password

getPassword

public BasePassword getPassword()
Returns the database password.

Returns:
the password

passwordTipText

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

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setTableName

public void setTableName(String value)
Sets the table name to store the data in.

Parameters:
value - the table name

getTableName

public String getTableName()
Returns the table name to store the data in.

Returns:
the table name

tableNameTipText

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

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setAutoKeyGeneration

public void setAutoKeyGeneration(boolean value)
Sets whether to automatically generate a primary key.

Parameters:
value - if true then a primary key is generated

getAutoKeyGeneration

public boolean getAutoKeyGeneration()
Returns whether a primary key is automatically generated.

Returns:
true if a primary key is generated

autoKeyGenerationTipText

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

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setUseRelationNameAsTable

public void setUseRelationNameAsTable(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

getUseRelationNameAsTable

public boolean getUseRelationNameAsTable()
Returns whether to output single Instance objects or just one Instances object.

Returns:
true if single Instance objects are output

useRelationNameAsTableTipText

public String useRelationNameAsTableTipText()
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.

accepts

public Class[] accepts()
Returns the class that the consumer accepts.

Returns:
weka.core.Instances.class, weka.core.Instance.class

doExecute

protected String doExecute()
Executes the flow item.

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

wrapUp

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

Overrides:
wrapUp in class AbstractSink


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