Resolve Attribute and properties fails with subPropertyName 69/91569/5
authorSteve Siani <alphonse.steve.siani.djissitchi@ibm.com>
Tue, 16 Jul 2019 21:46:53 +0000 (17:46 -0400)
committerSteve Siani <alphonse.steve.siani.djissitchi@ibm.com>
Thu, 18 Jul 2019 16:59:47 +0000 (12:59 -0400)
Issue-ID: CCSDK-1489
Signed-off-by: Steve Siani <alphonse.steve.siani.djissitchi@ibm.com>
Change-Id: If27c0dd301f2c0e63cecc662cd89b1a72d1b21f1

components/scripts/python/ccsdk_netconf/common.py
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ScriptComponentExtensions.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
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/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

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)
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 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 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 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