2 * Copyright © 2017-2018 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.apps.controllerblueprints.core.interfaces
19 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
20 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
21 import org.onap.ccsdk.apps.controllerblueprints.core.data.*
22 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
24 interface BluePrintEnhancer<T> {
25 fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T)
28 interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer<ServiceTemplate>
30 interface BluePrintTopologyTemplateEnhancer : BluePrintEnhancer<TopologyTemplate>
32 interface BluePrintWorkflowEnhancer : BluePrintEnhancer<Workflow>
34 interface BluePrintNodeTemplateEnhancer : BluePrintEnhancer<NodeTemplate>
36 interface BluePrintNodeTypeEnhancer : BluePrintEnhancer<NodeType>
38 interface BluePrintPolicyTypeEnhancer : BluePrintEnhancer<PolicyType>
40 interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer<PropertyDefinition>
42 interface BluePrintAttributeDefinitionEnhancer : BluePrintEnhancer<AttributeDefinition>
45 interface BluePrintEnhancerService {
47 @Throws(BluePrintException::class)
48 fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext
50 @Throws(BluePrintException::class)
51 fun enhance(basePath: String): BluePrintContext
53 @Throws(BluePrintException::class)
54 fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
57 interface BluePrintTypeEnhancerService {
59 fun getServiceTemplateEnhancers(): List<BluePrintServiceTemplateEnhancer>
61 fun getTopologyTemplateEnhancers(): List<BluePrintTopologyTemplateEnhancer>
63 fun getWorkflowEnhancers(): List<BluePrintWorkflowEnhancer>
65 fun getNodeTemplateEnhancers(): List<BluePrintNodeTemplateEnhancer>
67 fun getNodeTypeEnhancers(): List<BluePrintNodeTypeEnhancer>
69 fun getPolicyTypeEnhancers(): List<BluePrintPolicyTypeEnhancer>
71 fun getPropertyDefinitionEnhancers(): List<BluePrintPropertyDefinitionEnhancer>
73 fun getAttributeDefinitionEnhancers(): List<BluePrintAttributeDefinitionEnhancer>
75 fun enhanceServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) {
76 val enhancers = getServiceTemplateEnhancers()
77 doEnhancement(bluePrintContext, error, name, serviceTemplate, enhancers)
80 fun enhanceTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) {
81 val enhancers = getTopologyTemplateEnhancers()
82 doEnhancement(bluePrintContext, error, name, topologyTemplate, enhancers)
85 fun enhanceWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
86 val enhancers = getWorkflowEnhancers()
87 doEnhancement(bluePrintContext, error, name, workflow, enhancers)
90 fun enhanceNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
91 val enhancers = getNodeTemplateEnhancers()
92 doEnhancement(bluePrintContext, error, name, nodeTemplate, enhancers)
95 fun enhanceNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
96 val enhancers = getNodeTypeEnhancers()
97 doEnhancement(bluePrintContext, error, name, nodeType, enhancers)
100 fun enhancePolicyType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, policyType: PolicyType) {
101 val enhancers = getPolicyTypeEnhancers()
102 doEnhancement(bluePrintContext, error, name, policyType, enhancers)
105 fun enhancePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
106 val enhancers = getPropertyDefinitionEnhancers()
107 doEnhancement(bluePrintContext, error, name, propertyDefinition, enhancers)
110 fun enhanceAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) {
111 val enhancers = getAttributeDefinitionEnhancers()
112 doEnhancement(bluePrintContext, error, name, attributeDefinition, enhancers)
115 private fun <T> doEnhancement(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, enhancers: List<BluePrintEnhancer<T>>) {
116 if (enhancers.isNotEmpty()) {
118 it.enhance(bluePrintContext, error, name, definition as T)