Package cz.metacentrum.perun.core.impl
Class DatabaseManagerImpl
java.lang.Object
cz.metacentrum.perun.core.impl.DatabaseManagerImpl
- All Implemented Interfaces:
DatabaseManagerImplApi
Database manager can work with database version and upgraded state of perun DB.
- Author:
- Michal Stava email:<stavamichal@gmail.com>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateProperty(String property) Create new property in configurations.getChangelogVersions(String currentDBVersion, String fileName) Parses all new database versions from DB changelog file and creates from them list of DBVersion objects.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)Return current database version in string (ex. 3.0.1)Get DB driver information from datasource (name-version)Get DB information from datasource (name-version)Return JDBC template for performing custom simple SQLs where jdbc is not normally availablelongGet time in ns "nanoseconds" of calling 1 simple update query to DB.booleanpropertyExists(String property) Return true if property already exists, false if not.voidupdateDatabaseVersion(List<DBVersion> dbVersions) Method updates database to the current code version.
-
Field Details
-
VERSION_PROPERTY
- See Also:
-
PERFORMANCE_PROPERTY
- See Also:
-
-
Constructor Details
-
DatabaseManagerImpl
-
-
Method Details
-
createProperty
Description copied from interface:DatabaseManagerImplApiCreate new property in configurations. Initial value will be "N/A".- Specified by:
createPropertyin interfaceDatabaseManagerImplApi- Parameters:
property- name of property to be created
-
getChangelogVersions
Description copied from interface:DatabaseManagerImplApiParses 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:
getChangelogVersionsin interfaceDatabaseManagerImplApi- Parameters:
currentDBVersion- current DB versionfileName- DB changelog file name, file should be in resources- Returns:
- list of DBVersion objects ordered by version descending
-
getCodeDatabaseVersion
Description copied from interface:DatabaseManagerImplApiReturns 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:
getCodeDatabaseVersionin interfaceDatabaseManagerImplApi- Parameters:
dbVersions- list of DBVersion objectscurrentDBVersion- current DB version- Returns:
- current code version
-
getCurrentDatabaseVersion
Description copied from interface:DatabaseManagerImplApiReturn current database version in string (ex. 3.0.1)- Specified by:
getCurrentDatabaseVersionin interfaceDatabaseManagerImplApi- Returns:
- return current database version
-
getDatabaseDriverInformation
Description copied from interface:DatabaseManagerImplApiGet DB driver information from datasource (name-version)- Specified by:
getDatabaseDriverInformationin interfaceDatabaseManagerImplApi- Returns:
- string information about database driver
-
getDatabaseInformation
Description copied from interface:DatabaseManagerImplApiGet DB information from datasource (name-version)- Specified by:
getDatabaseInformationin interfaceDatabaseManagerImplApi- Returns:
- string information about database
-
getJdbcPerunTemplate
Description copied from interface:DatabaseManagerImplApiReturn JDBC template for performing custom simple SQLs where jdbc is not normally available- Specified by:
getJdbcPerunTemplatein interfaceDatabaseManagerImplApi- Returns:
- Peruns JDBC template
-
getTimeOfQueryPerformance
public long getTimeOfQueryPerformance()Description copied from interface:DatabaseManagerImplApiGet 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:
getTimeOfQueryPerformancein interfaceDatabaseManagerImplApi- Returns:
- time of processing query in nanoseconds
-
propertyExists
Description copied from interface:DatabaseManagerImplApiReturn true if property already exists, false if not.- Specified by:
propertyExistsin interfaceDatabaseManagerImplApi- Parameters:
property- name of property to check existence- Returns:
- true if property exists, false if not
-
updateDatabaseVersion
Description copied from interface:DatabaseManagerImplApiMethod 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:
updateDatabaseVersionin interfaceDatabaseManagerImplApi- Parameters:
dbVersions- list of dbVersion objects ordered by version descending, should not be empty
-