Add directed graph reterive and execution service.
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Tue, 20 Nov 2018 20:55:29 +0000 (15:55 -0500)
committerBrinda Santh Muthuramalingam <bs2796@att.com>
Fri, 30 Nov 2018 20:45:33 +0000 (20:45 +0000)
Change-Id: Ia31af4d14e38e6229166cda0f39fa090764ef1cb
Issue-ID: CCSDK-672
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml [new file with mode: 0644]

index 4764479..f73fb72 100644 (file)
@@ -57,10 +57,15 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
                 ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)")\r
     }\r
 \r
-    fun workflowStepNodeTemplate(workFlowName: String, stepName: String): NodeTemplate {\r
-        val nodeTemplateName = workflowStepByName(workFlowName, stepName).target\r
+    fun workflowStepNodeTemplate(workFlowName: String, stepName: String): String {\r
+        return workflowStepByName(workFlowName, stepName).target\r
                 ?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)")\r
-        return nodeTemplateByName(nodeTemplateName)\r
+    }\r
+\r
+    fun workflowFirstStepNodeTemplate(workFlowName: String): String {\r
+        val firstStepName = workflowByName(workFlowName).steps?.keys?.first()\r
+                ?: throw BluePrintException("could't get first step for workflow($workFlowName)")\r
+        return workflowStepNodeTemplate(workFlowName, firstStepName)\r
     }\r
 \r
     fun workflowStepFirstCallOperation(workFlowName: String, stepName: String): String {\r
@@ -156,6 +161,11 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
                 ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)")\r
     }\r
 \r
+    fun nodeTemplateArtifactForArtifactType(nodeTemplateName: String, artifactType: String): ArtifactDefinition {\r
+        return nodeTemplateArtifacts(nodeTemplateName)?.filter { it.value.type == artifactType }?.map { it.value }?.get(0)\r
+                ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)")\r
+    }\r
+\r
     fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment {\r
         return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first()\r
                 ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment")\r
index 9da5b0e..84ba104 100644 (file)
@@ -48,6 +48,14 @@ interface BluePrintRuntimeService<T> {
 \r
     fun cleanRuntime()\r
 \r
+    fun getAsString(key: String): String?\r
+\r
+    fun getAsBoolean(key: String): Boolean?\r
+\r
+    fun getAsInt(key: String): Int?\r
+\r
+    fun getAsDouble(key: String): Double?\r
+\r
     /*\r
       Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing\r
    */\r
@@ -139,9 +147,25 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
         return get(key)\r
     }\r
 \r
+    override fun getAsString(key: String): String? {\r
+        return get(key).asText()\r
+    }\r
+\r
+    override fun getAsBoolean(key: String): Boolean? {\r
+        return get(key).asBoolean()\r
+    }\r
+\r
+    override fun getAsInt(key: String): Int? {\r
+        return get(key).asInt()\r
+    }\r
+\r
+    override fun getAsDouble(key: String): Double? {\r
+        return get(key).asDouble()\r
+    }\r
+\r
     /*\r
-        Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing\r
-     */\r
+            Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing\r
+         */\r
     override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, JsonNode> {\r
         log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName)\r
         val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()\r
index 269fd0c..9d1172f 100644 (file)
@@ -60,7 +60,7 @@
         "artifacts": {
           "dg-activate-process": {
             "type": "artifact-directed-graph",
-            "file": "Plans/ActivateProcess.bpmn"
+            "file": "Plans/CONFIG_ActivateNetconf_1.0.0.xml"
           }
         }
       },
           }
         },
         "steps": {
-          "call-resource-assignment": {
+          "activate-process": {
             "description": "Netconf Activation Workflow",
-            "target": "resource-assignment",
+            "target": "activate-process",
             "activities": [
               {
                 "call_operation": "ResourceAssignmentComponent.process"
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml
new file mode 100644 (file)
index 0000000..d256bbd
--- /dev/null
@@ -0,0 +1,34 @@
+<!--
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ 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.
+  -->
+
+<service-logic
+        xmlns='http://www.onap.org/sdnc/svclogic'
+        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'>
+    <method rpc='ActivateNetconf' mode='sync'>
+        <block atomic="true">
+            <execute plugin="resource-assignment" method="process">
+                <outcome value='failure'>
+                    <return status="failure">
+                    </return>
+                </outcome>
+                <outcome value='success'>
+                    <return status='success'>
+                    </return>
+                </outcome>
+            </execute>
+        </block>
+    </method>
+</service-logic>
\ No newline at end of file