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 org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
20 import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
21 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
22 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer
23 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
24 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
25 import org.springframework.beans.factory.config.ConfigurableBeanFactory
26 import org.springframework.context.annotation.Scope
27 import org.springframework.stereotype.Service
30 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
31 open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
32 private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
33 : BluePrintServiceTemplateEnhancer {
35 lateinit var bluePrintContext: BluePrintContext
36 lateinit var error: BluePrintError
38 override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: ServiceTemplate) {
39 this.bluePrintContext = bluePrintContext
42 enhanceTopologyTemplate()
45 open fun initialCleanUp() {
46 bluePrintContext.serviceTemplate.artifactTypes?.clear()
47 bluePrintContext.serviceTemplate.nodeTypes?.clear()
48 bluePrintContext.serviceTemplate.dataTypes?.clear()
49 bluePrintContext.serviceTemplate.policyTypes?.clear()
51 bluePrintContext.serviceTemplate.artifactTypes = mutableMapOf()
52 bluePrintContext.serviceTemplate.nodeTypes = mutableMapOf()
53 bluePrintContext.serviceTemplate.dataTypes = mutableMapOf()
54 bluePrintContext.serviceTemplate.policyTypes = mutableMapOf()
58 open fun enhanceTopologyTemplate() {
59 bluePrintContext.serviceTemplate.topologyTemplate?.let { topologyTemplate ->
60 bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintContext, error, "default", topologyTemplate)