Merge "loopback Api- get Sources list"
authorDan Timoney <dtimoney@att.com>
Fri, 19 Jul 2019 13:55:50 +0000 (13:55 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 19 Jul 2019 13:55:50 +0000 (13:55 +0000)
40 files changed:
cds-ui/client/pom.xml
cds-ui/client/src/app/feature-modules/blueprint/select-template/template-options/template-options.component.html
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.html
cds-ui/pom.xml
cds-ui/server/package.json
cds-ui/server/pom.xml
components/scripts/python/ccsdk_netconf/common.py
docs/bluePrintsProcessorMS.rst [deleted file]
docs/controllerBlueprintStudioProcessorMS.rst [deleted file]
docs/datadictionary/index.rst
docs/datadictionary/media/mandatory.JPG [moved from docs/datadictionary/media/image0.JPG with 100% similarity]
docs/datadictionary/media/optional.JPG [moved from docs/datadictionary/media/image1.JPG with 100% similarity]
docs/datadictionary/resourcesource.rst
docs/microservices/enrichment.rst [new file with mode: 0644]
docs/microservices/media/Enrichment-REST.png [new file with mode: 0644]
docs/microservices/media/Enrichment-UI1.png [new file with mode: 0644]
docs/microservices/media/Enrichment-UI2.png [new file with mode: 0644]
ms/blueprintsprocessor/application/pom.xml
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ScriptComponentExtensions.kt
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutorTest.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
ms/blueprintsprocessor/modules/commons/message-lib/pom.xml
ms/blueprintsprocessor/modules/commons/ssh-lib/pom.xml
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentScriptExecutor.kt
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt
ms/blueprintsprocessor/parent/pom.xml
ms/controllerblueprints/modules/blueprint-core/pom.xml
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLTest.kt
pom.xml

index 86504b7..ed0087d 100644 (file)
@@ -50,8 +50,8 @@ limitations under the License.
         <version>1.3</version>
         <configuration>
           <nodeVersion>v8.12.0</nodeVersion>
+          <npmVersion>6.4.1</npmVersion>
           <nodeDownloadRoot>https://nodejs.org/dist/</nodeDownloadRoot>
-          <npmDownloadRoot>https://nodejs.org/dist/npm/</npmDownloadRoot>
           <installDirectory>./</installDirectory>
         </configuration>
         <executions>
index 57ff00d..1e8f469 100644 (file)
@@ -19,7 +19,7 @@ limitations under the License.
 ============LICENSE_END============================================
 -->
 <mat-radio-group>
-    <mat-radio-button value="1" (click)="selected(1)">Upload Template file</mat-radio-button><br> <br>
-    <mat-radio-button value="2" (click)="selected(2)">Starter Template</mat-radio-button><br> <br>
-    <mat-radio-button value="3" (click)="selected(3)">Existing Model File</mat-radio-button>
+    <mat-radio-button value="1" (click)="selected(1)">Upload From local</mat-radio-button><br> <br>
+    <mat-radio-button value="2" (click)="selected(2)">Existing Template File</mat-radio-button><br> <br>
+    <mat-radio-button value="3" (click)="selected(3)">Create New</mat-radio-button>
 </mat-radio-group>
\ No newline at end of file
index 5be2a14..19db82c 100644 (file)
 */-->
 
 
-<button disabled style="opacity: 0.5;" (click) ="changeView()" class="toggle-view-btn">{{viewText}}</button>
+<button (click) ="changeView()" class="toggle-view-btn">{{viewText}}</button>
 <br><br>
-<div *ngIf="designerMode">
+<!-- <div *ngIf="designerMode"> -->
+<div [hidden] = "!designerMode">
    <mat-card class="metadata-card">
         <mat-card-header>
             <mat-card-title>Resource Metadata</mat-card-title>
@@ -45,7 +46,8 @@
     </mat-card>
 </div>
 
-<div *ngIf="editorMode">
+<!-- <div *ngIf="editorMode"> -->
+<div [hidden] = "!editorMode">
        <json-editor  class="jsoneditor" *ngIf="editorMode" [options]="options" [data]="resources" on-change="onChange($event)"></json-editor>
 </div>
  
index e4c545e..a22dd43 100644 (file)
@@ -24,7 +24,7 @@ limitations under the License.
     <parent>
         <groupId>org.onap.ccsdk.parent</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.3.1-SNAPSHOT</version>
         <relativePath/>
     </parent>
 
index 627a34e..8abadb1 100644 (file)
@@ -86,5 +86,4 @@
         "@types/node": "^10.11.2",
         "@types/request": "^2.48.1"
     }
-
-}
\ No newline at end of file
+}
index 8d758c7..d0fc421 100644 (file)
@@ -80,8 +80,8 @@ limitations under the License.
                 <version>1.3</version>
                 <configuration>
                     <nodeVersion>v8.12.0</nodeVersion>
+                    <npmVersion>6.4.1</npmVersion>
                     <nodeDownloadRoot>https://nodejs.org/dist/</nodeDownloadRoot>
-                    <npmDownloadRoot>https://nodejs.org/dist/npm/</npmDownloadRoot>
                     <installDirectory>./</installDirectory>
                 </configuration>
                 <executions>
index f161e29..ad2057f 100644 (file)
@@ -1,4 +1,5 @@
 #  Copyright (c) 2019 Bell Canada.
+#  Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
 #
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
@@ -18,11 +19,11 @@ class ResolutionHelper:
     self.component_function = component_function
 
   def resolve_and_generate_message_from_template_prefix(self, artifact_prefix):
-    return self.component_function.resolveAndGenerateMessage(artifact_prefix)
+    return self.component_function.contentFromResolvedArtifact(artifact_prefix)
 
   def resolve_and_generate_message(self, artifact_mapping, artifact_template):
     return self.component_function.resolveAndGenerateMessage(artifact_mapping,
                                                              artifact_template)
 
   def retrieve_resolved_template_from_database(self, key, artifact_template):
-    return self.component_function.resolveFromDatabase(key, artifact_template)
+    return self.component_function.storedContentFromResolvedArtifact(key, artifact_template)
diff --git a/docs/bluePrintsProcessorMS.rst b/docs/bluePrintsProcessorMS.rst
deleted file mode 100644 (file)
index 3f30813..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-.. This work is licensed under a Creative Commons Attribution 4.0 International License.
-.. http://creativecommons.
-.. Copyright (C) 2019 IBM.
-
-Blueprints Processor
-====================
-
-.. toctree::
-   :maxdepth: 1
-   :titlesonly:
-   
-Micro service to Manage Controller Blueprint Models, such as Resource Dictionary, Service Models, Velocity Templates etc,  which will serve service for Controller Design Studio and Controller runtimes.
-
-This microservice is used to deploy Controller Blueprint Archive file in Run time database. This also helps to test the Valid Blueprint.
-
-Architecture:
--------------
-
-|image0|
-
-.. |image0| image:: images/blueprintprocessor.jpg
-   :height: 600px
-   :width: 800px
-   
-Running Blueprints Processor Microservice Locally:
---------------------------------------------------
-
-The purpose of this page is to show how to run the Blueprints Processor microservice locally, using the docker-compose.yaml file provided in the project.
-
-Check out the CDS' code:
-
-Check out the latest code from Gerrit: https://gerrit.onap.org/r/#/admin/projects/ccsdk/cds
-
-Build CDS locally:
-In the checked out directory, type
-
-    mvn clean install -DskipTests=true -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dadditionalparam=-Xdoclint:none
-       
-Create the needed Docker images:
-
-The Blueprints Processor microservice project has a module, called distribution, that provides a docker-compose.yaml file that can be used to spin up Docker containers to run this microservice.
-
-The first step is to create any custom image needed, by building the distribution module.  From the CDS home directory (where the code was checked out), navigate to the module:
-
-    cd ms/blueprintsprocessor/distribution/
-Build it using the Maven profile called Docker:
-
-    mvn clean install -Pdocker
-       
-Start Docker containers using docker-composer:
-----------------------------------------------
-
-Navigate to the docker-compose file in the distribution module:
-
-    cd src/main/dc/
-       
-From there, start the containers:
-
-    docker-compose up -d
-This will spin the Docker containers declared inside the docker-compose.yaml file in the background.
-
-
-To verify the logs generated by docker-composer, type:
-
-    docker-compose logs -f
-       
-       
-Testing the environment:
-------------------------
-
-Point your browser to http://localhost:8000/api/v1/execution-service/ping (please note that the port is 8000, not 8080)
-
-To authenticate, use ccsdkapps / ccsdkapps as login / password.
\ No newline at end of file
diff --git a/docs/controllerBlueprintStudioProcessorMS.rst b/docs/controllerBlueprintStudioProcessorMS.rst
deleted file mode 100644 (file)
index 6f3152d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-.. This work is licensed under a Creative Commons Attribution 4.0 International License.
-.. http://creativecommons.
-.. Copyright (C) 2019 IBM.
-
-Controller Blueprints Studio Processor
-======================================
-
-The Controller Blueprint Archive is the overall service design, fully model-driven, intent based package needed for SELF SERVICE provisioning and configuration management automation.
-
-The CBA is .zip file which is saved in Controller Blueprint Database.
-
-Dynamic API:
-------------
-
-The nature of the API request and response is meant to be model driven and dynamic. They both share the same definition.
-
-The actionName, under the actionIdentifiers refers to the name of a Workflow (see workflow)
-
-The content of the payload is what is fully dynamic / model driven.
-
-The first top level element will always be either $actionName-request for a request or $actionName-response for a response.
-
-Then the content within this element is fully based on the workflow input and output.
-
-
-Enrichment:
------------
-
-Helps to generate complete valid CBA file.
-
-  
-   
\ No newline at end of file
index 88122b4..0d87158 100644 (file)
@@ -61,10 +61,10 @@ Also please click below for resource source available details
 .. _Resource: https://wiki.onap.org/display/DW/Modeling+Concepts#ModelingConcepts-NodeResourceSource
 
 
-.. |image0| image:: media/image0.jpg
+.. |image0| image:: media/mandatory.jpg
    :width: 7.88889in 
    :height: 4.43750in
    
-.. |image1| image:: media/image1.jpg
+.. |image1| image:: media/optional.jpg
    :width: 7.88889in 
    :height: 4.43750in
\ No newline at end of file
index 1bc0de4..1a69fd6 100644 (file)
@@ -11,12 +11,10 @@ Expects the value to be provided as input to the request.
 
 source-input:
 
-{
   "description": "This is Input Resource Source Node Type",
   "version": "1.0.0",
   "properties": {},
   "derived_from": "tosca.nodes.ResourceSource"
-}
 
 
 Default:
@@ -25,12 +23,11 @@ Expects the value to be defaulted in the model itself.
 
 source-default:
 
-{
   "description": "This is Default Resource Source Node Type",
   "version": "1.0.0",
   "properties": {},
   "derived_from": "tosca.nodes.ResourceSource"
-}
+
 
 
 sql:
@@ -42,7 +39,7 @@ CDS is currently deployed along the side of SDNC, hence the primary database con
 
 |image0|
 
-.. |image0| image:: sqltable.jpg
+.. |image0| image:: media/sqltable.jpg
    :width: 7.88889in 
    :height: 4.43750in
 
@@ -68,7 +65,7 @@ CDS is currently deployed along the side of SDNC, hence the default rest connect
 
 |image1|
 
-.. |image1| image:: resttable.jpg
+.. |image1| image:: media/resttable.jpg
    :width: 7.88889in 
    :height: 4.43750in
 
@@ -99,7 +96,7 @@ Expects a script to be provided.
 
 |image2|
 
-.. |image2| image:: capabilitytable.jpg
+.. |image2| image:: media/capabilitytable.jpg
    :width: 7.88889in 
    :height: 4.43750in
    
diff --git a/docs/microservices/enrichment.rst b/docs/microservices/enrichment.rst
new file mode 100644 (file)
index 0000000..55984d7
--- /dev/null
@@ -0,0 +1,36 @@
+.. This work is licensed under a Creative Commons Attribution 4.0
+.. International License. http://creativecommons.org/licenses/by/4.0
+.. Copyright (C) 2019 IBM.
+
+
+Enrichment
+==========
+.. toctree::
+   :maxdepth: 1
+
+Once the base CBA zip file is done, the enrichment process will complete the design by providing all the definitions required for the self-service provisioning.
+
+The following shows 2 ways to run CBA enrichment
+
+*REST API request
+
+|image0|
+
+*CDS UI
+
+|image1|
+
+
+|image2|
+
+.. |image0| image:: media/Enrichment-REST.png
+   :width: 7.88889in
+   :height: 4.43750in
+   
+.. |image1| image:: media/Enrichment-UI1.png
+   :width: 7.88889in
+   :height: 4.43750in   
+.. |image2| image:: media/Enrichment-UI2.png
+   :width: 7.88889in
+   :height: 4.43750in 
\ No newline at end of file
diff --git a/docs/microservices/media/Enrichment-REST.png b/docs/microservices/media/Enrichment-REST.png
new file mode 100644 (file)
index 0000000..005f796
Binary files /dev/null and b/docs/microservices/media/Enrichment-REST.png differ
diff --git a/docs/microservices/media/Enrichment-UI1.png b/docs/microservices/media/Enrichment-UI1.png
new file mode 100644 (file)
index 0000000..62b870c
Binary files /dev/null and b/docs/microservices/media/Enrichment-UI1.png differ
diff --git a/docs/microservices/media/Enrichment-UI2.png b/docs/microservices/media/Enrichment-UI2.png
new file mode 100644 (file)
index 0000000..4449705
Binary files /dev/null and b/docs/microservices/media/Enrichment-UI2.png differ
index a955251..e412993 100755 (executable)
@@ -17,8 +17,7 @@
   ~  See the License for the specific language governing permissions and
   ~  limitations under the License.
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
index bac211a..510621b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2019 IBM.
+ *  Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -50,4 +51,8 @@ fun AbstractComponentFunction.netconfDeviceInfo(requirementName: String): Device
 
 private fun AbstractComponentFunction.netconfDeviceInfo(capabilityProperty: MutableMap<String, JsonNode>): DeviceInfo {
     return JacksonUtils.getInstanceFromMap(capabilityProperty, DeviceInfo::class.java)
-}
\ No newline at end of file
+}
+
+/**
+ * Blocking Methods called from Jython Scripts
+ */
\ No newline at end of file
index fa5d882..0f35e63 100644 (file)
@@ -44,6 +44,7 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
         const val INPUT_ARGUMENT_PROPERTIES = "argument-properties"
         const val INPUT_COMMAND = "command"
         const val INPUT_PACKAGES = "packages"
+        const val DEFAULT_SELECTOR = "remote-python"
 
         const val ATTRIBUTE_PREPARE_ENV_LOG = "prepare-environment-logs"
         const val ATTRIBUTE_EXEC_CMD_LOG = "execute-command-logs"
@@ -58,13 +59,13 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
         val blueprintVersion = bluePrintContext.version()
 
         val operationAssignment: OperationAssignment = bluePrintContext
-                .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
+            .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
 
         val artifactName: String = operationAssignment.implementation?.primary
-                ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
+            ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
 
         val artifactDefinition =
-                bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
+            bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
 
         checkNotBlank(artifactDefinition.file) { "couldn't get python script path($artifactName)" }
 
@@ -90,14 +91,20 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
 
         try {
             // Open GRPC Connection
-            remoteScriptExecutionService.init(endPointSelector.asText())
+            if (DEFAULT_SELECTOR == endPointSelector.asText()) {
+                remoteScriptExecutionService.init(endPointSelector.asText())
+            } else {
+                // Get endpoint from DSL
+                val endPointSelectorJson = bluePrintRuntimeService.resolveDSLExpression(endPointSelector.asText())
+                remoteScriptExecutionService.init(endPointSelectorJson)
+            }
 
             // If packages are defined, then install in remote server
             if (packages != null) {
                 val prepareEnvInput = PrepareRemoteEnvInput(requestId = processId,
-                        remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName,
-                                blueprintVersion = blueprintVersion),
-                        packages = packages
+                    remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName,
+                        blueprintVersion = blueprintVersion),
+                    packages = packages
                 )
                 val prepareEnvOutput = remoteScriptExecutionService.prepareEnv(prepareEnvInput)
                 log.info("$ATTRIBUTE_PREPARE_ENV_LOG - ${prepareEnvOutput.response}")
@@ -111,10 +118,10 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
             val properties = dynamicProperties?.returnNullIfMissing()?.rootFieldsToMap() ?: hashMapOf()
 
             val remoteExecutionInput = RemoteScriptExecutionInput(
-                    requestId = processId,
-                    remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
-                    command = scriptCommand,
-                    properties = properties)
+                requestId = processId,
+                remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
+                command = scriptCommand,
+                properties = properties)
             val remoteExecutionOutput = remoteScriptExecutionService.executeCommand(remoteExecutionInput)
             log.info("$ATTRIBUTE_EXEC_CMD_LOG  - ${remoteExecutionOutput.response}")
             setAttribute(ATTRIBUTE_EXEC_CMD_LOG, JacksonUtils.jsonNodeFromObject(remoteExecutionOutput.response))
@@ -131,7 +138,7 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
 
     override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
         bluePrintRuntimeService.getBluePrintError()
-                .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
+            .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}")
     }
 
     private fun formatNestedJsonNode(node: JsonNode): String {
index 0e97267..938affc 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
 
+import com.fasterxml.jackson.databind.JsonNode
 import kotlinx.coroutines.async
 import kotlinx.coroutines.awaitAll
 import kotlinx.coroutines.coroutineScope
@@ -25,10 +26,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.R
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.TemplateResolutionService
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
-import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.*
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintTemplateService
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -47,7 +45,7 @@ interface ResourceResolutionService {
                                     resolutionKey: String): String
 
     suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
-                                 artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
+                                 artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, JsonNode>
 
     suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
                                  artifactPrefix: String, properties: Map<String, Any>): String
@@ -85,17 +83,19 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
 
     override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
                                           artifactNames: List<String>,
-                                          properties: Map<String, Any>): MutableMap<String, String> {
+                                          properties: Map<String, Any>): MutableMap<String, JsonNode> {
 
 
         val resourceAssignmentRuntimeService =
             ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactNames.toString())
 
-        val resolvedParams: MutableMap<String, String> = hashMapOf()
+        val resolvedParams: MutableMap<String, JsonNode> = hashMapOf()
         artifactNames.forEach { artifactName ->
             val resolvedContent = resolveResources(resourceAssignmentRuntimeService, nodeTemplateName,
                 artifactName, properties)
-            resolvedParams[artifactName] = resolvedContent
+
+            resolvedParams[artifactName] = resolvedContent.asJsonType()
+
         }
         return resolvedParams
     }
index d423dfd..65d1474 100644 (file)
   ~  See the License for the specific language governing permissions and
   ~  limitations under the License.
   -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
         <artifactId>commons</artifactId>
         <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
@@ -47,4 +44,4 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index 6949c4f..1ba0403 100644 (file)
   ~  See the License for the specific language governing permissions and
   ~  limitations under the License.
   -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
         <artifactId>commons</artifactId>
         <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
@@ -43,4 +40,4 @@
             <artifactId>sshd-core</artifactId>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index 056f7e9..b5dac5a 100644 (file)
@@ -86,7 +86,7 @@ fun BluePrintTypes.componentScriptExecutor(): NodeType {
                 property(ComponentScriptExecutor.SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING, true,
                         "Script Type") {
                     defaultValue(BluePrintConstants.SCRIPT_INTERNAL)
-                    constrains {
+                    constrain {
                         validValues(listOf(BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(),
                                 BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive(),
                                 BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive()))
index 3af57a2..d4195ae 100644 (file)
@@ -22,6 +22,7 @@ import com.google.protobuf.Timestamp
 import com.google.protobuf.util.JsonFormat
 import io.grpc.ManagedChannel
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
+import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcClientService
 import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.BluePrintGrpcLibPropertyService
 import org.onap.ccsdk.cds.controllerblueprints.command.api.*
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -31,9 +32,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
 import org.springframework.context.annotation.Scope
 import org.springframework.stereotype.Service
 
-
 interface RemoteScriptExecutionService {
-    suspend fun init(selector: String)
+    suspend fun init(selector: Any)
     suspend fun prepareEnv(prepareEnvInput: PrepareRemoteEnvInput): RemoteScriptExecutionOutput
     suspend fun executeCommand(remoteExecutionInput: RemoteScriptExecutionInput): RemoteScriptExecutionOutput
     suspend fun close()
@@ -51,9 +51,14 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi
     private var channel: ManagedChannel? = null
     private lateinit var commandExecutorServiceGrpc: CommandExecutorServiceGrpc.CommandExecutorServiceBlockingStub
 
-    override suspend fun init(selector: String) {
+    override suspend fun init(selector: Any) {
         // Get the GRPC Client Service based on selector
-        val grpcClientService = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector)
+        val grpcClientService: BluePrintGrpcClientService
+        if (selector is JsonNode) {
+            grpcClientService = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector)
+        } else {
+            grpcClientService = bluePrintGrpcLibPropertyService.blueprintGrpcClientService(selector.toString())
+        }
         // Get the GRPC Channel
         channel = grpcClientService.channel()
         // Create Non Blocking Stub
index dc689ec..4d05550 100755 (executable)
@@ -14,8 +14,7 @@
   ~  See the License for the specific language governing permissions and
   ~  limitations under the License.
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onap.ccsdk.cds</groupId>
index d0710b2..f18821e 100644 (file)
@@ -15,8 +15,7 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
index 4832970..a5b18a1 100644 (file)
@@ -64,8 +64,33 @@ fun Double.asJsonPrimitive(): DoubleNode {
     return DoubleNode.valueOf(this)
 }
 
+/**
+ * Utility to convert Primitive object to Json Type Primitive.
+ */
+fun <T : Any?> T.asJsonPrimitive(): JsonNode {
+    return if (this == null || this is MissingNode || this is NullNode) {
+        NullNode.instance
+    } else {
+        when (this) {
+            is String ->
+                this.asJsonPrimitive()
+            is Boolean ->
+                this.asJsonPrimitive()
+            is Int ->
+                this.asJsonPrimitive()
+            is Double ->
+                this.asJsonPrimitive()
+            else ->
+                throw BluePrintException("$this type is not supported")
+        }
+    }
+}
+
+/**
+ * Utility to convert Complex or Primitive object to Json Type.
+ */
 fun <T : Any?> T.asJsonType(): JsonNode {
-    return if (this == null) {
+    return if (this == null || this is MissingNode || this is NullNode) {
         NullNode.instance
     } else {
         when (this) {
@@ -131,15 +156,11 @@ fun JsonNode.returnNullIfMissing(): JsonNode? {
 }
 
 fun <T : JsonNode> T?.isNull(): Boolean {
-    return if (this == null || this is NullNode || this is MissingNode) {
-        true
-    } else false
+    return this == null || this is NullNode || this is MissingNode
 }
 
 fun <T : JsonNode> T?.isNotNull(): Boolean {
-    return if (this == null || this is NullNode || this is MissingNode) {
-        false
-    } else true
+    return !(this == null || this is NullNode || this is MissingNode)
 }
 
 /**
@@ -232,4 +253,8 @@ fun nullToEmpty(value: String?): String {
     return if (isNotEmpty(value)) value!! else ""
 }
 
+inline fun <reified T : JsonNode> T.isComplexType(): Boolean {
+    return this is ObjectNode || this is ArrayNode
+}
+
 
index 15b3e22..d301340 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,7 +67,8 @@ data class OperationOutputExpression(
         val modelableEntityName: String = "SELF",
         val interfaceName: String,
         val operationName: String,
-        val propertyName: String
+        val propertyName: String,
+        var subPropertyName: String? = null
 )
 
 data class DSLExpression(
index 9e934c7..68e5b0a 100644 (file)
@@ -63,26 +63,24 @@ class Credential {
 A constraint clause defines an operation along with one or more compatible values that can be used to define a constraint on a property or parameter’s allowed values when it is defined in a TOSCA Service Template or one of its entities.
  */
 class ConstraintClause {
-    @get:JsonProperty("equal")
     var equal: JsonNode? = null
     @get:JsonProperty("greater_than")
-    var greaterThan: Any? = null
+    var greaterThan: JsonNode? = null
     @get:JsonProperty("greater_or_equal")
-    var greaterOrEqual: Any? = null
+    var greaterOrEqual: JsonNode? = null
     @get:JsonProperty("less_than")
-    var lessThan: Any? = null
+    var lessThan: JsonNode? = null
     @get:JsonProperty("less_or_equal")
-    var lessOrEqual: Any? = null
+    var lessOrEqual: JsonNode? = null
     @get:JsonProperty("in_range")
-    var inRange: Any? = null
+    var inRange: MutableList<JsonNode>? = null
     @get:JsonProperty("valid_values")
     var validValues: MutableList<JsonNode>? = null
-    @get:JsonProperty("length")
-    var length: Any? = null
+    var length: JsonNode? = null
     @get:JsonProperty("min_length")
-    var minLength: Any? = null
+    var minLength: JsonNode? = null
     @get:JsonProperty("max_length")
-    var maxLength: Any? = null
+    var maxLength: JsonNode? = null
     var pattern: String? = null
     var schema: String? = null
 }
@@ -164,6 +162,9 @@ class PropertyDefinition {
     var constraints: MutableList<ConstraintClause>? = null
     @get:JsonProperty("entry_schema")
     var entrySchema: EntrySchema? = null
+    @get:JsonProperty("external-schema")
+    var externalSchema: String? = null
+    var metadata: MutableMap<String, String>? = null
     // Mainly used in Workflow Outputs
     @get:ApiModelProperty(notes = "Property Value, It may be Expression or Json type values")
     var value: JsonNode? = null
@@ -398,7 +399,7 @@ A Relationship Type is a reusable entity that defines the type of one or more re
 class RelationshipType : EntityType() {
     var interfaces: MutableMap<String, InterfaceDefinition>? = null
     @get:JsonProperty("valid_target_types")
-    var validTargetTypes: ArrayList<String>? = null
+    var validTargetTypes: MutableList<String>? = null
 }
 
 /*
index f19ae8e..eec59d1 100644 (file)
@@ -76,11 +76,18 @@ class NodeTemplateBuilder(private val id: String,
                           private val type: String,
                           private val description: String? = "") {
     private var nodeTemplate: NodeTemplate = NodeTemplate()
+    private var properties: MutableMap<String, JsonNode>? = null
     private var interfaces: MutableMap<String, InterfaceAssignment>? = null
     private var artifacts: MutableMap<String, ArtifactDefinition>? = null
     private var capabilities: MutableMap<String, CapabilityAssignment>? = null
     private var requirements: MutableMap<String, RequirementAssignment>? = null
 
+    fun properties(block: PropertiesAssignmentBuilder.() -> Unit) {
+        if (properties == null)
+            properties = hashMapOf()
+        properties = PropertiesAssignmentBuilder().apply(block).build()
+    }
+
     fun operation(interfaceName: String, description: String? = "",
                   block: OperationAssignmentBuilder.() -> Unit) {
         if (interfaces == null)
@@ -122,6 +129,7 @@ class NodeTemplateBuilder(private val id: String,
         nodeTemplate.id = id
         nodeTemplate.type = type
         nodeTemplate.description = description
+        nodeTemplate.properties = properties
         nodeTemplate.interfaces = interfaces
         nodeTemplate.artifacts = artifacts
         nodeTemplate.capabilities = capabilities
@@ -133,12 +141,27 @@ class NodeTemplateBuilder(private val id: String,
 class ArtifactDefinitionBuilder(private val id: String, private val type: String, private val file: String) {
 
     private var artifactDefinition: ArtifactDefinition = ArtifactDefinition()
-    // TODO()
+    private var properties: MutableMap<String, JsonNode>? = null
+
+    fun repository(repository: String) {
+        artifactDefinition.repository = repository
+    }
+
+    fun deployPath(deployPath: String) {
+        artifactDefinition.deployPath = deployPath
+    }
+
+    fun properties(block: PropertiesAssignmentBuilder.() -> Unit) {
+        if (properties == null)
+            properties = hashMapOf()
+        properties = PropertiesAssignmentBuilder().apply(block).build()
+    }
 
     fun build(): ArtifactDefinition {
         artifactDefinition.id = id
         artifactDefinition.type = type
         artifactDefinition.file = file
+        artifactDefinition.properties = properties
         return artifactDefinition
     }
 }
index 0f01194..8afe695 100644 (file)
@@ -17,8 +17,8 @@
 package org.onap.ccsdk.cds.controllerblueprints.core.dsl
 
 import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
+import com.fasterxml.jackson.databind.node.ArrayNode
+import org.onap.ccsdk.cds.controllerblueprints.core.*
 import org.onap.ccsdk.cds.controllerblueprints.core.data.*
 
 
@@ -162,7 +162,16 @@ class ArtifactTypeBuilder(id: String, version: String, derivedFrom: String,
 class PolicyTypeBuilder(id: String, version: String, derivedFrom: String,
                         description: String?) : EntityTypeBuilder(id, version, derivedFrom, description) {
     private var policyType = PolicyType()
-    // TODO()
+
+    fun targets(targetsStr: String) {
+        val arrayNode = targetsStr.jsonAsJsonType() as ArrayNode
+        targets(arrayNode.asListOfString())
+    }
+
+    fun targets(target: List<String>) {
+        policyType.targets = target.toMutableList()
+    }
+
     fun build(): PolicyType {
         buildEntityType(policyType)
         return policyType
@@ -174,7 +183,16 @@ class RelationshipTypeBuilder(private val id: String, private val version: Strin
     : EntityTypeBuilder(id, version, derivedFrom, description) {
 
     private var relationshipType = RelationshipType()
-    // TODO()
+
+    fun validTargetTypes(validTargetTypesStr: String) {
+        val arrayNode = validTargetTypesStr.jsonAsJsonType() as ArrayNode
+        validTargetTypes(arrayNode.asListOfString())
+    }
+
+    fun validTargetTypes(validTargetTypes: List<String>) {
+        relationshipType.validTargetTypes = validTargetTypes.toMutableList()
+    }
+
     fun build(): RelationshipType {
         buildEntityType(relationshipType)
         relationshipType.id = id
@@ -187,7 +205,15 @@ class RelationshipTypeBuilder(private val id: String, private val version: Strin
 class DataTypeBuilder(id: String, version: String, derivedFrom: String,
                       description: String?) : EntityTypeBuilder(id, version, derivedFrom, description) {
     private var dataType = DataType()
-    // TODO()
+
+    fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+        if (dataType.constraints == null) {
+            dataType.constraints = mutableListOf()
+        }
+        val constraintClause = ConstraintClauseBuilder().apply(block).build()
+        dataType.constraints!!.add(constraintClause)
+    }
+
     fun build(): DataType {
         buildEntityType(dataType)
         return dataType
@@ -264,29 +290,6 @@ class OperationDefinitionBuilder(private val id: String,
     }
 }
 
-class AttributesDefinitionBuilder {
-    private val attributes: MutableMap<String, AttributeDefinition> = hashMapOf()
-
-    fun attribute(id: String, attribute: AttributeDefinition) {
-        attributes[id] = attribute
-    }
-
-    fun attribute(id: String, type: String?, required: Boolean?, description: String?) {
-        val attribute = AttributeDefinitionBuilder(id, type, required, description).build()
-        attributes[id] = attribute
-    }
-
-    fun attribute(id: String, type: String?, required: Boolean?, description: String?,
-                 block: AttributeDefinitionBuilder.() -> Unit) {
-        val attribute = AttributeDefinitionBuilder(id, type, required, description).apply(block).build()
-        attributes[id] = attribute
-    }
-
-    fun build(): MutableMap<String, AttributeDefinition> {
-        return attributes
-    }
-}
-
 class AttributeDefinitionBuilder(private val id: String,
                                  private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
                                  private val required: Boolean? = false,
@@ -302,7 +305,17 @@ class AttributeDefinitionBuilder(private val id: String,
         attributeDefinition.entrySchema = EntrySchemaBuilder(entrySchemaType).apply(block).build()
     }
 
-    // TODO("Constrains")
+    fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+        if (attributeDefinition.constraints == null) {
+            attributeDefinition.constraints = mutableListOf()
+        }
+        val constraintClause = ConstraintClauseBuilder().apply(block).build()
+        attributeDefinition.constraints!!.add(constraintClause)
+    }
+
+    fun defaultValue(defaultValue: Any) {
+        defaultValue(defaultValue.asJsonType())
+    }
 
     fun defaultValue(defaultValue: JsonNode) {
         attributeDefinition.defaultValue = defaultValue
@@ -355,8 +368,12 @@ class PropertyDefinitionBuilder(private val id: String,
         propertyDefinition.entrySchema = EntrySchemaBuilder(entrySchemaType).apply(block).build()
     }
 
-    fun constrains(block: ConstraintClauseBuilder.() -> Unit) {
-        propertyDefinition.constraints = ConstraintClauseBuilder().apply(block).build()
+    fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+        if (propertyDefinition.constraints == null) {
+            propertyDefinition.constraints = mutableListOf()
+        }
+        val constraintClause = ConstraintClauseBuilder().apply(block).build()
+        propertyDefinition.constraints!!.add(constraintClause)
     }
 
     fun defaultValue(defaultValue: Any) {
@@ -380,13 +397,11 @@ class PropertyDefinitionBuilder(private val id: String,
     }
 }
 
-class ConstraintClauseBuilder {
-    private val constraints: MutableList<ConstraintClause> = mutableListOf()
-    //TODO("Implementation")
+class ConstraintsClauseBuilder {
+    val constraints: MutableList<ConstraintClause> = mutableListOf()
 
-    fun validValues(values: List<JsonNode>) {
-        val constraintClause = ConstraintClause()
-        constraintClause.validValues = values.toMutableList()
+    fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+        val constraintClause = ConstraintClauseBuilder().apply(block).build()
         constraints.add(constraintClause)
     }
 
@@ -395,10 +410,82 @@ class ConstraintClauseBuilder {
     }
 }
 
+class ConstraintClauseBuilder {
+    private val constraintClause = ConstraintClause()
+
+    fun equal(equal: Any) = equal(equal.asJsonType())
+
+    fun equal(equal: JsonNode) {
+        constraintClause.equal = equal
+    }
+
+    fun greaterOrEqual(greaterOrEqual: Any) {
+        constraintClause.greaterOrEqual = greaterOrEqual.asJsonPrimitive()
+    }
+
+    fun greaterThan(greaterThan: Any) {
+        constraintClause.greaterThan = greaterThan.asJsonPrimitive()
+    }
+
+    fun lessOrEqual(lessOrEqual: Any) {
+        constraintClause.lessOrEqual = lessOrEqual.asJsonPrimitive()
+    }
+
+    fun lessThan(lessThan: Any) {
+        constraintClause.lessThan = lessThan.asJsonPrimitive()
+    }
+
+    fun inRange(inRangeStr: String) = inRange(inRangeStr.jsonAsJsonType() as ArrayNode)
+
+    fun inRange(inRangeNode: ArrayNode) {
+        constraintClause.inRange = inRangeNode.toMutableList()
+    }
+
+    fun validValues(validValuesStr: String) = validValues(validValuesStr.jsonAsJsonType() as ArrayNode)
+
+    fun validValues(validValuesNode: ArrayNode) = validValues(validValuesNode.toMutableList())
+
+    fun validValues(validValues: List<JsonNode>) {
+        constraintClause.validValues = validValues.toMutableList()
+    }
+
+    fun length(length: Any) {
+        constraintClause.length = length.asJsonPrimitive()
+    }
+
+    fun minLength(minLength: Any) {
+        constraintClause.minLength = minLength.asJsonPrimitive()
+    }
+
+    fun maxLength(maxLength: Any) {
+        constraintClause.maxLength = maxLength.asJsonPrimitive()
+    }
+
+    fun pattern(pattern: String) {
+        constraintClause.pattern = pattern
+    }
+
+    fun schema(schema: String) {
+        constraintClause.schema = schema
+    }
+
+    fun build(): ConstraintClause {
+        return constraintClause
+    }
+}
+
 
 class EntrySchemaBuilder(private val type: String) {
     private var entrySchema: EntrySchema = EntrySchema()
 
+    fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
+        if (entrySchema.constraints == null) {
+            entrySchema.constraints = mutableListOf()
+        }
+        val constraintClause = ConstraintClauseBuilder().apply(block).build()
+        entrySchema.constraints!!.add(constraintClause)
+    }
+
     fun build(): EntrySchema {
         entrySchema.type = type
         return entrySchema
index 32cb6ac..fbf9116 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -170,10 +170,16 @@ object BluePrintExpressionService {
             throw BluePrintException(String.format("missing operation output expression, " +
                     "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}", jsonNode))
         }
+
+        var subPropertyName: String? = null
+        if (arrayNode.size() == 5)
+            subPropertyName = arrayNode[4].asText()
+
         return OperationOutputExpression(modelableEntityName = arrayNode[0].asText(),
                 interfaceName = arrayNode[1].asText(),
                 operationName = arrayNode[2].asText(),
-                propertyName = arrayNode[3].asText()
+                propertyName = arrayNode[3].asText(),
+                subPropertyName = subPropertyName
         )
     }
 
index e6f3f71..ba210df 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018-2019 IBM.
+ * Modifications Copyright © 2018-2019 IBM, Bell Canada.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -213,8 +213,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 
     override fun loadEnvironments(type: String, fileName: String) {
         BluePrintMetadataUtils.environmentFileProperties(fileName).forEach { key, value ->
-            setNodeTemplateAttributeValue(type, key.toString(), value.toString()
-                    .asJsonPrimitive())
+            setNodeTemplateAttributeValue(type, key.toString(), value.asJsonType())
         }
     }
 
index 931d31e..30bd75f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,11 +21,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service
 import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.NullNode
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.*
 import org.onap.ccsdk.cds.controllerblueprints.core.data.*
-import org.onap.ccsdk.cds.controllerblueprints.core.format
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JsonParserUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.ResourceResolverUtils
@@ -143,8 +140,8 @@ If Property Assignment is Expression.
 
         }
         if (subAttributeName != null) {
-            if (valueNode.isObject || valueNode.isArray)
-                valueNode = JsonParserUtils.parse(valueNode, subAttributeName)
+            if (valueNode.isComplexType())
+                valueNode = JsonParserUtils.parse(valueNode.asJsonString(), subAttributeName)
         }
         return valueNode
     }
@@ -176,8 +173,8 @@ If Property Assignment is Expression.
         valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression)
 
         if (subPropertyName != null) {
-            if (valueNode.isObject || valueNode.isArray)
-                valueNode = JsonParserUtils.parse(valueNode, subPropertyName)
+            if (valueNode.isComplexType())
+                valueNode = JsonParserUtils.parse(valueNode.asJsonString(), subPropertyName)
         }
         return valueNode
     }
@@ -190,9 +187,17 @@ If Property Assignment is Expression.
         if (!operationOutputExpression.modelableEntityName.equals("SELF", true)) {
             outputNodeTemplateName = operationOutputExpression.modelableEntityName
         }
-        return bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName,
+
+        var valueNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName,
                 operationOutputExpression.interfaceName, operationOutputExpression.operationName,
                 operationOutputExpression.propertyName)
+
+        val subPropertyName: String? = operationOutputExpression.subPropertyName
+        if (subPropertyName != null) {
+            if (valueNode.isComplexType())
+                valueNode = JsonParserUtils.parse(valueNode.asJsonString(), subPropertyName)
+        }
+        return valueNode
     }
 
     /*
index 342ff76..e5eef5a 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2018 IBM.
+ *  Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -38,7 +39,7 @@ class JsonParserUtils {
         }
 
         fun paths(jsonNode: JsonNode, expression: String): List<String> {
-            return paths(jsonNode.toString(), expression)
+            return paths(jsonNode, expression)
         }
 
         fun parse(jsonContent: String, expression: String): JsonNode {
@@ -54,7 +55,8 @@ class JsonParserUtils {
         }
 
         fun parseNSet(jsonNode: JsonNode, expression: String, valueNode: JsonNode): JsonNode {
-            return parseNSet(jsonNode.toString(), expression, valueNode)
+
+            return parseNSet(jsonNode, expression, valueNode)
         }
     }
 }
\ No newline at end of file
index 020edc7..c0641be 100644 (file)
@@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl
 
 import org.junit.Test
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
 import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
 import kotlin.test.assertNotNull
 
@@ -152,6 +153,41 @@ class BluePrintDSLTest {
         //println(serviceTemplate.asJsonString(true))
     }
 
+    @Test
+    fun testNodeTypePropertyConstrains() {
+        val nodeType = nodeType("data-node", "1.0.0", "tosca.Nodes.root", "") {
+            property("ip-address", "string", true, "") {
+                defaultValue("127.0.0.1")
+                constrain {
+                    validValues(arrayListOf("""127.0.0.1""".asJsonPrimitive()))
+                    length(10)
+                    maxLength(20)
+                    minLength(10)
+                }
+
+            }
+            property("disk-space", "string", true, "") {
+                defaultValue(10)
+                constrain {
+                    validValues("""["200KB", "400KB"]""")
+                    equal("200KB")
+                    inRange("""["100KB", "500KB" ]""")
+                    maxLength("10MB")
+                    minLength("10KB")
+                }
+                constrain {
+                    validValues("""[ 200, 400]""")
+                    greaterOrEqual("10KB")
+                    greaterThan("20KB")
+                    lessOrEqual("200KB")
+                    lessThan("190KB")
+                }
+            }
+        }
+        assertNotNull(nodeType, "failed to get nodeType")
+       // println(nodeType.asJsonString(true))
+    }
+
     @Test
     fun testServiceTemplateWorkflow() {
         val serviceTemplate = serviceTemplate("sample-bp", "1.0.0",
diff --git a/pom.xml b/pom.xml
index 2a227c7..a5a8824 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -15,13 +15,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
     <parent>
         <groupId>org.onap.ccsdk.parent</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.3.0-SNAPSHOT</version>
+        <version>1.3.1-SNAPSHOT</version>
         <relativePath/>
     </parent>