Class DatabaseEngine
- java.lang.Object
-
- de.hshannover.dqgui.execution.database.api.DatabaseEngine
-
- Direct Known Subclasses:
MongoEngine
,PostgresEngine
public abstract class DatabaseEngine extends java.lang.Object
All 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 protected
DatabaseEngine()
Runs register driver hook.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
allowUseForIqm4hd()
abstract boolean
allowUseForRepository()
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.abstract DatabaseFetcher
createFetcher(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()
boolean
equals(java.lang.Object obj)
GuiConfiguration
guiConfiguration()
int
hashCode()
abstract boolean
isRelational()
EngineLanguage
language()
protected abstract void
loadDatabaseDriver()
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.String
name()
protected void
registerGuiSupport(GuiConfiguration config)
Registers GUI capabilities with the engine.
Should be called in the subclasses constructor.
Can only be called once.protected void
registerIdentifier(java.lang.String identifier)
Registers aEngineIdentifier
with 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 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.protected 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.protected void
registerRepositorySupport(RelationalRepositorySupport repositorySupport)
Optionally registers aRelationalRepositorySupport
with 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 boolean
supportsJdbc()
abstract DatabaseTests.DatabaseTestResult
test(DatabaseConnection connection)
Runs a test for the supplied connection.
JDBC supported engines can redirect to thejava.lang.String
toString()
EngineIdentifier
uniqueIdentifier()
-
-
-
Method Detail
-
registerIdentifier
protected final void registerIdentifier(java.lang.String identifier)
Registers aEngineIdentifier
with 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 aRelationalRepositorySupport
with 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
Optional
with the default port
-
guiConfiguration
public final GuiConfiguration guiConfiguration()
- Returns:
- GUI configuration of engine
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- identifier as string
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
loadDatabaseDriver
protected abstract void loadDatabaseDriver() throws java.lang.Exception
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.- 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.DatabaseTestResult
informing 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
-
-