summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt78
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt110
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt199
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt103
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt56
5 files changed, 407 insertions, 139 deletions
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt
index 6a60c98cd..c2055f9a5 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorDSL.kt
@@ -89,16 +89,11 @@ fun BluePrintTypes.dataTypeDtSystemPackages(): DataType {
/** Component Builder */
fun BluePrintTypes.nodeTemplateComponentRemotePythonExecutor(id: String,
description: String,
- block: ComponentRemotePythonExecutorNodeTemplateOperationImplBuilder.() -> Unit)
+ block: ComponentRemotePythonExecutorNodeTemplateBuilder.() -> Unit)
: NodeTemplate {
- return ComponentRemotePythonExecutorNodeTemplateOperationImplBuilder(id, description).apply(block).build()
+ return ComponentRemotePythonExecutorNodeTemplateBuilder(id, description).apply(block).build()
}
-class ComponentRemotePythonExecutorNodeTemplateOperationImplBuilder(id: String, description: String) :
- AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder, ComponentRemotePythonExecutorInputAssignmentBuilder,
- ComponentRemotePythonExecutorOutputAssignmentBuilder>(id, "component-remote-python-executor",
- "ComponentRemotePythonExecutor", description)
-
class DtSystemPackageDataTypeBuilder : PropertiesAssignmentBuilder() {
fun type(type: String) = type(type.asJsonPrimitive())
@@ -116,48 +111,55 @@ class DtSystemPackageDataTypeBuilder : PropertiesAssignmentBuilder() {
}
}
-class ComponentRemotePythonExecutorInputAssignmentBuilder : PropertiesAssignmentBuilder() {
+class ComponentRemotePythonExecutorNodeTemplateBuilder(id: String, description: String) :
+ AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder, ComponentRemotePythonExecutorNodeTemplateBuilder.InputsBuilder,
+ ComponentRemotePythonExecutorNodeTemplateBuilder.OutputsBuilder>(id, "component-remote-python-executor",
+ "ComponentRemotePythonExecutor", description) {
- private var packageList: ArrayNode? = null
+ class InputsBuilder : PropertiesAssignmentBuilder() {
- fun endpointSelector(endpointSelector: String) = endpointSelector(endpointSelector.asJsonPrimitive())
+ private var packageList: ArrayNode? = null
- fun endpointSelector(endpointSelector: JsonNode) {
- property(ComponentRemotePythonExecutor.INPUT_ENDPOINT_SELECTOR, endpointSelector)
- }
+ fun endpointSelector(endpointSelector: String) = endpointSelector(endpointSelector.asJsonPrimitive())
- fun dynamicProperties(dynamicProperties: String) = dynamicProperties(dynamicProperties.asJsonType())
+ fun endpointSelector(endpointSelector: JsonNode) {
+ property(ComponentRemotePythonExecutor.INPUT_ENDPOINT_SELECTOR, endpointSelector)
+ }
- fun dynamicProperties(dynamicProperties: JsonNode) {
- property(ComponentRemotePythonExecutor.INPUT_DYNAMIC_PROPERTIES, dynamicProperties)
- }
+ fun dynamicProperties(dynamicProperties: String) = dynamicProperties(dynamicProperties.asJsonType())
- fun argumentProperties(argumentProperties: String) = argumentProperties(argumentProperties.asJsonType())
+ fun dynamicProperties(dynamicProperties: JsonNode) {
+ property(ComponentRemotePythonExecutor.INPUT_DYNAMIC_PROPERTIES, dynamicProperties)
+ }
- fun argumentProperties(argumentProperties: JsonNode) {
- property(ComponentRemotePythonExecutor.INPUT_ARGUMENT_PROPERTIES, argumentProperties)
- }
+ fun argumentProperties(argumentProperties: String) = argumentProperties(argumentProperties.asJsonType())
- fun command(command: String) = command(command.asJsonPrimitive())
+ fun argumentProperties(argumentProperties: JsonNode) {
+ property(ComponentRemotePythonExecutor.INPUT_ARGUMENT_PROPERTIES, argumentProperties)
+ }
- fun command(command: JsonNode) {
- property(ComponentRemotePythonExecutor.INPUT_COMMAND, command)
- }
+ fun command(command: String) = command(command.asJsonPrimitive())
- fun packages(block: DtSystemPackageDataTypeBuilder.() -> Unit) {
- if (packageList == null)
- packageList = JacksonUtils.objectMapper.createArrayNode()
- val dtSysyemPackagePropertyAssignments = DtSystemPackageDataTypeBuilder().apply(block).build()
- packageList!!.add(dtSysyemPackagePropertyAssignments.asJsonType())
- }
+ fun command(command: JsonNode) {
+ property(ComponentRemotePythonExecutor.INPUT_COMMAND, command)
+ }
- override fun build(): MutableMap<String, JsonNode> {
- val propertyAssignments = super.build()
- if (packageList != null) {
- propertyAssignments[ComponentRemotePythonExecutor.INPUT_PACKAGES] = packageList!!
+ fun packages(block: DtSystemPackageDataTypeBuilder.() -> Unit) {
+ if (packageList == null)
+ packageList = JacksonUtils.objectMapper.createArrayNode()
+ val dtSysyemPackagePropertyAssignments = DtSystemPackageDataTypeBuilder().apply(block).build()
+ packageList!!.add(dtSysyemPackagePropertyAssignments.asJsonType())
+ }
+
+ override fun build(): MutableMap<String, JsonNode> {
+ val propertyAssignments = super.build()
+ if (packageList != null) {
+ propertyAssignments[ComponentRemotePythonExecutor.INPUT_PACKAGES] = packageList!!
+ }
+ return propertyAssignments
}
- return propertyAssignments
}
-}
-class ComponentRemotePythonExecutorOutputAssignmentBuilder : PropertiesAssignmentBuilder() \ No newline at end of file
+ class OutputsBuilder : PropertiesAssignmentBuilder()
+
+} \ No newline at end of file
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 2ca7046b3..40ea47e33 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
@@ -81,89 +81,91 @@ fun BluePrintTypes.nodeTypeComponentResourceResolution(): NodeType {
/** Component Builder */
fun BluePrintTypes.nodeTemplateComponentResourceResolution(id: String,
description: String,
- block: ComponentResourceResolutionNodeTemplateOperationImplBuilder.() -> Unit)
+ block: ComponentResourceResolutionNodeTemplateBuilder.() -> Unit)
: NodeTemplate {
- return ComponentResourceResolutionNodeTemplateOperationImplBuilder(id, description).apply(block).build()
+ return ComponentResourceResolutionNodeTemplateBuilder(id, description).apply(block).build()
}
-class ComponentResourceResolutionNodeTemplateOperationImplBuilder(id: String, description: String) :
- AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder, ComponentResourceResolutionInputAssignmentBuilder,
- ComponentResourceResolutionOutputAssignmentBuilder>(id, "component-script-executor",
+class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: String) :
+ AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
+ ComponentResourceResolutionNodeTemplateBuilder.InputsBuilder,
+ ComponentResourceResolutionNodeTemplateBuilder.OutputsBuilder>(id, "component-script-executor",
"ComponentResourceResolution",
- description)
+ description) {
-class ComponentResourceResolutionInputAssignmentBuilder : PropertiesAssignmentBuilder() {
+ class InputsBuilder : PropertiesAssignmentBuilder() {
- fun requestId(requestId: String) = requestId(requestId.asJsonPrimitive())
+ fun requestId(requestId: String) = requestId(requestId.asJsonPrimitive())
- fun requestId(requestId: JsonNode) {
- property(ResourceResolutionComponent.INPUT_REQUEST_ID, requestId)
- }
+ fun requestId(requestId: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_REQUEST_ID, requestId)
+ }
- fun resourceId(resourceId: String) = resourceId(resourceId.asJsonPrimitive())
+ fun resourceId(resourceId: String) = resourceId(resourceId.asJsonPrimitive())
- fun resourceId(resourceId: JsonNode) {
- property(ResourceResolutionComponent.INPUT_RESOURCE_ID, resourceId)
- }
+ fun resourceId(resourceId: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_RESOURCE_ID, resourceId)
+ }
- fun actionName(actionName: String) = actionName(actionName.asJsonPrimitive())
+ fun actionName(actionName: String) = actionName(actionName.asJsonPrimitive())
- fun actionName(actionName: JsonNode) {
- property(ResourceResolutionComponent.INPUT_ACTION_NAME, actionName)
- }
+ fun actionName(actionName: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_ACTION_NAME, actionName)
+ }
- fun resolutionKey(resolutionKey: String) = resolutionKey(resolutionKey.asJsonPrimitive())
+ fun resolutionKey(resolutionKey: String) = resolutionKey(resolutionKey.asJsonPrimitive())
- fun resolutionKey(resolutionKey: JsonNode) {
- property(ResourceResolutionComponent.INPUT_RESOLUTION_KEY, resolutionKey)
- }
+ fun resolutionKey(resolutionKey: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_RESOLUTION_KEY, resolutionKey)
+ }
- fun dynamicProperties(dynamicProperties: String) = dynamicProperties(dynamicProperties.asJsonType())
+ fun dynamicProperties(dynamicProperties: String) = dynamicProperties(dynamicProperties.asJsonType())
- fun dynamicProperties(dynamicProperties: JsonNode) {
- property(ResourceResolutionComponent.INPUT_DYNAMIC_PROPERTIES, dynamicProperties)
- }
+ fun dynamicProperties(dynamicProperties: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_DYNAMIC_PROPERTIES, dynamicProperties)
+ }
- fun occurrence(occurrence: Int) = occurrence(occurrence.asJsonPrimitive())
+ fun occurrence(occurrence: Int) = occurrence(occurrence.asJsonPrimitive())
- fun occurrence(resolutionKey: JsonNode) {
- property(ResourceResolutionComponent.INPUT_OCCURRENCE, resolutionKey)
- }
+ fun occurrence(resolutionKey: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_OCCURRENCE, resolutionKey)
+ }
- fun storeResult(storeResult: Boolean) = storeResult(storeResult.asJsonPrimitive())
+ fun storeResult(storeResult: Boolean) = storeResult(storeResult.asJsonPrimitive())
- fun storeResult(storeResult: JsonNode) {
- property(ResourceResolutionComponent.INPUT_STORE_RESULT, storeResult)
- }
+ fun storeResult(storeResult: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_STORE_RESULT, storeResult)
+ }
- fun resourceType(resourceType: String) = resourceType(resourceType.asJsonPrimitive())
+ fun resourceType(resourceType: String) = resourceType(resourceType.asJsonPrimitive())
- fun resourceType(resourceType: JsonNode) {
- property(ResourceResolutionComponent.INPUT_RESOURCE_TYPE, resourceType)
- }
+ fun resourceType(resourceType: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_RESOURCE_TYPE, resourceType)
+ }
- fun artifactPrefixNames(artifactPrefixNames: String) = artifactPrefixNames(artifactPrefixNames.jsonAsJsonType())
+ fun artifactPrefixNames(artifactPrefixNames: String) = artifactPrefixNames(artifactPrefixNames.jsonAsJsonType())
- fun artifactPrefixNames(artifactPrefixNameList: List<String>) {
- artifactPrefixNames(artifactPrefixNameList.asJsonString())
- }
+ fun artifactPrefixNames(artifactPrefixNameList: List<String>) =
+ artifactPrefixNames(artifactPrefixNameList.asJsonString())
- fun artifactPrefixNames(artifactPrefixNames: JsonNode) {
- property(ResourceResolutionComponent.INPUT_ARTIFACT_PREFIX_NAMES, artifactPrefixNames)
+ fun artifactPrefixNames(artifactPrefixNames: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_ARTIFACT_PREFIX_NAMES, artifactPrefixNames)
+ }
}
-}
-class ComponentResourceResolutionOutputAssignmentBuilder : PropertiesAssignmentBuilder() {
+ class OutputsBuilder : PropertiesAssignmentBuilder() {
- fun status(status: String) = status(status.asJsonPrimitive())
+ fun status(status: String) = status(status.asJsonPrimitive())
- fun status(status: JsonNode) {
- property(ResourceResolutionComponent.OUTPUT_STATUS, status)
- }
+ fun status(status: JsonNode) {
+ property(ResourceResolutionComponent.OUTPUT_STATUS, status)
+ }
- fun resourceAssignmentParams(resourceAssignmentParams: String) = resourceAssignmentParams(resourceAssignmentParams.asJsonType())
+ fun resourceAssignmentParams(resourceAssignmentParams: String) =
+ resourceAssignmentParams(resourceAssignmentParams.asJsonType())
- fun resourceAssignmentParams(resourceAssignmentParams: JsonNode) {
- property(ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_PARAMS, resourceAssignmentParams)
+ fun resourceAssignmentParams(resourceAssignmentParams: JsonNode) {
+ property(ResourceResolutionComponent.OUTPUT_RESOURCE_ASSIGNMENT_PARAMS, resourceAssignmentParams)
+ }
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt
index 4e0f0f18a..b1d694859 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSL.kt
@@ -16,11 +16,13 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
+import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.*
+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.AbstractNodeTemplatePropertyImplBuilder
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType
fun BluePrintTypes.nodeTypeSourceInput(): NodeType {
@@ -85,7 +87,7 @@ fun BluePrintTypes.nodeTypeSourceRest(): NodeType {
}
}
property("payload", BluePrintConstants.DATA_TYPE_STRING,
- false, ""){
+ false, "") {
defaultValue("".asJsonPrimitive())
}
property("endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
@@ -131,11 +133,196 @@ fun BluePrintTypes.nodeTypeSourceCapability(): NodeType {
}
property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
true, "Kotlin Script class name or jython script name.")
- property(ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
- false, "Dynamic Json Content or DSL Json reference.")
property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
true, "Resource Resolution dependency dictionary names.") {
entrySchema(BluePrintConstants.DATA_TYPE_STRING)
}
}
+}
+
+/** Node Template Source Input **/
+fun BluePrintTypes.nodeTemplateSourceInput(id: String, description: String,
+ block: SourceInputNodeTemplateBuilder.() -> Unit): NodeTemplate {
+ return SourceInputNodeTemplateBuilder(id, description).apply(block).build()
+}
+
+class SourceInputNodeTemplateBuilder(id: String, description: String) :
+ AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(id,
+ "source-input", description)
+
+/** Node Template Source Default **/
+fun BluePrintTypes.nodeTemplateSourceDefault(id: String, description: String,
+ block: SourceDefaultNodeTemplateBuilder.() -> Unit): NodeTemplate {
+ return SourceDefaultNodeTemplateBuilder(id, description).apply(block).build()
+}
+
+class SourceDefaultNodeTemplateBuilder(id: String, description: String) :
+ AbstractNodeTemplatePropertyImplBuilder<PropertiesAssignmentBuilder>(id,
+ "source-default", description)
+
+/** Node Template Source DB **/
+fun BluePrintTypes.nodeTemplateSourceDb(id: String, description: String,
+ block: SourceDbNodeTemplateBuilder.() -> Unit): NodeTemplate {
+ return SourceDbNodeTemplateBuilder(id, description).apply(block).build()
+}
+
+class SourceDbNodeTemplateBuilder(id: String, description: String) :
+ AbstractNodeTemplatePropertyImplBuilder<SourceDbNodeTemplateBuilder.PropertiesBuilder>(id,
+ "source-db", description) {
+
+ class PropertiesBuilder : PropertiesAssignmentBuilder() {
+ fun type(type: String) = type(type.asJsonPrimitive())
+
+ fun type(type: JsonNode) {
+ property("type", type)
+ }
+
+ fun endpointSelector(endpointSelector: String) = endpointSelector(endpointSelector.asJsonPrimitive())
+
+ fun endpointSelector(endpointSelector: JsonNode) {
+ property("endpoint-selector", endpointSelector)
+ }
+
+ fun query(query: String) = query(query.asJsonPrimitive())
+
+ fun query(query: JsonNode) {
+ property("query", query)
+ }
+
+ fun inputKeyMapping(block: KeyMappingBuilder.() -> Unit) {
+ val map = KeyMappingBuilder().apply(block).build()
+ property("input-key-mapping", map.asJsonType())
+ }
+
+ fun outputKeyMapping(block: KeyMappingBuilder.() -> Unit) {
+ val map = KeyMappingBuilder().apply(block).build()
+ property("output-key-mapping", map.asJsonType())
+ }
+
+ fun keyDependencies(keyDependencies: String) = keyDependencies(keyDependencies.asJsonType())
+
+ fun keyDependencies(keyDependencies: List<String>) = keyDependencies(keyDependencies.asJsonString())
+
+ fun keyDependencies(keyDependencies: JsonNode) {
+ property("key-dependencies", keyDependencies)
+ }
+ }
+}
+
+class KeyMappingBuilder() {
+ val map: MutableMap<String, String> = hashMapOf()
+ fun map(key: String, value: String) {
+ map[key] = value
+ }
+
+ fun build(): MutableMap<String, String> {
+ return map
+ }
+}
+
+
+/** Node Template Source Rest **/
+fun BluePrintTypes.nodeTemplateSourceRest(id: String, description: String,
+ block: SourceRestNodeTemplateBuilder.() -> Unit): NodeTemplate {
+ return SourceRestNodeTemplateBuilder(id, description).apply(block).build()
+}
+
+class SourceRestNodeTemplateBuilder(id: String, description: String) :
+ AbstractNodeTemplatePropertyImplBuilder<SourceRestNodeTemplateBuilder.PropertiesBuilder>(id,
+ "source-rest", description) {
+
+ class PropertiesBuilder : PropertiesAssignmentBuilder() {
+ fun type(type: String) = type(type.asJsonPrimitive())
+
+ fun type(type: JsonNode) {
+ property("type", type)
+ }
+
+ fun endpointSelector(endpointSelector: String) = endpointSelector(endpointSelector.asJsonPrimitive())
+
+ fun endpointSelector(endpointSelector: JsonNode) {
+ property("endpoint-selector", endpointSelector)
+ }
+
+ fun verb(verb: String) = verb(verb.asJsonPrimitive())
+
+ fun verb(verb: JsonNode) {
+ property("verb", verb)
+ }
+
+ fun payload(payload: String) = payload(payload.asJsonPrimitive())
+
+ fun payload(payload: JsonNode) {
+ property("payload", payload)
+ }
+
+ fun urlPath(urlPath: String) = urlPath(urlPath.asJsonPrimitive())
+
+ fun urlPath(urlPath: JsonNode) {
+ property("url-path", urlPath)
+ }
+
+ fun path(path: String) = path(path.asJsonPrimitive())
+
+ fun path(path: JsonNode) {
+ property("path", path)
+ }
+
+ fun expressionType(expressionType: String) = expressionType(expressionType.asJsonPrimitive())
+
+ fun expressionType(expressionType: JsonNode) {
+ property("expression-type", expressionType)
+ }
+
+ fun inputKeyMapping(block: KeyMappingBuilder.() -> Unit) {
+ val map = KeyMappingBuilder().apply(block).build()
+ property("input-key-mapping", map.asJsonType())
+ }
+
+ fun outputKeyMapping(block: KeyMappingBuilder.() -> Unit) {
+ val map = KeyMappingBuilder().apply(block).build()
+ property("output-key-mapping", map.asJsonType())
+ }
+
+ fun keyDependencies(keyDependencies: String) = keyDependencies(keyDependencies.asJsonType())
+
+ fun keyDependencies(keyDependencies: List<String>) = keyDependencies(keyDependencies.asJsonString())
+
+ fun keyDependencies(keyDependencies: JsonNode) {
+ property("key-dependencies", keyDependencies)
+ }
+ }
+}
+
+/** Node Template Source Rest **/
+fun BluePrintTypes.nodeTemplateSourceCapability(id: String, description: String,
+ block: SourceCapabilityNodeTemplateBuilder.() -> Unit): NodeTemplate {
+ return SourceCapabilityNodeTemplateBuilder(id, description).apply(block).build()
+}
+
+class SourceCapabilityNodeTemplateBuilder(id: String, description: String) :
+ AbstractNodeTemplatePropertyImplBuilder<SourceCapabilityNodeTemplateBuilder.PropertiesBuilder>(id,
+ "source-capability", description) {
+
+ class PropertiesBuilder : PropertiesAssignmentBuilder() {
+ fun type(type: String) = type(type.asJsonPrimitive())
+
+ fun type(type: JsonNode) {
+ property(ComponentScriptExecutor.INPUT_SCRIPT_TYPE, type)
+ }
+
+ fun scriptClassReference(scriptClassReference: String) = scriptClassReference(scriptClassReference.asJsonPrimitive())
+
+ fun scriptClassReference(scriptClassReference: JsonNode) {
+ property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, scriptClassReference)
+ }
+
+ fun keyDependencies(keyDependencies: String) = keyDependencies(keyDependencies.asJsonType())
+
+ fun keyDependencies(keyDependencies: List<String>) = keyDependencies(keyDependencies.asJsonString())
+
+ fun keyDependencies(keyDependencies: JsonNode) {
+ property("key-dependencies", keyDependencies)
+ }
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
index 6ad6bc56a..2eb208566 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceDSLTest.kt
@@ -24,36 +24,111 @@ class ResourceSourceDSLTest {
@Test
fun testNodeTypeSourceInput() {
- val nodeTemplate = BluePrintTypes.nodeTypeSourceInput()
- //println(nodeTemplate.asJsonString(true))
- assertNotNull(nodeTemplate, "failed to generate nodeTypeSourceInput")
+ val nodeType = BluePrintTypes.nodeTypeSourceInput()
+ //println(nodeType.asJsonString(true))
+ assertNotNull(nodeType, "failed to generate nodeTypeSourceInput")
}
@Test
fun testNodeTypeSourceDefault() {
- val nodeTemplate = BluePrintTypes.nodeTypeSourceDefault()
- //println(nodeTemplate.asJsonString(true))
- assertNotNull(nodeTemplate, "failed to generate nodeTypeSourceDefault")
+ val nodeType = BluePrintTypes.nodeTypeSourceDefault()
+ //println(nodeType.asJsonString(true))
+ assertNotNull(nodeType, "failed to generate nodeTypeSourceDefault")
}
@Test
fun testNodeTypeSourceDb() {
- val nodeTemplate = BluePrintTypes.nodeTypeSourceDb()
- //println(nodeTemplate.asJsonString(true))
- assertNotNull(nodeTemplate, "failed to generate nodeTypeSourceDb")
+ val nodeType = BluePrintTypes.nodeTypeSourceDb()
+ //println(nodeType.asJsonString(true))
+ assertNotNull(nodeType, "failed to generate nodeTypeSourceDb")
}
@Test
fun testNodeTypeSourceRest() {
- val nodeTemplate = BluePrintTypes.nodeTypeSourceRest()
- //println(nodeTemplate.asJsonString(true))
- assertNotNull(nodeTemplate, "failed to generate nodeTypeSourceRest")
+ val nodeType = BluePrintTypes.nodeTypeSourceRest()
+ //println(nodeType.asJsonString(true))
+ assertNotNull(nodeType, "failed to generate nodeTypeSourceRest")
}
@Test
fun testNodeTypeSourceCapability() {
- val nodeTemplate = BluePrintTypes.nodeTypeSourceCapability()
+ val nodeType = BluePrintTypes.nodeTypeSourceCapability()
+ //println(nodeType.asJsonString(true))
+ assertNotNull(nodeType, "failed to generate nodeTypeSourceCapability")
+ }
+
+ @Test
+ fun testNodeTemplateSourceInput() {
+ val nodeTemplate = BluePrintTypes.nodeTemplateSourceInput("InputSystem", "") {
+
+ }
+ //println(nodeTemplate.asJsonString(true))
+ assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceInput")
+ }
+
+ @Test
+ fun testNodeTemplateSourceDefault() {
+ val nodeTemplate = BluePrintTypes.nodeTemplateSourceDefault("DefaultSystem", "") {
+
+ }
+ //println(nodeTemplate.asJsonString(true))
+ assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDefault")
+ }
+
+ @Test
+ fun testNodeTemplateSourceDb() {
+ val nodeTemplate = BluePrintTypes.nodeTemplateSourceDb("DbSystem", "") {
+ definedProperties {
+ type("SQL")
+ query("SELECT * FROM DB WHERE name = \$name")
+ endpointSelector("db-source-endpoint")
+ inputKeyMapping {
+ map("name", "\$name")
+ }
+ outputKeyMapping {
+ map("field_name", "\$fieldValue")
+ }
+ keyDependencies(arrayListOf("name"))
+ }
+ }
+ //println(nodeTemplate.asJsonString(true))
+ assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceDb")
+ }
+
+ @Test
+ fun testNodeTemplateSourceRest() {
+ val nodeTemplate = BluePrintTypes.nodeTemplateSourceRest("restSystem", "") {
+ definedProperties {
+ type("JSON")
+ endpointSelector("rest-source-endpoint")
+ expressionType("JSON_PATH")
+ urlPath("/location")
+ path(".\$name")
+ verb("GET")
+ payload("sample payload")
+ inputKeyMapping {
+ map("name", "\$name")
+ }
+ outputKeyMapping {
+ map("field_name", "\$fieldValue")
+ }
+ keyDependencies(arrayListOf("name"))
+ }
+ }
+ //println(nodeTemplate.asJsonString(true))
+ assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceRest")
+ }
+
+ @Test
+ fun testNodeTemplateSourceCapability() {
+ val nodeTemplate = BluePrintTypes.nodeTemplateSourceCapability("capabiltySystem", "") {
+ definedProperties {
+ type("kotlin")
+ scriptClassReference("Scripts/Sample.kt")
+ keyDependencies(arrayListOf("name"))
+ }
+ }
//println(nodeTemplate.asJsonString(true))
- assertNotNull(nodeTemplate, "failed to generate nodeTypeSourceCapability")
+ assertNotNull(nodeTemplate, "failed to generate nodeTemplateSourceCapability")
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
index b678d65ba..bf49972a9 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutorDSL.kt
@@ -65,49 +65,51 @@ fun BluePrintTypes.nodeTypeComponentScriptExecutor(): NodeType {
/** Component Builder */
fun BluePrintTypes.nodeTemplateComponentScriptExecutor(id: String,
description: String,
- block: ComponentScriptExecutorNodeTemplateOperationImplBuilder.() -> Unit)
+ block: ComponentScriptExecutorNodeTemplateBuilder.() -> Unit)
: NodeTemplate {
- return ComponentScriptExecutorNodeTemplateOperationImplBuilder(id, description).apply(block).build()
+ return ComponentScriptExecutorNodeTemplateBuilder(id, description).apply(block).build()
}
-class ComponentScriptExecutorNodeTemplateOperationImplBuilder(id: String, description: String) :
- AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder, ComponentScriptExecutorInputAssignmentBuilder,
- ComponentScriptExecutorOutputAssignmentBuilder>(id, "component-script-executor",
+class ComponentScriptExecutorNodeTemplateBuilder(id: String, description: String) :
+ AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
+ ComponentScriptExecutorNodeTemplateBuilder.InputsBuilder,
+ ComponentScriptExecutorNodeTemplateBuilder.OutputsBuilder>(id, "component-script-executor",
"ComponentScriptExecutor",
- description)
+ description) {
-class ComponentScriptExecutorInputAssignmentBuilder : PropertiesAssignmentBuilder() {
+ class InputsBuilder : PropertiesAssignmentBuilder() {
- fun type(type: String) = type(type.asJsonPrimitive())
+ fun type(type: String) = type(type.asJsonPrimitive())
- fun type(type: JsonNode) {
- property(ComponentScriptExecutor.INPUT_SCRIPT_TYPE, type)
- }
+ fun type(type: JsonNode) {
+ property(ComponentScriptExecutor.INPUT_SCRIPT_TYPE, type)
+ }
- fun scriptClassReference(scriptClassReference: String) = scriptClassReference(scriptClassReference.asJsonPrimitive())
+ fun scriptClassReference(scriptClassReference: String) = scriptClassReference(scriptClassReference.asJsonPrimitive())
- fun scriptClassReference(scriptClassReference: JsonNode) {
- property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, scriptClassReference)
- }
+ fun scriptClassReference(scriptClassReference: JsonNode) {
+ property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, scriptClassReference)
+ }
- fun dynamicProperties(dynamicProperties: String) = dynamicProperties(dynamicProperties.asJsonType())
+ fun dynamicProperties(dynamicProperties: String) = dynamicProperties(dynamicProperties.asJsonType())
- fun dynamicProperties(dynamicProperties: JsonNode) {
- property(ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, dynamicProperties)
+ fun dynamicProperties(dynamicProperties: JsonNode) {
+ property(ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, dynamicProperties)
+ }
}
-}
-class ComponentScriptExecutorOutputAssignmentBuilder : PropertiesAssignmentBuilder() {
+ class OutputsBuilder : PropertiesAssignmentBuilder() {
- fun status(status: String) = status(status.asJsonPrimitive())
+ fun status(status: String) = status(status.asJsonPrimitive())
- fun status(status: JsonNode) {
- property(ComponentScriptExecutor.OUTPUT_STATUS, status)
- }
+ fun status(status: JsonNode) {
+ property(ComponentScriptExecutor.OUTPUT_STATUS, status)
+ }
- fun responseData(responseData: String) = responseData(responseData.asJsonType())
+ fun responseData(responseData: String) = responseData(responseData.asJsonType())
- fun responseData(responseData: JsonNode) {
- property(ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, responseData)
+ fun responseData(responseData: JsonNode) {
+ property(ComponentScriptExecutor.OUTPUT_RESPONSE_DATA, responseData)
+ }
}
} \ No newline at end of file