Interface Persistor

All Known Implementing Classes:
JdbcPersistorImpl

public interface Persistor

A Persistor is a class that handles callbacks from the Transformers persistence module and acts as a Bridge between Transformer and any Database

When an implementation of Persistor is loaded by Transformer, transformer looks for a constructor that takes exactly two Arguments of type PersistorConfiguration and Logger. If this constructor is not available, the default constructor gets called

  • Method Details

    • onUpsert

      int onUpsert(String table, Map<String,String> keys, Map<String,String> data)

      Implement this method to handle update or insert callbacks. This method is expected to update an existing row or insert a new one if the update did not affect any rows

      This method should attempt to update an existing row first by setting all the values given in data and using the entries of this map where the key matches key anded together in the where clause like: "key1=value1 and key2=value2". If the update did not affect any rows, then an insert should be executed with the data given

      Parameters:
      table - The table to be modified
      keys - Map containing column/value pairs to be used in the where clause for updates. If no row matches the criteria, a combination of keys and data is used as data for the rows, where entries in data take precedence over entries in keys
      data - Map containing column/value pairs to be set in the row identified by keys
      Returns:
      -1 on error or >=0 affected rows on success
    • onQuery

      List<Map<String,String>> onQuery(String table, String query, QueryParams params)

      Query the database for results.

      Queries the database with query being a valid sql selection and args being a list of arguments that get bound to ? in the query string

      Parameters:
      table - The table name to execute the query on.
      query - a valid sql where clause or an empty string for all rows.
      params - QueryParams to be used for the query
      Returns:
      null on error, an empty array if there were no results or an array holding all the rows returned by the query.
    • onDelete

      int onDelete(String table, Map<String,String> selector)

      Delete one or more rows from a table

      Delete rows where the all the columns specified in selector match their specified values

      Parameters:
      table - The table name to delete from.
      selector - Map of column names (keys) and values to be anded together in the where clause.
      Returns:
      true if the operation affected more than 0 rows, false otherwise.
    • onCall

      Map<String,String> onCall(String procedureName, String[] args)

      Call a stored procedure in the database.

      Calls a stored procedure in the database with procedureName being a valid procedure name within the database and args being a list of arguments to pass to the stored procedure.

      Parameters:
      procedureName - The name of the procedure to call.
      args - An ordered list of input arguments to be provided as input parameters to the procedure call.
      Returns:
      list of output parameters, null on error.
    • onShutdown

      void onShutdown()

      Called when transformer shuts down to close open connections and release acquired resources