Class DatabaseEngine
- java.lang.Object
-
- de.hshannover.dqgui.execution.database.api.DatabaseEngine
-
- Direct Known Subclasses:
MongoEngine,PostgresEngine
public abstract class DatabaseEngine extends java.lang.ObjectAll database engines must extend this base class.
To have the engine loaded they must be in the packagede.hshannover.dqgui.support.database.api.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDatabaseEngine()Runs register driver hook.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleanallowUseForIqm4hd()abstract booleanallowUseForRepository()abstract java.lang.StringcreateDataSourceUrl(DatabaseConnection connection)Creates a JDBC data source URL that is used to create the JDBC connection.
If the engine does not support JDBC this should return null.abstract DatabaseFetchercreateFetcher(DatabaseConnection connection)Returns a fetcher implementation for the database engine.
JDBC supported engines can redirect to theJdbcFetcher.Repository<?>createRepository(DatabaseConnection connection)Creates a repository for a given connection.protected abstract Repository<?>createRepositoryForConnection(DatabaseConnection connection)If your database supports a database backed repository create the repository object here.java.util.Optional<java.lang.Integer>defaultPort()booleanequals(java.lang.Object obj)GuiConfigurationguiConfiguration()inthashCode()abstract booleanisRelational()EngineLanguagelanguage()protected abstract voidloadDatabaseDriver()If you need to load database drivers, here is your chance.
Some JDBC drivers need to be loaded with Class.forName() to register with the JDBC driver manager.abstract java.lang.Stringname()protected voidregisterGuiSupport(GuiConfiguration config)Registers GUI capabilities with the engine.
Should be called in the subclasses constructor.
Can only be called once.protected voidregisterIdentifier(java.lang.String identifier)Registers aEngineIdentifierwith the engine.
Should be called in the subclasses constructor.
Can only be called once.
Attempting to load two engines with the same identifier will cause issues
The identifier will internally be converted to upper-case.
So postgres, pOstGres and POSTGRES will all convert to POSTGRES and thus be the same identifier.protected voidregisterLanguage(java.lang.String language)Registers a EngineLanguage with the engine.
Should be called in the subclasses constructor.
Can only be called once.
Language string will be converted to upper-case internally.protected voidregisterPort(java.lang.Integer port)Optionally allows to register a default port.
Should be called in the subclasses constructor.
Can only be called once.
If the database engine does not support networking over TCP or does not have a default port this can be ignored.protected voidregisterRepositorySupport(RelationalRepositorySupport repositorySupport)Optionally registers aRelationalRepositorySupportwith the engine.
Should be called in the subclasses constructor.
Can only be called once.
This is required ifallowUseForRepository()returns true.java.util.Optional<RelationalRepositorySupport>requestRepositorySupport()abstract booleansupportsJdbc()abstract DatabaseTests.DatabaseTestResulttest(DatabaseConnection connection)Runs a test for the supplied connection.
JDBC supported engines can redirect to thejava.lang.StringtoString()EngineIdentifieruniqueIdentifier()
-
-
-
Method Detail
-
registerIdentifier
protected final void registerIdentifier(java.lang.String identifier)
Registers aEngineIdentifierwith the engine.
Should be called in the subclasses constructor.
Can only be called once.
Attempting to load two engines with the same identifier will cause issues
The identifier will internally be converted to upper-case.
So postgres, pOstGres and POSTGRES will all convert to POSTGRES and thus be the same identifier.- Parameters:
identifier- to register for this engine.
-
registerLanguage
protected final void registerLanguage(java.lang.String language)
Registers a EngineLanguage with the engine.
Should be called in the subclasses constructor.
Can only be called once.
Language string will be converted to upper-case internally.- Parameters:
language- to register for the engine.
-
registerPort
protected final void registerPort(java.lang.Integer port)
Optionally allows to register a default port.
Should be called in the subclasses constructor.
Can only be called once.
If the database engine does not support networking over TCP or does not have a default port this can be ignored.- Parameters:
port- to register for the engine.
-
registerRepositorySupport
protected final void registerRepositorySupport(RelationalRepositorySupport repositorySupport)
Optionally registers aRelationalRepositorySupportwith the engine.
Should be called in the subclasses constructor.
Can only be called once.
This is required ifallowUseForRepository()returns true.- Parameters:
repositorySupport- to register with the engine.
-
registerGuiSupport
protected final void registerGuiSupport(GuiConfiguration config)
Registers GUI capabilities with the engine.
Should be called in the subclasses constructor.
Can only be called once.- Parameters:
config- GUI configuration
-
uniqueIdentifier
public final EngineIdentifier uniqueIdentifier()
- Returns:
- unique engine identifier
-
language
public final EngineLanguage language()
- Returns:
- supported database language
-
defaultPort
public final java.util.Optional<java.lang.Integer> defaultPort()
- Returns:
- an
Optionalwith the default port
-
guiConfiguration
public final GuiConfiguration guiConfiguration()
- Returns:
- GUI configuration of engine
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- identifier as string
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
loadDatabaseDriver
protected abstract void loadDatabaseDriver() throws java.lang.ExceptionIf you need to load database drivers, here is your chance.
Some JDBC drivers need to be loaded with Class.forName() to register with the JDBC driver manager.- Throws:
java.lang.Exception- in case driver loading fails
-
createFetcher
public abstract DatabaseFetcher createFetcher(DatabaseConnection connection)
Returns a fetcher implementation for the database engine.
JDBC supported engines can redirect to theJdbcFetcher.- Parameters:
connection- to create fetcher for.- Returns:
- fetcher that can fetch for the engine.
-
name
public abstract java.lang.String name()
- Returns:
- how the engine should be displayed in the UI. This will affect alphabetic sorting.
-
test
public abstract DatabaseTests.DatabaseTestResult test(DatabaseConnection connection)
Runs a test for the supplied connection.
JDBC supported engines can redirect to the- Parameters:
connection- to test for- Returns:
- a
DatabaseTests.DatabaseTestResultinforming about the outcome
-
isRelational
public abstract boolean isRelational()
- Returns:
- true if the engine is relational
-
allowUseForRepository
public abstract boolean allowUseForRepository()
- Returns:
- true if this engine should be used for the repository
-
allowUseForIqm4hd
public abstract boolean allowUseForIqm4hd()
- Returns:
- true if this engine should be used for iqm4hd
-
supportsJdbc
public abstract boolean supportsJdbc()
- Returns:
- true if JDBC is supported
-
createDataSourceUrl
public abstract java.lang.String createDataSourceUrl(DatabaseConnection connection)
Creates a JDBC data source URL that is used to create the JDBC connection.
If the engine does not support JDBC this should return null.- Parameters:
connection- to create the data source URL for- Returns:
- a data source URL ready to use with the JDBC driver manager
-
createRepositoryForConnection
protected abstract Repository<?> createRepositoryForConnection(DatabaseConnection connection)
If your database supports a database backed repository create the repository object here.- Parameters:
connection- to create repo for- Returns:
- a repository if supported or null
-
createRepository
public final Repository<?> createRepository(DatabaseConnection connection)
Creates a repository for a given connection.- Parameters:
connection- to create repository for- Returns:
- created repository
-
requestRepositorySupport
public final java.util.Optional<RelationalRepositorySupport> requestRepositorySupport()
- Returns:
- the repository support instance associated with the engine or null if no repository is supported
-
-