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!!