2 * Copyright © 2018-2019 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.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
20 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
21 import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
22 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRelationshipTypeEnhancer
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 BluePrintRelationshipTypeEnhancerImpl(
35 private val bluePrintRepoService: BluePrintRepoService,
36 private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService
37 ) : BluePrintRelationshipTypeEnhancer {
39 private val log = logger(BluePrintRelationshipTypeEnhancerImpl::class)
41 lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
42 lateinit var bluePrintContext: BluePrintContext
45 bluePrintRuntimeService: BluePrintRuntimeService<*>,
47 relationshipType: RelationshipType
49 this.bluePrintRuntimeService = bluePrintRuntimeService
50 this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
52 val derivedFrom = relationshipType.derivedFrom
54 if (!BluePrintTypes.rootRelationshipTypes().contains(derivedFrom)) {
55 val derivedFromRelationshipType =
56 BluePrintEnhancerUtils.populateRelationshipType(bluePrintContext, bluePrintRepoService, name)
57 // Enrich RelationshipType
58 enhance(bluePrintRuntimeService, derivedFrom, derivedFromRelationshipType)
61 // NodeType Attribute Definitions
62 enrichRelationshipTypeAttributes(name, relationshipType)
64 // NodeType Property Definitions
65 enrichRelationshipTypeProperties(name, relationshipType)
67 // TODO("Interface Enrichment, If needed")
70 open fun enrichRelationshipTypeAttributes(nodeTypeName: String, relationshipType: RelationshipType) {
71 relationshipType.attributes?.let {
72 bluePrintTypeEnhancerService.enhanceAttributeDefinitions(
73 bluePrintRuntimeService,
74 relationshipType.attributes!!
79 open fun enrichRelationshipTypeProperties(nodeTypeName: String, relationshipType: RelationshipType) {
80 relationshipType.properties?.let {
81 bluePrintTypeEnhancerService.enhancePropertyDefinitions(
82 bluePrintRuntimeService,
83 relationshipType.properties!!