2 * Copyright © 2017-2018 AT&T Intellectual Property.
3 * Modifications Copyright © 2019 IBM.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
20 import com.att.eelf.configuration.EELFLogger
21 import com.att.eelf.configuration.EELFManager
22 import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
23 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateEnhancer
24 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
25 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
26 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
27 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
28 import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils
29 import org.springframework.beans.factory.config.ConfigurableBeanFactory
30 import org.springframework.context.annotation.Scope
31 import org.springframework.stereotype.Service
34 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
35 open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
36 private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
37 : BluePrintNodeTemplateEnhancer {
39 private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString())
41 lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
42 lateinit var bluePrintContext: BluePrintContext
45 override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
46 log.info("***** Enhancing NodeTemplate($name)")
47 this.bluePrintRuntimeService = bluePrintRuntimeService
48 this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
51 val nodeTypeName = nodeTemplate.type
52 // Get NodeType from Repo and Update Service Template
53 val nodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext, bluePrintRepoService, nodeTypeName)
56 bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
58 //Enrich Node Template Artifacts
59 enhanceNodeTemplateArtifactDefinition(name, nodeTemplate)
62 open fun enhanceNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
64 nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition ->
65 // Enhance Artifacct Definitions
66 bluePrintTypeEnhancerService.enhanceArtifactDefinition(bluePrintRuntimeService, artifactDefinitionName, artifactDefinition)