From ba75d2fad2b0111a510f4ee4cc87e658fb32ac4b Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Tue, 31 Dec 2019 10:53:59 -0500 Subject: Flexible DSL Types and Templates definition. Easy search definitions Types and Templates inside ServiceTemplate DSL builder. Unit test modifications to support this change. Issue-ID: CCSDK-1054 Signed-off-by: Brinda Santh Change-Id: Ie944ff5f75f80c852555306e1a4e0fa7f5b803d7 --- .../resolution/ResourceResolutionComponentDSL.kt | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'ms/blueprintsprocessor/functions') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt index 25338c6ca..6573d0e9a 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt @@ -26,10 +26,18 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplateOperationImplBuilder import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder +import org.onap.ccsdk.cds.controllerblueprints.core.dsl.ServiceTemplateBuilder +import org.onap.ccsdk.cds.controllerblueprints.core.dsl.TopologyTemplateBuilder import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType /** Component Extensions **/ +fun ServiceTemplateBuilder.nodeTypeComponentResourceResolution() { + val nodeType = BluePrintTypes.nodeTypeComponentResourceResolution() + if (this.nodeTypes == null) this.nodeTypes = hashMapOf() + this.nodeTypes!![nodeType.id!!] = nodeType +} + fun BluePrintTypes.nodeTypeComponentResourceResolution(): NodeType { return nodeType( id = "component-resource-resolution", version = BluePrintConstants.DEFAULT_VERSION_NUMBER, @@ -112,19 +120,31 @@ fun BluePrintTypes.nodeTypeComponentResourceResolution(): NodeType { } /** Component Builder */ +fun TopologyTemplateBuilder.nodeTemplateComponentResourceResolution( + id: String, + description: String, + block: ComponentResourceResolutionNodeTemplateBuilder.() -> Unit +) { + val nodeTemplate = BluePrintTypes.nodeTemplateComponentResourceResolution( + id, description, + block + ) + if (nodeTemplates == null) nodeTemplates = hashMapOf() + nodeTemplates!![nodeTemplate.id!!] = nodeTemplate +} + fun BluePrintTypes.nodeTemplateComponentResourceResolution( id: String, description: String, block: ComponentResourceResolutionNodeTemplateBuilder.() -> Unit -): - NodeTemplate { +): NodeTemplate { return ComponentResourceResolutionNodeTemplateBuilder(id, description).apply(block).build() } class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: String) : AbstractNodeTemplateOperationImplBuilder( + ComponentResourceResolutionNodeTemplateBuilder.InputsBuilder, + ComponentResourceResolutionNodeTemplateBuilder.OutputsBuilder>( id, "component-script-executor", "ComponentResourceResolution", description -- cgit 1.2.3-korg