Interface Persistence


  • public interface Persistence
    Provides access to the Transformer persistence service.

    If a module uses the persistence service any data persisted is saved over restarts of Transformer and - if a central database is used - is also available on multiple Transformers is they are clustered together.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​java.lang.String> call​(java.lang.String procedure, java.lang.String[] args)
      Calls a stored procedure in the persistence service
      int delete​(java.lang.String table, java.util.Map<java.lang.String,​java.lang.String> selector)
      Deletes entries from the persistence service given the provided selector
      java.util.List<java.util.Map<java.lang.String,​java.lang.String>> get​(java.lang.String table, java.util.Map<java.lang.String,​java.lang.String> selector)  
      java.util.List<java.util.Map<java.lang.String,​java.lang.String>> get​(java.lang.String table, java.util.Map<java.lang.String,​java.lang.String> selector, long limit)  
      java.util.List<java.util.Map<java.lang.String,​java.lang.String>> get​(java.lang.String table, java.util.Map<java.lang.String,​java.lang.String> selector, java.util.LinkedHashMap<java.lang.String,​Ordering> ordering)  
      java.util.List<java.util.Map<java.lang.String,​java.lang.String>> get​(java.lang.String table, java.util.Map<java.lang.String,​java.lang.String> selector, java.util.LinkedHashMap<java.lang.String,​Ordering> ordering, long limit)
      Gets entries from the persistence service given the provided selector
      java.util.List<java.util.Map<java.lang.String,​java.lang.String>> query​(java.lang.String table, java.lang.String query, QueryParams params)
      Gets entries from the persistence service matching the provided query
      int upsert​(java.lang.String table, java.util.Map<java.lang.String,​java.lang.String> keys, java.util.Map<java.lang.String,​java.lang.String> data)
      Updates or inserts an entry to be stored by the persistence service
    • Method Detail

      • upsert

        int upsert​(java.lang.String table,
                   java.util.Map<java.lang.String,​java.lang.String> keys,
                   java.util.Map<java.lang.String,​java.lang.String> data)
            throws PersistenceException
        Updates or inserts an entry to be stored by the persistence service
        Parameters:
        table - The name of the table used for persistence
        keys - keys The key value pairs are used for building the WHERE clause of the SQL query, where key='value' for each key-value pair.
        data - Key value pairs representing the field names and their values to be set on the 'upsertion'
        Returns:
        The number of entries affected by the update / insertion
        Throws:
        PersistenceException - when the upsert fails
      • get

        java.util.List<java.util.Map<java.lang.String,​java.lang.String>> get​(java.lang.String table,
                                                                                   java.util.Map<java.lang.String,​java.lang.String> selector,
                                                                                   java.util.LinkedHashMap<java.lang.String,​Ordering> ordering,
                                                                                   long limit)
                                                                            throws PersistenceException
        Gets entries from the persistence service given the provided selector
        Parameters:
        table - The name of the table used for persistence
        selector - Key value pairs representing field names to field values. These are used for constructing the WHERE clause of the SELECT query, where the value for each given field name is matched against the field value.
        ordering - LinkedMap specifying the ordering criteria for this query in priority order. First element returned via iterating over this map represents the primary sort column. Null for database sort order.
        limit - Limits the number of rows returned by this query. The first limit rows with respect to the sort order will be returned, 0 for no limit
        Returns:
        The rows matching the selector. This consists of a Java List of Maps. Each Map represents a row (key value pairs corresponding to field names and their values). The List is empty if no rows match the search query.
        Throws:
        PersistenceException - if the persistence get fails Note: This method is a convenience wrapper for query(String, String, QueryParams)
        See Also:
        query(String, String, QueryParams)
      • query

        java.util.List<java.util.Map<java.lang.String,​java.lang.String>> query​(java.lang.String table,
                                                                                     java.lang.String query,
                                                                                     QueryParams params)
                                                                              throws PersistenceException
        Gets entries from the persistence service matching the provided query
        Parameters:
        table - The name of the table used for persistence
        query - Used as the predicate for the WHERE clause when constructing an SQL query. The query should be formatted as a JDBC Prepared Statement using '?' placeholders.
        params - QueryParams to specify arguments to be bound to '?' characters in the query string, custom sort criteria and a 'limit' specifying the maximum number of rows to be returned
        Returns:
        The rows matching the selector. This consists of a Java List of Maps. Each Map represents a row (key value pairs corresponding to field names and their values). The List is empty if no rows match the search query.
        Throws:
        PersistenceException - if the persistence query fails.
      • delete

        int delete​(java.lang.String table,
                   java.util.Map<java.lang.String,​java.lang.String> selector)
            throws PersistenceException
        Deletes entries from the persistence service given the provided selector
        Parameters:
        table - The name of the table used for persistence
        selector - Key value pairs representing field names to field values. These are used for constructing the WHERE clause of the SELECT query, where the value for each given field name is matched against the field value.
        Returns:
        The number of rows deleted
        Throws:
        PersistenceException - if the persistence delete fails.
      • call

        java.util.Map<java.lang.String,​java.lang.String> call​(java.lang.String procedure,
                                                                    java.lang.String[] args)
                                                             throws PersistenceException
        Calls a stored procedure in the persistence service
        Parameters:
        procedure - The name of the procedure to be called
        args - An ordered list of input arguments to be provided as input parameters to the procedure call.
        Returns:
        The output parameters. Keys are always uppercase for DBMS independence.
        Throws:
        PersistenceException - if the procedure call fails.