Class TrackingIndex

  • All Implemented Interfaces:
    Configurable, java.lang.AutoCloseable

    public class TrackingIndex
    extends JDBCConnection
    Tracking index stores component state in a database. Only SQLITE or local development should rely on createSchema. Mysql Schema Example:
     CREATE TABLE IF NOT EXISTS tracking_index
     (id INTEGER PRIMARY KEY AUTO_INCREMENT
     , created VARCHAR(255)
     , name VARCHAR(255)
     , data LONGTEXT
     , UNIQUE KEY name_index (name)
     ) ENGINE=innodb CHARSET=utf8;
     
    • Field Detail

      • DEFAULT_DRIVER

        public static final java.lang.String DEFAULT_DRIVER
        Variable for the default driver
        See Also:
        Constant Field Values
      • DEFAULT_TABLE

        public static final java.lang.String DEFAULT_TABLE
        Variable for the default table
        See Also:
        Constant Field Values
      • DEFAULT_URL

        public static final java.lang.String DEFAULT_URL
        Variable for the default URL
        See Also:
        Constant Field Values
    • Constructor Detail

      • TrackingIndex

        public TrackingIndex()
        Construct a TrackingIndex using defaults.
      • TrackingIndex

        public TrackingIndex​(java.lang.String driver,
                             java.lang.String url)
        Construct a TrackingIndex with the default table.
        Parameters:
        driver - Driver to use
        url - URL to use
      • TrackingIndex

        public TrackingIndex​(java.lang.String driver,
                             java.lang.String url,
                             java.lang.String table)
        Construct a TrackingIndex with custom driver, url, and table.
        Parameters:
        driver - Driver to use
        url - URL to use
        table - Table to use
    • Method Detail

      • getTable

        public java.lang.String getTable()
        Returns:
        table
      • setTable

        public void setTable​(java.lang.String table)
        Parameters:
        table - Table to set
      • configure

        public void configure​(Config config)
                       throws java.lang.Exception
        Description copied from class: JDBCConnection
        Implement Configurable
        Specified by:
        configure in interface Configurable
        Overrides:
        configure in class JDBCConnection
        Parameters:
        config - Config to set driver and URL in
        Throws:
        java.lang.Exception - Exception
      • startup

        public void startup()
                     throws java.lang.Exception
        After normal startup, check whether schema exists and attempt to create.
        Specified by:
        startup in interface Configurable
        Overrides:
        startup in class JDBCConnection
        Throws:
        java.lang.Exception - if error occurs
      • schemaExists

        public boolean schemaExists()
                             throws java.lang.Exception
        Check whether schema exists.
        Returns:
        boolean
        Throws:
        java.lang.Exception - if error occurs
      • createSchema

        public void createSchema()
                          throws java.lang.Exception
        Attempt to create schema. Only supports sqlite or mysql. When not using sqlite, relying on this method is only recommended for local development.
        Throws:
        java.lang.Exception - if error occurs
      • getTrackingData

        public javax.json.JsonObject getTrackingData​(java.lang.String name)
                                              throws java.lang.Exception
        Get tracking data for specified name.
        Parameters:
        name - name of tracking data.
        Returns:
        null if data not found.
        Throws:
        java.lang.Exception - if error occurs
      • removeTrackingData

        public void removeTrackingData​(java.lang.String name)
                                throws java.lang.Exception
        Remove tracking data.
        Parameters:
        name - name of tracking data.
        Throws:
        java.lang.Exception - if error occurs
      • setTrackingData

        public void setTrackingData​(java.lang.String name,
                                    javax.json.JsonObject data)
                             throws java.lang.Exception
        Add or update tracking data.
        Parameters:
        name - name of tracking data.
        data - data to store.
        Throws:
        java.lang.Exception - if error occurs