Class DatabaseManagerImpl

java.lang.Object
cz.metacentrum.perun.core.impl.DatabaseManagerImpl
All Implemented Interfaces:
DatabaseManagerImplApi

public class DatabaseManagerImpl extends Object implements DatabaseManagerImplApi
Database manager can work with database version and upgraded state of perun DB.
Author:
Michal Stava email:<stavamichal@gmail.com>
  • Field Details

  • Constructor Details

    • DatabaseManagerImpl

      public DatabaseManagerImpl(DataSource perunPool)
  • Method Details

    • createProperty

      public void createProperty(String property)
      Description copied from interface: DatabaseManagerImplApi
      Create new property in configurations. Initial value will be "N/A".
      Specified by:
      createProperty in interface DatabaseManagerImplApi
      Parameters:
      property - name of property to be created
    • getChangelogVersions

      public List<DBVersion> getChangelogVersions(String currentDBVersion, String fileName)
      Description copied from interface: DatabaseManagerImplApi
      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)
      Specified by:
      getChangelogVersions in interface DatabaseManagerImplApi
      Parameters:
      currentDBVersion - current DB version
      fileName - DB changelog file name, file should be in resources
      Returns:
      list of DBVersion objects ordered by version descending
    • getCodeDatabaseVersion

      public String getCodeDatabaseVersion(List<DBVersion> dbVersions, String currentDBVersion)
      Description copied from interface: DatabaseManagerImplApi
      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)
      Specified by:
      getCodeDatabaseVersion in interface DatabaseManagerImplApi
      Parameters:
      dbVersions - list of DBVersion objects
      currentDBVersion - current DB version
      Returns:
      current code version
    • getCurrentDatabaseVersion

      public String getCurrentDatabaseVersion()
      Description copied from interface: DatabaseManagerImplApi
      Return current database version in string (ex. 3.0.1)
      Specified by:
      getCurrentDatabaseVersion in interface DatabaseManagerImplApi
      Returns:
      return current database version
    • getDatabaseDriverInformation

      public String getDatabaseDriverInformation()
      Description copied from interface: DatabaseManagerImplApi
      Get DB driver information from datasource (name-version)
      Specified by:
      getDatabaseDriverInformation in interface DatabaseManagerImplApi
      Returns:
      string information about database driver
    • getDatabaseInformation

      public String getDatabaseInformation()
      Description copied from interface: DatabaseManagerImplApi
      Get DB information from datasource (name-version)
      Specified by:
      getDatabaseInformation in interface DatabaseManagerImplApi
      Returns:
      string information about database
    • getJdbcPerunTemplate

      public JdbcPerunTemplate getJdbcPerunTemplate()
      Description copied from interface: DatabaseManagerImplApi
      Return JDBC template for performing custom simple SQLs where jdbc is not normally available
      Specified by:
      getJdbcPerunTemplate in interface DatabaseManagerImplApi
      Returns:
      Peruns JDBC template
    • getTimeOfQueryPerformance

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

      public boolean propertyExists(String property)
      Description copied from interface: DatabaseManagerImplApi
      Return true if property already exists, false if not.
      Specified by:
      propertyExists in interface DatabaseManagerImplApi
      Parameters:
      property - name of property to check existence
      Returns:
      true if property exists, false if not
    • updateDatabaseVersion

      public void updateDatabaseVersion(List<DBVersion> dbVersions)
      Description copied from interface: DatabaseManagerImplApi
      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.
      Specified by:
      updateDatabaseVersion in interface DatabaseManagerImplApi
      Parameters:
      dbVersions - list of dbVersion objects ordered by version descending, should not be empty