2 * Copyright © 2017-2018 AT&T Intellectual Property.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
19 import com.att.eelf.configuration.EELFLogger
20 import com.att.eelf.configuration.EELFManager
21 import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
22 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
23 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer
24 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
25 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
26 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
27 import org.springframework.beans.factory.config.ConfigurableBeanFactory
28 import org.springframework.context.annotation.Scope
29 import org.springframework.stereotype.Service
32 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
33 open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
34 private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
35 : BluePrintServiceTemplateEnhancer {
36 private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())
39 lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
40 lateinit var bluePrintContext: BluePrintContext
42 override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: ServiceTemplate) {
43 this.bluePrintRuntimeService = bluePrintRuntimeService
44 this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
47 enhanceTopologyTemplate()
50 open fun initialCleanUp() {
51 bluePrintContext.serviceTemplate.artifactTypes?.clear()
52 bluePrintContext.serviceTemplate.nodeTypes?.clear()
53 bluePrintContext.serviceTemplate.dataTypes?.clear()
54 bluePrintContext.serviceTemplate.policyTypes?.clear()
56 bluePrintContext.serviceTemplate.artifactTypes = mutableMapOf()
57 bluePrintContext.serviceTemplate.nodeTypes = mutableMapOf()
58 bluePrintContext.serviceTemplate.dataTypes = mutableMapOf()
59 bluePrintContext.serviceTemplate.policyTypes = mutableMapOf()
63 open fun enhanceTopologyTemplate() {
64 bluePrintContext.serviceTemplate.topologyTemplate?.let { topologyTemplate ->
65 bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintRuntimeService, "default", topologyTemplate)