Fixing Blueprint Typo's and docs
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / inbounds / designer-api / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / designer / api / load / BlueprintDatabaseLoadService.kt
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  * Modifications Copyright © 2019 IBM.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load
19
20 import kotlinx.coroutines.runBlocking
21 import org.onap.ccsdk.cds.controllerblueprints.core.config.BlueprintLoadConfiguration
22 import org.slf4j.LoggerFactory
23 import org.springframework.stereotype.Service
24
25 @Service
26 open class BlueprintDatabaseLoadService(
27     private val bluePrintLoadConfiguration: BlueprintLoadConfiguration,
28     private val modelTypeLoadService: ModelTypeLoadService,
29     private val resourceDictionaryLoadService: ResourceDictionaryLoadService,
30     private val bluePrintCatalogLoadService: BlueprintCatalogLoadService
31 ) {
32
33     private val log = LoggerFactory.getLogger(BlueprintDatabaseLoadService::class.java)
34
35     open fun init() = runBlocking {
36         initModelTypes()
37         initResourceDictionary()
38         initBlueprintCatalog()
39     }
40
41     open suspend fun initModelTypes() {
42         log.info("model types load from paths(${bluePrintLoadConfiguration.loadModeTypePaths})")
43
44         val paths = bluePrintLoadConfiguration.loadModeTypePaths?.split(",")
45         paths?.let {
46             modelTypeLoadService.loadPathsModelType(paths)
47         }
48     }
49
50     open suspend fun initResourceDictionary() {
51         log.info("resource dictionary load from paths(${bluePrintLoadConfiguration.loadResourceDictionaryPaths})")
52
53         val paths = bluePrintLoadConfiguration.loadResourceDictionaryPaths?.split(",")
54         paths?.let {
55             resourceDictionaryLoadService.loadPathsResourceDictionary(paths)
56         }
57     }
58
59     open suspend fun initBlueprintCatalog() {
60         log.info("cba load from paths(${bluePrintLoadConfiguration.loadBlueprintPaths})")
61
62         val paths = bluePrintLoadConfiguration.loadBlueprintPaths?.split(",")
63         paths?.let {
64             bluePrintCatalogLoadService.loadPathsBlueprintModelCatalog(paths)
65         }
66     }
67 }