Class WekaDatabaseWriter

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, PasswordSupporter, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesInspectionHandler, VariableChangeListener, Actor, ErrorHandler, InputConsumer, Serializable, Comparable

    public class WekaDatabaseWriter
    extends AbstractSink
    implements PasswordSupporter
    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: .
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • 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

      • reset

        protected void reset()
        Resets the actor.
        Overrides:
        reset in class AbstractActor
      • 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.
      • 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.
        Specified by:
        accepts in interface InputConsumer
        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.
        Specified by:
        wrapUp in interface Actor
        Overrides:
        wrapUp in class AbstractSink