efefe0290bb1b35a4db62cb25fd13fca487c75c9
[ccsdk/cds.git] /
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.blueprintsprocessor.db
18
19 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
20 import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
21 import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.BluePrintDBLibPropertySevice
22 import org.springframework.boot.context.properties.EnableConfigurationProperties
23 import org.springframework.context.annotation.Bean
24 import org.springframework.context.annotation.ComponentScan
25 import org.springframework.context.annotation.Configuration
26
27 @Configuration
28 @ComponentScan
29 @EnableConfigurationProperties
30 open class BluePrintDBLibConfiguration(private var bluePrintProperties: BluePrintProperties) {
31
32     @Bean("primary-database-properties")
33     open fun getPrimaryProperties(): PrimaryDataSourceProperties {
34         return bluePrintProperties.propertyBeanType(DBLibConstants.PREFIX_DB_PRIMARY,
35                 PrimaryDataSourceProperties::class.java)
36     }
37 }
38
39 /**
40  * Exposed Dependency Service by this SSH Lib Module
41  */
42 //TODO("right now not wired with name ")
43 fun BluePrintDependencyService.dbLibPropertyService(): BluePrintDBLibPropertySevice =
44         instance(DBLibConstants.SERVICE_BLUEPRINT_DB_LIB_PROPERTY)
45
46
47 class DBLibConstants {
48     companion object {
49         //TODO("right now not wired with name ")
50         const val SERVICE_BLUEPRINT_DB_LIB_PROPERTY = "blueprint-db-lib-property-service"
51         const val PREFIX_DB_PRIMARY: String = "blueprintsprocessor.db.primary"
52
53         //list of database
54         const val MARIA_DB: String = "maria-db"
55         const val PRIMARY_DB: String = "primary-db"
56         const val MYSQL_DB: String = "mysql-db"
57         const val ORACLE_DB: String = "oracle-db"
58         const val POSTGRES_DB: String = "postgres-db"
59
60         //List of database drivers
61         const val DRIVER_MARIA_DB = "org.mariadb.jdbc.Driver"
62         const val DRIVER_MYSQL_DB = "com.mysql.jdbc.Driver"
63         const val DRIVER_ORACLE_DB = "oracle.jdbc.driver.OracleDriver"
64         const val DRIVER_POSTGRES_DB = "org.postgresql.Driver"
65
66
67     }
68 }