tigase.db.util

## Class SchemaLoader<P extends SchemaLoader.Parameters>

- java.lang.Object
- - tigase.db.util.SchemaLoader<P>

- Direct Known Subclasses:
    DBSchemaLoader

      public abstract class SchemaLoader<P extends SchemaLoader.Parameters>
      extends Object

  Author:
    andrzej

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `SchemaLoader.Parameters`
    `static class` | `SchemaLoader.Result`
    `static class` | `SchemaLoader.TypeInfo`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static Logger` | `log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SchemaLoader()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected <T extends DataSource> SchemaLoader.Result` | `addUsersToRepository(SchemaManager.SchemaInfo schemaInfo, T dataSource, Class<T> dataSourceClass, List<BareJID> jids, String password, Logger log)`
    `protected Function<AuthRepository,SchemaLoader.Result>` | `addUsersToRepositoryFunction(List<BareJID> jids, String pwd, Logger log)`
    `abstract SchemaLoader.Result` | `addXmppAdminAccount(SchemaManager.SchemaInfo schemaInfo)` Method attempts to add XMPP admin user account to the database using `AuthRepository`.
    `abstract P` | `createParameters()`
    `abstract SchemaLoader.Result` | `destroyDataSource()`
    `abstract void` | `execute(SchemaLoader.Parameters params)`
    `static List<SchemaLoader.TypeInfo>` | `getAllSupportedTypes()`
    `static Stream<SchemaLoader.TypeInfo>` | `getAllSupportedTypesStream()`
    `abstract List<CommandlineParameter>` | `getCommandlineParameters()`
    `abstract Optional<Version>` | `getComponentVersionFromDb(String component)`
    `protected String` | `getConfigString()`
    `protected <DS extends DataSource> Stream<Class<DataSourceAware<DS>>>` | `getDataSourceAwareClassesForSchemaInfo(SchemaManager.SchemaInfo schema, Class<DS> dataSourceIfc)`
    `abstract String` | `getDBUri()`
    `protected <DSIFC extends DataSource,DS extends DSIFC> Stream<DataSourceAware>` | `getInitializedDataSourceAwareForSchemaInfo(SchemaManager.SchemaInfo schema, Class<DSIFC> dataSourceIfc, DS dataSource, Logger log)`
    `static List<CommandlineParameter>` | `getMainCommandlineParameters(boolean forceNotRequired)`
    `abstract Optional<Version>` | `getMinimalRequiredComponentVersionForUpgrade(SchemaManager.SchemaInfo schema)`
    `abstract List<CommandlineParameter>` | `getSetupOptions()`
    `abstract List<SchemaLoader.TypeInfo>` | `getSupportedTypes()`
    `protected String` | `getType()`
    `void` | `init(P props)`
    `abstract void` | `init(P props, Optional<SchemaManager.RootCredentialsCache> rootCredentialsCache)`
    `protected AuthRepository` | `initializeAuthRepository(AuthRepository authRepository)`
    `protected <T extends DataSource> Function<DataSourceAware<T>,DataSourceAware<T>>` | `initializeDataSourceAwareFunction(T dataSource, Logger log)`
    `protected <T> T` | `instantiateClass(Class<T> clazz)`
    `boolean` | `isSupported(String dbType)`
    `SchemaLoader.Result` | `loadCommonSchema()`
    `abstract SchemaLoader.Result` | `loadSchema(SchemaManager.SchemaInfo schemaInfo, String version)`
    `abstract SchemaLoader.Result` | `loadSchemaFile(String fileName)` Method checks whether the connection to the database is possible and that database of specified name exists.
    `static void` | `main(String[] args)` Main method allowing pass arguments to the class and setting all logging to be printed to console.
    `static SchemaLoader` | `newInstance(String type)`
    `static SchemaLoader` | `newInstanceForURI(String uri)`
    `abstract SchemaLoader.Result` | `postInstallation()`
    `SchemaLoader.Result` | `printInfo()`
    `abstract SchemaLoader.Result` | `setComponentVersion(String component, String version)` Methods attempt to write to database loaded schema version for particular component
    `abstract SchemaLoader.Result` | `shutdown()`
    `abstract SchemaLoader.Result` | `validateDBConnection()` Method validates whether the connection can at least be eI stablished.
    `abstract SchemaLoader.Result` | `validateDBExists()` Method, if the connection is validated by `validateDBConnection`, checks whether desired database exists.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### log

          protected static final Logger log

  - ### Constructor Detail

    - #### SchemaLoader

          public SchemaLoader()

  - ### Method Detail

    - #### getMainCommandlineParameters

          public static List<CommandlineParameter> getMainCommandlineParameters(boolean forceNotRequired)

    - #### getAllSupportedTypesStream

          public static Stream<SchemaLoader.TypeInfo> getAllSupportedTypesStream()

    - #### getAllSupportedTypes

          public static List<SchemaLoader.TypeInfo> getAllSupportedTypes()

    - #### main

          public static void main(String[] args)

      Main method allowing pass arguments to the class and setting all logging to be printed to console.
      Parameters:
        `args` - key-value (in the form of `"-<variable> value"`) parameters.

    - #### newInstance

          public static SchemaLoader newInstance(String type)

    - #### newInstanceForURI

          public static SchemaLoader newInstanceForURI(String uri)

    - #### createParameters

          public abstract P createParameters()

    - #### execute

          public abstract void execute(SchemaLoader.Parameters params)

    - #### init

          public abstract void init(P props,
                                    Optional<SchemaManager.RootCredentialsCache> rootCredentialsCache)

    - #### init

          public void init(P props)

    - #### getSupportedTypes

          public abstract List<SchemaLoader.TypeInfo> getSupportedTypes()

    - #### isSupported

          public boolean isSupported(String dbType)

    - #### getDBUri

          public abstract String getDBUri()

    - #### getSetupOptions

          public abstract List<CommandlineParameter> getSetupOptions()

    - #### getCommandlineParameters

          public abstract List<CommandlineParameter> getCommandlineParameters()

    - #### validateDBConnection

          public abstract SchemaLoader.Result validateDBConnection()

      Method validates whether the connection can at least be eI stablished. If yes then appropriate flag is set.

    - #### validateDBExists

          public abstract SchemaLoader.Result validateDBExists()

      Method, if the connection is validated by `validateDBConnection`, checks whether desired database exists. If not it creates such database using `*-installer-create-db.sql` schema file substituting it's variables with ones provided.

    - #### postInstallation

          public abstract SchemaLoader.Result postInstallation()

    - #### getConfigString

          protected String getConfigString()
                                    throws IOException

      Throws:
        `IOException`

    - #### printInfo

          public SchemaLoader.Result printInfo()

    - #### addXmppAdminAccount

          public abstract SchemaLoader.Result addXmppAdminAccount(SchemaManager.SchemaInfo schemaInfo)

      Method attempts to add XMPP admin user account to the database using `AuthRepository`.

    - #### setComponentVersion

          public abstract SchemaLoader.Result setComponentVersion(String component,
                                                                  String version)

      Methods attempt to write to database loaded schema version for particular component
      Parameters:
        `component` - name of the component for which version should be set
        `version` - value which should be associated with the component
      Returns:
        a `SchemaLoader.Result` object indicating whether the call was successful

    - #### getComponentVersionFromDb

          public abstract Optional<Version> getComponentVersionFromDb(String component)

    - #### loadSchemaFile

          public abstract SchemaLoader.Result loadSchemaFile(String fileName)

      Method checks whether the connection to the database is possible and that database of specified name exists. If yes then a schema file from properties is loaded.
      Parameters:
        `fileName` - set of `String` with path to file

    - #### shutdown

          public abstract SchemaLoader.Result shutdown()

    - #### loadCommonSchema

          public SchemaLoader.Result loadCommonSchema()

    - #### loadSchema

          public abstract SchemaLoader.Result loadSchema(SchemaManager.SchemaInfo schemaInfo,
                                                         String version)

    - #### getMinimalRequiredComponentVersionForUpgrade

          public abstract Optional<Version> getMinimalRequiredComponentVersionForUpgrade(SchemaManager.SchemaInfo schema)

    - #### destroyDataSource

          public abstract SchemaLoader.Result destroyDataSource()

    - #### addUsersToRepository

          protected <T extends DataSource> SchemaLoader.Result addUsersToRepository(SchemaManager.SchemaInfo schemaInfo,
                                                                                    T dataSource,
                                                                                    Class<T> dataSourceClass,
                                                                                    List<BareJID> jids,
                                                                                    String password,
                                                                                    Logger log)

    - #### getDataSourceAwareClassesForSchemaInfo

          protected <DS extends DataSource> Stream<Class<DataSourceAware<DS>>> getDataSourceAwareClassesForSchemaInfo(SchemaManager.SchemaInfo schema,
                                                                                                                      Class<DS> dataSourceIfc)

    - #### getInitializedDataSourceAwareForSchemaInfo

          protected <DSIFC extends DataSource,DS extends DSIFC> Stream<DataSourceAware> getInitializedDataSourceAwareForSchemaInfo(SchemaManager.SchemaInfo schema,
                                                                                                                                   Class<DSIFC> dataSourceIfc,
                                                                                                                                   DS dataSource,
                                                                                                                                   Logger log)

    - #### initializeAuthRepository

          protected AuthRepository initializeAuthRepository(AuthRepository authRepository)

    - #### initializeDataSourceAwareFunction

          protected <T extends DataSource> Function<DataSourceAware<T>,DataSourceAware<T>> initializeDataSourceAwareFunction(T dataSource,
                                                                                                                             Logger log)

    - #### addUsersToRepositoryFunction

          protected Function<AuthRepository,SchemaLoader.Result> addUsersToRepositoryFunction(List<BareJID> jids,
                                                                                              String pwd,
                                                                                              Logger log)

    - #### instantiateClass

          protected <T> T instantiateClass(Class<T> clazz)

    - #### getType

          protected String getType()

Copyright © 2004–2020 "Tigase, Inc.". All rights reserved.