2 * Copyright © 2017-2018 AT&T Intellectual Property.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package org.onap.ccsdk.apps.controllerblueprints.core.service
\r
19 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
\r
20 import org.onap.ccsdk.apps.controllerblueprints.core.data.*
\r
24 * @author Brinda Santh
\r
26 class BluePrintChainedService {
\r
27 var bpc : BluePrintContext
\r
29 constructor(bpc : BluePrintContext){
\r
33 fun nodeTypeChained(nodeTypeName: String): NodeType {
\r
35 val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName)
\r
36 val attributes = hashMapOf<String, AttributeDefinition>()
\r
37 val properties = hashMapOf<String, PropertyDefinition>()
\r
38 val requirements = hashMapOf<String, RequirementDefinition>()
\r
39 val capabilities = hashMapOf<String, CapabilityDefinition>()
\r
40 val interfaces = hashMapOf<String, InterfaceDefinition>()
\r
41 val artifacts = hashMapOf<String, ArtifactDefinition>()
\r
43 recNodeTypesChained(nodeTypeName).forEach { nodeType ->
\r
45 val subAttributes = bpc.nodeTypeByName(nodeType.id!!).attributes
\r
46 if (subAttributes != null) {
\r
47 attributes.putAll(subAttributes)
\r
50 val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties
\r
51 if (subProperties != null) {
\r
52 properties.putAll(subProperties)
\r
55 val subRequirements = bpc.nodeTypeByName(nodeType.id!!).requirements
\r
56 if (subRequirements != null) {
\r
57 requirements.putAll(subRequirements)
\r
59 val subCapabilities = bpc.nodeTypeByName(nodeType.id!!).capabilities
\r
60 if (subCapabilities != null) {
\r
61 capabilities.putAll(subCapabilities)
\r
63 val subInterfaces = bpc.nodeTypeByName(nodeType.id!!).interfaces
\r
64 if (subInterfaces != null) {
\r
65 interfaces.putAll(subInterfaces)
\r
68 val subArtifacts = bpc.nodeTypeByName(nodeType.id!!).artifacts
\r
69 if (subArtifacts != null) {
\r
70 artifacts.putAll(subArtifacts)
\r
73 nodeType.attributes = attributes
\r
74 nodeType.properties = properties
\r
75 nodeType.requirements = requirements
\r
76 nodeType.capabilities = capabilities
\r
77 nodeType.interfaces = interfaces
\r
78 nodeType.artifacts = artifacts
\r
82 fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap<String, PropertyDefinition>? {
\r
83 val nodeType = bpc.nodeTypeByName(nodeTypeName)
\r
84 val properties = hashMapOf<String, PropertyDefinition>()
\r
86 recNodeTypesChained(nodeTypeName).forEach { nodeType ->
\r
87 val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties
\r
88 if (subProperties != null) {
\r
89 properties.putAll(subProperties)
\r
95 private fun recNodeTypesChained(nodeTypeName: String, nodeTypes: MutableList<NodeType>? = arrayListOf()): MutableList<NodeType> {
\r
96 val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName)
\r
97 nodeType.id = nodeTypeName
\r
98 val derivedFrom: String = nodeType.derivedFrom
\r
99 if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
\r
100 recNodeTypesChained(derivedFrom, nodeTypes)
\r
102 nodeTypes!!.add(nodeType)
\r
106 private fun recDataTypesChained(dataTypeName: String, dataTypes: MutableList<DataType>? = arrayListOf()): MutableList<DataType> {
\r
107 val dataType: DataType = bpc.dataTypeByName(dataTypeName)!!
\r
108 dataType.id = dataTypeName
\r
109 val derivedFrom: String = dataType.derivedFrom
\r
110 if (!BluePrintTypes.rootDataTypes().contains(derivedFrom)) {
\r
111 recDataTypesChained(derivedFrom, dataTypes)
\r
113 dataTypes!!.add(dataType)
\r