Migrate ccsdk/apps to ccsdk/cds
[ccsdk/cds.git] / ms / controllerblueprints / modules / service / src / test / java / org / onap / ccsdk / cds / controllerblueprints / DatabaseConfig.java
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.ccsdk.cds.controllerblueprints;
18
19 import org.springframework.boot.autoconfigure.domain.EntityScan;
20 import org.springframework.context.annotation.Bean;
21 import org.springframework.context.annotation.Configuration;
22 import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
23 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
24 import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
25 import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
26 import org.springframework.transaction.annotation.EnableTransactionManagement;
27
28 import javax.sql.DataSource;
29
30 /**
31  * DatabaseConfig.java Purpose: Provide Configuration Generator DatabaseConfig Information
32  *
33  * @author Brinda Santh
34  * @version 1.0
35  */
36 @Configuration
37 @EntityScan("org.onap.ccsdk.cds.controllerblueprints.service.domain")
38 @EnableTransactionManagement
39 @EnableJpaRepositories("org.onap.ccsdk.cds.controllerblueprints.service.repository")
40 @EnableJpaAuditing
41 public class DatabaseConfig {
42     /**
43      * This is a entityManagerFactory method
44      * 
45      * @param dataSource
46      * @return LocalContainerEntityManagerFactoryBean
47      */
48
49     @Bean
50     public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
51         HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
52         vendorAdapter.setGenerateDdl(true);
53         vendorAdapter.setShowSql(false);
54         LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
55         factory.setJpaVendorAdapter(vendorAdapter);
56         factory.setPackagesToScan("org.onap.ccsdk.cds.controllerblueprints.service.domain");
57         factory.setDataSource(dataSource);
58         return factory;
59     }
60
61 }