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.cds.blueprintsprocessor.designer.api.enhancer
20 import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
21 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
22 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemplateEnhancer
23 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
24 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
25 import org.onap.ccsdk.cds.controllerblueprints.core.logger
26 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
27 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
28 import org.springframework.beans.factory.config.ConfigurableBeanFactory
29 import org.springframework.context.annotation.Scope
30 import org.springframework.stereotype.Service
33 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
34 open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
35 private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
36 : BluePrintNodeTemplateEnhancer {
38 private val log= logger(BluePrintNodeTemplateEnhancerImpl::class)
40 lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
41 lateinit var bluePrintContext: BluePrintContext
44 override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
45 log.info("***** Enhancing NodeTemplate($name)")
46 this.bluePrintRuntimeService = bluePrintRuntimeService
47 this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
50 val nodeTypeName = nodeTemplate.type
51 // Get NodeType from Repo and Update Service Template
52 val nodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext, bluePrintRepoService, nodeTypeName)
55 bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
57 //Enrich Node Template Artifacts
58 enhanceNodeTemplateArtifactDefinition(name, nodeTemplate)
61 open fun enhanceNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
63 nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition ->
64 // Enhance Artifacct Definitions
65 bluePrintTypeEnhancerService.enhanceArtifactDefinition(bluePrintRuntimeService, artifactDefinitionName, artifactDefinition)