aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src
diff options
context:
space:
mode:
authorBrinda Santh <bs2796@att.com>2019-12-31 10:53:59 -0500
committerBrinda Santh <bs2796@att.com>2019-12-31 10:53:59 -0500
commitba75d2fad2b0111a510f4ee4cc87e658fb32ac4b (patch)
tree92c50b5bea79bb6c424aab6b0ac2e805a9e36e07 /ms/blueprintsprocessor/modules/blueprints/blueprint-core/src
parent1fdaf4953daf15970afe6ee10491dfa2d0a76753 (diff)
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 <bs2796@att.com> Change-Id: Ie944ff5f75f80c852555306e1a4e0fa7f5b803d7
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints/blueprint-core/src')
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt69
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt2
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt (renamed from ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt)17
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt27
4 files changed, 98 insertions, 17 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt
index c23e495fb..3c5561994 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt
@@ -46,9 +46,9 @@ fun serviceTemplate(
version: String,
author: String,
tags: String,
- block: BluePrintServiceDSLBuilder.() -> Unit
+ block: ServiceTemplateBuilder.() -> Unit
): ServiceTemplate {
- return BluePrintServiceDSLBuilder(name, version, author, tags).apply(block).build()
+ return ServiceTemplateBuilder(name, version, author, tags).apply(block).build()
}
fun workflow(id: String, description: String, block: WorkflowBuilder.() -> Unit): Workflow {
@@ -171,6 +171,11 @@ fun getNodeTemplateOperationOutput(
}
/** Blueprint Type Extensions */
+fun ServiceTemplateBuilder.nodeTypeComponent() {
+ val nodeType = BluePrintTypes.nodeTypeComponent()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
fun BluePrintTypes.nodeTypeComponent(): NodeType {
return nodeType(
@@ -182,6 +187,7 @@ fun BluePrintTypes.nodeTypeComponent(): NodeType {
}
}
+@Deprecated("CDS won't support, use implerative workflow definitions.")
fun BluePrintTypes.nodeTypeWorkflow(): NodeType {
return nodeType(
id = BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW,
@@ -192,6 +198,12 @@ fun BluePrintTypes.nodeTypeWorkflow(): NodeType {
}
}
+fun ServiceTemplateBuilder.nodeTypeVnf() {
+ val nodeType = BluePrintTypes.nodeTypeVnf()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
+
fun BluePrintTypes.nodeTypeVnf(): NodeType {
return nodeType(
id = BluePrintConstants.MODEL_TYPE_NODE_VNF,
@@ -202,6 +214,12 @@ fun BluePrintTypes.nodeTypeVnf(): NodeType {
}
}
+fun ServiceTemplateBuilder.nodeTypeResourceSource() {
+ val nodeType = BluePrintTypes.nodeTypeResourceSource()
+ if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
+ this.nodeTypes!![nodeType.id!!] = nodeType
+}
+
fun BluePrintTypes.nodeTypeResourceSource(): NodeType {
return nodeType(
id = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
@@ -213,6 +231,11 @@ fun BluePrintTypes.nodeTypeResourceSource(): NodeType {
}
/** Artifacts */
+fun ServiceTemplateBuilder.artifactTypeTemplateVelocity() {
+ val artifactType = BluePrintTypes.artifactTypeTemplateVelocity()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
fun BluePrintTypes.artifactTypeTemplateVelocity(): ArtifactType {
return artifactType(
@@ -225,6 +248,12 @@ fun BluePrintTypes.artifactTypeTemplateVelocity(): ArtifactType {
}
}
+fun ServiceTemplateBuilder.artifactTypeTempleJinja() {
+ val artifactType = BluePrintTypes.artifactTypeTempleJinja()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
+
fun BluePrintTypes.artifactTypeTempleJinja(): ArtifactType {
return artifactType(
id = BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA,
@@ -236,6 +265,12 @@ fun BluePrintTypes.artifactTypeTempleJinja(): ArtifactType {
}
}
+fun ServiceTemplateBuilder.artifactTypeMappingResource() {
+ val artifactType = BluePrintTypes.artifactTypeMappingResource()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
+
fun BluePrintTypes.artifactTypeMappingResource(): ArtifactType {
return artifactType(
id = BluePrintConstants.MODEL_TYPE_ARTIFACT_MAPPING_RESOURCE,
@@ -259,6 +294,12 @@ fun BluePrintTypes.artifactTypeScriptJython(): ArtifactType {
}
}
+fun ServiceTemplateBuilder.artifactTypeScriptKotlin() {
+ val artifactType = BluePrintTypes.artifactTypeScriptKotlin()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
+
fun BluePrintTypes.artifactTypeScriptKotlin(): ArtifactType {
return artifactType(
id = BluePrintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_KOTLIN,
@@ -282,6 +323,12 @@ fun BluePrintTypes.artifactTypeDirectedGraph(): ArtifactType {
}
}
+fun ServiceTemplateBuilder.artifactTypeComponentJar() {
+ val artifactType = BluePrintTypes.artifactTypeComponentJar()
+ if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
+ this.artifactTypes!![artifactType.id!!] = artifactType
+}
+
fun BluePrintTypes.artifactTypeComponentJar(): ArtifactType {
return artifactType(
id = BluePrintConstants.MODEL_TYPE_ARTIFACT_COMPONENT_JAR,
@@ -295,6 +342,12 @@ fun BluePrintTypes.artifactTypeComponentJar(): ArtifactType {
/** Relationship Types */
+fun ServiceTemplateBuilder.relationshipTypeConnectsTo() {
+ val relationshipType = BluePrintTypes.relationshipTypeConnectsTo()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeConnectsTo(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO,
@@ -306,6 +359,12 @@ fun BluePrintTypes.relationshipTypeConnectsTo(): RelationshipType {
}
}
+fun ServiceTemplateBuilder.relationshipTypeDependsOn() {
+ val relationshipType = BluePrintTypes.relationshipTypeDependsOn()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeDependsOn(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON,
@@ -316,6 +375,12 @@ fun BluePrintTypes.relationshipTypeDependsOn(): RelationshipType {
}
}
+fun ServiceTemplateBuilder.relationshipTypeHostedOn() {
+ val relationshipType = BluePrintTypes.relationshipTypeHostedOn()
+ if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
+ this.relationshipTypes!![relationshipType.id!!] = relationshipType
+}
+
fun BluePrintTypes.relationshipTypeHostedOn(): RelationshipType {
return relationshipType(
id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON,
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
index 216a0d16f..a89267387 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
@@ -36,7 +36,7 @@ import kotlin.reflect.jvm.reflect
open class TopologyTemplateBuilder {
private var topologyTemplate = TopologyTemplate()
- private var nodeTemplates: MutableMap<String, NodeTemplate>? = null
+ var nodeTemplates: MutableMap<String, NodeTemplate>? = null
var relationshipTemplates: MutableMap<String, RelationshipTemplate>? = null
private var workflows: MutableMap<String, Workflow>? = null
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt
index a3db88b6a..254e644b3 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/ServiceTemplateBuilder.kt
@@ -32,7 +32,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
import kotlin.reflect.KClass
-class BluePrintServiceDSLBuilder(
+class ServiceTemplateBuilder(
private val name: String,
private val version: String,
private val author: String,
@@ -44,11 +44,11 @@ class BluePrintServiceDSLBuilder(
private var metadata: MutableMap<String, String> = hashMapOf()
private var dslDefinitions: MutableMap<String, JsonNode>? = null
private var imports: MutableList<ImportDefinition> = mutableListOf()
- private var nodeTypes: MutableMap<String, NodeType>? = null
- private var artifactTypes: MutableMap<String, ArtifactType>? = null
- private var dataTypes: MutableMap<String, DataType>? = null
- private var relationshipTypes: MutableMap<String, RelationshipType>? = null
- private var policyTypes: MutableMap<String, PolicyType>? = null
+ var nodeTypes: MutableMap<String, NodeType>? = null
+ var artifactTypes: MutableMap<String, ArtifactType>? = null
+ var dataTypes: MutableMap<String, DataType>? = null
+ var relationshipTypes: MutableMap<String, RelationshipType>? = null
+ var policyTypes: MutableMap<String, PolicyType>? = null
private fun initMetaData() {
metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] = name
@@ -93,25 +93,21 @@ class BluePrintServiceDSLBuilder(
fun artifactTypes(artifactTypes: MutableMap<String, ArtifactType>) {
if (this.artifactTypes == null) this.artifactTypes = hashMapOf()
-
this.artifactTypes!!.putAll(artifactTypes)
}
fun relationshipTypes(relationshipTypes: MutableMap<String, RelationshipType>) {
if (this.relationshipTypes == null) this.relationshipTypes = hashMapOf()
-
this.relationshipTypes!!.putAll(relationshipTypes)
}
fun policyTypes(policyTypes: MutableMap<String, PolicyType>) {
if (this.policyTypes == null) this.policyTypes = hashMapOf()
-
this.policyTypes!!.putAll(policyTypes)
}
fun nodeType(nodeTypes: MutableMap<String, NodeType>) {
if (this.nodeTypes == null) this.nodeTypes = hashMapOf()
-
this.nodeTypes!!.putAll(nodeTypes)
}
@@ -139,7 +135,6 @@ class BluePrintServiceDSLBuilder(
fun policyType(policyType: PolicyType) {
if (policyTypes == null) policyTypes = hashMapOf()
-
policyTypes!![policyType.id!!] = policyType
}
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
index c2d764bd6..bf16ea93a 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
@@ -100,6 +100,21 @@ class BluePrintDSLTest {
import("Definition/data_types.json")
dsl("rest-endpoint", """{ "selector" : "odl-selector"}""")
dsl("db-endpoint", """{ "selector" : "db-selector"}""")
+
+ nodeTypeComponent()
+ nodeTypeResourceSource()
+ nodeTypeVnf()
+
+ artifactTypeTemplateVelocity()
+ artifactTypeTempleJinja()
+ artifactTypeScriptKotlin()
+ artifactTypeMappingResource()
+ artifactTypeComponentJar()
+
+ relationshipTypeConnectsTo()
+ relationshipTypeDependsOn()
+ relationshipTypeHostedOn()
+
topologyTemplate {
nodeTemplateOperation(
nodeTemplateName = "activate", type = "sample-node-type", interfaceName = "RestconfExecutor",
@@ -162,10 +177,16 @@ class BluePrintDSLTest {
}
}
+ // println(serviceTemplate.asJsonString(true))
+ assertNotNull(serviceTemplate.artifactTypes, "failed to get artifactTypes")
+ assertNotNull(serviceTemplate.nodeTypes, "failed to get nodeTypes")
+ assertNotNull(serviceTemplate.relationshipTypes, "failed to get relationshipTypes")
assertNotNull(serviceTemplate.topologyTemplate, "failed to get topology template")
assertNotNull(serviceTemplate.topologyTemplate?.nodeTemplates, "failed to get nodeTypes")
- assertNotNull(serviceTemplate.topologyTemplate?.nodeTemplates!!["activate"], "failed to get nodeTypes(activate)")
- // println(serviceTemplate.asJsonString(true))
+ assertNotNull(
+ serviceTemplate.topologyTemplate?.nodeTemplates!!["activate"],
+ "failed to get nodeTypes(activate)"
+ )
}
@Test
@@ -254,7 +275,7 @@ fun BluePrintTypes.nodeTemplateComponentTestExecutor(
description: String,
block: TestNodeTemplateOperationImplBuilder.() -> Unit
):
- NodeTemplate {
+ NodeTemplate {
return TestNodeTemplateOperationImplBuilder(id, description).apply(block).build()
}