Class TimeseriesDbReader

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

    public class TimeseriesDbReader
    extends AbstractDbSource
    Outputs timeseries containers generated from an SQL SELECT statement.
    A new container is started, whenever the value of the ID column changes (hence you need to ensure that the data is ordered on this column).

    Input/output:
    - generates:
       adams.data.timeseries.Timeseries


    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: TimeseriesDbReader
     
    -annotation <adams.core.base.BaseText> (property: annotations)
        The annotations to attach to this actor.
        default: 
     
    -skip <boolean> (property: skip)
        If set to true, transformation is skipped and the input token is just forwarded 
        as it is.
        default: false
     
    -stop-flow-on-error <boolean> (property: stopFlowOnError)
        If set to true, the flow gets stopped in case this actor encounters an error;
         useful for critical actors.
        default: false
     
    -sql <adams.db.SQLStatement> (property: SQL)
        The SQL statement that selects the timeseries data.
        default: select id,timestamp,value from table order by id
     
    -column-id <java.lang.String> (property: columnID)
        The name of the column containing the ID that distinguishes the timeseries 
        (accepted types: numeric, string); if left empty, the first string column 
        from the SQL statement is used.
        default: 
     
    -column-timestamp <java.lang.String> (property: columnTimestamp)
        The name of the column containing the timestamp for a data point (accepted 
        types: integer, date, time, datetime, timestamp); if left empty, the first 
        date-like column from the SQL statement is used.
        default: 
     
    -column-value <java.lang.String> (property: columnValue)
        The name of the column containing the value for a data point (accepted types:
         numeric); if left empty, the first numeric column from the SQL statement 
        is used.
        default: 
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_SQL

        protected SQLStatement m_SQL
        the SQL statement to execute.
      • m_ColumnID

        protected String m_ColumnID
        the ID column.
      • m_ColumnIDType

        protected int m_ColumnIDType
        the ID column type.
      • m_ColumnIDIndex

        protected int m_ColumnIDIndex
        the ID column index.
      • m_ColumnTimestamp

        protected String m_ColumnTimestamp
        the timestamp column.
      • m_ColumnTimestampType

        protected int m_ColumnTimestampType
        the timestamp column index.
      • m_ColumnTimestampIndex

        protected int m_ColumnTimestampIndex
        the timestamp column type.
      • m_ColumnValue

        protected String m_ColumnValue
        the value column.
      • m_ColumnValueType

        protected int m_ColumnValueType
        the value column type.
      • m_ColumnValueIndex

        protected int m_ColumnValueIndex
        the value column index.
      • m_Timeseries

        protected Timeseries m_Timeseries
        the current container.
      • m_ResultSet

        protected transient ResultSet m_ResultSet
        the resultset for retrieving the data.
    • Constructor Detail

      • TimeseriesDbReader

        public TimeseriesDbReader()
    • Method Detail

      • reset

        protected void reset()
        Resets the scheme.
        Overrides:
        reset in class AbstractActor
      • setSQL

        public void setSQL​(SQLStatement value)
        Sets the SQL statement to run.
        Parameters:
        value - the statement
      • getSQL

        public SQLStatement getSQL()
        Returns the SQL statement to run.
        Returns:
        the statement
      • SQLTipText

        public String SQLTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setColumnID

        public void setColumnID​(String value)
        Sets the name of the ID column.
        Parameters:
        value - the column name
      • getColumnID

        public String getColumnID()
        Returns the name of the ID column.
        Returns:
        the column name
      • columnIDTipText

        public String columnIDTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setColumnTimestamp

        public void setColumnTimestamp​(String value)
        Sets the name of the timestamp column.
        Parameters:
        value - the column name
      • getColumnTimestamp

        public String getColumnTimestamp()
        Returns the name of the timestamp column.
        Returns:
        the column name
      • columnTimestampTipText

        public String columnTimestampTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setColumnValue

        public void setColumnValue​(String value)
        Sets the name of the value column.
        Parameters:
        value - the column name
      • getColumnValue

        public String getColumnValue()
        Returns the name of the value column.
        Returns:
        the column name
      • columnValueTipText

        public String columnValueTipText()
        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.
        Returns:
        the Class of the generated tokens
      • readDataPoint

        protected TimeseriesPoint readDataPoint()
                                         throws Exception
        Reads the next timeseries data point.
        Returns:
        the next data point
        Throws:
        Exception - if reading of timeseries data fails
      • read

        protected Timeseries read()
                           throws Exception
        Completes and returns the last timeseries that was started.
        Returns:
        the last timeseries, null if none previously started
        Throws:
        Exception - if reading of timeseries data fails
      • analyzeColumns

        protected void analyzeColumns()
                               throws Exception
        Analyzes the columns.
        Throws:
        Exception - if columns not present or of wrong type
      • queryDatabase

        protected String queryDatabase()
        Performs the actual database query.
        Specified by:
        queryDatabase in class AbstractDbSource
        Returns:
        null if everything is fine, otherwise error message
      • hasPendingOutput

        public boolean hasPendingOutput()
        Checks whether there is pending output to be collected after executing the flow item.
        Returns:
        true if there is pending output
      • output

        public Token output()
        Returns the generated token.
        Returns:
        the generated token
      • wrapUp

        public void wrapUp()
        Cleans up after the execution has finished. Graphical output is left untouched.
        Specified by:
        wrapUp in interface Actor
        Overrides:
        wrapUp in class AbstractDbSource