Class AccountingPersistenceConfiguration

java.lang.Object
org.gcube.documentstore.persistence.PersistenceBackendConfiguration
org.gcube.accounting.persistence.AccountingPersistenceConfiguration

public class AccountingPersistenceConfiguration extends org.gcube.documentstore.persistence.PersistenceBackendConfiguration
The configuration of the accounting library, read from the Information System (Resource Registry): the harmonization rules for RegexRulesAggregator, the database for the database persistence backend and for the consumers which are not persistence backends. Any other persistence backend gets an empty configuration and discovers what it needs by itself.
Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • TIMESCALEDB_QUERY_TEMPLATE_NAME

      protected static final String TIMESCALEDB_QUERY_TEMPLATE_NAME
      See Also:
    • CONFIGURATION_QUERY

      protected static final String CONFIGURATION_QUERY
      See Also:
    • DATABASE_PERSISTENCE_BACKEND

      protected static final String DATABASE_PERSISTENCE_BACKEND
      The only persistence backend configured by the database EService of the IS. Every other persistence backend (e.g. PersistenceAccountingService) receives an empty configuration and discovers what it needs by itself: it never receives the database endpoint or credentials.
      See Also:
    • URL_PROPERTY_KEY

      public static final String URL_PROPERTY_KEY
      See Also:
    • USERNAME_PROPERTY_KEY

      public static final String USERNAME_PROPERTY_KEY
      See Also:
    • PASSWORD_PROPERTY_KEY

      public static final String PASSWORD_PROPERTY_KEY
      See Also:
    • clz

      protected Class<?> clz
      The class identifying the consumer requesting the configuration. It is retained so that subclasses can select the proper query template via getDatabaseQueryTemplateName().
  • Constructor Details

    • AccountingPersistenceConfiguration

      public AccountingPersistenceConfiguration()
    • AccountingPersistenceConfiguration

      public AccountingPersistenceConfiguration(Class<?> clz) throws Exception
      Reads from the IS the configuration requested by the given class.
      Parameters:
      clz - the class requesting the configuration
      Throws:
      Exception - if the IS cannot be queried or holds no configuration for the class
  • Method Details

    • loadFromGraphIS

      public boolean loadFromGraphIS(Class<?> clz) throws Exception
      Loads the configuration requested by the given class from the Graph IS: the harmonization rules for RegexRulesAggregator; the database configuration for the database persistence backend ("PersistencePostgreSQL") and for consumers which are not persistence backends. Any other persistence backend has no configuration: it is loaded empty, and the backend discovers what it needs by itself (e.g. PersistenceAccountingService finds the accounting service through the IS discovery library).
      Parameters:
      clz - the class requesting the configuration
      Returns:
      true if the configuration was loaded, false if the IS holds none
      Throws:
      Exception - if the Graph IS cannot be queried
    • getDatabaseQueryTemplateName

      protected String getDatabaseQueryTemplateName()
      Returns the name of the query template used to retrieve the database configuration from the Graph IS. The base implementation returns the template of the accounting library. Consumers that read/write a different database (e.g. the analytics or the aggregator components) are expected to override this method to return their own template. The templates of the accounting stack (accounting-*) belong to the reference set installed by the Resource Registry: the library only runs them by name.
      Returns:
      the query template name to execute for the database configuration