aboutsummaryrefslogtreecommitdiffstats
path: root/epsdk-app-onap/src/main/java
diff options
context:
space:
mode:
authorRina Roi <rina.roi@intl.att.com>2019-07-15 10:36:26 +0300
committerIttay Stern <ittay.stern@att.com>2019-07-22 18:52:30 +0300
commitbfcf8e43eab481162f41eb5076a7bf7c67f0ad22 (patch)
tree568f9a71244c5fe30d60df99612fa3340303ea33 /epsdk-app-onap/src/main/java
parent1af5b893812574be9cd67eefb2e382f623bcdb3f (diff)
Add LiquidBase to increment DB changes
Issue-ID: VID-517 Change-Id: Idad13fbd72bb1f1d356d790d3d84a1ddec30011f Signed-off-by: Rina Roi <rina.roi@intl.att.com> Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'epsdk-app-onap/src/main/java')
-rw-r--r--epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java56
1 files changed, 12 insertions, 44 deletions
diff --git a/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java b/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
index 2950c7f7d..b4dcd346a 100644
--- a/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
+++ b/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
@@ -40,6 +40,7 @@ package org.onap.portalapp.conf;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
+import liquibase.integration.spring.SpringLiquibase;
import org.onap.portalapp.login.LoginStrategyImpl;
import org.onap.portalsdk.core.auth.LoginStrategy;
import org.onap.portalsdk.core.conf.AppConfig;
@@ -49,7 +50,6 @@ import org.onap.portalsdk.core.objectcache.AbstractCacheManager;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.CacheManager;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -58,10 +58,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
-import org.springframework.core.io.Resource;
-import org.springframework.jdbc.datasource.init.DataSourceInitializer;
-import org.springframework.jdbc.datasource.init.DatabasePopulator;
-import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
+import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
@@ -87,14 +84,6 @@ public class ExternalAppConfig extends AppConfig implements Configurable {
/** The Constant LOG. */
private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(ExternalAppConfig.class);
- /** The vid schema script. */
- @Value("classpath:vid-schema.sql")
- private Resource vidSchemaScript;
-
- /** The vid data script. */
- @Value("classpath:vid-data.sql")
- private Resource vidDataScript;
-
/**
* The Class InnerConfiguration.
*/
@@ -107,6 +96,7 @@ public class ExternalAppConfig extends AppConfig implements Configurable {
* @see org.onap.portalsdk.core.conf.AppConfig#dataAccessService()
*/
@Override
+ @DependsOn("liquibaseBean")
public DataAccessService dataAccessService() {
// Echo the JDBC URL to assist developers when starting the app.
LOG.info("ExternalAppConfig: " + SystemProperties.DB_CONNECTIONURL + " is "
@@ -156,7 +146,7 @@ public class ExternalAppConfig extends AppConfig implements Configurable {
* @return New instance of {@link SchedulerFactoryBean}
*/
@Bean
- @DependsOn("dataSourceInitializer")
+ @DependsOn("liquibaseBean")
public SchedulerFactoryBean schedulerFactoryBean() {
SchedulerFactoryBean schedulerFactory = new SchedulerFactoryBean();
schedulerFactory.setJobFactory(new SpringBeanJobFactory());
@@ -164,36 +154,14 @@ public class ExternalAppConfig extends AppConfig implements Configurable {
}
- /**
- * Data source initializer.
- *
- * @param dataSource the data source
- * @return the data source initializer
- */
- @Bean
- public DataSourceInitializer dataSourceInitializer(DataSource dataSource) {
-
- LOG.info("Initializing VID data source");
-
- final DataSourceInitializer initializer = new DataSourceInitializer();
- initializer.setDataSource(dataSource);
- initializer.setDatabasePopulator(databasePopulator());
- return initializer;
- }
-
- /**
- * Database populator.
- *
- * @return the database populator
- */
- public DatabasePopulator databasePopulator() {
- LOG.info("Populating VID data source");
-
- final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
- populator.addScript(vidSchemaScript);
- populator.addScript(vidDataScript);
- return populator;
- }
+ @Bean
+ @Order(1)
+ public SpringLiquibase liquibaseBean(DataSource dataSource) {
+ SpringLiquibase springLiquibase = new SpringLiquibase();
+ springLiquibase.setDataSource(dataSource);
+ springLiquibase.setChangeLog("classpath:db-master-changelog.xml");
+ return springLiquibase;
+ }
@Bean
public LoginStrategy loginStrategy() {