aboutsummaryrefslogtreecommitdiffstats
path: root/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2020-03-11 15:54:10 -0400
committerDan Timoney <dtimoney@att.com>2020-03-12 11:34:33 -0400
commit88f749277195998d150925e14e12021cc2e9292b (patch)
tree8e31b64b8e169cbd126d56d77cb0cb7cb7aef7d6 /sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java
parentc46ebbb0f011a1587c3fe506c5029ce550b07ed2 (diff)
Add data persistence
Add code to persist MD-SAL data (test-results) Change-Id: I2c6d3e94e9e46ccbfad479c6d89507ec37939496 Issue-ID: CCSDK-2096 Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java')
-rw-r--r--sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java49
1 files changed, 48 insertions, 1 deletions
diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java
index fb4fe085..41d3791b 100644
--- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java
+++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java
@@ -21,23 +21,70 @@
package org.onap.ccsdk.sli.core.sliapi.springboot.core;
import org.onap.logging.filter.spring.LoggingInterceptor;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+
@EnableWebMvc
@Configuration
+@EnableJpaRepositories("org.onap.ccsdk.sli.core.sliapi.springboot.*")
+@ComponentScan(basePackages = {"org.onap.ccsdk.sli.core.sliapi.springboot.*"})
+@EntityScan("org.onap.ccsdk.sli.core.sliapi.springboot.*")
+@EnableTransactionManagement
public class WebConfig implements WebMvcConfigurer {
- @Bean
+/* @Bean
LoggingInterceptor loggingInterceptor() {
return new LoggingInterceptor();
}
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loggingInterceptor()); // handles audit log entries
+ }*/
+
+ @Bean
+ public DataSource dataSource() {
+
+ EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
+ builder.setName("sdnctl");
+ return builder.setType(EmbeddedDatabaseType.DERBY).build();
+ }
+
+ @Bean
+ public EntityManagerFactory entityManagerFactory() {
+
+ HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
+ vendorAdapter.setGenerateDdl(true);
+
+ LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
+ factory.setJpaVendorAdapter(vendorAdapter);
+ factory.setPackagesToScan("org.onap.ccsdk.sli.core.sliapi.springboot.*");
+ factory.setDataSource(dataSource());
+ factory.afterPropertiesSet();
+
+ return factory.getObject();
}
+ @Bean
+ public PlatformTransactionManager transactionManager() {
+
+ JpaTransactionManager txManager = new JpaTransactionManager();
+ txManager.setEntityManagerFactory(entityManagerFactory());
+ return txManager;
+ }
} \ No newline at end of file