Class TenantSchemaUtilsService

java.lang.Object
com.totvs.tjf.tenant.schema.TenantSchemaUtilsService
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

public class TenantSchemaUtilsService extends Object implements org.springframework.beans.factory.InitializingBean
Custom implementation to manipulate the schema creation/validation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TenantSchemaUtilsService(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, com.totvs.tjf.tenant.context.schema.SchemaUtils schemaUtils, com.totvs.tjf.tenant.context.schema.SchemaProperties schemaProperties, com.totvs.tjf.migration.context.FlywayMigrationService migrationService, com.totvs.tjf.repository.context.aggregate.MultiDataSourceProperties multiTenantProperties)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    Creates the schema if it has not been created.
    Get the all schemas in the cache list
    protected boolean
    Validate if the given tenant identifier exists in the database.
    protected boolean
    Verify if the given schema is should be ignored.
    void
    Validates the schema if it's created and up-to-date when connection was requested.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TenantSchemaUtilsService

      public TenantSchemaUtilsService(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, com.totvs.tjf.tenant.context.schema.SchemaUtils schemaUtils, com.totvs.tjf.tenant.context.schema.SchemaProperties schemaProperties, @Nullable com.totvs.tjf.migration.context.FlywayMigrationService migrationService, com.totvs.tjf.repository.context.aggregate.MultiDataSourceProperties multiTenantProperties)
  • Method Details

    • createSchema

      public void createSchema(String schema)
      Creates the schema if it has not been created.
      Parameters:
      schema - schema name
      See Also:
      • FlywayMigrationService.migrate(String)
    • validateSchemaDynamically

      public void validateSchemaDynamically(String schema)
      Validates the schema if it's created and up-to-date when connection was requested.
      Parameters:
      schema - schema name
      See Also:
      • FlywayMigrationService.validateDynamically(String)
    • isAvailable

      protected boolean isAvailable(String schema)
      Validate if the given tenant identifier exists in the database.

      Note: The validation occurs over the normalized tenant identifier.

      Parameters:
      schema - identifier to check the availability.
      Returns:
      true if the tenant have an equivalent schema in the database, otherwise, false.
      See Also:
      • SchemaUtils.normalizeSchema(String)
    • getSchemas

      public Set<String> getSchemas()
      Get the all schemas in the cache list
      Returns:
      schemas set of schemas
    • onlyAcceptedSchemas

      protected boolean onlyAcceptedSchemas(String schema)
      Verify if the given schema is should be ignored.
      Parameters:
      schema - to verified.
      Returns:
      true if schema is not present in ignored list, otherwise, false.
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception