Class 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 package de.hshannover.dqgui.support.database.api.
    • Constructor Detail

      • DatabaseEngine

        protected DatabaseEngine()
                          throws java.lang.Exception
        Runs register driver hook.
        Throws:
        java.lang.Exception - in case a driver load fails
    • Method Detail

      • registerIdentifier

        protected final void registerIdentifier​(java.lang.String identifier)
        Registers a EngineIdentifier 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 a RelationalRepositorySupport with the engine.
        Should be called in the subclasses constructor.
        Can only be called once.
        This is required if allowUseForRepository() 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 class java.lang.Object
        Returns:
        identifier as string
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.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 the JdbcFetcher.
        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.
      • 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