Class Migrator


  • public class Migrator
    extends java.lang.Object

    Migrator class.

    Version:
    $Id: $
    Author:
    ranger
    • Field Detail

      • LIQUIBASE_CHANGELOG_FILENAME

        public static final java.lang.String LIQUIBASE_CHANGELOG_FILENAME
        See Also:
        Constant Field Values
      • LIQUIBASE_CHANGELOG_LOCATION_PATTERN

        public static final java.lang.String LIQUIBASE_CHANGELOG_LOCATION_PATTERN
        See Also:
        Constant Field Values
    • Constructor Detail

      • Migrator

        public Migrator()
    • Method Detail

      • createProductionLiquibaseChangelogFilter

        public static java.util.function.Predicate<org.springframework.core.io.Resource> createProductionLiquibaseChangelogFilter()
      • getDataSource

        public javax.sql.DataSource getDataSource()

        getDataSource

        Returns:
        a DataSource object.
      • setDataSource

        public void setDataSource​(javax.sql.DataSource dataSource)

        setDataSource

        Parameters:
        dataSource - a DataSource object.
      • getAdminDataSource

        public javax.sql.DataSource getAdminDataSource()

        getAdminDataSource

        Returns:
        a DataSource object.
      • setAdminDataSource

        public void setAdminDataSource​(javax.sql.DataSource dataSource)

        setAdminDataSource

        Parameters:
        dataSource - a DataSource object.
      • setValidateDatabaseVersion

        public void setValidateDatabaseVersion​(boolean validate)

        setValidateDatabaseVersion

        Parameters:
        validate - a boolean.
      • setCreateUser

        public void setCreateUser​(boolean createUser)

        setCreateUser

        Parameters:
        createUser - a boolean.
      • setCreateDatabase

        public void setCreateDatabase​(boolean createDatabase)

        setCreateDatabase

        Parameters:
        createDatabase - a boolean.
      • setLiquibaseChangelogFilter

        public void setLiquibaseChangelogFilter​(java.util.function.Predicate<org.springframework.core.io.Resource> tester)
      • getDatabaseName

        public java.lang.String getDatabaseName()

        getDatabaseName

        Returns:
        a String object.
      • setDatabaseName

        public void setDatabaseName​(java.lang.String databaseName)

        setDatabaseName

        Parameters:
        databaseName - a String object.
      • getSchemaName

        public java.lang.String getSchemaName()
      • setSchemaName

        public void setSchemaName​(java.lang.String schemaName)
      • getDatabaseUser

        public java.lang.String getDatabaseUser()

        getDatabaseUser

        Returns:
        a String object.
      • setDatabaseUser

        public void setDatabaseUser​(java.lang.String databaseUser)

        setDatabaseUser

        Parameters:
        databaseUser - a String object.
      • getDatabasePassword

        public java.lang.String getDatabasePassword()

        getDatabasePassword

        Returns:
        a String object.
      • setDatabasePassword

        public void setDatabasePassword​(java.lang.String databasePassword)

        setDatabasePassword

        Parameters:
        databasePassword - a String object.
      • getAdminUser

        public java.lang.String getAdminUser()

        getAdminUser

        Returns:
        a String object.
      • setAdminUser

        public void setAdminUser​(java.lang.String adminUser)

        setAdminUser

        Parameters:
        adminUser - a String object.
      • getAdminPassword

        public java.lang.String getAdminPassword()

        getAdminPassword

        Returns:
        a String object.
      • setAdminPassword

        public void setAdminPassword​(java.lang.String adminPassword)

        setAdminPassword

        Parameters:
        adminPassword - a String object.
      • checkUnicode

        public void checkUnicode()
                          throws java.lang.Exception

        checkUnicode

        Throws:
        java.lang.Exception - if any.
      • vacuumDatabase

        public void vacuumDatabase​(boolean full)
                            throws MigrationException

        vacuumDatabase

        Parameters:
        full - a boolean.
        Throws:
        java.sql.SQLException - if any.
        MigrationException
      • addTimescaleDBExtension

        public void addTimescaleDBExtension​(boolean isNewDatabase)
                                     throws MigrationException
        This method creates the Timescale extension If is a new database will add it to template1 so any other database created after has access to Timescale extension If the database (opennms) already exists the it will enfoce the extension on that database and template1.
        Parameters:
        isNewDatabase -
        Throws:
        MigrationException
      • addTimescaleDBExtensionOnDatabase

        public void addTimescaleDBExtensionOnDatabase()
                                               throws MigrationException
        This method creates the Timescale extension on the user database (opennms) and then on template1 to give access to the extension to new databases.
        Throws:
        MigrationException
      • getLiquibaseContexts

        public static java.lang.String getLiquibaseContexts()
      • checkTime

        public void checkTime()
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setupDatabase

        public void setupDatabase​(boolean updateDatabase,
                                  boolean vacuum,
                                  boolean fullVacuum,
                                  boolean iplike,
                                  boolean timescaleDB)
                           throws MigrationException,
                                  java.lang.Exception,
                                  java.io.IOException
        Throws:
        MigrationException
        java.lang.Exception
        java.io.IOException
      • getLiquibaseChangelogs

        public java.util.Collection<org.springframework.core.io.Resource> getLiquibaseChangelogs​(boolean required)
                                                                                          throws java.io.IOException,
                                                                                                 java.lang.Exception
        Throws:
        java.io.IOException
        java.lang.Exception
      • getContextClassLoaderUrls

        public java.lang.String getContextClassLoaderUrls()
      • getSystemClassLoaderUrls

        public static java.lang.String getSystemClassLoaderUrls()
      • getResourceLoaderClassLoaderUrls

        public static java.lang.String getResourceLoaderClassLoaderUrls​(org.springframework.core.io.ResourceLoader resourceLoader)
      • getClassLoaderUrls

        public static java.lang.String getClassLoaderUrls​(java.lang.ClassLoader classLoader)
      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext context)
      • getApplicationContext

        public org.springframework.context.ApplicationContext getApplicationContext()