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.cds.blueprintsprocessor.designer.api.enhancer
19 import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
20 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintServiceTemplateEnhancer
21 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintTypeEnhancerService
22 import org.onap.ccsdk.cds.controllerblueprints.core.logger
23 import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext
24 import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService
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 bluePrintTypeEnhancerService: BlueprintTypeEnhancerService) :
32 BlueprintServiceTemplateEnhancer {
34 private val log = logger(BlueprintServiceTemplateEnhancerImpl::class)
36 lateinit var bluePrintRuntimeService: BlueprintRuntimeService<*>
37 lateinit var bluePrintContext: BlueprintContext
39 override fun enhance(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, type: ServiceTemplate) {
40 this.bluePrintRuntimeService = bluePrintRuntimeService
41 this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
44 enhanceTopologyTemplate()
47 open fun initialCleanUp() {
48 bluePrintContext.serviceTemplate.artifactTypes?.clear()
49 bluePrintContext.serviceTemplate.nodeTypes?.clear()
50 bluePrintContext.serviceTemplate.dataTypes?.clear()
51 bluePrintContext.serviceTemplate.policyTypes?.clear()
52 bluePrintContext.serviceTemplate.relationshipTypes?.clear()
54 bluePrintContext.serviceTemplate.artifactTypes = mutableMapOf()
55 bluePrintContext.serviceTemplate.nodeTypes = mutableMapOf()
56 bluePrintContext.serviceTemplate.dataTypes = mutableMapOf()
57 bluePrintContext.serviceTemplate.policyTypes = mutableMapOf()
58 bluePrintContext.serviceTemplate.relationshipTypes = mutableMapOf()
59 log.info("reinitialized all type definitions")
62 open fun enhanceTopologyTemplate() {
63 bluePrintContext.serviceTemplate.topologyTemplate?.let { topologyTemplate ->
64 bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintRuntimeService, "topology_template", topologyTemplate)