Interface DatabaseManagerImplApi

All Known Implementing Classes:
DatabaseManagerImpl

public interface DatabaseManagerImplApi
Database manager can work with database version and upgraded state of perun DB.
Author:
Michal Stava email:<stavamichal@gmail.com>
  • Method Details

    • createProperty

      void createProperty(String property)
      Create new property in configurations. Initial value will be "N/A".
      Parameters:
      property - name of property to be created
    • getChangelogVersions

      List<DBVersion> getChangelogVersions(String currentDBVersion, String fileName)
      Parses all new database versions from DB changelog file and creates from them list of DBVersion objects. The list contains all versions from currentDBVersion (without currentDBVersion itself) to now (the version at the top of the changelog file)
      Parameters:
      currentDBVersion - current DB version
      fileName - DB changelog file name, file should be in resources
      Returns:
      list of DBVersion objects ordered by version descending
      Throws:
      InternalErrorException - if 1.there is error reading file, 2.currentDBVersion was not found 3.db version does not match pattern 4.db versions are not ordered as they should be
    • getCodeDatabaseVersion

      String getCodeDatabaseVersion(List<DBVersion> dbVersions, String currentDBVersion)
      Returns current code version from dbVersions list (ex. 3.0.1) or currentDBVersion if list is empty (because in that case currentDBVersion = current code version)
      Parameters:
      dbVersions - list of DBVersion objects
      currentDBVersion - current DB version
      Returns:
      current code version
    • getCurrentDatabaseVersion

      String getCurrentDatabaseVersion()
      Return current database version in string (ex. 3.0.1)
      Returns:
      return current database version
      Throws:
      InternalErrorException
    • getDatabaseDriverInformation

      String getDatabaseDriverInformation()
      Get DB driver information from datasource (name-version)
      Returns:
      string information about database driver
      Throws:
      InternalErrorException
    • getDatabaseInformation

      String getDatabaseInformation()
      Get DB information from datasource (name-version)
      Returns:
      string information about database
      Throws:
      InternalErrorException
    • getJdbcPerunTemplate

      JdbcPerunTemplate getJdbcPerunTemplate()
      Return JDBC template for performing custom simple SQLs where jdbc is not normally available
      Returns:
      Peruns JDBC template
    • getTimeOfQueryPerformance

      long getTimeOfQueryPerformance()
      Get time in ns "nanoseconds" of calling 1 simple update query to DB. This query will update property for this purpose in configurations table.
      Returns:
      time of processing query in nanoseconds
    • propertyExists

      boolean propertyExists(String property)
      Return true if property already exists, false if not.
      Parameters:
      property - name of property to check existence
      Returns:
      true if property exists, false if not
    • updateDatabaseVersion

      void updateDatabaseVersion(List<DBVersion> dbVersions)
      Method updates database to the current code version. It takes list of dbVersions and executes all the commands from them. Commands from the oldest (lowest) version are executed first.
      Parameters:
      dbVersions - list of dbVersion objects ordered by version descending, should not be empty
      Throws:
      InternalErrorException - if any of the commands fails to execute