Package cz.metacentrum.perun.core.bl
Interface DatabaseManagerBl
- All Known Implementing Classes:
- DatabaseManagerBlImpl
public interface DatabaseManagerBl
Database manager can work with database version and upgraded state of perun DB.
- Author:
- Michal Stava email:<stavamichal@gmail.com>
- 
Field SummaryFields
- 
Method SummaryModifier 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.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.static ArrayprepareSQLArrayOfNumbers(List<? extends PerunBean> perunBeans, PreparedStatement preparedStatement) Take list of perunBeans and generate an array of ids in sql database from it.static ArrayprepareSQLArrayOfNumbersFromIntegers(List<Integer> integers, PreparedStatement preparedStatement) Take list of integers and generate an array of integers in sql database from it.static ArrayprepareSQLArrayOfStrings(List<String> strings, PreparedStatement preparedStatement) Take list of String and generate an array in sql database from it.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- 
NAME_OF_ORACLE_ARRAY_METHOD- See Also:
 
 
- 
- 
Method Details- 
prepareSQLArrayOfNumbersstatic Array prepareSQLArrayOfNumbers(List<? extends PerunBean> perunBeans, PreparedStatement preparedStatement) throws SQLException Take list of perunBeans and generate an array of ids in sql database from it. Implementation can be different for every type of supported DB- Parameters:
- perunBeans- list of PerunBeans to get Ids from
- preparedStatement- database prepared statement to get working connection
- Returns:
- java sql array with pre-loaded list of ids
- Throws:
- SQLException- if any sql exception has been thrown
- InternalErrorException- if oracle method to work with an array can't be get or invoked
 
- 
prepareSQLArrayOfNumbersFromIntegersstatic Array prepareSQLArrayOfNumbersFromIntegers(List<Integer> integers, PreparedStatement preparedStatement) throws SQLException Take list of integers and generate an array of integers in sql database from it. Implementation can be different for every type of supported DB- Parameters:
- integers- list of integers
- preparedStatement- database prepared statement to get working connection
- Returns:
- java sql array with pre-loaded list of integers
- Throws:
- SQLException- if any sql exception has been thrown
- InternalErrorException- if oracle method to work with an array can't be get or invoked
 
- 
prepareSQLArrayOfStringsstatic Array prepareSQLArrayOfStrings(List<String> strings, PreparedStatement preparedStatement) throws SQLException Take list of String and generate an array in sql database from it. Implementation can be different for every type of supported DB- Parameters:
- strings- list of Strings to get an sql array from
- preparedStatement- database prepared statement to get working connection
- Returns:
- java sql array with pre-loaded list of strings
- Throws:
- SQLException- if any sql exception has been thrown
- InternalErrorException- if oracle method to work with an array can't be get or invoked
 
- 
createPropertyCreate new property in configurations. Initial value will be "N/A".- Parameters:
- property- name of property to be created
 
- 
getChangelogVersionsParses 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 an error reading file, 2.currentDBVersion was not found 3.DBVersion does not match pattern 4.DB versions are not ordered as they should be
 
- 
getCurrentDatabaseVersionString getCurrentDatabaseVersion()Return current database version in string (ex. 3.0.1)- Returns:
- return current database version
- Throws:
- InternalErrorException
 
- 
getDatabaseDriverInformationString getDatabaseDriverInformation()Get DB driver information from datasource (name-version)- Returns:
- string information about database driver
- Throws:
- InternalErrorException
 
- 
getDatabaseInformationString getDatabaseInformation()Get DB information from datasource (name-version)- Returns:
- string information about database
- Throws:
- InternalErrorException
 
- 
getJdbcPerunTemplateJdbcPerunTemplate getJdbcPerunTemplate()Return JDBC template for performing custom simple SQLs where jdbc is not normally available- Returns:
- Peruns JDBC template
 
- 
getTimeOfQueryPerformancelong 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
 
- 
propertyExistsReturn true if property already exists, false if not.- Parameters:
- property- name of property to check existence
- Returns:
- true if property exists, false if not
 
- 
updateDatabaseVersionMethod 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
 
 
-