Controller Blueprints Microservice
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Tue, 4 Sep 2018 20:24:35 +0000 (20:24 +0000)
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Tue, 4 Sep 2018 20:47:03 +0000 (20:47 +0000)
Refactor controller blueprint core and resource dictionary modules to components module.

Change-Id: If5ba5e35e9c95bc19bc78fb10bd62d6551ba7aca
Issue-ID: CCSDK-514
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
119 files changed:
components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json [new file with mode: 0644]
components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json [new file with mode: 0644]
components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn [new file with mode: 0644]
components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py [new file with mode: 0644]
components/core/load/blueprints/baseconfiguration/Scripts/__init__.py [new file with mode: 0644]
components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta [new file with mode: 0644]
components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl [new file with mode: 0644]
components/core/load/blueprints/baseconfiguration/__init__.py [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/Scripts/__init__.py [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl [new file with mode: 0644]
components/core/load/blueprints/simple-baseconfig/__init__.py [new file with mode: 0644]
components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json [new file with mode: 0644]
components/core/load/model_type/artifact_type/artifact-directed-graph.json [new file with mode: 0644]
components/core/load/model_type/artifact_type/artifact-mapping-resource.json [new file with mode: 0644]
components/core/load/model_type/artifact_type/artifact-script-python.json [new file with mode: 0644]
components/core/load/model_type/artifact_type/artifact-template-velocity.json [new file with mode: 0644]
components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json [new file with mode: 0644]
components/core/load/model_type/data_type/datatype-property.json [new file with mode: 0644]
components/core/load/model_type/data_type/datatype-resource-assignment.json [new file with mode: 0644]
components/core/load/model_type/data_type/dt-license-key.json [new file with mode: 0644]
components/core/load/model_type/data_type/dt-v4-aggregate.json [new file with mode: 0644]
components/core/load/model_type/data_type/tosca.datatypes.Credential.json [new file with mode: 0644]
components/core/load/model_type/node_type/artifact-config-template.json [new file with mode: 0644]
components/core/load/model_type/node_type/component-config-generator.json [new file with mode: 0644]
components/core/load/model_type/node_type/component-netconf-executor.json [new file with mode: 0644]
components/core/load/model_type/node_type/component-resource-assignment.json [new file with mode: 0644]
components/core/load/model_type/node_type/dg-activate-netconf.json [new file with mode: 0644]
components/core/load/model_type/node_type/dg-config-generator.json [new file with mode: 0644]
components/core/load/model_type/node_type/dg-resource-assign-activate.json [new file with mode: 0644]
components/core/load/model_type/node_type/dg-resource-assignment.json [new file with mode: 0644]
components/core/load/model_type/node_type/vnf-netconf-device.json [new file with mode: 0644]
components/core/pom.xml [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt [new file with mode: 0644]
components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt [new file with mode: 0644]
components/core/src/test/resources/componentnode/default.json [new file with mode: 0644]
components/core/src/test/resources/data/alltype-data.json [new file with mode: 0644]
components/core/src/test/resources/data/default-context.json [new file with mode: 0644]
components/core/src/test/resources/dictionary/dictionary_schema.json [new file with mode: 0644]
components/core/src/test/resources/properties/convert.json [new file with mode: 0644]
components/core/src/test/resources/properties/default.json [new file with mode: 0644]
components/parent/pom.xml [new file with mode: 0644]
components/pom.xml [new file with mode: 0644]
components/resource-dict/load/model_type/node_type/source-component-java.json [new file with mode: 0644]
components/resource-dict/load/model_type/node_type/source-db.json [new file with mode: 0644]
components/resource-dict/load/model_type/node_type/source-default.json [new file with mode: 0644]
components/resource-dict/load/model_type/node_type/source-input.json [new file with mode: 0644]
components/resource-dict/load/model_type/node_type/source-rest.json [new file with mode: 0644]
components/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json [new file with mode: 0644]
components/resource-dict/load/resource_dictionary/db-source.json [new file with mode: 0644]
components/resource-dict/load/resource_dictionary/default-source.json [new file with mode: 0644]
components/resource-dict/load/resource_dictionary/input-source.json [new file with mode: 0644]
components/resource-dict/load/resource_dictionary/mdsal-source.json [new file with mode: 0644]
components/resource-dict/pom.xml [new file with mode: 0644]
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt [new file with mode: 0644]
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt [new file with mode: 0644]
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt [new file with mode: 0644]
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt [new file with mode: 0644]
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt [new file with mode: 0644]
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt [new file with mode: 0644]
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt [new file with mode: 0644]
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt [new file with mode: 0644]
components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt [new file with mode: 0644]
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java [new file with mode: 0644]
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java [new file with mode: 0644]
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt [new file with mode: 0644]
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java [new file with mode: 0644]
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java [new file with mode: 0644]
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java [new file with mode: 0644]
components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java [new file with mode: 0644]
components/resource-dict/src/test/resources/data/resource-assignment-input.json [new file with mode: 0644]
components/resource-dict/src/test/resources/enrich/simple-enrich.json [new file with mode: 0644]
components/resource-dict/src/test/resources/validation/cyclic.json [new file with mode: 0644]
components/resource-dict/src/test/resources/validation/duplicate.json [new file with mode: 0644]
components/resource-dict/src/test/resources/validation/success.json [new file with mode: 0644]

diff --git a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json
new file mode 100644 (file)
index 0000000..635e177
--- /dev/null
@@ -0,0 +1,411 @@
+{\r
+  "metadata": {\r
+    "template_author": "Brinda Santh Muthuramalingam",\r
+    "author-email": "brindasanth@gmail.com",\r
+    "user-groups" : "ADMIN, OPERATION",\r
+    "template_name": "baseconfiguration",\r
+    "template_version": "1.0.0",\r
+    "template_tags": "brinda, tosca"\r
+  },\r
+  "topology_template": {\r
+    "inputs": {\r
+      "request-id": {\r
+        "required": true,\r
+        "type": "string"\r
+      },\r
+      "action-name": {\r
+        "required": true,\r
+        "type": "string"\r
+      },\r
+      "scope-type": {\r
+        "required": true,\r
+        "type": "string"\r
+      },\r
+      "hostname": {\r
+        "required": true,\r
+        "type": "string"\r
+      }\r
+    },\r
+    "node_templates": {\r
+      "activate-process": {\r
+        "type": "bpmn-activate",\r
+        "properties": {\r
+          "process-name": { "get_input" : "action-name" },\r
+          "version" : { "get_property" : ["SELF", "process-name"] },\r
+          "content": { "get_artifact" : ["SELF", "activate-process"] }\r
+        },\r
+        "artifacts": {\r
+          "activate-process": {\r
+            "type": "artifact-bpmn-camunda",\r
+            "file": "Plans/ActivateProcess.bpmn"\r
+          }\r
+        }\r
+      },\r
+      "resource-assignment": {\r
+        "type": "component-resource-assignment",\r
+        "properties":{\r
+          "request-id": ["1234", "1234"]\r
+        },\r
+        "interfaces": {\r
+          "DefaultComponentNode": {\r
+            "operations": {\r
+              "process": {\r
+                "inputs": {\r
+                  "action-name": { "get_input" : "action-name" },\r
+                  "resource-type": "vnf-type",\r
+                  "request-id": { "get_input" : "request-id" },\r
+                  "resource-id": { "get_input" : "hostname" },\r
+                  "template-content": { "get_artifact" : ["SELF", "baseconfig-template"] },\r
+                  "mapping-content": { "get_artifact" : ["SELF", "baseconfig-mapping"] }\r
+                },\r
+                "outputs": {\r
+                  "resource-assignment-params": "",\r
+                  "status": ""\r
+                }\r
+              }\r
+            }\r
+          }\r
+        },\r
+        "artifacts": {\r
+          "baseconfig-template": {\r
+            "type": "artifact-template-velocity",\r
+            "file": "Templates/baseconfig-template.vtl"\r
+          },\r
+          "baseconfig-mapping": {\r
+            "type": "artifact-mapping-resource",\r
+            "file": "Mappings/baseconfig-mapping.json"\r
+          }\r
+        }\r
+      },\r
+      "resource-assignment-py": {\r
+        "type": "component-resource-assignment",\r
+        "properties":{\r
+          "request-id": ["1234", "1234"]\r
+        },\r
+        "interfaces": {\r
+          "DefaultComponentNode": {\r
+            "operations": {\r
+              "process": {\r
+                "implementation" :{\r
+                  "primary" : "component-script"\r
+                },\r
+                "inputs": {\r
+                  "action-name": { "get_input" : "action-name" }\r
+                },\r
+                "outputs": {\r
+                  "resource-assignment-params": "",\r
+                  "status": ""\r
+                }\r
+              }\r
+            }\r
+          }\r
+        },\r
+        "artifacts": {\r
+          "component-script": {\r
+            "type": "artifact-script-python",\r
+            "file": "Scripts/baseconfig-template.vtl"\r
+          }\r
+        }\r
+      }\r
+    },\r
+    "workflows":{\r
+      "activate-process":{\r
+        "steps" : {\r
+            "call-resource-assignment" : {\r
+              "description" : "Invoke Resource Assignment Component",\r
+              "target" : "resource-assignment",\r
+              "activities" : [\r
+                {\r
+                  "call_operation": "ResourceAssignmentNode.process"\r
+                }\r
+              ],\r
+              "on_success" : [\r
+                "download-baseconfig"\r
+              ]\r
+            },\r
+          "download-baseconfig" : {\r
+            "description" : "Call Download Base Config Component",\r
+            "target" : "activate-netconf",\r
+            "activities" : [\r
+              {\r
+                "call_operation": "NetconfTransactionNode.process"\r
+              }\r
+            ],\r
+            "on_success" : [\r
+              "download-licence"\r
+            ]\r
+          },\r
+          "download-licence" : {\r
+            "description" : "Call Download Licence Component",\r
+            "target" : "activate-netconf",\r
+            "activities" : [\r
+              {\r
+                "call_operation": "NetconfTransactionNode.process"\r
+              }\r
+            ]\r
+          }\r
+        }\r
+      }\r
+    }\r
+  },\r
+  "artifact_types": {\r
+    "artifact-template-velocity": {\r
+      "description": " Velocity Template used for Configuration",\r
+      "version": "1.0.0",\r
+      "file_ext": [\r
+        "vtl"\r
+      ],\r
+      "derived_from": "tosca.artifacts.Implementation"\r
+    },\r
+    "artifact-mapping-resource": {\r
+      "description": " Velocity Template Resource Mapping File used along with Configuration template",\r
+      "version": "1.0.0",\r
+      "file_ext": [\r
+        "json"\r
+      ],\r
+      "derived_from": "tosca.artifacts.Implementation"\r
+    },\r
+    "artifact-script-kotlin": {\r
+      "description": " Kotlin Script Template used for Configuration",\r
+      "version": "1.0.0",\r
+      "file_ext": [\r
+        "kt"\r
+      ],\r
+      "derived_from": "tosca.artifacts.Implementation"\r
+    },\r
+    "artifact-script-python": {\r
+      "description": " Kotlin Script Template used for Configuration",\r
+      "version": "1.0.0",\r
+      "file_ext": [\r
+        "py"\r
+      ],\r
+      "derived_from": "tosca.artifacts.Implementation"\r
+    },\r
+    "artifact-bpmn-camunda": {\r
+      "description": " Camunda BPM File",\r
+      "version": "1.0.0",\r
+      "file_ext": [\r
+        "bpmn"\r
+      ],\r
+      "derived_from": "tosca.artifacts.Implementation"\r
+    },\r
+    "artifact-component-jar": {\r
+      "description": "Component Jar",\r
+      "version": "1.0.0",\r
+      "file_ext": [\r
+        "jar"\r
+      ],\r
+      "derived_from": "tosca.artifacts.Implementation"\r
+    }\r
+  },\r
+  "node_types": {\r
+    "bpmn-activate": {\r
+      "description": "This is BPMN Activate node type",\r
+      "version": "1.0.0",\r
+      "properties": {\r
+        "content": {\r
+          "required": false,\r
+          "type": "string"\r
+        },\r
+        "process-name": {\r
+          "required": false,\r
+          "type": "string"\r
+        },\r
+        "version": {\r
+          "required": false,\r
+          "type": "string",\r
+          "default" : "LATEST"\r
+        }\r
+      },\r
+      "derived_from": "tosca.nodes.Component"\r
+    },\r
+    "tosca.nodes.Component": {\r
+      "description": "This is Resource Assignment Component API",\r
+      "version": "1.0.0",\r
+      "properties": {\r
+        "type": {\r
+          "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+          "required": false,\r
+          "type": "string"\r
+        }\r
+      },\r
+      "interfaces": {\r
+        "DefaultOperation": {\r
+          "operations": {\r
+            "validate": {\r
+              "inputs": {\r
+                "action-name": {\r
+                  "description": "validate for action",\r
+                  "required": false,\r
+                  "type": "string"\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      },\r
+      "artifacts" :{\r
+        "component-jar": {\r
+          "description": "Component Jar",\r
+          "type": "artifact-component-jar",\r
+          "file": "Component/basecomponent.jar"\r
+        }\r
+      },\r
+      "derived_from": "tosca.nodes.Root"\r
+    },\r
+    "tosca.nodes.component.Python": {\r
+      "description": "This is Resource Assignment Python Component API",\r
+      "version": "1.0.0",\r
+      "properties": {\r
+        "type": {\r
+          "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+          "required": false,\r
+          "type": "string"\r
+        }\r
+      },\r
+      "interfaces": {\r
+        "DefaultOperation": {\r
+          "operations": {\r
+            "validate": {\r
+              "inputs": {\r
+                "action-name": {\r
+                  "description": "validate for action",\r
+                  "required": false,\r
+                  "type": "string"\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      },\r
+      "artifacts" :{\r
+        "component-jar": {\r
+          "description": "Component Jar",\r
+          "type": "artifact-component-jar",\r
+          "file": "Component/basecomponent.jar"\r
+        }\r
+      },\r
+      "derived_from": "tosca.nodes.Root"\r
+    },\r
+    "component-resource-assignment": {\r
+      "description": "This is Resource Assignment Component API",\r
+      "version": "1.0.0",\r
+      "properties": {\r
+        "request-id": {\r
+          "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+          "required": true,\r
+          "type": "string"\r
+        }\r
+      },\r
+      "interfaces": {\r
+        "DefaultComponentNode": {\r
+          "operations": {\r
+            "process": {\r
+              "inputs": {\r
+                "action-name": {\r
+                  "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
+                  "required": false,\r
+                  "type": "string"\r
+                },\r
+                "resource-type": {\r
+                  "required": false,\r
+                  "type": "string"\r
+                },\r
+                "request-id": {\r
+                  "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+                  "required": true,\r
+                  "type": "string"\r
+                },\r
+                "resource-id": {\r
+                  "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",\r
+                  "required": true,\r
+                  "type": "string"\r
+                },\r
+                "template-content": {\r
+                  "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",\r
+                  "required": true,\r
+                  "type": "string"\r
+                },\r
+                "mapping-content": {\r
+                  "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",\r
+                  "required": true,\r
+                  "type": "string"\r
+                }\r
+              },\r
+              "outputs": {\r
+                "resource-assignment-params": {\r
+                  "required": true,\r
+                  "type": "string"\r
+                },\r
+                "status": {\r
+                  "required": true,\r
+                  "type": "string"\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      },\r
+      "derived_from": "tosca.nodes.Component"\r
+    },\r
+    "component-resource-assignment-python": {\r
+      "description": "This is Resource Assignment Component API",\r
+      "version": "1.0.0",\r
+      "properties": {\r
+        "request-id": {\r
+          "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+          "required": true,\r
+          "type": "string"\r
+        }\r
+      },\r
+      "interfaces": {\r
+        "DefaultComponentNode": {\r
+          "operations": {\r
+            "process": {\r
+              "inputs": {\r
+                "action-name": {\r
+                  "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
+                  "required": false,\r
+                  "type": "string"\r
+                }\r
+              },\r
+              "outputs": {\r
+                "resource-assignment-params": {\r
+                  "required": true,\r
+                  "type": "string"\r
+                },\r
+                "status": {\r
+                  "required": true,\r
+                  "type": "string"\r
+                }\r
+              }\r
+            }\r
+          }\r
+        }\r
+      },\r
+      "derived_from": "tosca.nodes.component.Python"\r
+    }\r
+  },\r
+  "data_types": {\r
+    "sample-property" : {\r
+      "description": "This is sample data type",\r
+      "version": "1.0.0",\r
+      "properties": {\r
+        "content": {\r
+          "required": false,\r
+          "type": "string"\r
+        },\r
+        "process-name": {\r
+          "required": false,\r
+          "type": "string"\r
+        },\r
+        "version": {\r
+          "required": false,\r
+          "type": "string",\r
+          "default" : "LATEST"\r
+        }\r
+      },\r
+      "derived_from" : "tosca.datatypes.Root"\r
+    }\r
+  }\r
+}
\ No newline at end of file
diff --git a/components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json b/components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json
new file mode 100644 (file)
index 0000000..6abfb51
--- /dev/null
@@ -0,0 +1,3 @@
+{\r
+  "assignments": "Sample Assignments"\r
+}
\ No newline at end of file
diff --git a/components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn b/components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn
new file mode 100644 (file)
index 0000000..5e94c0f
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"\r
+                  xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"\r
+                  xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"\r
+                  xmlns:camunda="http://camunda.org/schema/1.0/bpmn"\r
+                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1"\r
+                  targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.2">\r
+    <bpmn:process id="ActivateProcess" isExecutable="true">\r
+        <bpmn:startEvent id="StartEvent_1">\r
+            <bpmn:outgoing>SequenceFlow_0l0dq58</bpmn:outgoing>\r
+        </bpmn:startEvent>\r
+        <bpmn:endEvent id="EndEvent_1pr0kil">\r
+            <bpmn:incoming>SequenceFlow_1ay0k6p</bpmn:incoming>\r
+        </bpmn:endEvent>\r
+        <bpmn:sequenceFlow id="SequenceFlow_0l0dq58" sourceRef="StartEvent_1" targetRef="activate_device_task"/>\r
+        <bpmn:sequenceFlow id="SequenceFlow_1ay0k6p" sourceRef="activate_device_task" targetRef="EndEvent_1pr0kil"/>\r
+        <bpmn:serviceTask id="activate_device_task" name="Activate Device"\r
+                          camunda:delegateExpression="${componentDelegateService}">\r
+            <bpmn:extensionElements>\r
+                <camunda:inputOutput>\r
+                    <camunda:inputParameter name="selector"><![CDATA[resource-assignment\r
+]]></camunda:inputParameter>\r
+                </camunda:inputOutput>\r
+            </bpmn:extensionElements>\r
+            <bpmn:incoming>SequenceFlow_0l0dq58</bpmn:incoming>\r
+            <bpmn:outgoing>SequenceFlow_1ay0k6p</bpmn:outgoing>\r
+        </bpmn:serviceTask>\r
+    </bpmn:process>\r
+    <bpmndi:BPMNDiagram id="BPMNDiagram_1">\r
+        <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateProcess">\r
+            <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">\r
+                <dc:Bounds x="175" y="143" width="36" height="36"/>\r
+                <bpmndi:BPMNLabel>\r
+                    <dc:Bounds x="148" y="179" width="90" height="20"/>\r
+                </bpmndi:BPMNLabel>\r
+            </bpmndi:BPMNShape>\r
+            <bpmndi:BPMNShape id="EndEvent_1pr0kil_di" bpmnElement="EndEvent_1pr0kil">\r
+                <dc:Bounds x="575" y="114" width="36" height="36"/>\r
+                <bpmndi:BPMNLabel>\r
+                    <dc:Bounds x="593" y="154" width="0" height="12"/>\r
+                </bpmndi:BPMNLabel>\r
+            </bpmndi:BPMNShape>\r
+            <bpmndi:BPMNEdge id="SequenceFlow_0l0dq58_di" bpmnElement="SequenceFlow_0l0dq58">\r
+                <di:waypoint xsi:type="dc:Point" x="211" y="161"/>\r
+                <di:waypoint xsi:type="dc:Point" x="273" y="161"/>\r
+                <di:waypoint xsi:type="dc:Point" x="273" y="149"/>\r
+                <di:waypoint xsi:type="dc:Point" x="334" y="149"/>\r
+                <bpmndi:BPMNLabel>\r
+                    <dc:Bounds x="288" y="149" width="0" height="12"/>\r
+                </bpmndi:BPMNLabel>\r
+            </bpmndi:BPMNEdge>\r
+            <bpmndi:BPMNEdge id="SequenceFlow_1ay0k6p_di" bpmnElement="SequenceFlow_1ay0k6p">\r
+                <di:waypoint xsi:type="dc:Point" x="434" y="149"/>\r
+                <di:waypoint xsi:type="dc:Point" x="505" y="149"/>\r
+                <di:waypoint xsi:type="dc:Point" x="505" y="132"/>\r
+                <di:waypoint xsi:type="dc:Point" x="575" y="132"/>\r
+                <bpmndi:BPMNLabel>\r
+                    <dc:Bounds x="520" y="134.5" width="0" height="12"/>\r
+                </bpmndi:BPMNLabel>\r
+            </bpmndi:BPMNEdge>\r
+            <bpmndi:BPMNShape id="ServiceTask_0e8ek4f_di" bpmnElement="activate_device_task">\r
+                <dc:Bounds x="334" y="109" width="100" height="80"/>\r
+            </bpmndi:BPMNShape>\r
+        </bpmndi:BPMNPlane>\r
+    </bpmndi:BPMNDiagram>\r
+</bpmn:definitions>\r
diff --git a/components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py b/components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py
new file mode 100644 (file)
index 0000000..eb198c7
--- /dev/null
@@ -0,0 +1,8 @@
+from com.brvith.orchestrator.core.interfaces import ComponentNode\r
+\r
+class SamplePythonComponentNode(ComponentNode):\r
+    def prepare(self, context, componentContext):\r
+        return None\r
+\r
+    def prepare(self, context, componentContext):\r
+        return None
\ No newline at end of file
diff --git a/components/core/load/blueprints/baseconfiguration/Scripts/__init__.py b/components/core/load/blueprints/baseconfiguration/Scripts/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta b/components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta
new file mode 100644 (file)
index 0000000..fb38c15
--- /dev/null
@@ -0,0 +1,8 @@
+TOSCA-Meta-File-Version: 1.0.0\r
+CSAR-Version: 1.0\r
+Created-By: Brinda Santh M\r
+Entry-Definitions: Definitions/activation-blueprint.json\r
+Template-Tags: Brinda Santh, activation-blueprint\r
+\r
+Name: Plans/ActivateProcess.bpmn\r
+Content-Type: application/vnd.oasis.bpmn\r
diff --git a/components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl b/components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl
new file mode 100644 (file)
index 0000000..026c591
--- /dev/null
@@ -0,0 +1 @@
+This is Sample Velocity Template
\ No newline at end of file
diff --git a/components/core/load/blueprints/baseconfiguration/__init__.py b/components/core/load/blueprints/baseconfiguration/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json b/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json
new file mode 100644 (file)
index 0000000..6d469ea
--- /dev/null
@@ -0,0 +1,34 @@
+{\r
+  "description": "This is Resource Assignment Component API",\r
+  "version": "1.0.0",\r
+  "properties": {\r
+    "type": {\r
+      "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+      "required": false,\r
+      "type": "string"\r
+    }\r
+  },\r
+  "interfaces": {\r
+    "DefaultOperation": {\r
+      "operations": {\r
+        "validate": {\r
+          "inputs": {\r
+            "action-name": {\r
+              "description": "validate for action",\r
+              "required": false,\r
+              "type": "string"\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  },\r
+  "artifacts" :{\r
+    "component-jar": {\r
+      "description": "Component Jar",\r
+      "type": "artifact-component-jar",\r
+      "file": "Component/basecomponent.jar"\r
+    }\r
+  },\r
+  "derived_from": "tosca.nodes.Root"\r
+}
\ No newline at end of file
diff --git a/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json b/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json
new file mode 100644 (file)
index 0000000..e78f32f
--- /dev/null
@@ -0,0 +1,345 @@
+{\r
+  "metadata": {\r
+    "template_author": "Brinda Santh",\r
+    "template_name": "simple-baseconfig",\r
+    "template_version": "1.0.0",\r
+    "service-type": "Sample Service",\r
+    "release": "1806",\r
+    "vnf-type": "VPE"\r
+  },\r
+  "topology_template": {\r
+    "inputs": {\r
+      "request-id": {\r
+        "required": true,\r
+        "type": "string"\r
+      },\r
+      "service-instance-id": {\r
+        "required": true,\r
+        "type": "string"\r
+      },\r
+      "scope-type": {\r
+        "required": true,\r
+        "type": "string"\r
+      },\r
+      "action-name": {\r
+        "required": true,\r
+        "type": "string"\r
+      },\r
+      "hostname": {\r
+        "required": true,\r
+        "type": "string"\r
+      }\r
+    },\r
+    "node_templates": {\r
+      "vpe-netconf-device": {\r
+        "capabilities": {\r
+          "netconf": {\r
+            "properties": {\r
+              "login-key": "sdnc",\r
+              "login-account": "sndc-local",\r
+              "source": "local",\r
+              "target-ip-address": "{\"get_attribute\":\"lo0-local-ipv4-address\"}",\r
+              "port-number": 22,\r
+              "connection-time-out": 30\r
+            }\r
+          }\r
+        },\r
+        "type": "vnf-netconf-device"\r
+      },\r
+      "activate-netconf-component": {\r
+        "capabilities": {\r
+          "component-node": {}\r
+        },\r
+        "requirements": {\r
+          "netconf-connection": {\r
+            "capability": "netconf",\r
+            "node": "vpe-netconf-device",\r
+            "relationship": "tosca.relationships.ConnectsTo"\r
+          }\r
+        },\r
+        "interfaces": {\r
+          "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": {\r
+            "operations": {\r
+              "process": {\r
+                "inputs": {\r
+                  "action-name": "{ \"get_input\" : \"action-name\" }",\r
+                  "service-template-name": "{ \"get_attribute\" : \"template_name\" }",\r
+                  "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }",\r
+                  "resource-type": "vnf-type",\r
+                  "request-id": "{ \"get_input\" : \"request-id\" }",\r
+                  "resource-id": "{ \"get_input\" : \"hostname\" }",\r
+                  "execution-script": "execution-script"\r
+                },\r
+                "outputs": {\r
+                  "response-data": "{ \"get_attribute\" : \"netconf-executor-baseconfig.response-data\" }",\r
+                  "status": "{ \"get_attribute\" : \"netconf-executor-baseconfig.status\" }"\r
+                },\r
+                "implementation" : {\r
+                  "primary" : "file://netconf_adaptor/DefaultBaseLicenceConfig.py"\r
+                }\r
+              }\r
+            }\r
+          }\r
+        },\r
+        "type": "component-netconf-executor"\r
+      },\r
+      "resource-assignment-ra-component": {\r
+        "capabilities": {\r
+          "component-node": {}\r
+        },\r
+        "interfaces": {\r
+          "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": {\r
+            "operations": {\r
+              "process": {\r
+                "inputs": {\r
+                  "template-names": [\r
+                    "base-config-template",\r
+                    "licence-template"\r
+                  ],\r
+                  "action-name": "{ \"get_input\" : \"action-name\" }",\r
+                  "service-template-name": "{ \"get_attribute\" : \"template_name\" }",\r
+                  "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }",\r
+                  "resource-type": "vnf-type",\r
+                  "request-id": "{ \"get_input\" : \"request-id\" }",\r
+                  "resource-id": "{ \"get_input\" : \"hostname\" }"\r
+                },\r
+                "outputs": {\r
+                  "resource-assignment-params": "success",\r
+                  "status": "status"\r
+                }\r
+              }\r
+            }\r
+          }\r
+        },\r
+        "type": "component-resource-assignment"\r
+      },\r
+      "resource-assignment-action": {\r
+        "properties": {\r
+          "mode": "sync",\r
+          "version": "LATEST",\r
+          "is-start-flow": "false"\r
+        },\r
+        "requirements": {\r
+          "component-dependency": {\r
+            "capability": "component-node",\r
+            "node": "resource-assignment-ra-component",\r
+            "relationship": "tosca.relationships.DependsOn"\r
+          }\r
+        },\r
+        "capabilities": {\r
+          "dg-node": {},\r
+          "content": {\r
+            "properties": {\r
+              "type": "json"\r
+            }\r
+          }\r
+        },\r
+        "interfaces": {\r
+          "CONFIG": {\r
+            "operations": {\r
+              "ResourceAssignment": {\r
+                "inputs": {\r
+                  "params": []\r
+                }\r
+              }\r
+            }\r
+          }\r
+        },\r
+        "type": "dg-resource-assignment"\r
+      },\r
+      "activate-action": {\r
+        "properties": {\r
+          "mode": "sync",\r
+          "version": "LATEST",\r
+          "is-start-flow": "false"\r
+        },\r
+        "requirements": {\r
+          "component-dependency": {\r
+            "capability": "component-node",\r
+            "node": "activate-netconf-component",\r
+            "relationship": "tosca.relationships.DependsOn"\r
+          }\r
+        },\r
+        "capabilities": {\r
+          "dg-node": {},\r
+          "content": {\r
+            "properties": {\r
+              "type": "json"\r
+            }\r
+          }\r
+        },\r
+        "interfaces": {\r
+          "CONFIG": {\r
+            "operations": {\r
+              "ActivateNetconf": {\r
+                "inputs": {\r
+                  "params": []\r
+                }\r
+              }\r
+            }\r
+          }\r
+        },\r
+        "type": "dg-activate-netconf"\r
+      },\r
+      "base-config-template": {\r
+        "capabilities": {\r
+          "content": {\r
+            "properties": {\r
+              "content": "db://base-config-template"\r
+            }\r
+          },\r
+          "mapping": {\r
+            "properties": {\r
+              "mapping": [\r
+                {\r
+                  "name": "bundle-mac",\r
+                  "property": {\r
+                    "description": "",\r
+                    "required": true,\r
+                    "type": "string",\r
+                    "status": "",\r
+                    "constraints": [\r
+                      {}\r
+                    ],\r
+                    "entry_schema": {\r
+                      "type": ""\r
+                    }\r
+                  },\r
+                  "input-param": false,\r
+                  "dictionary-name": "bundle-mac",\r
+                  "dictionary-source": "db",\r
+                  "dependencies": [\r
+                    "hostname"\r
+                  ],\r
+                  "version": 0\r
+                },\r
+                {\r
+                  "name": "wan-aggregate-ipv4-addresses",\r
+                  "property": {\r
+                    "description": "",\r
+                    "required": true,\r
+                    "type": "list",\r
+                    "status": "",\r
+                    "constraints": [\r
+                      {}\r
+                    ],\r
+                    "entry_schema": {\r
+                      "type": "dt-v4-aggregate"\r
+                    }\r
+                  },\r
+                  "input-param": false,\r
+                  "dictionary-name": "wan-aggregate-ipv4-addresses",\r
+                  "dictionary-source": "mdsal",\r
+                  "dependencies": [\r
+                    "service-instance-id",\r
+                    "oam-network-role",\r
+                    "oam-v4-ip-type ",\r
+                    "oam-vm-type"\r
+                  ],\r
+                  "version": 0\r
+                },\r
+                {\r
+                  "name": "hostname",\r
+                  "property": {\r
+                    "required": true,\r
+                    "type": "string"\r
+                  },\r
+                  "dictionary-name": "hostname",\r
+                  "dictionary-source": "input",\r
+                  "version": 0,\r
+                  "input-param": false\r
+                },\r
+                {\r
+                  "name": "service",\r
+                  "property": {\r
+                    "required": true,\r
+                    "type": "string"\r
+                  },\r
+                  "dictionary-name": "service",\r
+                  "dictionary-source": "input",\r
+                  "version": 0,\r
+                  "input-param": false\r
+                },\r
+                {\r
+                  "name": "service-instance-id",\r
+                  "property": {\r
+                    "required": true,\r
+                    "type": "string"\r
+                  },\r
+                  "dictionary-name": "service-instance-id",\r
+                  "dictionary-source": "input",\r
+                  "version": 0,\r
+                  "input-param": false\r
+                }\r
+              ]\r
+            }\r
+          }\r
+        },\r
+        "properties": {\r
+          "action-names": [\r
+            "resource-assignment-action"\r
+          ]\r
+        },\r
+        "type": "artifact-config-template"\r
+      },\r
+      "licence-template": {\r
+        "capabilities": {\r
+          "content": {\r
+            "properties": {\r
+              "content": "db://licence-template"\r
+            }\r
+          },\r
+          "mapping": {\r
+            "properties": {\r
+              "mapping": [\r
+                {\r
+                  "name": "licenses",\r
+                  "property": {\r
+                    "description": "",\r
+                    "required": true,\r
+                    "type": "list",\r
+                    "status": "",\r
+                    "constraints": [\r
+                      {}\r
+                    ],\r
+                    "entry_schema": {\r
+                      "type": "dt-license-key"\r
+                    }\r
+                  },\r
+                  "input-param": false,\r
+                  "dictionary-name": "licenses",\r
+                  "dictionary-source": "mdsal",\r
+                  "dependencies": [\r
+                    "service-instance-id"\r
+                  ],\r
+                  "version": 0\r
+                },\r
+                {\r
+                  "name": "service-instance-id",\r
+                  "property": {\r
+                    "required": true,\r
+                    "type": "string"\r
+                  },\r
+                  "dictionary-name": "service-instance-id",\r
+                  "dictionary-source": "input",\r
+                  "version": 0,\r
+                  "input-param": false\r
+                }\r
+              ]\r
+            }\r
+          }\r
+        },\r
+        "properties": {\r
+          "action-names": [\r
+            "resource-assignment-action"\r
+          ]\r
+        },\r
+        "type": "artifact-config-template"\r
+      }\r
+    }\r
+  },\r
+  "node_types": {\r
+  },\r
+  "data_types": {\r
+  }\r
+}
\ No newline at end of file
diff --git a/components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json b/components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json
new file mode 100644 (file)
index 0000000..6abfb51
--- /dev/null
@@ -0,0 +1,3 @@
+{\r
+  "assignments": "Sample Assignments"\r
+}
\ No newline at end of file
diff --git a/components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn b/components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn
new file mode 100644 (file)
index 0000000..5e94c0f
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"\r
+                  xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"\r
+                  xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"\r
+                  xmlns:camunda="http://camunda.org/schema/1.0/bpmn"\r
+                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1"\r
+                  targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.2">\r
+    <bpmn:process id="ActivateProcess" isExecutable="true">\r
+        <bpmn:startEvent id="StartEvent_1">\r
+            <bpmn:outgoing>SequenceFlow_0l0dq58</bpmn:outgoing>\r
+        </bpmn:startEvent>\r
+        <bpmn:endEvent id="EndEvent_1pr0kil">\r
+            <bpmn:incoming>SequenceFlow_1ay0k6p</bpmn:incoming>\r
+        </bpmn:endEvent>\r
+        <bpmn:sequenceFlow id="SequenceFlow_0l0dq58" sourceRef="StartEvent_1" targetRef="activate_device_task"/>\r
+        <bpmn:sequenceFlow id="SequenceFlow_1ay0k6p" sourceRef="activate_device_task" targetRef="EndEvent_1pr0kil"/>\r
+        <bpmn:serviceTask id="activate_device_task" name="Activate Device"\r
+                          camunda:delegateExpression="${componentDelegateService}">\r
+            <bpmn:extensionElements>\r
+                <camunda:inputOutput>\r
+                    <camunda:inputParameter name="selector"><![CDATA[resource-assignment\r
+]]></camunda:inputParameter>\r
+                </camunda:inputOutput>\r
+            </bpmn:extensionElements>\r
+            <bpmn:incoming>SequenceFlow_0l0dq58</bpmn:incoming>\r
+            <bpmn:outgoing>SequenceFlow_1ay0k6p</bpmn:outgoing>\r
+        </bpmn:serviceTask>\r
+    </bpmn:process>\r
+    <bpmndi:BPMNDiagram id="BPMNDiagram_1">\r
+        <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateProcess">\r
+            <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">\r
+                <dc:Bounds x="175" y="143" width="36" height="36"/>\r
+                <bpmndi:BPMNLabel>\r
+                    <dc:Bounds x="148" y="179" width="90" height="20"/>\r
+                </bpmndi:BPMNLabel>\r
+            </bpmndi:BPMNShape>\r
+            <bpmndi:BPMNShape id="EndEvent_1pr0kil_di" bpmnElement="EndEvent_1pr0kil">\r
+                <dc:Bounds x="575" y="114" width="36" height="36"/>\r
+                <bpmndi:BPMNLabel>\r
+                    <dc:Bounds x="593" y="154" width="0" height="12"/>\r
+                </bpmndi:BPMNLabel>\r
+            </bpmndi:BPMNShape>\r
+            <bpmndi:BPMNEdge id="SequenceFlow_0l0dq58_di" bpmnElement="SequenceFlow_0l0dq58">\r
+                <di:waypoint xsi:type="dc:Point" x="211" y="161"/>\r
+                <di:waypoint xsi:type="dc:Point" x="273" y="161"/>\r
+                <di:waypoint xsi:type="dc:Point" x="273" y="149"/>\r
+                <di:waypoint xsi:type="dc:Point" x="334" y="149"/>\r
+                <bpmndi:BPMNLabel>\r
+                    <dc:Bounds x="288" y="149" width="0" height="12"/>\r
+                </bpmndi:BPMNLabel>\r
+            </bpmndi:BPMNEdge>\r
+            <bpmndi:BPMNEdge id="SequenceFlow_1ay0k6p_di" bpmnElement="SequenceFlow_1ay0k6p">\r
+                <di:waypoint xsi:type="dc:Point" x="434" y="149"/>\r
+                <di:waypoint xsi:type="dc:Point" x="505" y="149"/>\r
+                <di:waypoint xsi:type="dc:Point" x="505" y="132"/>\r
+                <di:waypoint xsi:type="dc:Point" x="575" y="132"/>\r
+                <bpmndi:BPMNLabel>\r
+                    <dc:Bounds x="520" y="134.5" width="0" height="12"/>\r
+                </bpmndi:BPMNLabel>\r
+            </bpmndi:BPMNEdge>\r
+            <bpmndi:BPMNShape id="ServiceTask_0e8ek4f_di" bpmnElement="activate_device_task">\r
+                <dc:Bounds x="334" y="109" width="100" height="80"/>\r
+            </bpmndi:BPMNShape>\r
+        </bpmndi:BPMNPlane>\r
+    </bpmndi:BPMNDiagram>\r
+</bpmn:definitions>\r
diff --git a/components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py b/components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py
new file mode 100644 (file)
index 0000000..eb198c7
--- /dev/null
@@ -0,0 +1,8 @@
+from com.brvith.orchestrator.core.interfaces import ComponentNode\r
+\r
+class SamplePythonComponentNode(ComponentNode):\r
+    def prepare(self, context, componentContext):\r
+        return None\r
+\r
+    def prepare(self, context, componentContext):\r
+        return None
\ No newline at end of file
diff --git a/components/core/load/blueprints/simple-baseconfig/Scripts/__init__.py b/components/core/load/blueprints/simple-baseconfig/Scripts/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta b/components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta
new file mode 100644 (file)
index 0000000..d7ae5e8
--- /dev/null
@@ -0,0 +1,8 @@
+TOSCA-Meta-File-Version: 1.0.0\r
+CSAR-Version: 1.0\r
+Created-By: Brinda Santh M\r
+Entry-Definitions: Definitions/simple-baseconfig.json\r
+Template-Tags: vrr-test, Brinda Santh\r
+\r
+Name: Plans/ActivateProcess.bpmn\r
+Content-Type: application/vnd.oasis.bpmn\r
diff --git a/components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl b/components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl
new file mode 100644 (file)
index 0000000..92dba10
--- /dev/null
@@ -0,0 +1,40 @@
+ <config>\r
+               <configuration>\r
+                       <groups>\r
+                               <name>${group-name}</name>\r
+                               <routing-instances>\r
+                                       <instance>\r
+                                               <name>&lt;*&gt;</name>\r
+                                               <protocols>\r
+                                                       <pim>\r
+                                                               <dense-groups>\r
+                                                                       <dynamic-reject />\r
+                                                                       <pim-dense-group-type>\r
+                                                                               <name>224.0.1.40/32</name>\r
+                                                                       </pim-dense-group-type>\r
+                                                                       <pim-dense-group-type>\r
+                                                                               <name>224.0.1.39/32</name>\r
+                                                                       </pim-dense-group-type>\r
+                                                                       <pim-dense-group-type>\r
+                                                                               <name>224.0.0.0/4</name>\r
+                                                                               <reject />\r
+                                                                       </pim-dense-group-type>\r
+                                                               </dense-groups>\r
+                                                               <rp>\r
+                                                                       <auto-rp>\r
+                                                                               <discovery />\r
+                                                                       </auto-rp>\r
+                                                               </rp>\r
+                                                               <interface>\r
+                                                                       <name>&lt;*&gt;</name>\r
+                                                                       <disable />\r
+                                                                       <priority>1000</priority>\r
+                                                               </interface>\r
+                                                               <reset-tracking-bit />\r
+                                                       </pim>\r
+                                               </protocols>\r
+                                       </instance>\r
+                               </routing-instances>\r
+                       </groups>\r
+               </configuration>\r
+       </config>
\ No newline at end of file
diff --git a/components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl b/components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl
new file mode 100644 (file)
index 0000000..026c591
--- /dev/null
@@ -0,0 +1 @@
+This is Sample Velocity Template
\ No newline at end of file
diff --git a/components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl b/components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl
new file mode 100644 (file)
index 0000000..626974f
--- /dev/null
@@ -0,0 +1,4 @@
+ <config>\r
+               <configuration>\r
+               </configuration>\r
+                </config>\r
diff --git a/components/core/load/blueprints/simple-baseconfig/__init__.py b/components/core/load/blueprints/simple-baseconfig/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json b/components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json
new file mode 100644 (file)
index 0000000..ac76b4f
--- /dev/null
@@ -0,0 +1,8 @@
+{\r
+  "description": " Camunda BPM File",\r
+  "version": "1.0.0",\r
+  "file_ext": [\r
+    "bpmn"\r
+  ],\r
+  "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/artifact_type/artifact-directed-graph.json b/components/core/load/model_type/artifact_type/artifact-directed-graph.json
new file mode 100644 (file)
index 0000000..7ab3a54
--- /dev/null
@@ -0,0 +1,9 @@
+{\r
+  "description": "Directed Graph File",\r
+  "version": "1.0.0",\r
+  "file_ext": [\r
+    "json",\r
+    "xml"\r
+  ],\r
+  "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/artifact_type/artifact-mapping-resource.json b/components/core/load/model_type/artifact_type/artifact-mapping-resource.json
new file mode 100644 (file)
index 0000000..0a3261b
--- /dev/null
@@ -0,0 +1,8 @@
+{\r
+  "description": " Velocity Template Resource Mapping File used along with Configuration template",\r
+  "version": "1.0.0",\r
+  "file_ext": [\r
+    "json"\r
+  ],\r
+  "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/artifact_type/artifact-script-python.json b/components/core/load/model_type/artifact_type/artifact-script-python.json
new file mode 100644 (file)
index 0000000..b48d2b6
--- /dev/null
@@ -0,0 +1,8 @@
+{\r
+  "description": " Kotlin Script Template used for Configuration",\r
+  "version": "1.0.0",\r
+  "file_ext": [\r
+    "py"\r
+  ],\r
+  "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/artifact_type/artifact-template-velocity.json b/components/core/load/model_type/artifact_type/artifact-template-velocity.json
new file mode 100644 (file)
index 0000000..9395d39
--- /dev/null
@@ -0,0 +1,8 @@
+{\r
+  "description": " Velocity Template used for Configuration",\r
+  "version": "1.0.0",\r
+  "file_ext": [\r
+    "vtl"\r
+  ],\r
+  "derived_from": "tosca.artifacts.Implementation"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json b/components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json
new file mode 100644 (file)
index 0000000..5a7c956
--- /dev/null
@@ -0,0 +1,5 @@
+{\r
+  "description": "TOSCA base type for implementation artifacts",\r
+  "version": "1.0.0",\r
+  "derived_from": "tosca.artifacts.Root"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/data_type/datatype-property.json b/components/core/load/model_type/data_type/datatype-property.json
new file mode 100644 (file)
index 0000000..5584b10
--- /dev/null
@@ -0,0 +1,27 @@
+{\r
+       "version": "1.0.0",\r
+       "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",\r
+       "properties": {\r
+               "type": {\r
+                       "required": true,\r
+                       "type": "string"\r
+               },\r
+               "description": {\r
+                       "required": false,\r
+                       "type": "string"\r
+               },\r
+               "required": {\r
+                       "required": false,\r
+                       "type": "boolean"\r
+               },\r
+               "default": {\r
+                       "required": false,\r
+                       "type": "string"\r
+               },\r
+               "entry_schema": {\r
+                       "required": false,\r
+                       "type": "string"\r
+               }\r
+       },\r
+       "derived_from": "tosca.datatypes.Root"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/data_type/datatype-resource-assignment.json b/components/core/load/model_type/data_type/datatype-resource-assignment.json
new file mode 100644 (file)
index 0000000..cc9816e
--- /dev/null
@@ -0,0 +1,46 @@
+{\r
+       "version": "1.0.0",\r
+       "description": "This is Resource Assignment Data Type",\r
+       "properties": {\r
+               "property": {\r
+                       "required": true,\r
+                       "type": "datatype-property"\r
+               },\r
+               "input-param": {\r
+                       "required": true,\r
+                       "type": "boolean"\r
+               },\r
+               "dictionary-name": {\r
+                       "required": false,\r
+                       "type": "string"\r
+               },\r
+               "dictionary-source": {\r
+                       "required": false,\r
+                       "type": "string"\r
+               },\r
+               "dependencies": {\r
+                       "required": true,\r
+                       "type": "list",\r
+                       "entry_schema": {\r
+                               "type": "string"\r
+                       }\r
+               },\r
+               "status": {\r
+                       "required": false,\r
+                       "type": "string"\r
+               },\r
+               "message": {\r
+                       "required": false,\r
+                       "type": "string"\r
+               },\r
+               "updated-date": {\r
+                       "required": false,\r
+                       "type": "string"\r
+               },\r
+               "updated-by": {\r
+                       "required": false,\r
+                       "type": "string"\r
+               }\r
+       },\r
+       "derived_from": "tosca.datatypes.Root"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/data_type/dt-license-key.json b/components/core/load/model_type/data_type/dt-license-key.json
new file mode 100644 (file)
index 0000000..e9c312b
--- /dev/null
@@ -0,0 +1,11 @@
+{\r
+       "version": "1.0.0",\r
+       "description": "This is dt-plicense-key Data Type",\r
+       "properties": {\r
+               "license-key": {\r
+                       "required": true,\r
+                       "type": "string"\r
+               }\r
+       },\r
+       "derived_from": "tosca.datatypes.Root"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/data_type/dt-v4-aggregate.json b/components/core/load/model_type/data_type/dt-v4-aggregate.json
new file mode 100644 (file)
index 0000000..842a7f8
--- /dev/null
@@ -0,0 +1,15 @@
+{\r
+       "version": "1.0.0",\r
+       "description": "This is dt-v4-aggregate Data Type",\r
+       "properties": {\r
+               "ipv4-address": {\r
+                       "required": true,\r
+                       "type": "string"\r
+               },\r
+               "ipv4-plen": {\r
+                       "required": false,\r
+                       "type": "integer"\r
+               }\r
+       },\r
+       "derived_from": "tosca.datatypes.Root"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/data_type/tosca.datatypes.Credential.json b/components/core/load/model_type/data_type/tosca.datatypes.Credential.json
new file mode 100644 (file)
index 0000000..820a551
--- /dev/null
@@ -0,0 +1,31 @@
+{\r
+  "version": "1.0.0",\r
+  "description": "Credential",\r
+  "properties": {\r
+    "protocol": {\r
+      "required": false,\r
+      "type": "string"\r
+    },\r
+    "token_type": {\r
+      "required": true,\r
+      "type": "string",\r
+      "default" : "password"\r
+    },\r
+    "token": {\r
+      "required": false,\r
+      "type": "string"\r
+    },\r
+    "keys": {\r
+      "required": false,\r
+      "type": "list",\r
+      "entry_schema": {\r
+        "type": "string"\r
+      }\r
+    },\r
+    "user": {\r
+      "required": false,\r
+      "type": "string"\r
+    }\r
+  },\r
+  "derived_from": "tosca.datatypes.Root"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/node_type/artifact-config-template.json b/components/core/load/model_type/node_type/artifact-config-template.json
new file mode 100644 (file)
index 0000000..be9bbfc
--- /dev/null
@@ -0,0 +1,37 @@
+{\r
+       "description": "This is Configuration Velocity Template",\r
+       "version": "1.0.0",\r
+       "properties": {\r
+               "action-names": {\r
+                       "required": true,\r
+                       "type": "list",\r
+                       "entry_schema": {\r
+                               "type": "string"\r
+                       }\r
+               }\r
+       },\r
+       "capabilities": {\r
+               "content": {\r
+                       "type": "tosca.capability.Content",\r
+                       "properties": {\r
+                               "content": {\r
+                                       "required": true,\r
+                                       "type": "string"\r
+                               }\r
+                       }\r
+               },\r
+               "mapping": {\r
+                       "type": "tosca.capability.Mapping",\r
+                       "properties": {\r
+                               "mapping": {\r
+                                       "required": false,\r
+                                       "type": "list",\r
+                                       "entry_schema": {\r
+                                               "type": "datatype-resource-assignment"\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "derived_from": "tosca.nodes.Artifact"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/node_type/component-config-generator.json b/components/core/load/model_type/node_type/component-config-generator.json
new file mode 100644 (file)
index 0000000..764f9e8
--- /dev/null
@@ -0,0 +1,72 @@
+{\r
+       "description": "This is Generate Configuration Component API",\r
+       "version": "1.0.0",\r
+       "capabilities": {\r
+               "component-node": {\r
+                       "type": "tosca.capabilities.Node"\r
+               }\r
+       },\r
+       "interfaces": {\r
+               "org-openecomp-sdnc-config-generator-service-ConfigGeneratorNode": {\r
+                       "operations": {\r
+                               "process": {\r
+                                       "inputs": {\r
+                                               "template-data": {\r
+                                                       "description": "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present",\r
+                                                       "required": false,\r
+                                                       "type": "string"\r
+                                               },\r
+                                               "template-content": {\r
+                                                       "description": "Conditional : Dynamic Template used to generate Configuration.",\r
+                                                       "required": false,\r
+                                                       "type": "string"\r
+                                               },\r
+                                               "resource-type": {\r
+                                                       "description": "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present",\r
+                                                       "required": false,\r
+                                                       "type": "string"\r
+                                               },\r
+                                               "request-id": {\r
+                                                       "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+                                                       "required": true,\r
+                                                       "type": "string"\r
+                                               },\r
+                                               "resource-id": {\r
+                                                       "description": "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present",\r
+                                                       "required": false,\r
+                                                       "type": "string"\r
+                                               },\r
+                                               "action-name": {\r
+                                                       "description": "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
+                                                       "required": false,\r
+                                                       "type": "string"\r
+                                               },\r
+                                               "template-name": {\r
+                                                       "description": "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",\r
+                                                       "required": true,\r
+                                                       "type": "string"\r
+                                               }\r
+                                       },\r
+                                       "outputs": {\r
+                                               "generated-config": {\r
+                                                       "description": "Generated Configuration for the Template adn Resource Data",\r
+                                                       "required": true,\r
+                                                       "type": "string"\r
+                                               },\r
+                                               "mask-info": {\r
+                                                       "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.apps.controllerblueprints.core.data.custom.MaskInfo ",\r
+                                                       "required": false,\r
+                                                       "type": "string"\r
+                                               },\r
+                                               "status": {\r
+                                                       "description": "Status of the Component Execution ( success or failure )",\r
+                                                       "required": true,\r
+                                                       "type": "string"\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "derived_from": "tosca.nodes.Component"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/node_type/component-netconf-executor.json b/components/core/load/model_type/node_type/component-netconf-executor.json
new file mode 100644 (file)
index 0000000..aed667a
--- /dev/null
@@ -0,0 +1,79 @@
+{\r
+  "description": "This is Netconf Transaction Configuration Component API",\r
+  "version": "1.0.0",\r
+  "capabilities": {\r
+    "component-node": {\r
+      "type": "tosca.capabilities.Node"\r
+    }\r
+  },\r
+  "requirements": {\r
+    "netconf-connection": {\r
+      "capability": "netconf",\r
+      "node": "vnf-netconf-device",\r
+      "relationship": "tosca.relationships.ConnectsTo"\r
+    }\r
+  },\r
+  "interfaces": {\r
+    "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": {\r
+      "operations": {\r
+        "process": {\r
+          "inputs": {\r
+            "request-id": {\r
+              "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+              "required": true,\r
+              "type": "string"\r
+            },\r
+            "service-template-name": {\r
+              "description": "Service Template Name",\r
+              "required": true,\r
+              "type": "string"\r
+            },\r
+            "service-template-version": {\r
+              "description": "Service Template Version",\r
+              "required": true,\r
+              "type": "string"\r
+            },\r
+            "action-name": {\r
+              "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
+              "required": false,\r
+              "type": "string"\r
+            },\r
+            "resource-type": {\r
+              "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
+              "required": false,\r
+              "type": "string"\r
+            },\r
+            "resource-id": {\r
+              "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
+              "required": false,\r
+              "type": "string"\r
+            },\r
+            "reservation-id": {\r
+                               "description": "Reservation Id used to send to NPM",\r
+                               "required": false,\r
+                               "type": "string"\r
+                       },\r
+            "execution-script": {\r
+              "description": "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.",\r
+              "required": true,\r
+              "type": "string"\r
+            }\r
+          },\r
+          "outputs": {\r
+            "response-data": {\r
+              "description": "Execution Response Data in JSON format.",\r
+              "required": false,\r
+              "type": "string"\r
+            },\r
+            "status": {\r
+              "description": "Status of the Component Execution ( success or failure )",\r
+              "required": true,\r
+              "type": "string"\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  },\r
+  "derived_from": "tosca.nodes.Component"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/node_type/component-resource-assignment.json b/components/core/load/model_type/node_type/component-resource-assignment.json
new file mode 100644 (file)
index 0000000..34c0284
--- /dev/null
@@ -0,0 +1,68 @@
+{\r
+  "description": "This is Resource Assignment Component API",\r
+  "version": "1.0.0",\r
+  "capabilities": {\r
+    "component-node": {\r
+      "type": "tosca.capabilities.Node"\r
+    }\r
+  },\r
+  "interfaces": {\r
+    "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": {\r
+      "operations": {\r
+        "process": {\r
+          "inputs": {\r
+            "service-template-name": {\r
+              "description": "Service Template Name.",\r
+              "required": true,\r
+              "type": "string"\r
+            },\r
+            "service-template-version": {\r
+              "description": "Service Template Version.",\r
+              "required": true,\r
+              "type": "string"\r
+            },\r
+            "resource-type": {\r
+              "description": "Request type.",\r
+              "required": true,\r
+              "type": "string"\r
+            },\r
+            "template-names": {\r
+              "description": "Name of the artifact Node Templates, to get the template Content.",\r
+              "required": true,\r
+              "type": "list",\r
+              "entry_schema": {\r
+                "type": "string"\r
+              }\r
+            },\r
+            "request-id": {\r
+              "description": "Request Id, Unique Id for the request.",\r
+              "required": true,\r
+              "type": "string"\r
+            },\r
+            "resource-id": {\r
+              "description": "Resource Id.",\r
+              "required": true,\r
+              "type": "string"\r
+            },\r
+            "action-name": {\r
+              "description": "Action Name of the process",\r
+              "required": true,\r
+              "type": "string"\r
+            }\r
+          },\r
+          "outputs": {\r
+            "resource-assignment-params": {\r
+              "required": true,\r
+              "type": "string"\r
+            },\r
+            "status": {\r
+              "required": true,\r
+              "type": "string"\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  },\r
+  "derived_from": "tosca.nodes.Component"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/node_type/dg-activate-netconf.json b/components/core/load/model_type/node_type/dg-activate-netconf.json
new file mode 100644 (file)
index 0000000..c638df0
--- /dev/null
@@ -0,0 +1,66 @@
+{
+       "description": "This is Download Netconf Directed Graph",
+       "version": "1.0.0",
+       "properties": {
+               "mode": {
+                       "required": false,
+                       "type": "string",
+                       "default": "sync"
+               },
+               "version": {
+                       "required": false,
+                       "type": "string",
+                       "default": "LATEST"
+               },
+               "is-start-flow": {
+                       "required": false,
+                       "type": "boolean",
+                       "default": "false"
+               }
+       },
+       "capabilities": {
+               "dg-node": {
+                       "type": "tosca.capabilities.Node"
+               },
+               "content": {
+                       "type": "tosca.capability.Content",
+                       "properties": {
+                               "type": {
+                                       "required": false,
+                                       "type": "string",
+                                       "default": "json"
+                               },
+                               "content": {
+                                       "required": true,
+                                       "type": "string"
+                               }
+                       }
+               }
+       },
+       "requirements": {
+               "component-dependency": {
+                       "capability": "component-node",
+                       "node": "component-netconf-executor",
+                       "relationship": "tosca.relationships.DependsOn"
+               }
+       },
+       "interfaces": {
+               "CONFIG": {
+                       "operations": {
+                               "ActivateNetconf": {
+                                       "inputs": {
+                                               "params": {
+                                                       "required": false,
+                                                       "type": "list",
+                                                       "entry_schema": {
+                                                               "type": "datatype-property"
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+       },
+       
+       "derived_from": "tosca.nodes.DG"
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/node_type/dg-config-generator.json b/components/core/load/model_type/node_type/dg-config-generator.json
new file mode 100644 (file)
index 0000000..28bace0
--- /dev/null
@@ -0,0 +1,65 @@
+{\r
+       "description": "This is Activate DG for Config Generator Directed Graph",\r
+       "version": "1.0.0",\r
+       "properties": {\r
+               "mode": {\r
+                       "required": false,\r
+                       "type": "string",\r
+                       "default": "sync"\r
+               },\r
+               "version": {\r
+                       "required": false,\r
+                       "type": "string",\r
+                       "default": "LATEST"\r
+               },\r
+               "is-start-flow": {\r
+                       "required": false,\r
+                       "type": "boolean",\r
+                       "default": "false"\r
+               }\r
+       },\r
+       "capabilities": {\r
+               "dg-node": {\r
+                       "type": "tosca.capabilities.Node"\r
+               },\r
+               "content": {\r
+                       "type": "tosca.capability.Content",\r
+                       "properties": {\r
+                               "type": {\r
+                                       "required": false,\r
+                                       "type": "string",\r
+                                       "default": "json"\r
+                               },\r
+                               "content": {\r
+                                       "required": true,\r
+                                       "type": "string"\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "requirements": {\r
+               "component-dependency": {\r
+                       "capability": "component-node",\r
+                       "node": "component-config-generator",\r
+                       "relationship": "tosca.relationships.DependsOn"\r
+               }\r
+       },\r
+       "interfaces": {\r
+               "CONFIG": {\r
+                       "operations": {\r
+                               "GenerateConfiguration": {\r
+                                       "inputs": {\r
+                                               "params": {\r
+                                                       "required": false,\r
+                                                       "type": "list",\r
+                                                       "entry_schema": {\r
+                                                               "type": "datatype-property"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "derived_from": "tosca.nodes.DG"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/node_type/dg-resource-assign-activate.json b/components/core/load/model_type/node_type/dg-resource-assign-activate.json
new file mode 100644 (file)
index 0000000..e98fa5a
--- /dev/null
@@ -0,0 +1,70 @@
+{\r
+       "description": "This is Resource Assign and Activate Netconf Directed Graph",\r
+       "version": "1.0.0",\r
+       "properties": {\r
+               "mode": {\r
+                       "required": false,\r
+                       "type": "string",\r
+                       "default": "sync"\r
+               },\r
+               "version": {\r
+                       "required": false,\r
+                       "type": "string",\r
+                       "default": "LATEST"\r
+               },\r
+               "is-start-flow": {\r
+                       "required": false,\r
+                       "type": "boolean",\r
+                       "default": "false"\r
+               }\r
+       },\r
+       "capabilities": {\r
+               "dg-node": {\r
+                       "type": "tosca.capabilities.Node"\r
+               },\r
+               "content": {\r
+                       "type": "tosca.capability.Content",\r
+                       "properties": {\r
+                               "type": {\r
+                                       "required": false,\r
+                                       "type": "string",\r
+                                       "default": "json"\r
+                               },\r
+                               "content": {\r
+                                       "required": false,\r
+                                       "type": "string"\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "requirements": {\r
+               "ra-component": {\r
+                       "capability": "component-node",\r
+                       "node": "component-resource-assignment",\r
+                       "relationship": "tosca.relationships.DependsOn"\r
+               },\r
+               "netconf-component": {\r
+                       "capability": "component-node",\r
+                       "node": "component-netconf-executor",\r
+                       "relationship": "tosca.relationships.DependsOn"\r
+               }\r
+       },\r
+       "interfaces": {\r
+               "CONFIG": {\r
+                       "operations": {\r
+                               "ResourceAssignAndActivate": {\r
+                                       "inputs": {\r
+                                               "params": {\r
+                                                       "required": false,\r
+                                                       "type": "list",\r
+                                                       "entry_schema": {\r
+                                                               "type": "datatype-property"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "derived_from": "tosca.nodes.DG"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/node_type/dg-resource-assignment.json b/components/core/load/model_type/node_type/dg-resource-assignment.json
new file mode 100644 (file)
index 0000000..36fbb68
--- /dev/null
@@ -0,0 +1,65 @@
+{\r
+       "description": "This is Resource Assignment Directed Graph",\r
+       "version": "1.0.0",\r
+       "properties": {\r
+               "mode": {\r
+                       "required": false,\r
+                       "type": "string",\r
+                       "default": "sync"\r
+               },\r
+               "version": {\r
+                       "required": false,\r
+                       "type": "string",\r
+                       "default": "LATEST"\r
+               },\r
+               "is-start-flow": {\r
+                       "required": false,\r
+                       "type": "boolean",\r
+                       "default": "false"\r
+               }\r
+       },\r
+       "capabilities": {\r
+               "dg-node": {\r
+                       "type": "tosca.capabilities.Node"\r
+               },\r
+               "content": {\r
+                       "type": "tosca.capability.Content",\r
+                       "properties": {\r
+                               "type": {\r
+                                       "required": false,\r
+                                       "type": "string",\r
+                                       "default": "json"\r
+                               },\r
+                               "content": {\r
+                                       "required": false,\r
+                                       "type": "string"\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "requirements": {\r
+               "component-dependency": {\r
+                       "capability": "component-node",\r
+                       "node": "component-resource-assignment",\r
+                       "relationship": "tosca.relationships.DependsOn"\r
+               }\r
+       },\r
+       "interfaces": {\r
+               "CONFIG": {\r
+                       "operations": {\r
+                               "ResourceAssignment": {\r
+                                       "inputs": {\r
+                                               "params": {\r
+                                                       "required": false,\r
+                                                       "type": "list",\r
+                                                       "entry_schema": {\r
+                                                               "type": "datatype-property"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "derived_from": "tosca.nodes.DG"\r
+}
\ No newline at end of file
diff --git a/components/core/load/model_type/node_type/vnf-netconf-device.json b/components/core/load/model_type/node_type/vnf-netconf-device.json
new file mode 100644 (file)
index 0000000..54573ba
--- /dev/null
@@ -0,0 +1,42 @@
+{\r
+       "description": "This is VNF Device with Netconf  Capability",\r
+       "version": "1.0.0",\r
+       "capabilities": {\r
+               "netconf": {\r
+                       "type": "tosca.capability.Netconf",\r
+                       "properties": {\r
+                               "login-key": {\r
+                                       "required": true,\r
+                                       "type": "string",\r
+                                       "default": "sdnc"\r
+                               },\r
+                               "login-account": {\r
+                                       "required": true,\r
+                                       "type": "string",\r
+                                       "default": "sdnc-tacacs"\r
+                               },\r
+                               "source": {\r
+                                       "required": true,\r
+                                       "type": "string",\r
+                                       "default": "npm"\r
+                               },\r
+                               "target-ip-address": {\r
+                                       "required": true,\r
+                                       "type": "string"\r
+                               },\r
+                               "port-number": {\r
+                                       "required": true,\r
+                                       "type": "integer",\r
+                                       "default": 830\r
+                               },\r
+                               "connection-time-out": {\r
+                                       "required": false,\r
+                                       "type": "integer",\r
+                                       "default": 30\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "derived_from": "tosca.nodes.Vnf"\r
+       \r
+}\r
diff --git a/components/core/pom.xml b/components/core/pom.xml
new file mode 100644 (file)
index 0000000..fc6624e
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
+  ~\r
+  ~ Modifications Copyright © 2018 IBM.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~     http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  -->\r
+\r
+<project\r
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"\r
+        xmlns="http://maven.apache.org/POM/4.0.0"\r
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+    <modelVersion>4.0.0</modelVersion>\r
+    <parent>\r
+        <groupId>org.onap.ccsdk.apps.components</groupId>\r
+        <artifactId>parent</artifactId>\r
+        <version>0.3.0-SNAPSHOT</version>\r
+        <relativePath>../parent</relativePath>\r
+    </parent>\r
+    <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>\r
+    <artifactId>core</artifactId>\r
+    <name>Controller Blueprints Core</name>\r
+\r
+    <dependencies>\r
+        <dependency>\r
+            <groupId>com.fasterxml.jackson.dataformat</groupId>\r
+            <artifactId>jackson-dataformat-xml</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>com.fasterxml.jackson.dataformat</groupId>\r
+            <artifactId>jackson-dataformat-yaml</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>com.fasterxml.jackson.module</groupId>\r
+            <artifactId>jackson-module-jsonSchema</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>io.projectreactor</groupId>\r
+            <artifactId>reactor-core</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.yaml</groupId>\r
+            <artifactId>snakeyaml</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.jetbrains.kotlin</groupId>\r
+            <artifactId>kotlin-test</artifactId>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>junit</groupId>\r
+            <artifactId>junit</artifactId>\r
+        </dependency>\r
+    </dependencies>\r
+\r
+</project>\r
+\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
new file mode 100644 (file)
index 0000000..4ae1f4d
--- /dev/null
@@ -0,0 +1,142 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core\r
+/**\r
+ * BluePrintConstants\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object BluePrintConstants {\r
+\r
+    const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID"\r
+    const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion"\r
+    const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"\r
+    const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"\r
+\r
+    const val TYPE_DEFAULT: String = "default"\r
+\r
+    const val DATA_TYPE_STRING: String = "string"\r
+    const val DATA_TYPE_INTEGER: String = "integer"\r
+    const val DATA_TYPE_FLOAT: String = "float"\r
+    const val DATA_TYPE_BOOLEAN: String = "boolean"\r
+    const val DATA_TYPE_TIMESTAMP: String = "timestamp"\r
+    const val DATA_TYPE_NULL: String = "null"\r
+    const val DATA_TYPE_LIST: String = "list"\r
+    const val DATA_TYPE_MAP: String = "map"\r
+\r
+    const val USER_SYSTEM: String = "System"\r
+\r
+    const val MODEL_CONTENT_TYPE_JSON: String = "JSON"\r
+    const val MODEL_CONTENT_TYPE_YAML: String = "YAML"\r
+    const val MODEL_CONTENT_TYPE_YANG: String = "YANG"\r
+    const val MODEL_CONTENT_TYPE_SCHEMA: String = "SCHEMA"\r
+\r
+    const val PATH_DIVIDER: String = "/"\r
+    const val PATH_INPUTS: String = "inputs"\r
+    const val PATH_NODE_WORKFLOWS: String = "workflows"\r
+    const val PATH_NODE_TEMPLATES: String = "node_templates"\r
+    const val PATH_CAPABILITIES: String = "capabilities"\r
+    const val PATH_REQUIREMENTS: String = "requirements"\r
+    const val PATH_INTERFACES: String = "interfaces"\r
+    const val PATH_OPERATIONS: String = "operations"\r
+    const val PATH_OUTPUTS: String = "outputs"\r
+    const val PATH_PROPERTIES: String = "properties"\r
+    const val PATH_ATTRIBUTES: String = "attributes"\r
+    const val PATH_ARTIFACTS: String = "artifacts"\r
+\r
+    const val MODEL_DIR_MODEL_TYPE: String = "model_type"\r
+\r
+    const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type"\r
+    const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type"\r
+    const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type"\r
+    const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type"\r
+    const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type"\r
+\r
+    const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root"\r
+    const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root"\r
+    const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root"\r
+    const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root"\r
+    const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root"\r
+    const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root"\r
+    const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root"\r
+\r
+    const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn"\r
+    const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn"\r
+    const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo"\r
+    const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"\r
+    const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"\r
+\r
+    const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"\r
+    const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"\r
+    const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"\r
+    @Deprecated("Artifacts will be attached to Node Template")\r
+    const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"\r
+    const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource"\r
+\r
+    const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java"\r
+    const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"\r
+    const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"\r
+    const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"\r
+    const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"\r
+\r
+    const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"\r
+\r
+    const val EXPRESSION_GET_INPUT: String = "get_input"\r
+    const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"\r
+    const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"\r
+    const val EXPRESSION_GET_PROPERTY: String = "get_property"\r
+    const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output"\r
+    const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type"\r
+\r
+    const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id"\r
+    const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath"\r
+    const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime"\r
+    const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data"\r
+    const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context"\r
+    const val PROPERTY_BLUEPRINT_NAME: String = "template_name"\r
+    const val PROPERTY_BLUEPRINT_VERSION: String = "template_version"\r
+\r
+    const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta"\r
+    const val TOSCA_PLANS_DIR: String = "Plans"\r
+    const val TOSCA_SCRIPTS_DIR: String = "Scripts"\r
+    const val TOSCA_MAPPINGS_DIR: String = "Mappings"\r
+    const val TOSCA_TEMPLATES_DIR: String = "Templates"\r
+\r
+    const val METADATA_USER_GROUPS = "user-groups"\r
+    const val METADATA_TEMPLATE_NAME = "template_name"\r
+    const val METADATA_TEMPLATE_VERSION = "template_version"\r
+    const val METADATA_TEMPLATE_AUTHOR = "template_author"\r
+    const val METADATA_TEMPLATE_TAGS = "template_tags"\r
+\r
+    const val PAYLOAD_CONTENT = "payload-content"\r
+    const val PAYLOAD_DATA = "payload-data"\r
+    const val SELECTOR = "selector"\r
+    const val PROPERTY_CURRENT_INTERFACE = "current-interface"\r
+    const val PROPERTY_CURRENT_OPERATION = "current-operation"\r
+    const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"\r
+\r
+    const val PROPERTY_ACTION_NAME = "action"\r
+\r
+    const val OPERATION_PROCESS = "process"\r
+    const val OPERATION_PREPARE = "prepare"\r
+\r
+    const val BLUEPRINT_RETRIEVE_TYPE_DB = "db"\r
+    const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file"\r
+    const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo"\r
+\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt
new file mode 100644 (file)
index 0000000..5c386c2
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class BluePrintException : Exception {\r
+\r
+    var code: Int = 100\r
+\r
+    constructor(cause: Throwable) : super(cause)\r
+    constructor(message: String) : super(message)\r
+    constructor(message: String, cause: Throwable) : super(message, cause)\r
+    constructor(cause: Throwable, message: String, vararg args: Any?) : super(String.format(message, *args), cause)\r
+\r
+    constructor(code: Int, cause: Throwable) : super(cause) {\r
+        this.code = code\r
+    }\r
+\r
+    constructor(code: Int, message: String) : super(message) {\r
+        this.code = code\r
+    }\r
+\r
+    constructor(code: Int, message: String, cause: Throwable) : super(message, cause) {\r
+        this.code = code\r
+    }\r
+\r
+    constructor(code: Int, cause: Throwable, message: String, vararg args: Any?)\r
+            : super(String.format(message, *args), cause) {\r
+        this.code = code\r
+    }\r
+}\r
+\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt
new file mode 100644 (file)
index 0000000..5071703
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class BluePrintProcessorException : Exception {\r
+    var code: Int = 100\r
+\r
+    constructor(message: String, cause: Throwable) : super(message, cause)\r
+    constructor(message: String) : super(message)\r
+    constructor(cause: Throwable) : super(cause)\r
+    constructor(cause: Throwable, message: String, vararg args: Any?) : super(format(message, *args), cause)\r
+\r
+    constructor(code: Int, cause: Throwable) : super(cause) {\r
+        this.code = code\r
+    }\r
+\r
+    constructor(code: Int, message: String) : super(message) {\r
+        this.code = code\r
+    }\r
+\r
+    constructor(code: Int, message: String, cause: Throwable) : super(message, cause) {\r
+        this.code = code\r
+    }\r
+\r
+    constructor(code: Int, cause: Throwable, message: String, vararg args: Any?)\r
+            : super(String.format(message, *args), cause) {\r
+        this.code = code\r
+    }\r
+}\r
+\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
new file mode 100644 (file)
index 0000000..33c811f
--- /dev/null
@@ -0,0 +1,91 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object BluePrintTypes {\r
+\r
+    @JvmStatic\r
+    fun validModelTypes(): List<String> {\r
+        val validTypes: MutableList<String> = arrayListOf()\r
+        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)\r
+        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)\r
+        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)\r
+        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)\r
+        validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)\r
+        return validTypes\r
+    }\r
+\r
+    @JvmStatic\r
+    fun validPropertyTypes(): List<String> {\r
+        val validTypes: MutableList<String> = arrayListOf()\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_STRING)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_NULL)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_LIST)\r
+        return validTypes\r
+    }\r
+\r
+    @JvmStatic\r
+    fun validPrimitiveTypes(): List<String> {\r
+        val validTypes: MutableList<String> = arrayListOf()\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_STRING)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_NULL)\r
+        return validTypes\r
+    }\r
+\r
+    @JvmStatic\r
+    fun validCollectionTypes(): List<String> {\r
+        val validTypes: MutableList<String> = arrayListOf()\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_LIST)\r
+        validTypes.add(BluePrintConstants.DATA_TYPE_MAP)\r
+        return validTypes\r
+    }\r
+\r
+    @JvmStatic\r
+    fun validCommands(): List<String> {\r
+        return listOf(BluePrintConstants.EXPRESSION_GET_INPUT,\r
+                BluePrintConstants.EXPRESSION_GET_ATTRIBUTE,\r
+                BluePrintConstants.EXPRESSION_GET_PROPERTY,\r
+                BluePrintConstants.EXPRESSION_GET_ARTIFACT,\r
+                BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT,\r
+                BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun rootNodeTypes(): List<String> {\r
+        return listOf(BluePrintConstants.MODEL_TYPE_NODES_ROOT)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun rootDataTypes(): List<String> {\r
+        return listOf(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)\r
+    }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
new file mode 100644 (file)
index 0000000..8459220
--- /dev/null
@@ -0,0 +1,44 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object ConfigModelConstant {\r
+\r
+    const val MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON"\r
+    const val MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE"\r
+\r
+    const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"\r
+\r
+    const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"\r
+\r
+    const val MODEL_TYPE_CAPABILITY_NETCONF = "tosca.capability.Netconf"\r
+    const val MODEL_TYPE_CAPABILITY_SSH = "tosca.capability.Ssh"\r
+    const val MODEL_TYPE_CAPABILITY_SFTP = "tosca.capability.Sftp"\r
+    const val MODEL_TYPE_CAPABILITY_CHEF = "tosca.capability.Chef"\r
+    const val MODEL_TYPE_CAPABILITY_ANSIBLEF = "tosca.capability.Ansible"\r
+\r
+    const val CAPABILITY_PROPERTY_MAPPING = "mapping"\r
+\r
+    const val PROPERTY_RECIPE_NAMES = "action-names"\r
+\r
+}\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
new file mode 100644 (file)
index 0000000..7302f2b
--- /dev/null
@@ -0,0 +1,75 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core\r
+\r
+import org.slf4j.helpers.MessageFormatter\r
+import java.io.File\r
+import java.io.InputStream\r
+import kotlin.reflect.KClass\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+\r
+fun format(message: String, vararg args: Any?) : String{\r
+    if(args != null && args.isNotEmpty()){\r
+        return MessageFormatter.arrayFormat(message, args).message\r
+    }\r
+   return message\r
+}\r
+\r
+fun <T : Any> MutableMap<String, *>.getCastOptionalValue(key: String, valueType: KClass<T>): T? {\r
+    if (containsKey(key)) {\r
+        return get(key) as? T\r
+    } else {\r
+        return null\r
+    }\r
+}\r
+\r
+fun <T : Any> MutableMap<String, *>.getCastValue(key: String, valueType: KClass<T>): T {\r
+    if (containsKey(key)) {\r
+        return get(key) as T\r
+    } else {\r
+        throw BluePrintException("couldn't find the key " + key)\r
+    }\r
+}\r
+\r
+fun checkNotEmpty(value : String?) : Boolean{\r
+    return value != null && value.isNotEmpty()\r
+}\r
+\r
+fun checkNotEmptyNThrow(value : String?, message : String? = value.plus(" is null/empty ")) : Boolean{\r
+    val notEmpty = value != null && value.isNotEmpty()\r
+    if(!notEmpty){\r
+        throw BluePrintException(message!!)\r
+    }\r
+    return notEmpty\r
+}\r
+\r
+fun InputStream.toFile(path: String) : File {\r
+    val file = File(path)\r
+    file.outputStream().use { this.copyTo(it) }\r
+    return file\r
+}\r
+\r
+\r
+\r
+\r
+\r
+\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt
new file mode 100644 (file)
index 0000000..c0eb13f
--- /dev/null
@@ -0,0 +1,70 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.data\r
+\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.ObjectNode\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+data class ExpressionData(\r
+        var isExpression: Boolean = false,\r
+        var valueNode: JsonNode,\r
+        var expressionNode: ObjectNode? = null,\r
+        var inputExpression: InputExpression? = null,\r
+        var propertyExpression: PropertyExpression? = null,\r
+        var attributeExpression: AttributeExpression? = null,\r
+        var artifactExpression: ArtifactExpression? = null,\r
+        var operationOutputExpression: OperationOutputExpression? = null,\r
+        var command: String? = null\r
+)\r
+\r
+data class InputExpression(\r
+        var propertyName: String\r
+)\r
+\r
+data class PropertyExpression(\r
+        var modelableEntityName: String = "SELF",\r
+        var reqOrCapEntityName: String? = null,\r
+        var propertyName: String,\r
+        var subPropertyName: String?  = null\r
+)\r
+\r
+data class AttributeExpression(\r
+        var modelableEntityName: String = "SELF",\r
+        var reqOrCapEntityName: String? = null,\r
+        var attributeName: String,\r
+        var subAttributeName: String? = null\r
+)\r
+\r
+data class ArtifactExpression(\r
+        val modelableEntityName: String = "SELF",\r
+        val artifactName: String,\r
+        val location: String? =  "LOCAL_FILE",\r
+        val remove: Boolean? = false\r
+)\r
+\r
+data class OperationOutputExpression(\r
+        val modelableEntityName: String = "SELF",\r
+        val interfaceName: String,\r
+        val operationName: String,\r
+        val propertyName: String\r
+)\r
+\r
+\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
new file mode 100644 (file)
index 0000000..ef8bbf2
--- /dev/null
@@ -0,0 +1,612 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.data\r
+\r
+import com.fasterxml.jackson.annotation.JsonIgnore\r
+import com.fasterxml.jackson.annotation.JsonProperty\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import io.swagger.annotations.ApiModelProperty\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+open class EntityType {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    var version: String = "1.0.0"\r
+    var metadata: MutableMap<String, String>? = null\r
+    @get:JsonProperty("derived_from")\r
+    lateinit var derivedFrom: String\r
+    var attributes: MutableMap<String, AttributeDefinition>? = null\r
+    var properties: MutableMap<String, PropertyDefinition>? = null\r
+}\r
+\r
+/*\r
+ 5.3.2 tosca.datatypes.Credential\r
+ The Credential type is a complex TOSCA data Type used when describing\r
+ authorization credentials used to access network accessible resources.\r
+ */\r
+class Credential {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var protocol: String? = null\r
+    @get:JsonProperty("token_type")\r
+    lateinit var tokenType: String\r
+    lateinit var token: String\r
+    var keys: MutableMap<String, String>? = null\r
+    lateinit var user: String\r
+}\r
+\r
+/*\r
+3.5.2 Constraint clause\r
+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.\r
+ */\r
+class ConstraintClause {\r
+    @get:JsonProperty("equal")\r
+    var equal: JsonNode? = null\r
+    @get:JsonProperty("greater_than")\r
+    var greaterThan: Any? = null\r
+    @get:JsonProperty("greater_or_equal")\r
+    var greaterOrEqual: Any? = null\r
+    @get:JsonProperty("less_than")\r
+    var lessThan: Any? = null\r
+    @get:JsonProperty("less_or_equal")\r
+    var lessOrEqual: Any? = null\r
+    @get:JsonProperty("in_range")\r
+    var inRange: Any? = null\r
+    @get:JsonProperty("valid_values")\r
+    var validValues: MutableList<JsonNode>? = null\r
+    @get:JsonProperty("length")\r
+    var length: Any? = null\r
+    @get:JsonProperty("min_length")\r
+    var minLength: Any? = null\r
+    @get:JsonProperty("max_length")\r
+    var maxLength: Any? = null\r
+    var pattern: String? = null\r
+    var schema: String? = null\r
+}\r
+\r
+/*\r
+3.5.4 Node Filter definition\r
+A node filter definition defines criteria for selection of a TOSCA Node Template based upon the template’s property values, capabilities and capability properties.\r
+ */\r
+\r
+class NodeFilterDefinition {\r
+    var properties: MutableMap<String, PropertyDefinition>? = null\r
+    var capabilities : MutableList<String>? = null\r
+}\r
+\r
+/*\r
+3.5.5 Repository definition\r
+ A repository definition defines a named external repository which contains deployment\r
+ and implementation artifacts that are referenced within the TOSCA Service Template.\r
+*/\r
+class RepositoryDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    lateinit var url: String\r
+    var credential: Credential? = null\r
+}\r
+\r
+\r
+/*\r
+3.5.6 Artifact definition\r
+An artifact definition defines a named, typed file that can be associated with Node Type\r
+or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations.\r
+ */\r
+class ArtifactDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var type: String? = null\r
+    var file: String? = null\r
+    var repository: String? = null\r
+    var description: String? = null\r
+    @get:JsonProperty("deploy_Path")\r
+    var deployPath: String? = null\r
+    var properties: MutableMap<String, JsonNode>? = null\r
+    var content: String? = null\r
+    @Deprecated("Mapping content is define by the Type")\r
+    var mappingContent: String? = null\r
+}\r
+\r
+\r
+/*\r
+3.5.7 Import definition\r
+An import definition is used within a TOSCA Service Template to locate and uniquely name\r
+another TOSCA Service Template file which has type and template definitions to be imported (included)\r
+and referenced within another Service Template.\r
+ */\r
+class ImportDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    lateinit var file: String\r
+    var repository: String? = null\r
+    @get:JsonProperty("namespace_uri")\r
+    var namespaceUri: String? = null\r
+    @get:JsonProperty("namespace_prefix")\r
+    var namespacePrefix: String? = null\r
+}\r
+\r
+/*\r
+3.5.8 Property definition A property definition defines a named, typed value and related data that can be associated with an\r
+entity defined in this specification (e.g., Node Types, Relationship Types, Capability Types, etc.).\r
+Properties are used by template authors to provide input values to TOSCA entities which indicate their “desired state” when they are\r
+instantiated. The value of a property can be retrieved using the get_property function within TOSCA Service Templates.\r
+ */\r
+class PropertyDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    var required: Boolean? = null\r
+    lateinit var type: String\r
+    @get:JsonProperty("default")\r
+    var defaultValue: JsonNode? = null\r
+    var status: String? = null\r
+    var constraints: MutableList<ConstraintClause>? = null\r
+    @get:JsonProperty("entry_schema")\r
+    var entrySchema: EntrySchema? = null\r
+    @get:ApiModelProperty(notes = "Property Value, It may be raw JSON or primitive data type values")\r
+    var value: JsonNode? = null\r
+}\r
+\r
+\r
+/*\r
+3.5.10 Attribute definition\r
+\r
+An attribute definition defines a named, typed value that can be associated with an entity defined in this\r
+specification (e.g., a Node, Relationship or Capability Type).  Specifically, it is used to expose the\r
+“actual state” of some property of a TOSCA entity after it has been deployed and instantiated\r
+(as set by the TOSCA orchestrator). Attribute values can be retrieved via the get_attribute function\r
+from the instance model and used as values to other entities within TOSCA Service Templates.\r
+ */\r
+\r
+class AttributeDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    lateinit var type: String\r
+    @JsonProperty("default")\r
+    var defaultValue: JsonNode? = null\r
+    var status: String? = null\r
+    @JsonProperty("entry_schema")\r
+    var entrySchema: String? = null\r
+}\r
+\r
+/*\r
+3.5.13 Operation definition\r
+An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script).\r
+ */\r
+class OperationDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    var implementation: Implementation? = null\r
+    var inputs: MutableMap<String, PropertyDefinition>? = null\r
+    var outputs: MutableMap<String, PropertyDefinition>? = null\r
+}\r
+\r
+class Implementation {\r
+    lateinit var primary: String\r
+    var dependencies: MutableList<String>? = null\r
+}\r
+\r
+/*\r
+3.5.14 Interface definition\r
+An interface definition defines a named interface that can be associated with a Node or Relationship Type\r
+ */\r
+class InterfaceDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var type: String? = null\r
+    var operations: MutableMap<String, OperationDefinition>? = null\r
+    var inputs: MutableMap<String, PropertyDefinition>? = null\r
+}\r
+\r
+/*\r
+3.5.15 Event Filter definition\r
+An event filter definition defines criteria for selection of an attribute, for the purpose of monitoring it, within a TOSCA entity, or one its capabilities.\r
+ */\r
+class EventFilterDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    lateinit var node: String\r
+    var requirement: String? = null\r
+    var capability: String? = null\r
+}\r
+\r
+/*\r
+3.5.16 Trigger definition TODO\r
+A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with.\r
+ */\r
+class TriggerDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    @get:JsonProperty("event_type")\r
+    lateinit var eventType: String\r
+    @get:JsonProperty("target_filter")\r
+    var targetFilter: EventFilterDefinition? = null\r
+    var condition: ConditionClause? = null\r
+    var constraint: ConditionClause? = null\r
+    var method: String? = null\r
+    lateinit var action: String\r
+}\r
+\r
+/*\r
+    3.5.17 Workflow activity definition\r
+    A workflow activity defines an operation to be performed in a TOSCA workflow. Activities allows to:\r
+    · Delegate the workflow for a node expected to be provided        by the orchestrator\r
+    · Set the state of a node\r
+    · Call an operation       defined on a TOSCA interface of a node, relationship or group\r
+    · Inline another workflow defined in the topology (to allow reusability)\r
+ */\r
+class Activity {\r
+    var delegate: String? = null\r
+    @get:JsonProperty("set_state")\r
+    var setState: String? = null\r
+    @get:JsonProperty("call_operation")\r
+    var callOperation: String? = null\r
+    var inlines: ArrayList<String>? = null\r
+}\r
+\r
+/*\r
+3.5.20 Workflow precondition definition\r
+A workflow condition can be used as a filter or precondition to check if a workflow can be processed or not based on the state of the instances of a TOSCA topology deployment. When not met, the workflow will not be triggered.\r
+ */\r
+class PreConditionDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    lateinit var target: String\r
+    @get:JsonProperty("target_relationship")\r
+    lateinit var targetRelationship: String\r
+    lateinit var condition: ArrayList<ConditionClause>\r
+}\r
+\r
+/*\r
+3.5.21 Workflow step definition\r
+A workflow step allows to define one or multiple sequenced activities in a workflow and how they are connected to other steps in the workflow. They are the building blocks of a declarative workflow.\r
+ */\r
+class Step {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    var target: String? = null\r
+    @JsonProperty("target_relationship")\r
+    var targetRelationship: String? = null\r
+    @JsonProperty("operation_host")\r
+    var operationHost: String? = null\r
+    var activities: ArrayList<Activity>? = null\r
+    @get:JsonProperty("on_success")\r
+    var onSuccess: ArrayList<String>? = null\r
+    @get:JsonProperty("on_failure")\r
+    var onFailure: ArrayList<String>? = null\r
+}\r
+\r
+/*\r
+3.6.2 Capability definition\r
+A capability definition defines a named, typed set of data that can be associated with Node Type or Node Template to describe a transparent capability or feature of the software component the node describes.\r
+ */\r
+\r
+class CapabilityDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var type: String? = null\r
+    var description: String? = null\r
+    var properties: MutableMap<String, PropertyDefinition>? = null\r
+    @get:JsonProperty("valid_source_types")\r
+    var validSourceTypes: MutableList<String>? = null\r
+    var occurrences: MutableList<Any>? = null\r
+}\r
+\r
+/*\r
+3.6.3 Requirement definition\r
+The Requirement definition describes a named requirement (dependencies) of a TOSCA Node Type or Node template which needs to be fulfilled by a matching Capability definition declared by another TOSCA modelable entity.  The requirement definition may itself include the specific name of the fulfilling entity (explicitly) or provide an abstract type, along with additional filtering characteristics, that a TOSCA orchestrator can use to fulfill the capability at runtime (implicitly).\r
+ */\r
+class RequirementDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    var capability: String? = null\r
+    var node: String? = null\r
+    var relationship: String? = null\r
+    var occurrences: MutableList<Any>? = null\r
+}\r
+\r
+/*\r
+3.6.4 Artifact Type\r
+An Artifact Type is a reusable entity that defines the type of one or more files that are used to define implementation or deployment artifacts that are referenced by nodes or relationships on their operations.\r
+ */\r
+class ArtifactType : EntityType() {\r
+    @get:JsonProperty("mime_type")\r
+    var mimeType: String? = null\r
+    @get:JsonProperty("file_ext")\r
+    var fileExt: MutableList<String>? = null\r
+\r
+}\r
+\r
+/*\r
+3.6.6 Data Type\r
+A Data Type definition defines the schema for new named datatypes in TOSCA.\r
+ */\r
+\r
+class DataType : EntityType(){\r
+    var constraints: MutableList<ConstraintClause>? = null\r
+}\r
+\r
+/*\r
+3.6.9 Node Type\r
+A Node Type is a reusable entity that defines the type of one or more Node Templates. As such, a Node Type defines the structure of observable properties via a Properties Definition, the Requirements and Capabilities of the node as well as its supported interfaces.\r
+\r
+ */\r
+\r
+class NodeType : EntityType() {\r
+    var capabilities: MutableMap<String, CapabilityDefinition>? = null\r
+    var requirements: MutableMap<String, RequirementDefinition>? = null\r
+    var interfaces: MutableMap<String, InterfaceDefinition>? = null\r
+    var artifacts: MutableMap<String, ArtifactDefinition>? = null\r
+}\r
+\r
+/*\r
+3.6.8 Requirement Type\r
+A Requirement Type is a reusable entity that describes a kind of requirement that a Node Type can declare to expose.  The TOSCA Simple Profile seeks to simplify the need for declaring specific Requirement Types from nodes and instead rely upon nodes declaring their features sets using TOSCA Capability Types along with a named Feature notation.\r
+ */\r
+\r
+class RequirementType : EntityType() {\r
+    var requirements: MutableMap<String, RequirementDefinition>? = null\r
+    var capabilities: MutableMap<String, CapabilityDefinition>? = null\r
+    var interfaces: MutableMap<String, InterfaceDefinition>? = null\r
+    var artifacts: MutableMap<String, ArtifactDefinition>? = null\r
+}\r
+\r
+/*\r
+3.6.10 Relationship Type\r
+A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates.\r
+*/\r
+\r
+class RelationshipType : EntityType() {\r
+    var interfaces: MutableMap<String, InterfaceDefinition>? = null\r
+    @get:JsonProperty("valid_target_types")\r
+    var validTargetTypes: ArrayList<String>? = null\r
+}\r
+\r
+/*\r
+3.6.11 Group Type\r
+A Group Type defines logical grouping types for nodes, typically for different management purposes.\r
+Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology\r
+ of an application, yet can have capabilities and the ability to attach policies and interfaces\r
+ that can be applied (depending on the group type) to its member nodes.\r
+ */\r
+\r
+class GroupType : EntityType() {\r
+    var members: MutableList<String>? = null\r
+    var requirements: ArrayList<RequirementDefinition>? = null\r
+    var capabilities: MutableMap<String, CapabilityDefinition>? = null\r
+    var interfaces: MutableMap<String, InterfaceDefinition>? = null\r
+\r
+}\r
+\r
+/*\r
+    3.6.12 Policy Type\r
+    A Policy Type defines a type of requirement that affects or governs an application or service’s\r
+    topology at some stage of its lifecycle, but is not explicitly part of the topology itself\r
+    (i.e., it does not prevent the application or service from being deployed or run if it did not exist).\r
+ */\r
+class PolicyType : EntityType(){\r
+    lateinit var targets: MutableList<String>\r
+}\r
+\r
+/*\r
+3.7.1 Capability assignment\r
+A capability assignment allows node template authors to assign values to properties and attributes for a named capability definition that is part of a Node Template’s type definition.\r
+ */\r
+class CapabilityAssignment {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var attributes: MutableMap<String, JsonNode>? = null\r
+    var properties: MutableMap<String, JsonNode>? = null\r
+}\r
+\r
+/*\r
+3.7.4 Relationship Template\r
+A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template.  A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations.\r
+ */\r
+class GroupDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    lateinit var type: String\r
+    var description: String? = null\r
+    var metadata : MutableMap<String, String>? = null\r
+    var properties : MutableMap<String, JsonNode>? = null\r
+    var members = ArrayList<String>()\r
+    var interfaces : MutableMap<String, InterfaceDefinition>?= null\r
+}\r
+\r
+/*\r
+3.7.6 Policy definition\r
+A policy definition defines a policy that can be associated with a TOSCA topology or top-level entity definition (e.g., group definition, node template, etc.).\r
+ */\r
+class PolicyDefinition {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    lateinit var type: String\r
+    var description: String? = null\r
+    var metadata: MutableMap<String, String>? = null\r
+    var properties: MutableMap<String, JsonNode>? = null\r
+    var targets: MutableList<String>? = null\r
+}\r
+\r
+\r
+/*\r
+3.8 Topology Template definition\r
+This section defines the topology template of a cloud application. The main ingredients of the topology template are node templates representing components of the application and relationship templates representing links between the components. These elements are defined in the nested node_templates section and the nested relationship_templates sections, respectively.  Furthermore, a topology template allows for defining input parameters, output parameters as well as grouping of node templates.\r
+ */\r
+class TopologyTemplate {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    var inputs: MutableMap<String, PropertyDefinition>? = null\r
+    @get:JsonProperty("node_templates")\r
+    var nodeTemplates: MutableMap<String, NodeTemplate>? = null\r
+    @get:JsonProperty("relationship_templates")\r
+    var relationshipTemplates: MutableMap<String, RelationshipTemplate>? = null\r
+    var policies: MutableMap<String, PolicyDefinition>? = null\r
+    var outputs: MutableMap<String, PropertyDefinition>? = null\r
+    @get:JsonProperty("substitution_mappings")\r
+    var substitutionMappings: Any? = null\r
+    var workflows: MutableMap<String, Workflow>? = null\r
+}\r
+\r
+class SubstitutionMapping {\r
+    @get:JsonProperty("node_type")\r
+    lateinit var nodeType: String\r
+    lateinit var capabilities: ArrayList<String>\r
+    lateinit var requirements: ArrayList<String>\r
+}\r
+\r
+class EntrySchema {\r
+    lateinit var type: String\r
+    var constraints: MutableList<ConstraintClause>? = null\r
+}\r
+\r
+class InterfaceAssignment {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var operations: MutableMap<String, OperationAssignment>? = null\r
+    var inputs: MutableMap<String, JsonNode>? = null\r
+}\r
+\r
+/*\r
+3.7.3 Node Template\r
+A Node Template specifies the occurrence of a manageable software component as part of an application’s topology model which is defined in a TOSCA Service Template.  A Node template is an instance of a specified Node Type and can provide customized properties, constraints or operations which override the defaults provided by its Node Type and its implementations.\r
+ */\r
+\r
+class NodeTemplate {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    lateinit var type: String\r
+    var metadata: MutableMap<String, String>? = null\r
+    var directives: MutableList<String>? = null\r
+    //@get:JsonSerialize(using = PropertyDefinitionValueSerializer::class)\r
+    var properties: MutableMap<String, JsonNode>? = null\r
+    var attributes: MutableMap<String, JsonNode>? = null\r
+    var capabilities: MutableMap<String, CapabilityAssignment>? = null\r
+    var requirements: MutableMap<String, RequirementAssignment>? = null\r
+    var interfaces: MutableMap<String, InterfaceAssignment>? = null\r
+    var artifacts: MutableMap<String, ArtifactDefinition>? = null\r
+    @get:JsonProperty("node_filter")\r
+    var nodeFilter: NodeFilterDefinition? = null\r
+    var copy: String? = null\r
+}\r
+\r
+class OperationAssignment {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    var implementation: Implementation? = null\r
+    var inputs: MutableMap<String, JsonNode>? = null\r
+    var outputs: MutableMap<String, JsonNode>? = null\r
+}\r
+\r
+/*\r
+3.7.4 Relationship Template\r
+A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template.  A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations.\r
+ */\r
+\r
+class RelationshipTemplate {\r
+    var type: String? = null\r
+    var description: String? = null\r
+    var metadata: MutableMap<String, String>? = null\r
+    var properties: MutableMap<String, PropertyDefinition>? = null\r
+    var attributes: MutableMap<String, JsonNode>? = null\r
+    var interfaces: MutableMap<String, InterfaceDefinition>? = null\r
+    var copy: String? = null\r
+}\r
+\r
+/*\r
+3.7.2 Requirement assignment\r
+A Requirement assignment allows template authors to provide either concrete names of TOSCA templates or provide abstract selection criteria for providers to use to find matching TOSCA templates that are used to fulfill a named requirement’s declared TOSCA Node Type.\r
+ */\r
+\r
+class RequirementAssignment {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var capability: String? = null\r
+    var node: String? = null\r
+    //Relationship Type or Relationship Template\r
+    var relationship: String? = null\r
+}\r
+\r
+\r
+class Workflow {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    var description: String? = null\r
+    var steps: MutableMap<String, Step>? = null\r
+    var preconditions: ArrayList<PreConditionDefinition>? = null\r
+    var inputs: MutableMap<String, PropertyDefinition>? = null\r
+}\r
+\r
+\r
+class ConditionClause {\r
+    var and: ArrayList<MutableMap<String, Any>>? = null\r
+    var or: ArrayList<MutableMap<String, Any>>? = null\r
+    @get:JsonProperty("assert")\r
+    var assertConditions: ArrayList<MutableMap<String, Any>>? = null\r
+}\r
+\r
+/*\r
+3.9 Service Template definition\r
+A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document.\r
+ */\r
+\r
+class ServiceTemplate {\r
+    @get:JsonIgnore\r
+    var id: String? = null\r
+    @get:JsonProperty("tosca_definitions_version")\r
+    var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0"\r
+    var metadata: MutableMap<String, String>? = null\r
+    var description: String? = null\r
+    @get:JsonProperty("dsl_definitions")\r
+    var dslDefinitions: MutableMap<String, Any>? = null\r
+    var repositories: MutableMap<String, RepositoryDefinition>? = null\r
+    var imports: MutableList<ImportDefinition>? = null\r
+    @get:JsonProperty("artifact_types")\r
+    var artifactTypes: MutableMap<String, ArtifactType>? = null\r
+    @get:JsonProperty("data_types")\r
+    var dataTypes: MutableMap<String, DataType>? = null\r
+    @get:JsonProperty("node_types")\r
+    var nodeTypes: MutableMap<String, NodeType>? = null\r
+    @get:JsonProperty("policy_types")\r
+    var policyTypes: PolicyType? = null\r
+    @get:JsonProperty("topology_template")\r
+    var topologyTemplate: TopologyTemplate? = null\r
+}\r
+\r
+class ToscaMetaData {\r
+    lateinit var toscaMetaFileVersion: String\r
+    lateinit var csarVersion: String\r
+    lateinit var createdBy: String\r
+    lateinit var entityDefinitions: String\r
+    var templateTags: String? = null\r
+}\r
+\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt
new file mode 100644 (file)
index 0000000..d796597
--- /dev/null
@@ -0,0 +1,45 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.factory\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+\r
+\r
+/**\r
+ * BluePrintEnhancerFactory\r
+ * @author Brinda Santh\r
+ *\r
+ */\r
+\r
+object BluePrintEnhancerFactory {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    var bluePrintEnhancerServices: MutableMap<String, BluePrintEnhancerService> = HashMap()\r
+\r
+    fun register(key: String, bluePrintEnhancerService: BluePrintEnhancerService) {\r
+        bluePrintEnhancerServices[key] = bluePrintEnhancerService\r
+    }\r
+\r
+    /**\r
+     * Called by clients to get a Blueprint Parser for the Blueprint parser type\r
+     */\r
+    fun instance(key: String): BluePrintEnhancerService? {\r
+        return bluePrintEnhancerServices.get(key)\r
+    }\r
+}\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt
new file mode 100644 (file)
index 0000000..83233ab
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.factory\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintParserDefaultService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintParserService\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+\r
+/**\r
+ *\r
+ * BluePrintParserFactory\r
+ * @author Brinda Santh\r
+ */\r
+\r
+object BluePrintParserFactory {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    var bluePrintParserServices: MutableMap<String, BluePrintParserService> = HashMap()\r
+\r
+    init {\r
+        log.info("Initialised default BluePrintParser Service ")\r
+        bluePrintParserServices.put(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT, BluePrintParserDefaultService())\r
+    }\r
+\r
+    fun register(key:String, bluePrintParserService: BluePrintParserService){\r
+        bluePrintParserServices.put(key, bluePrintParserService)\r
+    }\r
+\r
+    /**\r
+     * Called by clients to get a Blueprint Parser for the Blueprint parser type\r
+     */\r
+    fun instance(key : String) : BluePrintParserService? {\r
+        return bluePrintParserServices.get(key)\r
+    }\r
+}\r
+\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt
new file mode 100644 (file)
index 0000000..63f788a
--- /dev/null
@@ -0,0 +1,45 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.factory\r
+\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorService\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+\r
+object BluePrintValidatorFactory {\r
+\r
+    var bluePrintValidatorServices: MutableMap<String, BluePrintValidatorService> = HashMap()\r
+\r
+    init {\r
+        bluePrintValidatorServices[org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT] = BluePrintValidatorDefaultService()\r
+    }\r
+\r
+    fun register(key:String, bluePrintValidatorService: BluePrintValidatorService){\r
+        bluePrintValidatorServices[key] = bluePrintValidatorService\r
+    }\r
+\r
+    fun instance(key : String) : BluePrintValidatorService?{\r
+        return bluePrintValidatorServices[key]\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt
new file mode 100644 (file)
index 0000000..0651763
--- /dev/null
@@ -0,0 +1,117 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class BluePrintChainedService {\r
+    var bpc : BluePrintContext\r
+\r
+    constructor(bpc : BluePrintContext){\r
+        this.bpc = bpc\r
+    }\r
+\r
+    fun nodeTypeChained(nodeTypeName: String): NodeType {\r
+\r
+        val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName)\r
+        val attributes = hashMapOf<String, AttributeDefinition>()\r
+        val properties = hashMapOf<String, PropertyDefinition>()\r
+        val requirements = hashMapOf<String, RequirementDefinition>()\r
+        val capabilities = hashMapOf<String, CapabilityDefinition>()\r
+        val interfaces = hashMapOf<String, InterfaceDefinition>()\r
+        val artifacts = hashMapOf<String, ArtifactDefinition>()\r
+\r
+        recNodeTypesChained(nodeTypeName).forEach { nodeType ->\r
+\r
+            val subAttributes =  bpc.nodeTypeByName(nodeType.id!!).attributes\r
+            if (subAttributes != null) {\r
+                attributes.putAll(subAttributes)\r
+            }\r
+\r
+            val subProperties =  bpc.nodeTypeByName(nodeType.id!!).properties\r
+            if (subProperties != null) {\r
+                properties.putAll(subProperties)\r
+            }\r
+\r
+            val subRequirements =  bpc.nodeTypeByName(nodeType.id!!).requirements\r
+            if (subRequirements != null) {\r
+                requirements.putAll(subRequirements)\r
+            }\r
+            val subCapabilities =  bpc.nodeTypeByName(nodeType.id!!).capabilities\r
+            if (subCapabilities != null) {\r
+                capabilities.putAll(subCapabilities)\r
+            }\r
+            val subInterfaces =  bpc.nodeTypeByName(nodeType.id!!).interfaces\r
+            if (subInterfaces != null) {\r
+                interfaces.putAll(subInterfaces)\r
+            }\r
+\r
+            val subArtifacts =  bpc.nodeTypeByName(nodeType.id!!).artifacts\r
+            if (subArtifacts != null) {\r
+                artifacts.putAll(subArtifacts)\r
+            }\r
+        }\r
+        nodeType.attributes = attributes\r
+        nodeType.properties = properties\r
+        nodeType.requirements = requirements\r
+        nodeType.capabilities = capabilities\r
+        nodeType.interfaces = interfaces\r
+        nodeType.artifacts = artifacts\r
+        return nodeType\r
+    }\r
+\r
+    fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap<String, PropertyDefinition>? {\r
+        val nodeType =  bpc.nodeTypeByName(nodeTypeName)\r
+        val properties = hashMapOf<String, PropertyDefinition>()\r
+\r
+        recNodeTypesChained(nodeTypeName).forEach { nodeType ->\r
+            val subProperties =  bpc.nodeTypeByName(nodeType.id!!).properties\r
+            if (subProperties != null) {\r
+                properties.putAll(subProperties)\r
+            }\r
+        }\r
+        return properties\r
+    }\r
+\r
+    private fun recNodeTypesChained(nodeTypeName: String, nodeTypes: MutableList<NodeType>? = arrayListOf()): MutableList<NodeType> {\r
+        val nodeType: NodeType =  bpc.nodeTypeByName(nodeTypeName)\r
+        nodeType.id = nodeTypeName\r
+        val derivedFrom: String = nodeType.derivedFrom\r
+        if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {\r
+            recNodeTypesChained(derivedFrom, nodeTypes)\r
+        }\r
+        nodeTypes!!.add(nodeType)\r
+        return nodeTypes\r
+    }\r
+\r
+    private fun recDataTypesChained(dataTypeName: String, dataTypes: MutableList<DataType>? = arrayListOf()): MutableList<DataType> {\r
+        val dataType: DataType =  bpc.dataTypeByName(dataTypeName)!!\r
+        dataType.id = dataTypeName\r
+        val derivedFrom: String = dataType.derivedFrom\r
+        if (!BluePrintTypes.rootDataTypes().contains(derivedFrom)) {\r
+            recDataTypesChained(derivedFrom, dataTypes)\r
+        }\r
+        dataTypes!!.add(dataType)\r
+        return dataTypes\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
new file mode 100644 (file)
index 0000000..875cbea
--- /dev/null
@@ -0,0 +1,177 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class BluePrintContext(serviceTemplate: ServiceTemplate) {\r
+\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    val serviceTemplate: ServiceTemplate = serviceTemplate\r
+\r
+    val imports: List<ImportDefinition>? = serviceTemplate.imports\r
+\r
+    val metadata: MutableMap<String, String>? = serviceTemplate.metadata\r
+\r
+    val dataTypes: MutableMap<String, DataType>? = serviceTemplate.dataTypes\r
+\r
+    val inputs: MutableMap<String, PropertyDefinition>? = serviceTemplate.topologyTemplate?.inputs\r
+\r
+    val workflows: MutableMap<String, Workflow>? = serviceTemplate.topologyTemplate?.workflows\r
+\r
+    fun blueprintJson(pretty: Boolean = false): String = print("json", pretty)\r
+\r
+    fun blueprintYaml(pretty: Boolean = false): String = print("yaml", pretty)\r
+\r
+    private fun print(type: String? = "json", pretty: Boolean = false): String {\r
+        return JacksonUtils.getJson(serviceTemplate, pretty)\r
+    }\r
+\r
+    // Workflow\r
+    fun workflowByName(name: String): Workflow? = workflows?.get(name)\r
+\r
+    // Data Type\r
+    fun dataTypeByName(name: String): DataType? = dataTypes?.get(name)\r
+\r
+    // Artifact Type\r
+    val artifactTypes: MutableMap<String, ArtifactType>? = serviceTemplate.artifactTypes\r
+\r
+    // Node Type Methods\r
+    val nodeTypes: MutableMap<String, NodeType>? = serviceTemplate.nodeTypes\r
+\r
+    fun nodeTypeByName(name: String): NodeType =\r
+            nodeTypes?.get(name) ?: throw BluePrintException(String.format("Failed to get node type for the name : %s", name))\r
+\r
+    fun nodeTypeDerivedFrom(name: String): MutableMap<String, NodeType>? {\r
+        return nodeTypes?.filterValues { nodeType -> nodeType.derivedFrom == name }?.toMutableMap()\r
+    }\r
+\r
+    fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition? {\r
+        return nodeTypeByName(nodeTypeName).interfaces?.values?.first()\r
+    }\r
+\r
+    fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition? {\r
+        return nodeTypeInterface(nodeTypeName, interfaceName)?.operations?.get(operationName)\r
+    }\r
+\r
+    fun interfaceNameForNodeType(nodeTypeName: String): String? {\r
+        return nodeTypeByName(nodeTypeName).interfaces?.keys?.first()\r
+    }\r
+\r
+    fun nodeTypeInterfaceOperationInputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap<String, PropertyDefinition>? {\r
+        return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName)?.inputs\r
+    }\r
+\r
+    fun nodeTypeInterfaceOperationOutputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap<String, PropertyDefinition>? {\r
+        return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName)?.outputs\r
+    }\r
+\r
+    // Node Template Methods\r
+    val nodeTemplates: MutableMap<String, NodeTemplate>? = serviceTemplate.topologyTemplate?.nodeTemplates\r
+\r
+    fun nodeTemplateByName(name: String): NodeTemplate =\r
+            nodeTemplates?.get(name) ?: throw BluePrintException("Failed to get node template for the name " + name)\r
+\r
+    fun nodeTemplateForNodeType(name: String): MutableMap<String, NodeTemplate>? {\r
+        return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap()\r
+    }\r
+\r
+    fun nodeTemplateNodeType(nodeTemplateName: String): NodeType {\r
+        val nodeTemplateType: String = nodeTemplateByName(nodeTemplateName).type\r
+        return nodeTypeByName(nodeTemplateType)\r
+    }\r
+\r
+    fun nodeTemplateProperty(nodeTemplateName: String, propertyName: String): Any? {\r
+        return nodeTemplateByName(nodeTemplateName).properties?.get(propertyName)\r
+    }\r
+\r
+    fun nodeTemplateArtifacts(nodeTemplateName: String): MutableMap<String, ArtifactDefinition>? {\r
+        return nodeTemplateByName(nodeTemplateName).artifacts\r
+    }\r
+\r
+    fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition? {\r
+        return nodeTemplateArtifacts(nodeTemplateName)?.get(artifactName)\r
+    }\r
+\r
+    fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment? {\r
+        return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first()\r
+    }\r
+\r
+    fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String? {\r
+        return nodeTemplateByName(nodeTemplateName).interfaces?.keys?.first()\r
+    }\r
+\r
+    fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String? {\r
+        return nodeTemplateFirstInterface(nodeTemplateName)?.operations?.keys?.first()\r
+    }\r
+\r
+    fun nodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>? {\r
+        return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)?.operations?.get(operationName)?.inputs\r
+    }\r
+\r
+    fun nodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>? {\r
+        return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)?.operations?.get(operationName)?.outputs\r
+    }\r
+\r
+    fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment? {\r
+        return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)\r
+    }\r
+\r
+\r
+    fun nodeTemplateInterfaceOperation(nodeTemplateName: String, interfaceName: String, operationName: String): OperationAssignment? {\r
+        return nodeTemplateInterface(nodeTemplateName, interfaceName)?.operations?.get(operationName)\r
+    }\r
+\r
+    fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment? {\r
+        return nodeTemplateByName(nodeTemplateName).capabilities?.get(capabilityName)\r
+    }\r
+\r
+    fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment? {\r
+        return nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)\r
+    }\r
+\r
+    fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate {\r
+        val nodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node\r
+                ?: throw BluePrintException(String.format("failed to get node name for node template's (%s) requirement's (%s) " + nodeTemplateName, requirementName))\r
+        return nodeTemplateByName(nodeTemplateName)\r
+    }\r
+\r
+    fun nodeTemplateCapabilityProperty(nodeTemplateName: String, capabilityName: String, propertyName: String): Any? {\r
+        return nodeTemplateCapability(nodeTemplateName, capabilityName)?.properties?.get(propertyName)\r
+    }\r
+\r
+    // Chained Functions\r
+\r
+    fun nodeTypeChained(nodeTypeName: String): NodeType {\r
+        return BluePrintChainedService(this).nodeTypeChained(nodeTypeName)\r
+    }\r
+\r
+    fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap<String, PropertyDefinition>? {\r
+        return BluePrintChainedService(this).nodeTypeChainedProperties(nodeTypeName)\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
new file mode 100644 (file)
index 0000000..f38c317
--- /dev/null
@@ -0,0 +1,259 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
+import org.onap.ccsdk.apps.controllerblueprints.core.format\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils\r
+import java.io.Serializable\r
+\r
+/**\r
+ * BluePrintEnhancerService\r
+ * @author Brinda Santh\r
+ *\r
+ */\r
+interface BluePrintEnhancerService : Serializable {\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun enhance(content: String): ServiceTemplate\r
+\r
+    /**\r
+     * Read Blueprint from CSAR structure Directory\r
+     */\r
+    @Throws(BluePrintException::class)\r
+    fun enhance(fileName: String, basePath: String): ServiceTemplate\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate)\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun enrichNodeType(nodeTypeName: String, nodeType: NodeType)\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition)\r
+}\r
+\r
+open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {\r
+\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerDefaultService::class.toString())\r
+\r
+    lateinit var serviceTemplate: ServiceTemplate\r
+\r
+    @Throws(BluePrintException::class)\r
+    override fun enhance(content: String): ServiceTemplate {\r
+        return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate ->\r
+            enhance(serviceTemplate!!)\r
+        }.block()!!\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    override fun enhance(fileName: String, basePath: String): ServiceTemplate {\r
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate {\r
+        this.serviceTemplate = serviceTemplate\r
+        initialCleanUp()\r
+        enrichTopologyTemplate(serviceTemplate)\r
+\r
+        // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true))\r
+        return this.serviceTemplate\r
+    }\r
+\r
+    open fun initialCleanUp() {\r
+        serviceTemplate.artifactTypes?.clear()\r
+        serviceTemplate.nodeTypes?.clear()\r
+        serviceTemplate.dataTypes?.clear()\r
+\r
+        serviceTemplate.artifactTypes = HashMap()\r
+        serviceTemplate.nodeTypes = HashMap()\r
+        serviceTemplate.dataTypes = HashMap()\r
+\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun enrichTopologyTemplate(serviceTemplate: ServiceTemplate) {\r
+        serviceTemplate.topologyTemplate?.let { topologyTemplate ->\r
+            enrichTopologyTemplateInputs(topologyTemplate)\r
+            enrichTopologyTemplateNodeTemplates(topologyTemplate)\r
+        }\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun enrichTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {\r
+        topologyTemplate.inputs?.let { inputs ->\r
+            enrichPropertyDefinitions(inputs)\r
+        }\r
+    }\r
+\r
+    open fun enrichTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) {\r
+        topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate ->\r
+            enrichNodeTemplate(nodeTemplateName, nodeTemplate)\r
+        }\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    override fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {\r
+        val nodeTypeName = nodeTemplate.type\r
+        // Get NodeType from Repo and Update Service Template\r
+        val nodeType = populateNodeType(nodeTypeName)\r
+\r
+        // Enrich NodeType\r
+        enrichNodeType(nodeTypeName, nodeType)\r
+\r
+        //Enrich Node Template Artifacts\r
+        enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {\r
+\r
+        // NodeType Property Definitions\r
+        enrichNodeTypeProperties(nodeTypeName, nodeType)\r
+\r
+        //NodeType Requirement\r
+        enrichNodeTypeRequirements(nodeTypeName, nodeType)\r
+\r
+        //NodeType Capability\r
+        enrichNodeTypeCapabilityProperties(nodeTypeName, nodeType)\r
+\r
+        //NodeType Interface\r
+        enrichNodeTypeInterfaces(nodeTypeName, nodeType)\r
+    }\r
+\r
+    open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) {\r
+        nodeType.properties?.let { enrichPropertyDefinitions(nodeType.properties!!) }\r
+    }\r
+\r
+    open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) {\r
+\r
+        nodeType.requirements?.forEach { _, requirementDefinition ->\r
+            // Populate Requirement Node\r
+            requirementDefinition.node?.let { requirementNodeTypeName ->\r
+                // Get Requirement NodeType from Repo and Update Service Template\r
+                val requirementNodeType = populateNodeType(requirementNodeTypeName)\r
+\r
+                enrichNodeType(requirementNodeTypeName, requirementNodeType)\r
+            }\r
+        }\r
+    }\r
+\r
+    open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {\r
+        nodeType.capabilities?.forEach { capabilityDefinitionName, capabilityDefinition ->\r
+            capabilityDefinition.properties?.let { properties ->\r
+                enrichPropertyDefinitions(properties)\r
+            }\r
+        }\r
+    }\r
+\r
+    open fun enrichNodeTypeInterfaces(nodeTypeName: String, nodeType: NodeType) {\r
+        nodeType.interfaces?.forEach { interfaceName, interfaceObj ->\r
+            // Populate Node type Interface Operation\r
+            log.info("*** ** Enriching NodeType: {} Interface {}", nodeTypeName, interfaceName)\r
+            populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj)\r
+\r
+        }\r
+    }\r
+\r
+    open fun populateNodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, interfaceObj: InterfaceDefinition) {\r
+\r
+        interfaceObj.operations?.forEach { operationName, operation ->\r
+            enrichNodeTypeInterfaceOperationInputs(nodeTypeName, operationName, operation)\r
+            enrichNodeTypeInterfaceOperationOputputs(nodeTypeName, operationName, operation)\r
+        }\r
+    }\r
+\r
+    open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {\r
+        operation.inputs?.let { inputs ->\r
+            enrichPropertyDefinitions(inputs)\r
+        }\r
+    }\r
+\r
+    open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {\r
+        operation.outputs?.let { inputs ->\r
+            enrichPropertyDefinitions(inputs)\r
+        }\r
+    }\r
+\r
+    open fun enrichPropertyDefinitions(properties: MutableMap<String, PropertyDefinition>) {\r
+\r
+        properties.forEach { propertyName, propertyDefinition ->\r
+            enrichPropertyDefinition(propertyName, propertyDefinition)\r
+        }\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    override fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {\r
+        val propertyType = propertyDefinition.type\r
+        if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {\r
+\r
+        } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {\r
+            val entrySchema = propertyDefinition.entrySchema\r
+                    ?: throw BluePrintException(format("Entry Schema is missing for collection property : {}", propertyName))\r
+\r
+            if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {\r
+                populateDataTypes(entrySchema.type)\r
+            }\r
+        } else {\r
+            populateDataTypes(propertyType)\r
+        }\r
+\r
+    }\r
+\r
+    open fun enrichNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) {\r
+\r
+        nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition ->\r
+            val artifactTypeName = artifactDefinition.type\r
+                    ?: throw BluePrintException(format("Artifact type is missing for NodeTemplate({}) artifact({})", nodeTemplateName, artifactDefinitionName))\r
+\r
+            // Populate Artifact Type\r
+            populateArtifactType(artifactTypeName)\r
+        }\r
+    }\r
+\r
+    open fun populateNodeType(nodeTypeName: String): NodeType {\r
+        val nodeType = bluePrintRepoService.getNodeType(nodeTypeName)?.block()\r
+                ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))\r
+        serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)\r
+        return nodeType\r
+    }\r
+\r
+    open fun populateArtifactType(artifactTypeName: String): ArtifactType {\r
+        val artifactType = bluePrintRepoService.getArtifactType(artifactTypeName)?.block()\r
+                ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))\r
+        serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)\r
+        return artifactType\r
+    }\r
+\r
+    open fun populateDataTypes(dataTypeName: String): DataType {\r
+        val dataType = bluePrintRepoService.getDataType(dataTypeName)?.block()\r
+                ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))\r
+        serviceTemplate.dataTypes?.put(dataTypeName, dataType)\r
+        return dataType\r
+    }\r
+\r
+}\r
+\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt
new file mode 100644 (file)
index 0000000..19d515e
--- /dev/null
@@ -0,0 +1,176 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.ArrayNode\r
+import com.fasterxml.jackson.databind.node.ObjectNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object BluePrintExpressionService {\r
+    val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    @JvmStatic\r
+    fun getExpressionData(propertyAssignment: Any): ExpressionData {\r
+        val propertyAssignmentNode: JsonNode = JacksonUtils.jsonNodeFromObject(propertyAssignment)\r
+        return getExpressionData(propertyAssignmentNode)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData {\r
+        log.trace("Assignment Data/Expression : {}", propertyAssignmentNode)\r
+        val expressionData = ExpressionData(valueNode = propertyAssignmentNode)\r
+        if (propertyAssignmentNode is ObjectNode) {\r
+\r
+            val commands: Set<String> = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BluePrintTypes.validCommands())\r
+            if (commands.isNotEmpty()) {\r
+                expressionData.isExpression = true\r
+                expressionData.command = commands.first()\r
+                expressionData.expressionNode = propertyAssignmentNode\r
+\r
+                when (expressionData.command) {\r
+                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT -> {\r
+                        expressionData.inputExpression = populateInputExpression(propertyAssignmentNode)\r
+                    }\r
+                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> {\r
+                        expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode)\r
+                    }\r
+                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY -> {\r
+                        expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode)\r
+                    }\r
+                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> {\r
+                        expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode)\r
+                    }\r
+                    org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT -> {\r
+                        expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode)\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        return expressionData\r
+    }\r
+\r
+    @JvmStatic\r
+    fun populateInputExpression(jsonNode: JsonNode): InputExpression {\r
+        return InputExpression(propertyName = jsonNode.first().textValue())\r
+    }\r
+\r
+    @JvmStatic\r
+    fun populatePropertyExpression(jsonNode: JsonNode): PropertyExpression {\r
+        val arrayNode: ArrayNode = jsonNode.first() as ArrayNode\r
+        check(arrayNode.size() >= 2) {\r
+            throw BluePrintException(String.format("missing property expression, " +\r
+                    "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, " +\r
+                    "<nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ] , but present {}", jsonNode))\r
+        }\r
+        var reqOrCapEntityName: String? = null\r
+        var propertyName = ""\r
+        var subProperty: String? = null\r
+        when {\r
+            arrayNode.size() == 2 -> propertyName = arrayNode[1].textValue()\r
+            arrayNode.size() == 3 -> {\r
+                reqOrCapEntityName = arrayNode[1].textValue()\r
+                propertyName = arrayNode[2].textValue()\r
+            }\r
+            arrayNode.size() > 3 -> {\r
+                reqOrCapEntityName = arrayNode[1].textValue()\r
+                propertyName = arrayNode[2].textValue()\r
+                val propertyPaths: List<String> = arrayNode.filterIndexed { index, obj ->\r
+                    index >= 3\r
+                }.map { it.textValue() }\r
+                subProperty = propertyPaths.joinToString("/")\r
+            }\r
+        }\r
+\r
+        return PropertyExpression(modelableEntityName = arrayNode[0].asText(),\r
+                reqOrCapEntityName = reqOrCapEntityName,\r
+                propertyName = propertyName,\r
+                subPropertyName = subProperty\r
+        )\r
+    }\r
+\r
+    @JvmStatic\r
+    fun populateAttributeExpression(jsonNode: JsonNode): AttributeExpression {\r
+        val arrayNode: ArrayNode = jsonNode.first() as ArrayNode\r
+        check(arrayNode.size() >= 3) {\r
+            throw BluePrintException(String.format("missing attribute expression, " +\r
+                    "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <attribute_name>," +\r
+                    " <nested_attribute_name_or_index_1>, ..., <nested_attribute_name_or_index_n> ] , but present {}", jsonNode))\r
+        }\r
+\r
+        var reqOrCapEntityName: String? = null\r
+        var propertyName = ""\r
+        var subProperty: String? = null\r
+        if (arrayNode.size() == 2) {\r
+            propertyName = arrayNode[1].textValue()\r
+        } else if (arrayNode.size() == 3) {\r
+            reqOrCapEntityName = arrayNode[1].textValue()\r
+            propertyName = arrayNode[2].textValue()\r
+        } else if (arrayNode.size() > 3) {\r
+            reqOrCapEntityName = arrayNode[1].textValue()\r
+            propertyName = arrayNode[2].textValue()\r
+            val propertyPaths: List<String> = arrayNode.filterIndexed { index, obj ->\r
+                index >= 3\r
+            }.map { it.textValue() }\r
+            subProperty = propertyPaths.joinToString("/")\r
+        }\r
+        return AttributeExpression(modelableEntityName = arrayNode[0].asText(),\r
+                reqOrCapEntityName = reqOrCapEntityName,\r
+                attributeName = propertyName,\r
+                subAttributeName = subProperty\r
+        )\r
+    }\r
+\r
+    @JvmStatic\r
+    fun populateOperationOutputExpression(jsonNode: JsonNode): OperationOutputExpression {\r
+        val arrayNode: ArrayNode = jsonNode.first() as ArrayNode\r
+\r
+        check(arrayNode.size() >= 4) {\r
+            throw BluePrintException(String.format("missing operation output expression, " +\r
+                    "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}", jsonNode))\r
+        }\r
+        return OperationOutputExpression(modelableEntityName = arrayNode[0].asText(),\r
+                interfaceName = arrayNode[1].asText(),\r
+                operationName = arrayNode[2].asText(),\r
+                propertyName = arrayNode[3].asText()\r
+        )\r
+    }\r
+\r
+    @JvmStatic\r
+    fun populateArtifactExpression(jsonNode: JsonNode): ArtifactExpression {\r
+        val arrayNode: ArrayNode = jsonNode.first() as ArrayNode\r
+\r
+        check(arrayNode.size() >= 2) {\r
+            throw BluePrintException(String.format("missing artifact expression, " +\r
+                    "it should be [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ] , but present {}", jsonNode))\r
+        }\r
+        return ArtifactExpression(modelableEntityName = arrayNode[0].asText(),\r
+                artifactName = arrayNode[1].asText(),\r
+                location = arrayNode[2]?.asText() ?: "LOCAL_FILE",\r
+                remove = arrayNode[3]?.asBoolean() ?: false\r
+        )\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt
new file mode 100644 (file)
index 0000000..43267ff
--- /dev/null
@@ -0,0 +1,62 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import java.io.File\r
+import java.io.Serializable\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+interface BluePrintParserService : Serializable {\r
+    fun readBlueprint(content: String) : BluePrintContext\r
+    fun readBlueprintFile(fileName: String) : BluePrintContext\r
+    /**\r
+     * Read Blueprint from CSAR structure Directory\r
+     */\r
+    fun readBlueprintFile(fileName: String, basePath : String) : BluePrintContext\r
+}\r
+\r
+class BluePrintParserDefaultService : BluePrintParserService {\r
+\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    var basePath : String = javaClass.classLoader.getResource(".").path\r
+\r
+    override fun readBlueprint(content: String): BluePrintContext {\r
+        return BluePrintContext(ServiceTemplateUtils.getServiceTemplateFromContent(content))\r
+    }\r
+\r
+    override fun readBlueprintFile(fileName: String): BluePrintContext {\r
+        return readBlueprintFile(fileName, basePath )\r
+    }\r
+\r
+    override fun readBlueprintFile(fileName: String, basePath : String): BluePrintContext {\r
+        val rootFilePath: String = StringBuilder().append(basePath).append(File.separator).append(fileName).toString()\r
+        val rootServiceTemplate : ServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)\r
+        // TODO("Nested Lookup Implementation based on Import files")\r
+        return BluePrintContext(rootServiceTemplate)\r
+    }\r
+\r
+\r
+}\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
new file mode 100644 (file)
index 0000000..a7c14ad
--- /dev/null
@@ -0,0 +1,98 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils\r
+import reactor.core.publisher.Mono\r
+import java.io.Serializable\r
+\r
+/**\r
+ * BluePrintRepoFileService\r
+ * @author Brinda Santh\r
+ *\r
+ */\r
+\r
+interface BluePrintRepoService : Serializable {\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun getNodeType(nodeTypeName: String): Mono<NodeType>?\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun getDataType(dataTypeName: String): Mono<DataType>?\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>?\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>?\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>?\r
+\r
+}\r
+\r
+\r
+open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService {\r
+\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString())\r
+\r
+    private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)\r
+    private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)\r
+    private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)\r
+    private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)\r
+    private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)\r
+    private val extension = ".json"\r
+\r
+    override fun getDataType(dataTypeName: String): Mono<DataType>? {\r
+        val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
+                .plus(dataTypeName).plus(extension)\r
+        return getModelType(fileName, DataType::class.java)\r
+    }\r
+\r
+    override fun getNodeType(nodeTypeName: String): Mono<NodeType>? {\r
+        val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension)\r
+        return getModelType(fileName, NodeType::class.java)\r
+    }\r
+\r
+    override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>? {\r
+        val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
+                .plus(artifactTypeName).plus(extension)\r
+        return getModelType(fileName, ArtifactType::class.java)\r
+    }\r
+\r
+    override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>? {\r
+        val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
+                .plus(relationshipTypeName).plus(extension)\r
+        return getModelType(fileName, RelationshipType::class.java)\r
+    }\r
+\r
+    override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>? {\r
+        val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
+                .plus(capabilityDefinitionName).plus(extension)\r
+        return getModelType(fileName, CapabilityDefinition::class.java)\r
+    }\r
+\r
+    private fun <T> getModelType(fileName: String, valueType: Class<T>): Mono<T> {\r
+        return JacksonReactorUtils.readValueFromFile(fileName, valueType)\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
new file mode 100644 (file)
index 0000000..ce0bcee
--- /dev/null
@@ -0,0 +1,278 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.NullNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var context: MutableMap<String, Any> = hashMapOf()) {\r
+\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString())\r
+\r
+    /*\r
+        Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing\r
+     */\r
+    open fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, Any?> {\r
+        log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName)\r
+        val propertyAssignmentValue: MutableMap<String, Any?> = hashMapOf()\r
+\r
+        val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)\r
+\r
+        val propertyAssignments: MutableMap<String, Any?> =\r
+                nodeTemplate.properties as MutableMap<String, Any?>\r
+\r
+        // Get the Node Type Definitions\r
+        val nodeTypeProperties: MutableMap<String, PropertyDefinition> =\r
+                bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!!\r
+\r
+        // Iterate Node Type Properties\r
+        nodeTypeProperties.forEach { nodeTypePropertyName, nodeTypeProperty ->\r
+            // Get the Express or Value for the Node Template\r
+            val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName]\r
+\r
+            var resolvedValue: JsonNode = NullNode.getInstance()\r
+            if (propertyAssignment != null) {\r
+                // Resolve the Expressing\r
+                val propertyAssignmentExpression = PropertyAssignmentService(context, this)\r
+                resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)\r
+            } else {\r
+                // Assign default value to the Operation\r
+                nodeTypeProperty.defaultValue?.let { defaultValue ->\r
+                    resolvedValue = defaultValue\r
+                }\r
+            }\r
+            // Set for Return of method\r
+            propertyAssignmentValue[nodeTypePropertyName] = resolvedValue\r
+        }\r
+        log.info("resolved property definition for node template ({}), values ({})", nodeTemplateName, propertyAssignmentValue)\r
+        return propertyAssignmentValue\r
+    }\r
+\r
+    open fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String,\r
+                                                    interfaceName: String, operationName: String): MutableMap<String, Any?> {\r
+        log.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " +\r
+                "operationName({})", nodeTemplateName, interfaceName, operationName)\r
+\r
+        val propertyAssignmentValue: MutableMap<String, Any?> = hashMapOf()\r
+\r
+        val propertyAssignments: MutableMap<String, Any> =\r
+                bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>\r
+                        ?: throw BluePrintException(String.format("failed to get input definitions for node template (%s), " +\r
+                                "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName))\r
+\r
+        val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type\r
+\r
+        val nodeTypeInterfaceOperationInputs: MutableMap<String, PropertyDefinition> =\r
+                bluePrintContext.nodeTypeInterfaceOperationInputs(nodeTypeName, interfaceName, operationName)\r
+                        ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " +\r
+                                "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName))\r
+\r
+        log.info("input definition for node template ({}), values ({})", nodeTemplateName, propertyAssignments)\r
+\r
+        // Iterate Node Type Properties\r
+        nodeTypeInterfaceOperationInputs.forEach { nodeTypePropertyName, nodeTypeProperty ->\r
+            // Get the Express or Value for the Node Template\r
+            val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName]\r
+\r
+            var resolvedValue: JsonNode = NullNode.getInstance()\r
+            if (propertyAssignment != null) {\r
+                // Resolve the Expressing\r
+                val propertyAssignmentExpression = PropertyAssignmentService(context, this)\r
+                resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)\r
+            } else {\r
+                // Assign default value to the Operation\r
+                nodeTypeProperty.defaultValue?.let {\r
+                    resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!)\r
+                }\r
+            }\r
+            // Set for Return of method\r
+            propertyAssignmentValue[nodeTypePropertyName] = resolvedValue\r
+        }\r
+        log.info("resolved input assignments for node template ({}), values ({})", nodeTemplateName, propertyAssignmentValue)\r
+\r
+        return propertyAssignmentValue\r
+    }\r
+\r
+\r
+    open fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String,\r
+                                                     interfaceName: String, operationName: String, componentContext: MutableMap<String, Any?>) {\r
+        log.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " +\r
+                "operationName({})", nodeTemplateName, interfaceName, operationName)\r
+\r
+        val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type\r
+\r
+        val nodeTypeInterfaceOperationOutputs: MutableMap<String, PropertyDefinition> =\r
+                bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName)\r
+                        ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " +\r
+                                "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName))\r
+\r
+        // Iterate Node Type Properties\r
+        nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty ->\r
+\r
+            val operationOutputPropertyName: String = StringBuilder().append(nodeTemplateName)\r
+                    .append(".").append(interfaceName)\r
+                    .append(".").append(operationName)\r
+                    .append(".").append(nodeTypePropertyName).toString()\r
+            // Get the Value from component context\r
+            val resolvedValue: JsonNode = componentContext[operationOutputPropertyName] as? JsonNode\r
+                    ?: NullNode.getInstance()\r
+            // Store  operation output values into context\r
+            setNodeTemplateOperationPropertyValue(nodeTemplateName, interfaceName, operationName, nodeTypePropertyName, resolvedValue)\r
+            log.debug("resolved output assignments for node template ({}), property name ({}), value ({})", nodeTemplateName, nodeTypePropertyName, resolvedValue)\r
+        }\r
+    }\r
+\r
+    open fun resolveNodeTemplateArtifact(nodeTemplateName: String,\r
+                                    artifactName: String): String {\r
+        val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)\r
+\r
+        val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName)\r
+                ?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template"\r
+                        , artifactName))\r
+        val propertyAssignmentExpression = PropertyAssignmentService(context, this)\r
+        return propertyAssignmentExpression.artifactContent(artifactDefinition)\r
+    }\r
+\r
+\r
+    open fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) {\r
+        val path = StringBuilder(BluePrintConstants.PATH_INPUTS)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        log.trace("setting input path ({}), values ({})", path, value)\r
+        context[path] = value\r
+    }\r
+\r
+    open fun setWorkflowInputValue(workflowName: String, propertyName: String, value: JsonNode) {\r
+        val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS).append(BluePrintConstants.PATH_DIVIDER).append(workflowName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        context[path] = value\r
+    }\r
+\r
+    open fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) {\r
+\r
+        val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        context[path] = value\r
+    }\r
+\r
+    open fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
+                                              value: JsonNode) {\r
+        val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        log.trace("setting operation property path ({}), values ({})", path, value)\r
+        context[path] = value\r
+    }\r
+\r
+    open fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
+                                           value: JsonNode) {\r
+        val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(interfaceName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(operationName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        context[path] = value\r
+    }\r
+\r
+    open fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String,\r
+                                            value: JsonNode) {\r
+        val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(interfaceName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(operationName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        context[path] = value\r
+    }\r
+\r
+\r
+    open fun getInputValue(propertyName: String): JsonNode {\r
+        val path = StringBuilder(BluePrintConstants.PATH_INPUTS)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        return context[path] as? JsonNode ?: NullNode.instance\r
+    }\r
+\r
+    open fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode {\r
+        val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        return context[path] as JsonNode\r
+    }\r
+\r
+    open fun getPropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? {\r
+        val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        return context[path] as JsonNode\r
+    }\r
+\r
+    open fun getRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: String): JsonNode? {\r
+        val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_REQUIREMENTS).append(requirementName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        return context[path] as JsonNode\r
+    }\r
+\r
+    open fun getCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: String): JsonNode? {\r
+        val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_CAPABILITIES).append(capabilityName)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES)\r
+                .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()\r
+        return context[path] as JsonNode\r
+    }\r
+\r
+    open fun assignInputs(jsonNode: JsonNode) {\r
+        log.info("assignInputs from input JSON ({})", jsonNode.toString())\r
+        bluePrintContext.inputs?.forEach { propertyName, property ->\r
+            val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
+                    ?: NullNode.getInstance()\r
+            setInputValue(propertyName, property, valueNode)\r
+        }\r
+    }\r
+\r
+    open fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) {\r
+        log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString())\r
+        bluePrintContext.workflowByName(workflowName)?.inputs?.forEach { propertyName, property ->\r
+            val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
+                    ?: NullNode.getInstance()\r
+            setWorkflowInputValue(workflowName, propertyName, valueNode)\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt
new file mode 100644 (file)
index 0000000..34399fd
--- /dev/null
@@ -0,0 +1,360 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.google.common.base.Preconditions\r
+import org.apache.commons.lang3.StringUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.*\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import java.io.Serializable\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+interface BluePrintValidatorService : Serializable {\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap<String, Any>)\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap<String, Any>)\r
+}\r
+\r
+open class BluePrintValidatorDefaultService : BluePrintValidatorService {\r
+\r
+    val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorDefaultService::class.toString())\r
+\r
+    lateinit var bluePrintContext: BluePrintContext\r
+    lateinit var serviceTemplate: ServiceTemplate\r
+    lateinit var properties: MutableMap<String, Any>\r
+    var message: StringBuilder = StringBuilder()\r
+    private val separator: String = BluePrintConstants.PATH_DIVIDER\r
+    var paths: MutableList<String> = arrayListOf()\r
+\r
+    @Throws(BluePrintException::class)\r
+    override fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap<String, Any>) {\r
+        validateBlueprint(bluePrintContext.serviceTemplate,properties)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    override fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap<String, Any>) {\r
+        this.bluePrintContext = BluePrintContext(serviceTemplate)\r
+        this.serviceTemplate = serviceTemplate\r
+        this.properties = properties\r
+        try {\r
+            message.appendln("-> Config Blueprint")\r
+            serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) }\r
+            serviceTemplate.artifactTypes?.let { validateArtifactTypes(serviceTemplate.artifactTypes!!) }\r
+            serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) }\r
+            serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) }\r
+            serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) }\r
+        } catch (e: Exception) {\r
+            log.error("validation failed in the path : {}", paths.joinToString(separator), e)\r
+            log.error("validation trace message :{} ", message)\r
+            throw BluePrintException(e,\r
+                    format("failed to validate blueprint on path ({}) with message {}"\r
+                            , paths.joinToString(separator), e.message))\r
+        }\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateMetadata(metaDataMap: MutableMap<String, String>) {\r
+        paths.add("metadata")\r
+\r
+        val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME]\r
+        val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION]\r
+        val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS]\r
+        val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]\r
+\r
+        Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata")\r
+        Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata")\r
+        Preconditions.checkArgument(StringUtils.isNotBlank(templateTags), "failed to get template tags metadata")\r
+        Preconditions.checkArgument(StringUtils.isNotBlank(templateAuthor), "failed to get template author metadata")\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateArtifactTypes(artifactTypes: MutableMap<String, ArtifactType>) {\r
+        paths.add("artifact_types")\r
+        artifactTypes.forEach { artifactName, artifactType ->\r
+            paths.add(artifactName)\r
+            message.appendln("--> Artifact Type :" + paths.joinToString(separator))\r
+            artifactType.properties?.let { validatePropertyDefinitions(artifactType.properties!!) }\r
+            paths.removeAt(paths.lastIndex)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateDataTypes(dataTypes: MutableMap<String, DataType>) {\r
+        paths.add("dataTypes")\r
+        dataTypes.forEach { dataTypeName, dataType ->\r
+            paths.add(dataTypeName)\r
+            message.appendln("--> Data Type :" + paths.joinToString(separator))\r
+            dataType.properties?.let { validatePropertyDefinitions(dataType.properties!!) }\r
+            paths.removeAt(paths.lastIndex)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateNodeTypes(nodeTypes: MutableMap<String, NodeType>) {\r
+        paths.add("nodeTypes")\r
+        nodeTypes.forEach { nodeTypeName, nodeType ->\r
+            // Validate Single Node Type\r
+            validateNodeType(nodeTypeName,nodeType)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateNodeType(nodeTypeName: String, nodeType: NodeType) {\r
+        paths.add(nodeTypeName)\r
+        message.appendln("--> Node Type :" + paths.joinToString(separator))\r
+        val derivedFrom: String = nodeType.derivedFrom\r
+        //Check Derived From\r
+        checkValidNodeTypesDerivedFrom(derivedFrom)\r
+\r
+        nodeType.properties?.let { validatePropertyDefinitions(nodeType.properties!!) }\r
+        nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) {\r
+        paths.add("topology")\r
+        message.appendln("--> Topology Template")\r
+        topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) }\r
+        topologyTemplate.nodeTemplates?.let { validateNodeTemplates(topologyTemplate.nodeTemplates!!) }\r
+        topologyTemplate.workflows?.let { validateWorkFlows(topologyTemplate.workflows!!) }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateInputs(inputs: MutableMap<String, PropertyDefinition>) {\r
+        paths.add("inputs")\r
+        message.appendln("---> Input :" + paths.joinToString(separator))\r
+        validatePropertyDefinitions(inputs)\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateNodeTemplates(nodeTemplates: MutableMap<String, NodeTemplate>) {\r
+        paths.add("nodeTemplates")\r
+        nodeTemplates.forEach { nodeTemplateName, nodeTemplate ->\r
+            validateNodeTemplate(nodeTemplateName, nodeTemplate)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateNodeTemplate(nodeTemplateName : String, nodeTemplate: NodeTemplate) {\r
+        paths.add(nodeTemplateName)\r
+        message.appendln("---> Node Template :" + paths.joinToString(separator))\r
+        val type: String = nodeTemplate.type\r
+\r
+        val nodeType: NodeType = serviceTemplate.nodeTypes?.get(type)\r
+                ?: throw BluePrintException(format("Failed to get node type definition  for node template : {}", nodeTemplateName))\r
+\r
+        nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) }\r
+        nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }\r
+        nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeTemplate.capabilities!!) }\r
+        nodeTemplate.requirements?.let { validateRequirementAssignments(nodeTemplate.requirements!!) }\r
+        nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeTemplate.interfaces!!) }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateWorkFlows(workflows: MutableMap<String, Workflow>) {\r
+        paths.add("workflows")\r
+        workflows.forEach { workflowName, workflow ->\r
+\r
+            // Validate Single workflow\r
+            validateWorkFlow(workflowName, workflow)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateWorkFlow(workflowName:String, workflow: Workflow) {\r
+        paths.add(workflowName)\r
+        message.appendln("---> Workflow :" + paths.joinToString(separator))\r
+        // Step Validation Start\r
+        paths.add("steps")\r
+        workflow.steps?.forEach { stepName, step ->\r
+            paths.add(stepName)\r
+            message.appendln("----> Steps :" + paths.joinToString(separator))\r
+            paths.removeAt(paths.lastIndex)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+        // Step Validation Ends\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validatePropertyDefinitions(properties: MutableMap<String, PropertyDefinition>) {\r
+        paths.add("properties")\r
+        properties.forEach { propertyName, propertyDefinition ->\r
+            paths.add(propertyName)\r
+            val dataType: String = propertyDefinition.type\r
+            when {\r
+                BluePrintTypes.validPrimitiveTypes().contains(dataType) -> {\r
+                    // Do Nothing\r
+                }\r
+                BluePrintTypes.validCollectionTypes().contains(dataType) -> {\r
+                    val entrySchemaType: String = propertyDefinition.entrySchema?.type\r
+                            ?: throw BluePrintException(format("Entry schema for data type ({}) for the property ({}) not found", dataType, propertyName))\r
+                    checkPrimitiveOrComplex(entrySchemaType, propertyName)\r
+                }\r
+                else -> checkPropertyDataType(dataType, propertyName)\r
+            }\r
+            message.appendln("property " + paths.joinToString(separator) + " of type " + dataType)\r
+            paths.removeAt(paths.lastIndex)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,\r
+                                         properties: MutableMap<String, JsonNode>) {\r
+        properties.forEach { propertyName, propertyAssignment ->\r
+            val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]\r
+                    ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName))\r
+            // Check and Validate if Expression Node\r
+            val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)\r
+            if (!expressionData.isExpression) {\r
+                checkPropertyValue(propertyDefinition, propertyAssignment)\r
+            }\r
+        }\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateArtifactDefinitions(artifacts: MutableMap<String, ArtifactDefinition>) {\r
+        paths.add("artifacts")\r
+        artifacts.forEach { artifactName, artifactDefinition ->\r
+            paths.add(artifactName)\r
+            message.appendln("Validating artifact " + paths.joinToString(separator))\r
+            val type: String = artifactDefinition.type\r
+                    ?: throw BluePrintException("type is missing for artifact definition :" + artifactName)\r
+            // Check Artifact Type\r
+            checkValidArtifactType(type)\r
+\r
+            val file: String = artifactDefinition.file\r
+                    ?: throw BluePrintException(format("file is missing for artifact definition : {}", artifactName))\r
+\r
+            paths.removeAt(paths.lastIndex)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateCapabilityAssignments(capabilities: MutableMap<String, CapabilityAssignment>) {\r
+\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateRequirementAssignments(requirements: MutableMap<String, RequirementAssignment>) {\r
+\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateInterfaceAssignments(interfaces: MutableMap<String, InterfaceAssignment>) {\r
+\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateInterfaceDefinitions(interfaces: MutableMap<String, InterfaceDefinition>) {\r
+        paths.add("interfaces")\r
+        interfaces.forEach { interfaceName, interfaceDefinition ->\r
+            paths.add(interfaceName)\r
+            message.appendln("Validating : " + paths.joinToString(separator))\r
+            interfaceDefinition.operations?.let { validateOperationDefinitions(interfaceDefinition.operations!!) }\r
+            paths.removeAt(paths.lastIndex)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateOperationDefinitions(operations: MutableMap<String, OperationDefinition>) {\r
+        paths.add("operations")\r
+        operations.forEach { opertaionName, operationDefinition ->\r
+            paths.add(opertaionName)\r
+            message.appendln("Validating : " + paths.joinToString(separator))\r
+            operationDefinition.implementation?.let { validateImplementation(operationDefinition.implementation!!) }\r
+            operationDefinition.inputs?.let { validatePropertyDefinitions(operationDefinition.inputs!!) }\r
+            operationDefinition.outputs?.let { validatePropertyDefinitions(operationDefinition.outputs!!) }\r
+            paths.removeAt(paths.lastIndex)\r
+        }\r
+        paths.removeAt(paths.lastIndex)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun validateImplementation(implementation: Implementation) {\r
+        checkNotEmptyNThrow(implementation.primary)\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun checkValidNodeType(nodeType : String) {\r
+\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun checkValidArtifactType(artifactType: String) {\r
+\r
+        serviceTemplate.artifactTypes?.containsKey(artifactType)\r
+                ?: throw BluePrintException(format("Failed to node type definition for artifact definition : {}", artifactType))\r
+    }\r
+\r
+    @Throws(BluePrintException::class)\r
+    open fun checkValidNodeTypesDerivedFrom(derivedFrom: String) {\r
+\r
+    }\r
+\r
+    private fun checkPropertyValue(propertyDefinition: PropertyDefinition, jsonNode: JsonNode) {\r
+        //log.info("validating path ({}), Property {}, value ({})", paths, propertyDefinition, jsonNode)\r
+    }\r
+\r
+    private fun checkPropertyDataType(dataType: String, propertyName: String): Boolean {\r
+        if (checkDataType(dataType)) {\r
+            return true\r
+        } else {\r
+            throw BluePrintException(format("Data type ({}) for the property ({}) not found", dataType, propertyName))\r
+        }\r
+    }\r
+\r
+    private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean {\r
+        if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) {\r
+            return true\r
+        } else {\r
+            throw BluePrintException(format("Data type ({}) for the property ({}) is not valid", dataType))\r
+        }\r
+    }\r
+\r
+    private fun checkDataType(key: String): Boolean {\r
+        return serviceTemplate.dataTypes?.containsKey(key) ?: false\r
+    }\r
+\r
+    private fun checkNodeType(key: String): Boolean {\r
+        return serviceTemplate.nodeTypes?.containsKey(key) ?: false\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
new file mode 100644 (file)
index 0000000..ece09d6
--- /dev/null
@@ -0,0 +1,200 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.NullNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
+import org.onap.ccsdk.apps.controllerblueprints.core.format\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class PropertyAssignmentService(var context: MutableMap<String, Any>,\r
+                                var bluePrintRuntimeService: BluePrintRuntimeService) {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext\r
+\r
+/*\r
+\r
+If Property Assignment is Expression.\r
+    Get the Expression\r
+    Recurssely resolve the expression\r
+ */\r
+\r
+    fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String,\r
+                                            assignment: Any): JsonNode {\r
+        val valueNode: JsonNode\r
+        log.trace("Assignment ({})", assignment)\r
+        val expressionData = BluePrintExpressionService.getExpressionData(assignment)\r
+\r
+        if (expressionData.isExpression) {\r
+            valueNode = resolveExpression(nodeTemplateName, assignmentName, expressionData)\r
+        } else {\r
+            valueNode = expressionData.valueNode\r
+        }\r
+        return valueNode\r
+    }\r
+\r
+    fun resolveExpression(nodeTemplateName: String, propName: String, expressionData: ExpressionData): JsonNode {\r
+\r
+        var valueNode: JsonNode = NullNode.getInstance()\r
+\r
+        if(expressionData.isExpression) {\r
+            val command = expressionData.command!!\r
+\r
+            when(command){\r
+                org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT ->{\r
+                    valueNode = bluePrintRuntimeService.getInputValue(expressionData.inputExpression?.propertyName!!)\r
+                }\r
+                org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE ->{\r
+                    valueNode = resolveAttributeExpression(nodeTemplateName, expressionData.attributeExpression!!)\r
+                }\r
+                org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY ->{\r
+                    valueNode = resolvePropertyExpression(nodeTemplateName, expressionData.propertyExpression!!)\r
+                }\r
+                org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT ->{\r
+                    valueNode = resolveOperationOutputExpression(nodeTemplateName, expressionData.operationOutputExpression!!)\r
+                }\r
+                org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT ->{\r
+                    valueNode = resolveArtifactExpression(nodeTemplateName, expressionData.artifactExpression!!)\r
+                }\r
+                org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE ->{\r
+\r
+                }\r
+                else ->{\r
+                    throw BluePrintException(String.format("for property ({}), command ({}) is not supported ", propName, command))\r
+                }\r
+            }\r
+        }\r
+        return valueNode\r
+    }\r
+\r
+    /*\r
+    get_property: [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>,\r
+    <nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ]\r
+ */\r
+    fun resolveAttributeExpression(nodeTemplateName: String, attributeExpression: AttributeExpression): JsonNode {\r
+        val valueNode: JsonNode\r
+\r
+        val attributeName = attributeExpression.attributeName\r
+        val subAttributeName: String? = attributeExpression.subAttributeName\r
+\r
+        var attributeNodeTemplateName = nodeTemplateName\r
+        if (!attributeExpression.modelableEntityName.equals("SELF", true)) {\r
+            attributeNodeTemplateName = attributeExpression.modelableEntityName\r
+        }\r
+\r
+        val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName)\r
+                ?: throw BluePrintException(String.format("failed to get property definitions for node template ({})'s property name ({}) ", nodeTemplateName, attributeName))\r
+\r
+        var propertyDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!!\r
+\r
+        log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression)\r
+\r
+        // Check it it is a nested expression\r
+        valueNode = resolveAssignmentExpression(attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression)\r
+\r
+//        subPropertyName?.let {\r
+//            valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName))\r
+//        }\r
+        return valueNode\r
+    }\r
+\r
+    /*\r
+        get_property: [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>,\r
+        <nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ]\r
+     */\r
+    fun resolvePropertyExpression(nodeTemplateName: String, propertyExpression: PropertyExpression): JsonNode {\r
+        val valueNode: JsonNode\r
+\r
+        val propertyName = propertyExpression.propertyName\r
+        val subPropertyName: String? = propertyExpression.subPropertyName\r
+\r
+        var propertyNodeTemplateName = nodeTemplateName\r
+        if (!propertyExpression.modelableEntityName.equals("SELF", true)) {\r
+            propertyNodeTemplateName = propertyExpression.modelableEntityName\r
+        }\r
+\r
+        val nodeTemplatePropertyExpression = bluePrintContext.nodeTemplateByName(propertyNodeTemplateName).properties?.get(propertyName)\r
+                ?: throw BluePrintException(format("failed to get property definitions for node template ({})'s property name ({}) ", nodeTemplateName, propertyName))\r
+\r
+        var propertyDefinition: PropertyDefinition = bluePrintContext.nodeTemplateNodeType(propertyNodeTemplateName).properties?.get(propertyName)!!\r
+\r
+        log.info("node template name ({}), property Name ({}) resolved value ({})", propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression)\r
+\r
+        // Check it it is a nested expression\r
+        valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression)\r
+\r
+//        subPropertyName?.let {\r
+//            valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName))\r
+//        }\r
+        return valueNode\r
+    }\r
+\r
+    /*\r
+    get_operation_output: <modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>\r
+     */\r
+    fun resolveOperationOutputExpression(nodeTemplateName: String, operationOutputExpression: OperationOutputExpression): JsonNode {\r
+        var outputNodeTemplateName = nodeTemplateName\r
+        if (!operationOutputExpression.modelableEntityName.equals("SELF", true)) {\r
+            outputNodeTemplateName = operationOutputExpression.modelableEntityName\r
+        }\r
+        return bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName,\r
+                operationOutputExpression.interfaceName, operationOutputExpression.operationName,\r
+                operationOutputExpression.propertyName)\r
+    }\r
+\r
+    /*\r
+    get_artifact: [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ]\r
+     */\r
+    fun resolveArtifactExpression(nodeTemplateName: String,  artifactExpression: ArtifactExpression): JsonNode {\r
+\r
+        var artifactNodeTemplateName = nodeTemplateName\r
+        if (!artifactExpression.modelableEntityName.equals("SELF", true)) {\r
+            artifactNodeTemplateName = artifactExpression.modelableEntityName\r
+        }\r
+        val artifactDefinition: ArtifactDefinition = bluePrintContext.nodeTemplateByName(artifactNodeTemplateName)\r
+                .artifacts?.get(artifactExpression.artifactName)\r
+                ?: throw BluePrintException(String.format("failed to get artifact definitions for node template ({})'s " +\r
+                        "artifact name ({}) ", nodeTemplateName, artifactExpression.artifactName))\r
+\r
+        return JacksonUtils.jsonNodeFromObject(artifactContent(artifactDefinition))\r
+    }\r
+\r
+    fun artifactContent(artifactDefinition: ArtifactDefinition): String {\r
+        val bluePrintBasePath: String = context[org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] as? String\r
+                ?: throw BluePrintException(String.format("failed to get property (%s) from context", org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH))\r
+\r
+        if (artifactDefinition.repository != null) {\r
+            TODO()\r
+        } else if (artifactDefinition.file != null) {\r
+            return ResourceResolverUtils.getFileContent(artifactDefinition.file!!, bluePrintBasePath)\r
+        }\r
+        return ""\r
+    }\r
+}\r
+\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
new file mode 100644 (file)
index 0000000..b7f9fc7
--- /dev/null
@@ -0,0 +1,95 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+\r
+import org.apache.commons.io.FileUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import java.io.File\r
+import java.nio.charset.Charset\r
+\r
+object BluePrintMetadataUtils {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    @JvmStatic\r
+    fun toscaMetaData(basePath: String): ToscaMetaData {\r
+        val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus("TOSCA-Metadata/TOSCA.meta")\r
+        return toscaMetaDataFromMetaFile(toscaMetaPath)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData {\r
+        val toscaMetaData = ToscaMetaData()\r
+        val lines: MutableList<String> = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset())\r
+        lines.forEach { line ->\r
+            if (line.contains(":")) {\r
+                val keyValue = line.split(":")\r
+                if (keyValue.size == 2) {\r
+                    val value: String = keyValue[1].trim()\r
+                    when (keyValue[0]) {\r
+                        "TOSCA-Meta-File-Version" -> toscaMetaData.toscaMetaFileVersion = value\r
+                        "CSAR-Version" -> toscaMetaData.csarVersion = value\r
+                        "Created-By" -> toscaMetaData.createdBy = value\r
+                        "Entry-Definitions" -> toscaMetaData.entityDefinitions = value\r
+                        "Template-Tags" -> toscaMetaData.templateTags = value\r
+                    }\r
+                }\r
+            }\r
+\r
+        }\r
+        return toscaMetaData\r
+    }\r
+\r
+    /*\r
+    fun getBluePrintContext(blueprintBasePath: String): BluePrintContext {\r
+\r
+        val metaDataFile = StringBuilder().append(blueprintBasePath).append(File.separator)\r
+                .append(BluePrintConstants.DEFAULT_TOSCA_METADATA_ENTRY_DEFINITION_FILE).toString()\r
+\r
+        val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(metaDataFile)\r
+\r
+        log.info("Processing blueprint base path ({}) and entry definition file ({})", blueprintBasePath, toscaMetaData.entityDefinitions)\r
+\r
+        return BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
+                .readBlueprintFile(toscaMetaData.entityDefinitions!!, blueprintBasePath)\r
+    }\r
+\r
+    fun getBluePrintRuntime(requestId: String, blueprintBasePath: String): BluePrintRuntimeService {\r
+\r
+        val metaDataFile = StringBuilder().append(blueprintBasePath).append(File.separator)\r
+                .append(BluePrintConstants.DEFAULT_TOSCA_METADATA_ENTRY_DEFINITION_FILE).toString()\r
+\r
+        val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(metaDataFile)\r
+\r
+        log.info("Processing blueprint base path ({}) and entry definition file ({})", blueprintBasePath, toscaMetaData.entityDefinitions)\r
+\r
+        val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
+                .readBlueprintFile(toscaMetaData.entityDefinitions!!, blueprintBasePath)\r
+\r
+        val context: MutableMap<String, Any> = hashMapOf()\r
+        context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath\r
+        context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = requestId\r
+\r
+        val bluePrintRuntimeService: BluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)\r
+\r
+        return bluePrintRuntimeService\r
+    }\r
+    */\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt
new file mode 100644 (file)
index 0000000..07b819f
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.NullNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object BluePrintRuntimeUtils {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, Any>) {\r
+        val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName)\r
+        return assignInputs(bluePrintContext, jsonNode, context)\r
+    }\r
+\r
+    fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap<String, Any>) {\r
+        val jsonNode: JsonNode = JacksonUtils.jsonNode(content)\r
+        return assignInputs(bluePrintContext, jsonNode, context)\r
+    }\r
+\r
+    fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap<String, Any>) {\r
+        log.info("assignInputs from input JSON ({})", jsonNode.toString())\r
+        bluePrintContext.inputs?.forEach { propertyName, property ->\r
+            val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance()\r
+\r
+            val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(propertyName)\r
+            log.trace("setting input path ({}), values ({})", path, valueNode)\r
+            context[path] = valueNode\r
+        }\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt
new file mode 100644 (file)
index 0000000..0ed9017
--- /dev/null
@@ -0,0 +1,108 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
+import reactor.core.publisher.Mono\r
+import reactor.core.publisher.toMono\r
+\r
+object JacksonReactorUtils {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    @JvmStatic\r
+    fun getContent(fileName: String): Mono<String> {\r
+        return JacksonUtils.getContent(fileName).toMono()\r
+    }\r
+\r
+    @JvmStatic\r
+    fun getClassPathFileContent(fileName: String): Mono<String> {\r
+        return JacksonUtils.getClassPathFileContent(fileName).toMono()\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> readValue(content: String, valueType: Class<T>): Mono<T> {\r
+        return Mono.just(jacksonObjectMapper().readValue(content, valueType))\r
+    }\r
+\r
+    @JvmStatic\r
+    fun jsonNode(content: String): Mono<JsonNode> {\r
+        return Mono.just(jacksonObjectMapper().readTree(content))\r
+    }\r
+\r
+    @JvmStatic\r
+    fun getJson(any: kotlin.Any, pretty: Boolean = false): Mono<String> {\r
+        return Mono.just(JacksonUtils.getJson(any, pretty))\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> getListFromJson(content: String, valueType: Class<T>): Mono<List<T>> {\r
+        val objectMapper = jacksonObjectMapper()\r
+        val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)\r
+        return objectMapper.readValue<List<T>>(content, javaType).toMono()\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> readValueFromFile(fileName: String, valueType: Class<T>): Mono<T> {\r
+        return getContent(fileName)\r
+                .flatMap { content ->\r
+                    readValue(content, valueType)\r
+                }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): Mono<T> {\r
+        return getClassPathFileContent(fileName)\r
+                .flatMap { content ->\r
+                    readValue(content, valueType)\r
+                }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun jsonNodeFromFile(fileName: String): Mono<JsonNode> {\r
+        return getContent(fileName)\r
+                .flatMap { content ->\r
+                    jsonNode(content)\r
+                }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun jsonNodeFromClassPathFile(fileName: String): Mono<JsonNode> {\r
+        return getClassPathFileContent(fileName)\r
+                .flatMap { content ->\r
+                    jsonNode(content)\r
+                }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> getListFromFile(fileName: String, valueType: Class<T>): Mono<List<T>> {\r
+        return getContent(fileName)\r
+                .flatMap { content ->\r
+                    getListFromJson(content, valueType)\r
+                }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): Mono<List<T>> {\r
+        return getClassPathFileContent(fileName)\r
+                .flatMap { content ->\r
+                    getListFromJson(content, valueType)\r
+                }\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
new file mode 100644 (file)
index 0000000..5075e72
--- /dev/null
@@ -0,0 +1,248 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import com.fasterxml.jackson.annotation.JsonInclude\r
+import com.fasterxml.jackson.core.type.TypeReference\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.SerializationFeature\r
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
+import org.apache.commons.io.FileUtils\r
+import org.apache.commons.io.IOUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
+import org.onap.ccsdk.apps.controllerblueprints.core.format\r
+import java.io.File\r
+import java.nio.charset.Charset\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object JacksonUtils {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    inline fun <reified T : Any> readValue(content: String): T =\r
+            jacksonObjectMapper().readValue(content, T::class.java)\r
+\r
+    @JvmStatic\r
+    fun <T> readValue(content: String, valueType: Class<T>): T? {\r
+        return jacksonObjectMapper().readValue(content, valueType)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun getContent(fileName: String): String {\r
+        return File(fileName).readText(Charsets.UTF_8)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun getClassPathFileContent(fileName: String): String {\r
+        return IOUtils.toString(JacksonUtils::class.java.classLoader\r
+                .getResourceAsStream(fileName), Charset.defaultCharset())\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {\r
+        val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
+                ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+        return readValue(content, valueType)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {\r
+        val content: String = getClassPathFileContent(fileName)\r
+        return readValue(content, valueType)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java)\r
+\r
+    @JvmStatic\r
+    fun jsonNodeFromClassPathFile(fileName: String): JsonNode {\r
+        val content: String = getClassPathFileContent(fileName)\r
+        return jsonNode(content)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun jsonNodeFromFile(fileName: String): JsonNode {\r
+        val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
+                ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+        return jsonNode(content)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun jsonNode(content: String): JsonNode {\r
+        return jacksonObjectMapper().readTree(content)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun getJson(any: kotlin.Any): String {\r
+        return getJson(any, false)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun getJson(any: kotlin.Any, pretty: Boolean = false): String {\r
+        val objectMapper = jacksonObjectMapper()\r
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)\r
+        if (pretty) {\r
+            objectMapper.enable(SerializationFeature.INDENT_OUTPUT)\r
+        }\r
+        return objectMapper.writeValueAsString(any)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {\r
+        val objectMapper = jacksonObjectMapper()\r
+        val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)\r
+        return objectMapper.readValue<List<T>>(content, javaType)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {\r
+        val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
+                ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+        return getListFromJson(content, valueType)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {\r
+        val content: String = getClassPathFileContent(fileName)\r
+        return getListFromJson(content, valueType)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {\r
+        val objectMapper = jacksonObjectMapper()\r
+        val typeRef = object : TypeReference<MutableMap<String, T>>() {}\r
+        return objectMapper.readValue(content, typeRef)\r
+    }\r
+\r
+    @JvmStatic\r
+    fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {\r
+        if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
+            return checkJsonNodeValueOfPrimitiveType(type, jsonNode)\r
+        } else if (BluePrintTypes.validCollectionTypes().contains(type)) {\r
+            return checkJsonNodeValueOfCollectionType(type, jsonNode)\r
+        }\r
+        return false\r
+    }\r
+\r
+    @JvmStatic\r
+    fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {\r
+        when (primitiveType) {\r
+            BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual\r
+            BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean\r
+            BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt\r
+            BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble\r
+            BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual\r
+            else -> return false\r
+        }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {\r
+        when (type) {\r
+            BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray\r
+            BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode\r
+            else -> return false\r
+        }\r
+\r
+    }\r
+/*\r
+    @JvmStatic\r
+    fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {\r
+        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
+            objectNode.put(key, value as Boolean)\r
+        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
+            objectNode.put(key, value as Int)\r
+        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
+            objectNode.put(key, value as Float)\r
+        } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {\r
+            objectNode.put(key, value as String)\r
+        } else {\r
+            objectNode.put(key, value as String)\r
+        }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun populatePrimitiveValues(value: Any, primitiveType: String, objectNode: ArrayNode) {\r
+        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
+            objectNode.add(value as Boolean)\r
+        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
+            objectNode.add(value as Int)\r
+        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
+            objectNode.add(value as Float)\r
+        } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) {\r
+            objectNode.add(value as String)\r
+        } else {\r
+            objectNode.add(value as String)\r
+        }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {\r
+        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
+            objectNode.put(key, false)\r
+        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
+            objectNode.put(key, 0)\r
+        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
+            objectNode.put(key, 0.0)\r
+        } else {\r
+            objectNode.put(key, "")\r
+        }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {\r
+        if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {\r
+            arrayNode.add(false)\r
+        } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) {\r
+            arrayNode.add(0)\r
+        } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) {\r
+            arrayNode.add(0.0)\r
+        } else {\r
+            arrayNode.add("")\r
+        }\r
+    }\r
+\r
+    @JvmStatic\r
+    fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) {\r
+        if (nodeValue == null || nodeValue is NullNode) {\r
+            objectNode.set(key, nodeValue)\r
+        } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
+            if (BluePrintConstants.DATA_TYPE_BOOLEAN == type) {\r
+                objectNode.put(key, nodeValue.asBoolean())\r
+            } else if (BluePrintConstants.DATA_TYPE_INTEGER == type) {\r
+                objectNode.put(key, nodeValue.asInt())\r
+            } else if (BluePrintConstants.DATA_TYPE_FLOAT == type) {\r
+                objectNode.put(key, nodeValue.floatValue())\r
+            } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == type) {\r
+                objectNode.put(key, nodeValue.asText())\r
+            } else {\r
+                objectNode.put(key, nodeValue.asText())\r
+            }\r
+        } else {\r
+            objectNode.set(key, nodeValue)\r
+        }\r
+    }\r
+    */\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt
new file mode 100644 (file)
index 0000000..bc0d9b4
--- /dev/null
@@ -0,0 +1,62 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+import org.apache.commons.io.FileUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import java.io.File\r
+import java.net.URL\r
+import java.nio.charset.Charset\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object ResourceResolverUtils {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    @JvmStatic\r
+    fun getFileContent(filename : String, basePath : String?): String {\r
+        log.trace("file ({}), basePath ({}) ", filename, basePath)\r
+        try{\r
+            var resolvedFileName : String = filename\r
+            if(filename.startsWith("http", true)\r
+                    || filename.startsWith("https", true)){\r
+                val givenUrl : String = URL(filename).toString()\r
+                val systemUrl : String = File(".").toURI().toURL().toString()\r
+                log.trace("givenUrl ({}), systemUrl ({}) ", givenUrl, systemUrl)\r
+                if(givenUrl.startsWith(systemUrl)){\r
+\r
+                }\r
+            }else{\r
+                if(!filename.startsWith("/")){\r
+                    if (checkNotEmpty(basePath)) {\r
+                        resolvedFileName = basePath.plus(File.separator).plus(filename)\r
+                    }else{\r
+                        resolvedFileName = javaClass.classLoader.getResource(".").path.plus(filename)\r
+                    }\r
+                }\r
+            }\r
+            return FileUtils.readFileToString(File(resolvedFileName), Charset.defaultCharset())\r
+        }catch (e : Exception){\r
+            throw BluePrintException(e, "failed to file (%s), basePath (%s) ", filename, basePath)\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt
new file mode 100644 (file)
index 0000000..0d73935
--- /dev/null
@@ -0,0 +1,44 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+import org.apache.commons.io.FileUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate\r
+import java.io.File\r
+import java.nio.charset.Charset\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object ServiceTemplateUtils {\r
+\r
+    @JvmStatic\r
+    fun getServiceTemplate(fileName: String): ServiceTemplate {\r
+        val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
+        return getServiceTemplateFromContent(content)\r
+    }\r
+\r
+\r
+    @JvmStatic\r
+    fun getServiceTemplateFromContent(content: String): ServiceTemplate {\r
+        return JacksonUtils.readValue(content)\r
+    }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt
new file mode 100644 (file)
index 0000000..dcafa97
--- /dev/null
@@ -0,0 +1,131 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+import java.util.*\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class TopologicalSortingUtils<V> {\r
+\r
+    private val neighbors: MutableMap<V, MutableList<V>> = hashMapOf()\r
+\r
+    val isDag: Boolean\r
+        get() = topSort() != null\r
+\r
+    override fun toString(): String {\r
+        val s = StringBuffer()\r
+        for (v in neighbors.keys)\r
+            s.append("\n    " + v + " -> " + neighbors[v])\r
+        return s.toString()\r
+    }\r
+\r
+    fun getNeighbors(): Map<V, List<V>> {\r
+        return neighbors\r
+    }\r
+\r
+    fun add(vertex: V) {\r
+        if (neighbors.containsKey(vertex))\r
+            return\r
+        neighbors[vertex] = arrayListOf()\r
+    }\r
+\r
+    operator fun contains(vertex: V): Boolean {\r
+        return neighbors.containsKey(vertex)\r
+    }\r
+\r
+    fun add(from: V, to: V) {\r
+        this.add(from)\r
+        this.add(to)\r
+        neighbors[from]?.add(to)\r
+    }\r
+\r
+    fun remove(from: V, to: V) {\r
+        if (!(this.contains(from) && this.contains(to)))\r
+            throw IllegalArgumentException("Nonexistent vertex")\r
+        neighbors[from]?.remove(to)\r
+    }\r
+\r
+    fun outDegree(): Map<V, Int> {\r
+        var result: MutableMap<V, Int> = hashMapOf()\r
+        for (v in neighbors.keys)\r
+            result[v] = neighbors[v]!!.size\r
+        return result\r
+    }\r
+\r
+\r
+    fun inDegree(): MutableMap<V, Int> {\r
+        val result = HashMap<V, Int>()\r
+        for (v in neighbors.keys)\r
+            result[v] = 0       // All in-degrees are 0\r
+        for (from in neighbors.keys) {\r
+            for (to in neighbors[from]!!) {\r
+                result[to] = result[to]!! + 1           // Increment in-degree\r
+            }\r
+        }\r
+        return result\r
+    }\r
+\r
+    fun topSort(): List<V>? {\r
+        val degree = inDegree()\r
+        // Determine all vertices with zero in-degree\r
+        val zeroVerts = Stack<V>()        // Stack as good as any here\r
+        for (v in degree.keys) {\r
+            if (degree[v] == 0) zeroVerts.push(v)\r
+        }\r
+        // Determine the topological order\r
+        val result = ArrayList<V>()\r
+        while (!zeroVerts.isEmpty()) {\r
+            val v = zeroVerts.pop()                  // Choose a vertex with zero in-degree\r
+            result.add(v)                          // Vertex v is next in topol order\r
+            // "Remove" vertex v by updating its neighbors\r
+            for (neighbor in neighbors[v]!!) {\r
+                degree[neighbor] = degree[neighbor]!! - 1\r
+                // Remember any vertices that now have zero in-degree\r
+                if (degree[neighbor] == 0) zeroVerts.push(neighbor)\r
+            }\r
+        }\r
+        // Check that we have used the entire graph (if not, there was a cycle)\r
+        return if (result.size != neighbors.size) null else result\r
+    }\r
+\r
+\r
+    fun bfsDistance(start: V): Map<*, *> {\r
+        var distance: MutableMap<V, Int> = hashMapOf()\r
+        // Initially, all distance are infinity, except start node\r
+        for (v in neighbors.keys)\r
+            distance[v] = -1\r
+        distance[start] = 0\r
+        // Process nodes in queue order\r
+        val queue = LinkedList<V>()\r
+        queue.offer(start)                                    // Place start node in queue\r
+        while (!queue.isEmpty()) {\r
+            val v = queue.remove()\r
+            val vDist = distance[v]!!\r
+            // Update neighbors\r
+            for (neighbor in neighbors[v]!!) {\r
+                if (distance[neighbor] != null) continue  // Ignore if already done\r
+                distance[neighbor] = vDist + 1\r
+                queue.offer(neighbor)\r
+            }\r
+        }\r
+        return distance\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt
new file mode 100644 (file)
index 0000000..128b7f5
--- /dev/null
@@ -0,0 +1,35 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core\r
+\r
+import org.junit.Test\r
+import kotlin.test.assertEquals\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class CustomFunctionsTest {\r
+    @Test\r
+    fun testFormat(): Unit {\r
+        val returnValue : String = format("This is {} for times {}", "test", 2)\r
+        assertEquals("This is test for times 2", returnValue, "Failed to format String")\r
+\r
+        val returnValue1 : String = format("This is test for times 2")\r
+        assertEquals("This is test for times 2", returnValue1, "Failed to format empty args")\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt
new file mode 100644 (file)
index 0000000..7a74ca4
--- /dev/null
@@ -0,0 +1,70 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+\r
+import org.apache.commons.io.FileUtils\r
+import org.junit.Before\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import java.io.File\r
+import java.nio.charset.Charset\r
+import kotlin.test.assertNotNull\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class BluePrintContextTest {\r
+\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    lateinit var bluePrintContext: BluePrintContext\r
+\r
+    @Before\r
+    fun setUp() {\r
+\r
+        val basepath = "load/blueprints"\r
+\r
+        bluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
+                .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)\r
+        assertNotNull(bluePrintContext, "Failed to populate Blueprint context")\r
+    }\r
+\r
+    @Test\r
+    fun testBluePrintContextFromContent() {\r
+        val fileName = "load/blueprints/baseconfiguration/Definitions/activation-blueprint.json"\r
+        val content : String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
+        val bpContext  = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
+                .readBlueprint(content)\r
+        assertNotNull(bpContext, "Failed to get blueprint content")\r
+        assertNotNull(bpContext.serviceTemplate, "Failed to get blueprint content's service template")\r
+    }\r
+\r
+    @Test\r
+    fun testChainedProperty() {\r
+        val nodeType = bluePrintContext.nodeTypeChained("component-resource-assignment")\r
+        assertNotNull(nodeType, "Failed to get chained node type")\r
+        log.trace("Properties {}", JacksonUtils.getJson(nodeType, true))\r
+    }\r
+\r
+\r
+}\r
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt
new file mode 100644 (file)
index 0000000..8e6d5ef
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils\r
+\r
+/**\r
+ * BluePrintEnhancerServiceTest\r
+ * @author Brinda Santh\r
+ *\r
+ */\r
+\r
+class BluePrintEnhancerServiceTest {\r
+    val basePath = "load/model_type"\r
+\r
+    @Test\r
+    fun testEnrichBlueprint() {\r
+        val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\r
+        val bluePrintEnhancerService: BluePrintEnhancerService = BluePrintEnhancerDefaultService(bluePrintEnhancerRepoFileService)\r
+\r
+        val serviceTemplate = ServiceTemplateUtils.getServiceTemplate("load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json")\r
+        bluePrintEnhancerService.enhance(serviceTemplate)\r
+\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
new file mode 100644 (file)
index 0000000..911a891
--- /dev/null
@@ -0,0 +1,109 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ExpressionData\r
+import kotlin.test.assertEquals\r
+import kotlin.test.assertNotNull\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class BluePrintExpressionServiceTest {\r
+    @Test\r
+    fun testInputExpression() {\r
+        val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }")\r
+        val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)\r
+        assertNotNull(expressionData, " Failed to populate expression data")\r
+        assertEquals(expressionData.isExpression, true, "Failed to identify as expression")\r
+        assertNotNull(expressionData.inputExpression, " Failed to populate input expression data")\r
+        assertEquals("input-name", expressionData.inputExpression?.propertyName, "Failed to get propertyName from expression data")\r
+    }\r
+\r
+    @Test\r
+    fun testPropertyExpression() {\r
+        val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }")\r
+        val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)\r
+        assertNotNull(expressionData, " Failed to populate expression data")\r
+        assertEquals(expressionData.isExpression, true, "Failed to identify as expression")\r
+        assertNotNull(expressionData.propertyExpression, " Failed to populate property expression data")\r
+        assertEquals("SELF", expressionData.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName")\r
+        assertEquals("property-name", expressionData.propertyExpression?.propertyName, " Failed to get expected propertyName")\r
+\r
+        val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }")\r
+        val expressionData1  : ExpressionData  = BluePrintExpressionService.getExpressionData(node1)\r
+        assertNotNull(expressionData1, " Failed to populate expression data")\r
+        assertEquals(expressionData1.isExpression, true, "Failed to identify as nested property expression")\r
+        assertNotNull(expressionData1.propertyExpression, " Failed to populate nested property expression data")\r
+        assertEquals("SELF", expressionData1.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName")\r
+        assertEquals("property-name", expressionData1.propertyExpression?.propertyName, " Failed to get expected propertyName")\r
+        assertEquals("resource/name",expressionData1.propertyExpression?.subPropertyName, " Failed to populate nested subPropertyName expression data")\r
+    }\r
+\r
+    @Test\r
+    fun testAttributeExpression() {\r
+        val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }")\r
+        val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)\r
+        assertNotNull(expressionData, " Failed to populate expression data")\r
+        assertEquals(expressionData.isExpression, true, "Failed to identify as expression")\r
+        assertNotNull(expressionData.attributeExpression, " Failed to populate attribute expression data")\r
+        assertEquals("SELF", expressionData.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName")\r
+        assertEquals("attribute-name", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName")\r
+        assertEquals("resource/name",expressionData.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data")\r
+    }\r
+\r
+\r
+    @Test\r
+    fun testOutputOperationExpression() {\r
+        val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }")\r
+        val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)\r
+        assertNotNull(expressionData, " Failed to populate expression data")\r
+        assertEquals(expressionData.isExpression, true, "Failed to identify as expression")\r
+        assertNotNull(expressionData.operationOutputExpression, " Failed to populate output expression data")\r
+        assertEquals("SELF", expressionData.operationOutputExpression?.modelableEntityName, " Failed to get expected modelableEntityName")\r
+        assertEquals("interface-name", expressionData.operationOutputExpression?.interfaceName, " Failed to get expected interfaceName")\r
+        assertEquals("operation-name", expressionData.operationOutputExpression?.operationName, " Failed to get expected operationName")\r
+        assertEquals("output-property-name", expressionData.operationOutputExpression?.propertyName, " Failed to get expected propertyName")\r
+    }\r
+\r
+\r
+    @Test\r
+    fun testArtifactExpression() {\r
+        val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }")\r
+        val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)\r
+        assertNotNull(expressionData, " Failed to populate expression data")\r
+        assertEquals(expressionData.isExpression, true, "Failed to identify as expression")\r
+        assertNotNull(expressionData.artifactExpression, " Failed to populate Artifact expression data")\r
+        assertEquals("SELF", expressionData.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName")\r
+        assertEquals("artifact-template", expressionData.artifactExpression?.artifactName, " Failed to get expected artifactName")\r
+\r
+\r
+        val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }")\r
+        val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)\r
+        assertNotNull(expressionData1, " Failed to populate expression data")\r
+        assertEquals(expressionData1.isExpression, true, "Failed to identify as expression")\r
+        assertNotNull(expressionData1.artifactExpression, " Failed to populate Artifact expression data")\r
+        assertEquals("SELF", expressionData1.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName")\r
+        assertEquals("artifact-template", expressionData1.artifactExpression?.artifactName, " Failed to get expected artifactName")\r
+        assertEquals("location", expressionData1.artifactExpression?.location, " Failed to get expected location")\r
+        assertEquals(true, expressionData1.artifactExpression?.remove, " Failed to get expected remove")\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt
new file mode 100644 (file)
index 0000000..5a5557d
--- /dev/null
@@ -0,0 +1,42 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import kotlin.test.assertNotNull\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class BluePrintParserFactoryTest {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    @Test\r
+    fun testBluePrintJson() {\r
+        val basepath = "load/blueprints"\r
+\r
+        val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT)!!\r
+                .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)\r
+        assertNotNull(bluePrintContext, "Failed to populate Blueprint context")\r
+        log.trace("Blue Print {}",bluePrintContext.blueprintJson(true))\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
new file mode 100644 (file)
index 0000000..88aea91
--- /dev/null
@@ -0,0 +1,57 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import org.junit.Test\r
+import java.io.FileNotFoundException\r
+import kotlin.test.assertNotNull\r
+\r
+/**\r
+ * BluePrintRepoFileServiceTest\r
+ * @author Brinda Santh\r
+ *\r
+ */\r
+class BluePrintRepoFileServiceTest {\r
+\r
+    private val basePath = "load/model_type"\r
+    private val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\r
+\r
+    @Test\r
+    fun testGetDataType() {\r
+        val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")?.block()\r
+        assertNotNull(dataType, "Failed to get DataType from repo")\r
+    }\r
+\r
+    @Test\r
+    fun testGetNodeType() {\r
+        val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")?.block()\r
+        assertNotNull(nodeType, "Failed to get NodeType from repo")\r
+    }\r
+\r
+    @Test\r
+    fun testGetArtifactType() {\r
+        val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")?.block()\r
+        assertNotNull(nodeType, "Failed to get ArtifactType from repo")\r
+    }\r
+\r
+    @Test(expected = FileNotFoundException::class)\r
+    fun testModelNotFound() {\r
+        val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")?.block()\r
+        assertNotNull(dataType, "Failed to get DataType from repo")\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
new file mode 100644 (file)
index 0000000..5d24b07
--- /dev/null
@@ -0,0 +1,131 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.NullNode\r
+import org.junit.Before\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import kotlin.test.assertEquals\r
+import kotlin.test.assertNotNull\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class BluePrintRuntimeServiceTest {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+    val basepath = "load/blueprints"\r
+\r
+\r
+    @Before\r
+    fun setUp(): Unit {\r
+\r
+    }\r
+\r
+    @Test\r
+    fun testResolveNodeTemplateProperties() {\r
+        log.info("************************ testResolveNodeTemplateProperties **********************")\r
+        val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
+                .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)\r
+\r
+        val context: MutableMap<String, Any> = hashMapOf()\r
+        context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")\r
+        val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)\r
+\r
+        val inputDataPath =  "src/test/resources/data/default-context.json"\r
+\r
+        val inputNode: JsonNode = jsonNodeFromFile(inputDataPath)\r
+        bluePrintRuntimeService.assignInputs(inputNode)\r
+\r
+        val propContext: MutableMap<String, Any?> = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process")\r
+        log.info("Context {}" ,bluePrintRuntimeService.context)\r
+\r
+        assertNotNull(propContext, "Failed to populate interface property values")\r
+        assertEquals(propContext.get("process-name"), jsonNodeFromObject("sample-action"), "Failed to populate parameter process-name")\r
+        assertEquals(propContext.get("version"), jsonNodeFromObject("sample-action"), "Failed to populate parameter version")\r
+    }\r
+\r
+    @Test\r
+    fun testResolveNodeTemplateInterfaceOperationInputs() {\r
+        log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************")\r
+        val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
+                .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)\r
+        assertNotNull(bluePrintContext, "Failed to populate Blueprint context")\r
+\r
+        val context: MutableMap<String, Any> = hashMapOf()\r
+        context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig")\r
+\r
+        val inputDataPath =  "src/test/resources/data/default-context.json"\r
+        BluePrintRuntimeUtils.assignInputsFromFile(bluePrintContext, inputDataPath, context)\r
+\r
+\r
+        val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)\r
+\r
+        log.info("Prepared Context {}" ,context)\r
+\r
+        val inContext: MutableMap<String, Any?> = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment",\r
+                "DefaultComponentNode", "process")\r
+\r
+        log.trace("In Context {}" ,inContext)\r
+\r
+        assertNotNull(inContext, "Failed to populate interface input property values")\r
+        assertEquals(inContext.get("action-name"), jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")\r
+        assertEquals(inContext.get("request-id"), jsonNodeFromObject("12345"), "Failed to populate parameter action-name")\r
+        assertEquals(inContext.get("template-content"), jsonNodeFromObject("This is Sample Velocity Template"), "Failed to populate parameter action-name")\r
+\r
+    }\r
+\r
+    @Test\r
+    fun testResolveNodeTemplateInterfaceOperationOutputs() {\r
+        log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************")\r
+        val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
+                .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath)\r
+        assertNotNull(bluePrintContext, "Failed to populate Blueprint context")\r
+\r
+        val context: MutableMap<String, Any> = hashMapOf()\r
+        context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] =  basepath.plus("/simple-baseconfig")\r
+\r
+        val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context)\r
+\r
+        val componentContext: MutableMap<String, Any?> = hashMapOf()\r
+        val successValue : JsonNode= jsonNodeFromObject("Success")\r
+        componentContext["resource-assignment.DefaultComponentNode.process.status"] = successValue\r
+        componentContext["resource-assignment.DefaultComponentNode.process.resource-assignment-params"] = null\r
+\r
+        bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment",\r
+                "DefaultComponentNode", "process", componentContext)\r
+\r
+        assertEquals(NullNode.instance,\r
+                context.get("node_templates/resource-assignment/interfaces/DefaultComponentNode/operations/process/properties/resource-assignment-params"),\r
+                "Failed to get operation property resource-assignment-params")\r
+\r
+        assertEquals(successValue,\r
+                context.get("node_templates/resource-assignment/interfaces/DefaultComponentNode/operations/process/properties/status"),\r
+                "Failed to get operation property status")\r
+\r
+\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt
new file mode 100644 (file)
index 0000000..b05fcb6
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.service\r
+\r
+import org.junit.Before\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+\r
+/**\r
+ *\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class BluePrintValidatorDefaultServiceTest {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+    val basepath = "load/blueprints"\r
+\r
+    @Before\r
+    fun setUp(): Unit {\r
+\r
+    }\r
+\r
+    @Test\r
+    fun testValidateBluePrint() {\r
+        val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!!\r
+                .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json",  basepath)\r
+        val properties : MutableMap<String, Any> = hashMapOf()\r
+        val validatorService = BluePrintValidatorDefaultService()\r
+        validatorService.validateBlueprint(bluePrintContext.serviceTemplate,properties)\r
+        log.info("Validation Message {}", properties)\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
new file mode 100644 (file)
index 0000000..ddb39a2
--- /dev/null
@@ -0,0 +1,40 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData\r
+import kotlin.test.assertNotNull\r
+\r
+class BluePrintMetadataUtilsTest {\r
+    \r
+    @Test\r
+    fun testToscaMetaData(){\r
+\r
+        val basePath : String = "load/blueprints/baseconfiguration"\r
+\r
+        val toscaMetaData : ToscaMetaData =  BluePrintMetadataUtils.toscaMetaData(basePath)\r
+        assertNotNull(toscaMetaData, "Missing Tosca Definition Object")\r
+        assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version")\r
+        assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version")\r
+        assertNotNull(toscaMetaData.createdBy, "Missing Created by")\r
+        assertNotNull(toscaMetaData.entityDefinitions, "Missing Tosca Entity Definition")\r
+        assertNotNull(toscaMetaData.templateTags, "Missing Template Tags")\r
+\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
new file mode 100644 (file)
index 0000000..d13caa5
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate\r
+import java.io.FileNotFoundException\r
+import kotlin.test.assertEquals\r
+import kotlin.test.assertNotNull\r
+\r
+class JacksonReactorUtilsTest {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+    @Test\r
+    fun testReadValues() {\r
+\r
+        val serviceTemplate = JacksonReactorUtils.readValueFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json",\r
+                ServiceTemplate::class.java).block()\r
+\r
+        assertNotNull(serviceTemplate, "Failed to simple transform Service Template")\r
+        assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")\r
+\r
+        val jsonContent = JacksonReactorUtils.getJson(serviceTemplate!!, true).block()\r
+        assertNotNull(jsonContent, "Failed to get json content")\r
+\r
+        val jsonNode = JacksonReactorUtils.jsonNodeFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json")\r
+                .block()\r
+        assertNotNull(jsonContent, "Failed to get json Node")\r
+    }\r
+\r
+    @Test(expected = FileNotFoundException::class)\r
+    fun testReadValuesFailure() {\r
+        JacksonReactorUtils.jsonNodeFromFile("load/blueprints/not-found.json")\r
+                .block()\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt
new file mode 100644 (file)
index 0000000..a5a630e
--- /dev/null
@@ -0,0 +1,93 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
+import kotlin.test.assertEquals\r
+import kotlin.test.assertNotNull\r
+import kotlin.test.assertTrue\r
+\r
+/**\r
+ * JacksonUtilsTest\r
+ * @author Brinda Santh\r
+ * ${DATA}\r
+ */\r
+class JacksonUtilsTest {\r
+\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())\r
+\r
+    val basePath = "load/blueprints"\r
+\r
+    @Test\r
+    fun testReadValues() {\r
+        val content = ResourceResolverUtils.getFileContent("baseconfiguration/Definitions/activation-blueprint.json", basePath)\r
+        val serviceTemplate = JacksonUtils.readValue(content, ServiceTemplate::class.java)\r
+        assertNotNull(serviceTemplate, "Failed to simple transform Service Template")\r
+        assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")\r
+\r
+        val jsonContent = JacksonUtils.getJson(serviceTemplate!!, true)\r
+        assertNotNull(jsonContent, "Failed to get json content")\r
+    }\r
+\r
+    @Test\r
+    fun testJsonNodeFromClassPathFile() {\r
+        val filePath = "data/default-context.json"\r
+        JacksonUtils.jsonNodeFromClassPathFile(filePath)\r
+    }\r
+\r
+    @Test\r
+    fun testJsonNodeFromFile() {\r
+        val filePath = basePath + "/baseconfiguration/Definitions/activation-blueprint.json"\r
+        JacksonUtils.jsonNodeFromFile(filePath)\r
+    }\r
+\r
+    @Test\r
+    fun testGetListFromJson() {\r
+        val content = "[\"good\",\"boy\" ]"\r
+        val nodeType = JacksonUtils.getListFromJson(content, String::class.java)\r
+        assertNotNull(nodeType, "Failed to get String array from content")\r
+    }\r
+\r
+\r
+    @Test\r
+    fun testJsonValue() {\r
+        val filePath = "data/alltype-data.json"\r
+        val rootJson = JacksonUtils.jsonNodeFromClassPathFile(filePath)\r
+        assertNotNull(rootJson, "Failed to get all type data json node")\r
+        val intValue = rootJson.get("intValue")\r
+        assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_INTEGER, intValue), "Failed to get as int value")\r
+        val floatValue = rootJson.get("floatValue")\r
+        assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_FLOAT, floatValue), "Failed to get as float value")\r
+        val stringValue = rootJson.get("stringValue")\r
+        assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_STRING, stringValue), "Failed to get as string value")\r
+        val booleanValue = rootJson.get("booleanValue")\r
+        assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_BOOLEAN, booleanValue), "Failed to get as boolean value")\r
+        val arrayStringValue = rootJson.get("arrayStringValue")\r
+        assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, arrayStringValue), "Failed to get as List value")\r
+        val mapValue = rootJson.get("mapValue")\r
+        assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_MAP, mapValue), "Failed to get as Map value")\r
+\r
+        assertTrue(!JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, stringValue), "Negative type failed")\r
+\r
+\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt
new file mode 100644 (file)
index 0000000..3fa4f75
--- /dev/null
@@ -0,0 +1,36 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core.utils\r
+\r
+import org.junit.Test\r
+\r
+class TopologicalSortingUtilsTest {\r
+    \r
+    @Test\r
+    fun testSorting(): Unit {\r
+        val graph: TopologicalSortingUtils<String> = TopologicalSortingUtils()\r
+        graph.add("bundle-id", "bundle-mac")\r
+        graph.add("bundle-id", "bundle-ip")\r
+        graph.add("bundle-mac", "bundle-ip")\r
+        graph.add("bundle-ip", "bundle-mac")\r
+\r
+        println("The current graph: " + graph)\r
+        println("In-degrees: " + graph.inDegree())\r
+        println("Out-degrees: " + graph.outDegree())\r
+        println("A topological sort of the vertices: " + graph.topSort())\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/resources/componentnode/default.json b/components/core/src/test/resources/componentnode/default.json
new file mode 100644 (file)
index 0000000..b7265fc
--- /dev/null
@@ -0,0 +1,100 @@
+{\r
+       "metadata": {\r
+               "template_author": "bs2796",\r
+               "vendor": "Juniper",\r
+               "os": "XXX",\r
+               "service-type": "AVPN",\r
+               "vnf-type": "VRR",\r
+               "action": "Base Configuration",\r
+               "sub-action": "Generate Configuration",\r
+               "template_name": "VRR-baseconfiguration",\r
+               "template_version": "1.0.0"\r
+       },\r
+       "topology_template": {\r
+               "inputs": {\r
+                       "service-instance-id": {\r
+                               "required": true,\r
+                               "type": "string"\r
+                       },\r
+                       "vnf-id": {\r
+                               "required": true,\r
+                               "type": "string"\r
+                       },\r
+                       "service": {\r
+                               "required": true,\r
+                               "type": "string"\r
+                       },\r
+                       "region": {\r
+                               "required": true,\r
+                               "type": "string"\r
+                       },\r
+                       "bundle-id": {\r
+                               "required": true,\r
+                               "type": "string"\r
+                       },\r
+                       "bundle-mac": {\r
+                               "required": true,\r
+                               "type": "string"\r
+                       }\r
+               },\r
+               "node_templates": {\r
+                       "generate-configuration": {\r
+                               "type": "mock-component-generateConfig",\r
+                               "interfaces": {\r
+                                       "org-openecomp-sdnc-config-params-service-MockComponentNode": {\r
+                                               "operations": {\r
+                                                       "process": {\r
+                                                               "inputs": {\r
+                                                                       "entity-type": "vnf-type",\r
+                                                                       "template-content": "sample-template",\r
+                                                                       "entity-id": "{ \"get_input\" : \"vnf-id\" }"\r
+                                                               },\r
+                                                               "outputs": {\r
+                                                                       "mergedData": "merged Data",\r
+                                                                       "status": "status"\r
+                                                               }\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       "node_types": {\r
+               "mock-component-generateConfig": {\r
+                       "interfaces": {\r
+                               "org-openecomp-sdnc-config-params-service-MockComponentNode": {\r
+                                       "operations": {\r
+                                               "process": {\r
+                                                       "inputs": {\r
+                                                               "entity-type": {\r
+                                                                       "required": false,\r
+                                                                       "type": "string"\r
+                                                               },\r
+                                                               "template-content": {\r
+                                                                       "required": false,\r
+                                                                       "type": "string"\r
+                                                               },\r
+                                                               "entity-id": {\r
+                                                                       "required": true,\r
+                                                                       "type": "string"\r
+                                                               }\r
+                                                       },\r
+                                                       "outputs": {\r
+                                                               "generated-config": {\r
+                                                                       "required": true,\r
+                                                                       "type": "string"\r
+                                                               },\r
+                                                               "status": {\r
+                                                                       "required": true,\r
+                                                                       "type": "string"\r
+                                                               }\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       },\r
+                       "derived_from": "tosca.nodes.Component"\r
+               }\r
+       }\r
+}\r
diff --git a/components/core/src/test/resources/data/alltype-data.json b/components/core/src/test/resources/data/alltype-data.json
new file mode 100644 (file)
index 0000000..055b096
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "intValue" : 1,
+  "floatValue" : 1.34,
+  "booleanValue" : true,
+  "stringValue" : "sample-String",
+  "timeValue" : "2018-09-29",
+  "arrayStringValue" : ["one", "two"],
+  "mapValue" : {"profile_name1":"profile_name1",
+                "profile_name2":"profile_name2"}
+}
\ No newline at end of file
diff --git a/components/core/src/test/resources/data/default-context.json b/components/core/src/test/resources/data/default-context.json
new file mode 100644 (file)
index 0000000..fcd4cbe
--- /dev/null
@@ -0,0 +1,5 @@
+{\r
+  "request-id" : "12345",\r
+  "hostname" : "localhost",\r
+  "action-name" : "sample-action"\r
+}
\ No newline at end of file
diff --git a/components/core/src/test/resources/dictionary/dictionary_schema.json b/components/core/src/test/resources/dictionary/dictionary_schema.json
new file mode 100644 (file)
index 0000000..d031700
--- /dev/null
@@ -0,0 +1,261 @@
+{\r
+       "type": "object",\r
+       "properties": {\r
+               "resource-path": {\r
+                       "type": "string",\r
+                       "required": true\r
+               },\r
+               "description": {\r
+                       "type": "string"\r
+               },\r
+               "updated-by": {\r
+                       "type": "string"\r
+               },\r
+               "data-type": {\r
+                       "type": "string",\r
+                       "required": true\r
+               },\r
+               "source": {\r
+                       "type": "object",\r
+                       "required": true,\r
+                       "properties": {\r
+                               "input": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "key": {\r
+                                                       "type": "string"\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "component": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "name": {\r
+                                                       "type": "string",\r
+                                                       "required": true\r
+                                               },\r
+                                               "input-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               },\r
+                                               "output-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "default": {\r
+                                       "type": "any"\r
+                               },\r
+                               "aai": {\r
+                                       "type": "any"\r
+                               },\r
+                               "mdsal": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "path": {\r
+                                                       "type": "string",\r
+                                                       "required": true\r
+                                               },\r
+                                               "url-path": {\r
+                                                       "type": "string",\r
+                                                       "required": true\r
+                                               },\r
+                                               "input-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               },\r
+                                               "type": {\r
+                                                       "type": "string",\r
+                                                       "required": true\r
+                                               },\r
+                                               "output-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               },\r
+                                               "base": {\r
+                                                       "type": "string",\r
+                                                       "required": true\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "network-resource-discovery": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "input-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               },\r
+                                               "output-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "db": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "query": {\r
+                                                       "type": "string",\r
+                                                       "required": true\r
+                                               },\r
+                                               "input-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               },\r
+                                               "type": {\r
+                                                       "type": "string",\r
+                                                       "required": true\r
+                                               },\r
+                                               "output-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               },\r
+                                               "base": {\r
+                                                       "type": "string",\r
+                                                       "required": true\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "policy": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "input-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               },\r
+                                               "output-key-mapping": {\r
+                                                       "type": "object",\r
+                                                       "additionalProperties": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               },\r
+               "candidate-dependency": {\r
+                       "type": "object",\r
+                       "properties": {\r
+                               "input": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "names": {\r
+                                                       "type": "array",\r
+                                                       "items": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "component": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "names": {\r
+                                                       "type": "array",\r
+                                                       "items": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "aai": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "names": {\r
+                                                       "type": "array",\r
+                                                       "items": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "mdsal": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "names": {\r
+                                                       "type": "array",\r
+                                                       "items": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "network-resource-discovery": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "names": {\r
+                                                       "type": "array",\r
+                                                       "items": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "db": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "names": {\r
+                                                       "type": "array",\r
+                                                       "items": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               },\r
+                               "policy": {\r
+                                       "type": "object",\r
+                                       "properties": {\r
+                                               "names": {\r
+                                                       "type": "array",\r
+                                                       "items": {\r
+                                                               "type": "string"\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               },\r
+               "tags": {\r
+                       "type": "string"\r
+               },\r
+               "default": {\r
+                       "type": "any"\r
+               },\r
+               "name": {\r
+                       "type": "string",\r
+                       "required": true\r
+               },\r
+               "valid-values": {\r
+                       "type": "string"\r
+               },\r
+               "resource-type": {\r
+                       "type": "string",\r
+                       "required": true\r
+               },\r
+               "sample-value": {\r
+                       "type": "string"\r
+               },\r
+               "entry-schema": {\r
+                       "type": "string"\r
+               }\r
+       }\r
+}\r
diff --git a/components/core/src/test/resources/properties/convert.json b/components/core/src/test/resources/properties/convert.json
new file mode 100644 (file)
index 0000000..cb7d08e
--- /dev/null
@@ -0,0 +1,33 @@
+{\r
+       "type": "sdnc-component-getResourceAssignment",\r
+       "interfaces": {\r
+               "ResourceAssignmentService": {\r
+                       "operations": {\r
+                               "getResourceAssignment": {\r
+                                       "inputs": {\r
+                                               "assignment-mappings": [\r
+                                                       {\r
+                                                               "name": "service-name",\r
+                                                               "mapping-field": "service",\r
+                                                               "mapping-category": "SDN",\r
+                                                               "required": true\r
+                                                       },\r
+                                                       {\r
+                                                               "name": "region-name",\r
+                                                               "mapping-field": "region",\r
+                                                               "mapping-category": "SDN",\r
+                                                               "required": true\r
+                                                       }\r
+                                               ],\r
+                                               "pre-data": "{ \"get_attribute\" : \"get-resource-assignment.config-params\" }",\r
+                                               "prifix": "get-resource-assignment"\r
+                                       },\r
+                                       "outputs": {\r
+                                               "resource-assignment-status": "success",\r
+                                               "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params\" }"\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/components/core/src/test/resources/properties/default.json b/components/core/src/test/resources/properties/default.json
new file mode 100644 (file)
index 0000000..0ac97f9
--- /dev/null
@@ -0,0 +1,16 @@
+{\r
+       "default": "{ \"get_input\" : \"loopback-default\" }",\r
+       "domain": "ethernet",\r
+       "criteria": [\r
+               {\r
+                       "value": "attga301me1",\r
+                       "type": "complex",\r
+                       "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name"\r
+               },\r
+               {\r
+                       "value": "{ \"get_input\" : \"host-ip-address\" }",\r
+                       "type": "simple",\r
+                       "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name"\r
+               }\r
+       ]\r
+}\r
diff --git a/components/parent/pom.xml b/components/parent/pom.xml
new file mode 100644 (file)
index 0000000..cbbeeff
--- /dev/null
@@ -0,0 +1,299 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.
+  ~
+  ~ Modifications Copyright © 2018 IBM.
+  ~
+  ~ 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.
+  -->
+<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.apps</groupId>
+        <artifactId>components</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+    </parent>
+    <groupId>org.onap.ccsdk.apps.components</groupId>
+    <artifactId>parent</artifactId>
+    <name>App Components Parent</name>
+    <packaging>pom</packaging>
+    <properties>
+        <spring.boot.version>2.0.4.RELEASE</spring.boot.version>
+        <spring.version>5.0.8.RELEASE</spring.version>
+        <kotlin.version>1.2.60</kotlin.version>
+        <eelf.version>1.0.0</eelf.version>
+        <guava.version>26.0-jre</guava.version>
+        <springfox.swagger2.version>2.9.2</springfox.swagger2.version>
+        <h2database.version>1.4.197</h2database.version>
+        <onap.logger.slf4j>1.2.2-SNAPSHOT</onap.logger.slf4j>
+    </properties>
+    <dependencyManagement>
+        <dependencies>
+            <!-- Spring boot -->
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring.boot.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+
+            <dependency>
+                <groupId>com.att.eelf</groupId>
+                <artifactId>eelf-core</artifactId>
+                <version>${eelf.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.onap.logging-analytics</groupId>
+                <artifactId>logging-slf4j</artifactId>
+                <version>${onap.logger.slf4j}</version>
+            </dependency>
+
+            <!--Swagger Dependencies -->
+            <dependency>
+                <groupId>io.springfox</groupId>
+                <artifactId>springfox-swagger2</artifactId>
+                <version>${springfox.swagger2.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.springfox</groupId>
+                <artifactId>springfox-swagger-ui</artifactId>
+                <version>${springfox.swagger2.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-lang3</artifactId>
+                <version>3.2.1</version>
+            </dependency>
+            <dependency>
+                <groupId>commons-collections</groupId>
+                <artifactId>commons-collections</artifactId>
+                <version>3.2.2</version>
+            </dependency>
+            <dependency>
+                <groupId>commons-io</groupId>
+                <artifactId>commons-io</artifactId>
+                <version>2.6</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.velocity</groupId>
+                <artifactId>velocity</artifactId>
+                <version>1.7</version>
+            </dependency>
+            <dependency>
+                <groupId>com.google.guava</groupId>
+                <artifactId>guava</artifactId>
+                <version>${guava.version}</version>
+            </dependency>
+
+            <!-- Kotlin Dependencies -->
+            <dependency>
+                <groupId>org.jetbrains.kotlin</groupId>
+                <artifactId>kotlin-stdlib</artifactId>
+                <version>${kotlin.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.jetbrains.kotlin</groupId>
+                <artifactId>kotlin-reflect</artifactId>
+                <version>${kotlin.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.jetbrains.kotlin</groupId>
+                <artifactId>kotlin-stdlib-jdk8</artifactId>
+                <version>${kotlin.version}</version>
+            </dependency>
+
+
+            <!-- Database -->
+            <dependency>
+                <groupId>com.h2database</groupId>
+                <artifactId>h2</artifactId>
+                <version>${h2database.version}</version>
+            </dependency>
+
+
+            <!-- Application Components -->
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+                <artifactId>core</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+                <artifactId>service</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+                <artifactId>application</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+                <artifactId>resource-dict</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+
+            <!-- Testing Dependencies -->
+            <dependency>
+                <groupId>org.powermock</groupId>
+                <artifactId>powermock-api-mockito2</artifactId>
+                <version>1.7.4</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.jetbrains.kotlin</groupId>
+                <artifactId>kotlin-test</artifactId>
+                <version>${kotlin.version}</version>
+                <scope>test</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.att.eelf</groupId>
+            <artifactId>eelf-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.logging-analytics</groupId>
+            <artifactId>logging-slf4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+         </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.jayway.jsonpath</groupId>
+            <artifactId>json-path</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jetbrains.kotlin</groupId>
+            <artifactId>kotlin-stdlib</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jetbrains.kotlin</groupId>
+            <artifactId>kotlin-stdlib-jdk8</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.module</groupId>
+            <artifactId>jackson-module-kotlin</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>3.0.1</version>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <artifactId>kotlin-maven-plugin</artifactId>
+                <groupId>org.jetbrains.kotlin</groupId>
+                <version>${kotlin.version}</version>
+                <executions>
+                    <execution>
+                        <id>compile</id>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                        <configuration>
+                            <sourceDirs>
+                                <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
+                                <sourceDir>${project.basedir}/src/main/java</sourceDir>
+                            </sourceDirs>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>test-compile</id>
+                        <goals>
+                            <goal>test-compile</goal>
+                        </goals>
+                        <configuration>
+                            <sourceDirs>
+                                <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
+                                <sourceDir>${project.basedir}/src/test/java</sourceDir>
+                            </sourceDirs>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.5.1</version>
+                <configuration>
+                    <source>${maven.compiler.source}</source>
+                    <target>${maven.compiler.target}</target>
+                </configuration>
+                <executions>
+                    <!-- Replacing default-compile as it is treated specially by maven -->
+                    <execution>
+                        <id>default-compile</id>
+                        <phase>none</phase>
+                    </execution>
+                    <!-- Replacing default-testCompile as it is treated specially by maven -->
+                    <execution>
+                        <id>default-testCompile</id>
+                        <phase>none</phase>
+                    </execution>
+                    <execution>
+                        <id>java-compile</id>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>java-test-compile</id>
+                        <phase>test-compile</phase>
+                        <goals>
+                            <goal>testCompile</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/components/pom.xml b/components/pom.xml
new file mode 100644 (file)
index 0000000..aada3eb
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+         xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <parent>
+        <groupId>org.onap.ccsdk.apps</groupId>
+        <artifactId>ccsdk-apps</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.onap.ccsdk.apps</groupId>
+    <artifactId>components</artifactId>
+    <name>App Components Root</name>
+    <packaging>pom</packaging>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
+        <build.number>${maven.build.timestamp}</build.number>
+        <java.version>1.8</java.version>
+        <maven.compiler.target>1.8</maven.compiler.target>
+        <maven.compiler.source>1.8</maven.compiler.source>
+    </properties>
+    <modules>
+        <module>parent</module>
+        <module>core</module>
+        <module>resource-dict</module>
+    </modules>
+</project>
+
diff --git a/components/resource-dict/load/model_type/node_type/source-component-java.json b/components/resource-dict/load/model_type/node_type/source-component-java.json
new file mode 100644 (file)
index 0000000..95a9801
--- /dev/null
@@ -0,0 +1,31 @@
+{
+  "description": "This is Custom Java Component Resource Source Node Type",
+  "version": "1.0.0",
+  "properties": {
+    "type": {
+      "required": false,
+      "type": "string",
+      "default" : "DYNAMIC",
+      "constraints": [
+        {
+          "validValues": [
+            "DYNAMIC"
+          ]
+        }
+      ]
+    },
+    "class-name": {
+      "required": true,
+      "type": "string",
+      "description" : "Fully Qualified Class Name ( <Package Name> + . + <Class Name> )"
+    },
+    "key-dependencies": {
+      "required": false,
+      "type": "list",
+      "entry_schema": {
+        "type": "string"
+      }
+    }
+  },
+  "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
diff --git a/components/resource-dict/load/model_type/node_type/source-db.json b/components/resource-dict/load/model_type/node_type/source-db.json
new file mode 100644 (file)
index 0000000..661a950
--- /dev/null
@@ -0,0 +1,44 @@
+{
+  "description": "This is Database Resource Source Node Type",
+  "version": "1.0.0",
+  "properties": {
+    "type": {
+      "required": true,
+      "type": "string",
+      "constraints": [
+        {
+          "valid_values": [
+            "SQL",
+            "PLSQL"
+          ]
+        }
+      ]
+    },
+    "query": {
+      "required": true,
+      "type": "string"
+    },
+    "input-key-mapping": {
+      "required": false,
+      "type": "map",
+      "entry_schema": {
+        "type": "string"
+      }
+    },
+    "output-key-mapping": {
+      "required": false,
+      "type": "map",
+      "entry_schema": {
+        "type": "string"
+      }
+    },
+    "key-dependencies": {
+      "required": true,
+      "type": "list",
+      "entry_schema": {
+        "type": "string"
+      }
+    }
+  },
+  "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
diff --git a/components/resource-dict/load/model_type/node_type/source-default.json b/components/resource-dict/load/model_type/node_type/source-default.json
new file mode 100644 (file)
index 0000000..13e234e
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "description": "This is Default Resource Source Node Type",
+  "version": "1.0.0",
+  "properties": {
+    "key": {
+      "required": false,
+      "type": "string"
+    },
+    "key-dependencies": {
+      "required": true,
+      "type": "list",
+      "entry_schema": {
+        "type": "string"
+      }
+    }
+  },
+  "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
diff --git a/components/resource-dict/load/model_type/node_type/source-input.json b/components/resource-dict/load/model_type/node_type/source-input.json
new file mode 100644 (file)
index 0000000..126ea30
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "description": "This is Input Resource Source Node Type",
+  "version": "1.0.0",
+  "properties": {
+    "key": {
+      "required": false,
+      "type": "string"
+    },
+    "key-dependencies": {
+      "required": true,
+      "type": "list",
+      "entry_schema": {
+        "type": "string"
+      }
+    }
+  },
+  "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
diff --git a/components/resource-dict/load/model_type/node_type/source-rest.json b/components/resource-dict/load/model_type/node_type/source-rest.json
new file mode 100644 (file)
index 0000000..f8dd8b6
--- /dev/null
@@ -0,0 +1,61 @@
+{
+  "description": "This is Rest Resource Source Node Type",
+  "version": "1.0.0",
+  "properties": {
+    "type": {
+      "required": false,
+      "type": "string",
+      "default": "JSON",
+      "constraints": [
+        {
+          "valid_values": [
+            "JSON"
+          ]
+        }
+      ]
+    },
+    "url-path": {
+      "required": true,
+      "type": "string"
+    },
+    "path": {
+      "required": true,
+      "type": "string"
+    },
+    "expression-type": {
+      "required": false,
+      "type": "string",
+      "default": "JSON_PATH",
+      "constraints": [
+        {
+          "valid_values": [
+            "JSON_PATH",
+            "JSON_POINTER"
+          ]
+        }
+      ]
+    },
+    "input-key-mapping": {
+      "required": false,
+      "type": "map",
+      "entry_schema": {
+        "type": "string"
+      }
+    },
+    "output-key-mapping": {
+      "required": false,
+      "type": "map",
+      "entry_schema": {
+        "type": "string"
+      }
+    },
+    "key-dependencies": {
+      "required": true,
+      "type": "list",
+      "entry_schema": {
+        "type": "string"
+      }
+    }
+  },
+  "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
diff --git a/components/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json b/components/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json
new file mode 100644 (file)
index 0000000..2ef553e
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "description": "TOSCA base type for Resource Sources",
+  "version": "1.0.0",
+  "derived_from": "tosca.nodes.Root"
+}
\ No newline at end of file
diff --git a/components/resource-dict/load/resource_dictionary/db-source.json b/components/resource-dict/load/resource_dictionary/db-source.json
new file mode 100644 (file)
index 0000000..92b16a2
--- /dev/null
@@ -0,0 +1,26 @@
+{\r
+  "name": "db-source",\r
+  "property" :{\r
+    "description": "name of the ",\r
+    "type": "string"\r
+  },\r
+  "resource-type": "ONAP",\r
+  "resource-path": "vnf/bundle-id",\r
+  "updated-by": "brindasanth@onap.com",\r
+  "tags": "bundle-id, brindasanth@onap.com",\r
+  "sources": {\r
+    "db": {\r
+      "type": "source-db",\r
+      "properties": {\r
+        "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
+        "input-key-mapping": {\r
+          "profile_name": "profile_name"\r
+        },\r
+        "output-key-mapping": {\r
+          "db-country": "country",\r
+          "db-state": "state"\r
+        }\r
+      }\r
+    }\r
+  }\r
+}
\ No newline at end of file
diff --git a/components/resource-dict/load/resource_dictionary/default-source.json b/components/resource-dict/load/resource_dictionary/default-source.json
new file mode 100644 (file)
index 0000000..1c47f37
--- /dev/null
@@ -0,0 +1,18 @@
+{\r
+  "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",\r
+  "name": "default-source",\r
+  "property" :{\r
+    "description": "name of the ",\r
+    "type": "string"\r
+  },\r
+  "updated-by": "brindasanth@onap.com",\r
+  "resource-type": "ONAP",\r
+  "resource-path": "vnf/v4-ip-type",\r
+  "sources": {\r
+    "default": {\r
+      "type": "source-default",\r
+      "properties": {\r
+      }\r
+    }\r
+  }\r
+}
\ No newline at end of file
diff --git a/components/resource-dict/load/resource_dictionary/input-source.json b/components/resource-dict/load/resource_dictionary/input-source.json
new file mode 100644 (file)
index 0000000..676d92f
--- /dev/null
@@ -0,0 +1,19 @@
+{\r
+       "name": "input-source",\r
+       "property" :{\r
+               "description": "name of the ",\r
+               "type": "string"\r
+       },\r
+       "resource-path": "action-name",\r
+       "resource-type": "ONAP",\r
+       "updated-by": "brindasanth@onap.com",\r
+       "tags": null,\r
+       "sources": {\r
+               "input": {\r
+                       "type": "source-input",\r
+                       "properties": {\r
+                               "key": "action-name"\r
+                       }\r
+               }\r
+       }\r
+}
\ No newline at end of file
diff --git a/components/resource-dict/load/resource_dictionary/mdsal-source.json b/components/resource-dict/load/resource_dictionary/mdsal-source.json
new file mode 100644 (file)
index 0000000..b49146a
--- /dev/null
@@ -0,0 +1,36 @@
+{\r
+  "tags": "oam-local-ipv4-address",\r
+  "name": "mdsal-source",\r
+  "property" :{\r
+    "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",\r
+    "type": "string"\r
+  },\r
+  "updated-by": "brindasanth@onap.com",\r
+  "resource-type": "ATT",\r
+  "resource-path": "vnf/oam-local-ipv4-address",\r
+  "sources": {\r
+    "mdsal": {\r
+      "type": "source-rest",\r
+      "properties": {\r
+        "type": "JSON",\r
+        "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type",\r
+        "path": "/v4-assigned-ip-list/0/v4-ip-prefix",\r
+        "input-key-mapping": {\r
+          "service-instance-id": "service-instance-id",\r
+          "network-role": "network-role",\r
+          "v4-ip-type": "v4-ip-type",\r
+          "vm-type": "vm-type"\r
+        },\r
+        "output-key-mapping": {\r
+          "oam-local-ipv4-address": "v4-ip-prefix"\r
+        },\r
+        "key-dependencies": [\r
+          "service-instance-id",\r
+          "network-role",\r
+          "v4-ip-type",\r
+          "vm-type"\r
+        ]\r
+      }\r
+    }\r
+  }\r
+}
\ No newline at end of file
diff --git a/components/resource-dict/pom.xml b/components/resource-dict/pom.xml
new file mode 100644 (file)
index 0000000..7eecb5e
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
+  ~\r
+  ~ Modifications Copyright © 2018 IBM.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~     http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  -->\r
+\r
+<project\r
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"\r
+        xmlns="http://maven.apache.org/POM/4.0.0"\r
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+    <modelVersion>4.0.0</modelVersion>\r
+    <parent>\r
+        <groupId>org.onap.ccsdk.apps.components</groupId>\r
+        <artifactId>parent</artifactId>\r
+        <version>0.3.0-SNAPSHOT</version>\r
+        <relativePath>../parent</relativePath>\r
+    </parent>\r
+    <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>\r
+    <artifactId>resource-dict</artifactId>\r
+    <name>Controller Blueprints Resource Dictionary</name>\r
+\r
+    <dependencies>\r
+        <dependency>\r
+            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>\r
+            <artifactId>core</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.jetbrains.kotlin</groupId>\r
+            <artifactId>kotlin-test</artifactId>\r
+            <scope>test</scope>\r
+        </dependency>\r
+    </dependencies>\r
+\r
+\r
+</project>\r
+\r
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt
new file mode 100644 (file)
index 0000000..a6802f6
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  Copyright © 2018 IBM.
+ *
+ *  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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+
+interface ResourceAssignmentProcessor {
+
+    @Throws(BluePrintProcessorException::class)
+    fun validate(resourceAssignment: ResourceAssignment, context : MutableMap<String, Any>)
+
+    @Throws(BluePrintProcessorException::class)
+    fun process(resourceAssignment: ResourceAssignment, context : MutableMap<String, Any>)
+
+    @Throws(BluePrintProcessorException::class)
+    fun errorHandle(resourceAssignment: ResourceAssignment, context : MutableMap<String, Any>)
+
+    @Throws(BluePrintProcessorException::class)
+    fun reTrigger(resourceAssignment: ResourceAssignment, context : MutableMap<String, Any>)
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt
new file mode 100644 (file)
index 0000000..0808073
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ *  Copyright © 2018 IBM.
+ *
+ *  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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import com.fasterxml.jackson.annotation.JsonProperty
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+import java.io.Serializable
+import java.util.*
+
+open class ResourceDefinition {
+
+    @JsonProperty(value = "name", required = true)
+    lateinit var name: String
+
+    @JsonProperty(value = "property", required = true)
+    lateinit var property: PropertyDefinition
+
+    var tags: String? = null
+
+    @JsonProperty(value = "updated-by")
+    lateinit var updatedBy: String
+
+    @JsonProperty(value = "resource-type", required = true)
+    lateinit var resourceType: String
+
+    @JsonProperty(value = "resource-path", required = true)
+    lateinit var resourcePath: String
+
+    @JsonProperty(value = "sources", required = true)
+    lateinit var sources: MutableMap<String, NodeTemplate>
+}
+
+open class ResourceAssignment {
+
+    @JsonProperty(value = "name", required = true)
+    lateinit var name: String
+
+    @JsonProperty(value = "property")
+    var property: PropertyDefinition? = null
+
+    @JsonProperty("input-param")
+    var inputParameter: Boolean = false
+
+    @JsonProperty("dictionary-name")
+    var dictionaryName: String? = null
+
+    @JsonProperty("dictionary-source")
+    var dictionarySource: String? = null
+
+    @JsonProperty("dependencies")
+    var dependencies: MutableList<String>? = null
+
+    @JsonProperty("version")
+    var version: Int = 0
+
+    @JsonProperty("status")
+    var status: String? = null
+
+    @JsonProperty("message")
+    var message: String? = null
+
+    @JsonProperty("updated-date")
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+    var updatedDate: Date? = null
+
+    @JsonProperty("updated-by")
+    var updatedBy: String? = null
+
+    override fun toString(): String {
+        return StringBuilder()
+                .append("[")
+                .append("name=", name)
+                .append(", dictionaryName=", dictionaryName)
+                .append(", dictionarySource=", dictionarySource)
+                .append("]")
+                .toString()
+    }
+}
+
+/**
+ * Interface for Source Definitions (ex Input Source,
+ * Default Source, Database Source, Rest Sources, etc)
+ */
+interface ResourceSource : Serializable
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
new file mode 100644 (file)
index 0000000..aa6a9fb
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  Copyright © 2018 IBM.
+ *
+ *  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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict
+/**
+ * ResourceDictionaryConstants
+ *
+ * @author Brinda Santh
+ */
+object ResourceDictionaryConstants {
+    const val SOURCE_INPUT = "input"
+    const val SOURCE_DEFAULT = "default"
+    const val SOURCE_DB = "db"
+
+    const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary"
+
+    const val PROPERTY_TYPE = "type"
+    const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping"
+    const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping"
+    const val PROPERTY_KEY_DEPENDENCIES = "key-dependencies"
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt
new file mode 100644 (file)
index 0000000..c5a78a9
--- /dev/null
@@ -0,0 +1,86 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service\r
+\r
+import com.att.eelf.configuration.EELFLogger\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition\r
+import com.att.eelf.configuration.EELFManager\r
+\r
+/**\r
+ * ResourceAssignmentEnhancerService.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+interface ResourceAssignmentEnhancerService {\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,\r
+                         resourceAssignments: List<ResourceAssignment>)\r
+\r
+    @Throws(BluePrintException::class)\r
+    fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate\r
+}\r
+\r
+/**\r
+ * ResourceAssignmentEnhancerDefaultService.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)\r
+    : ResourceAssignmentEnhancerService {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)\r
+\r
+    /**\r
+     * Get the defined source instance from the ResourceAssignment,\r
+     * then get the NodeType of the Sources assigned\r
+     */\r
+    override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,\r
+                                  resourceAssignments: List<ResourceAssignment>) {\r
+\r
+        // Iterate the Resource Assignment and\r
+        resourceAssignments.map { resourceAssignment ->\r
+            val dictionaryName = resourceAssignment.dictionaryName!!\r
+            val dictionarySource = resourceAssignment.dictionarySource!!\r
+            log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,\r
+                    dictionaryName, dictionarySource)\r
+            // Get the Resource Definition from Repo\r
+            val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)\r
+\r
+            val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)\r
+\r
+            // Enrich as NodeTemplate\r
+            bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!)\r
+        }\r
+    }\r
+\r
+    override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {\r
+        val bluePrintEnhancerService = BluePrintEnhancerDefaultService(resourceDefinitionRepoService)\r
+        bluePrintEnhancerService.serviceTemplate = ServiceTemplate()\r
+        bluePrintEnhancerService.initialCleanUp()\r
+        enhanceBluePrint(bluePrintEnhancerService, resourceAssignments)\r
+        return bluePrintEnhancerService.serviceTemplate\r
+    }\r
+\r
+    private fun getResourceDefinition(name: String): ResourceDefinition {\r
+        return resourceDefinitionRepoService.getResourceDefinition(name)!!.block()!!\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
new file mode 100644 (file)
index 0000000..228b39e
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ *  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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
+
+import com.att.eelf.configuration.EELFLogger
+import org.apache.commons.collections.CollectionUtils
+import org.apache.commons.lang3.StringUtils
+import org.apache.commons.lang3.text.StrBuilder
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import com.att.eelf.configuration.EELFManager
+import java.io.Serializable
+
+/**
+ * ResourceAssignmentValidationService.
+ *
+ * @author Brinda Santh
+ */
+interface ResourceAssignmentValidationService : Serializable {
+
+    @Throws(BluePrintException::class)
+    fun validate(resourceAssignments: List<ResourceAssignment>): Boolean
+}
+
+/**
+ * ResourceAssignmentValidationDefaultService.
+ *
+ * @author Brinda Santh
+ */
+open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValidationService {
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)
+
+    open var resourceAssignmentMap: Map<String, ResourceAssignment> = hashMapOf()
+    open val validationMessage = StrBuilder()
+
+    override fun validate(resourceAssignments: List<ResourceAssignment>): Boolean {
+        try {
+            validateSources(resourceAssignments)
+            validateTemplateNDictionaryKeys(resourceAssignments)
+            validateCyclicDependency(resourceAssignments)
+            if (StringUtils.isNotBlank(validationMessage)) {
+                throw BluePrintException("Resource Assignment Validation Failure")
+            }
+        } catch (e: Exception) {
+            throw BluePrintException("Resource Assignment Validation :" + validationMessage.toString(), e)
+        }
+        return true
+    }
+
+    open fun validateSources(resourceAssignments: List<ResourceAssignment>) {
+        log.info("validating resource assignment sources")
+    }
+
+    open fun validateTemplateNDictionaryKeys(resourceAssignments: List<ResourceAssignment>) {
+
+        resourceAssignmentMap = resourceAssignments.map { it.name to it }.toMap()
+
+        val duplicateKeyNames = resourceAssignments.groupBy { it.name }
+                .filter { it.value.size > 1 }
+                .map { it.key }
+
+        if (duplicateKeyNames.isNotEmpty()) {
+            validationMessage.appendln(String.format("Duplicate Assignment Template Keys (%s) is Present", duplicateKeyNames))
+        }
+
+        val duplicateDictionaryKeyNames = resourceAssignments.groupBy { it.dictionaryName }
+                .filter { it.value.size > 1 }
+                .map { it.key }
+        if (duplicateDictionaryKeyNames.isNotEmpty()) {
+            validationMessage.appendln(String.format("Duplicate Assignment Dictionary Keys (%s) is Present", duplicateDictionaryKeyNames))
+        }
+
+        val dependenciesNames = resourceAssignments.mapNotNull { it.dependencies }.flatten()
+
+        log.info("Resource assignment definitions : {}", resourceAssignmentMap.keys)
+        log.info("Resource assignment Dictionary dependencies : {}", dependenciesNames)
+
+        val notPresentDictionaries = dependenciesNames.filter { !resourceAssignmentMap.containsKey(it) }.distinct()
+        if (notPresentDictionaries.isNotEmpty()) {
+            validationMessage.appendln(String.format("No assignments for Dictionary Keys (%s)", notPresentDictionaries))
+        }
+
+        if (StringUtils.isNotBlank(validationMessage)) {
+            throw BluePrintException("Resource Assignment Validation Failure")
+        }
+    }
+
+    open fun validateCyclicDependency(resourceAssignments: List<ResourceAssignment>) {
+        val startResourceAssignment = ResourceAssignment()
+        startResourceAssignment.name = "*"
+
+        val topologySorting = TopologicalSortingUtils<ResourceAssignment>()
+
+        resourceAssignmentMap.map { it.value }.map { resourceAssignment ->
+            if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) {
+                resourceAssignment.dependencies!!.map {
+                    log.info("Topological Graph link from {} to {}", it, resourceAssignment.name)
+                    topologySorting.add(resourceAssignmentMap[it]!!, resourceAssignment)
+                }
+            } else {
+                topologySorting.add(startResourceAssignment, resourceAssignment)
+            }
+        }
+
+        if (!topologySorting.isDag) {
+            val graph = getTopologicalGraph(topologySorting)
+            validationMessage.appendln("Cyclic Dependency :$graph")
+        }
+    }
+
+    open fun getTopologicalGraph(topologySorting: TopologicalSortingUtils<ResourceAssignment>): String {
+        val s = StringBuilder()
+        val neighbors = topologySorting.getNeighbors()
+
+        neighbors.forEach { v, vs ->
+            if (v.name == "*") {
+                s.append("\n    * -> [")
+                for (resourceAssignment in vs) {
+                    s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name
+                            + "),")
+                }
+                s.append("]")
+            } else {
+                s.append("\n    (" + v.dictionaryName + ":" + v.name + ") -> [")
+                for (resourceAssignment in vs) {
+                    s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name
+                            + "),")
+                }
+                s.append("]")
+            }
+        }
+        return s.toString()
+    }
+
+
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt
new file mode 100644 (file)
index 0000000..d51338c
--- /dev/null
@@ -0,0 +1,61 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition\r
+import reactor.core.publisher.Mono\r
+/**\r
+ * ResourceDefinitionRepoService.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+interface ResourceDefinitionRepoService : BluePrintRepoService {\r
+\r
+    fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>?\r
+}\r
+\r
+/**\r
+ * ResourceDefinitionFileRepoService.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+open class ResourceDefinitionFileRepoService : BluePrintRepoFileService,\r
+        ResourceDefinitionRepoService {\r
+\r
+    private var resourceDefinitionPath: String\r
+    private val extension = ".json"\r
+\r
+    constructor(basePath: String) : this(basePath,\r
+            basePath.plus(BluePrintConstants.PATH_DIVIDER)\r
+                    .plus(BluePrintConstants.MODEL_DIR_MODEL_TYPE))\r
+\r
+    constructor(basePath: String, modelTypePath: String) : super(modelTypePath) {\r
+        resourceDefinitionPath = basePath.plus("/resource_dictionary")\r
+    }\r
+\r
+    override fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>? {\r
+\r
+        val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER)\r
+                .plus(resourceDefinitionName).plus(extension)\r
+\r
+        return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java)\r
+    }\r
+}\r
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
new file mode 100644 (file)
index 0000000..14855d4
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ *  Copyright © 2018 IBM.
+ *  Modifications 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
+
+import com.att.eelf.configuration.EELFLogger
+import com.fasterxml.jackson.databind.JsonNode
+import com.google.common.base.Preconditions
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import com.att.eelf.configuration.EELFManager
+import java.io.Serializable
+/**
+ * ResourceDefinitionValidationService.
+ *
+ * @author Brinda Santh
+ */
+interface ResourceDefinitionValidationService : Serializable {
+
+    @Throws(BluePrintException::class)
+    fun validate(resourceDefinition: ResourceDefinition)
+
+}
+/**
+ * ResourceDefinitionValidationService.
+ *
+ * @author Brinda Santh
+ */
+open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService {
+
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidationService::class.java)
+
+    override fun validate(resourceDefinition: ResourceDefinition) {
+        Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition")
+        log.trace("Validating Resource Dictionary Definition {}", resourceDefinition.name)
+
+        resourceDefinition.sources.forEach { (name, nodeTemplate) ->
+            val sourceType = nodeTemplate.type
+
+            val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)?.block()
+                    ?: throw BluePrintException(format("Failed to get source({}) node type definition({})", name, sourceType))
+
+            // Validate Property Name, expression, values and Data Type
+            validateNodeTemplateProperties(nodeTemplate, sourceNodeType)
+        }
+    }
+
+
+    open fun validateNodeTemplateProperties(nodeTemplate: NodeTemplate, nodeType: NodeType) {
+        nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
+    }
+
+
+    open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,
+                                         properties: MutableMap<String, JsonNode>) {
+        properties.forEach { propertyName, propertyAssignment ->
+            val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]
+                    ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName))
+            // Check and Validate if Expression Node
+            val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
+            if (!expressionData.isExpression) {
+                checkPropertyValue(propertyDefinition, propertyName, propertyAssignment)
+            } else {
+                throw BluePrintException(format("property({}) of expression ({}) is not supported",
+                        propertyName, propertyAssignment))
+            }
+        }
+    }
+
+    open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) {
+        val propertyType = propertyDefinition.type
+        val isValid : Boolean
+
+        if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
+            isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
+
+        } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
+
+            isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment)
+        } else {
+            bluePrintRepoService.getDataType(propertyType)
+                    ?: throw BluePrintException(format("property({}) defined of data type({}) is not in repository",
+                            propertyName, propertyType))
+            isValid = true
+        }
+
+        check(isValid) {
+            throw BluePrintException(format("property({}) defined of type({}) is not compatable with the value ({})",
+                    propertyName, propertyType, propertyAssignment))
+        }
+    }
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt
new file mode 100644 (file)
index 0000000..747639c
--- /dev/null
@@ -0,0 +1,109 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils\r
+\r
+import com.att.eelf.configuration.EELFLogger\r
+import org.apache.commons.collections.CollectionUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
+import com.att.eelf.configuration.EELFManager\r
+import java.util.ArrayList\r
+/**\r
+ * BulkResourceSequencingUtils.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object BulkResourceSequencingUtils {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(BulkResourceSequencingUtils::class.java)\r
+\r
+    @JvmStatic\r
+    fun process(resourceAssignments: MutableList<ResourceAssignment>): List<List<ResourceAssignment>> {\r
+        val resourceAssignmentMap: MutableMap<String, ResourceAssignment> = hashMapOf()\r
+        val sequenceBatchResourceAssignment = ArrayList<List<ResourceAssignment>>()\r
+        log.info("Assignments ({})", resourceAssignments)\r
+        // Prepare Map\r
+        resourceAssignments.forEach { resourceAssignment ->\r
+            log.trace("Processing Key ({})", resourceAssignment.name)\r
+            resourceAssignmentMap.put(resourceAssignment.name, resourceAssignment)\r
+        }\r
+\r
+        val startResourceAssignment = ResourceAssignment()\r
+        startResourceAssignment.name = "*"\r
+\r
+        // Preepare Sorting Map\r
+        val topologySorting = TopologicalSortingUtils<ResourceAssignment>()\r
+        resourceAssignmentMap.forEach { _, resourceAssignment ->\r
+            if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) {\r
+                for (dependency in resourceAssignment.dependencies!!) {\r
+                    topologySorting.add(resourceAssignmentMap[dependency]!!, resourceAssignment)\r
+                }\r
+            } else {\r
+                topologySorting.add(startResourceAssignment, resourceAssignment)\r
+            }\r
+        }\r
+\r
+        val sequencedResourceAssignments: MutableList<ResourceAssignment> = topologySorting.topSort()!! as MutableList<ResourceAssignment>\r
+        log.info("Sorted Sequenced Assignments ({})", sequencedResourceAssignments)\r
+\r
+        var batchResourceAssignment: MutableList<ResourceAssignment>? = null\r
+        var batchAssignmentName: MutableList<String>? = null\r
+\r
+        // Prepare Sorting\r
+        sequencedResourceAssignments.forEachIndexed { index, resourceAssignment ->\r
+\r
+            var previousResourceAssignment: ResourceAssignment? = null\r
+\r
+            if (index > 0) {\r
+                previousResourceAssignment = sequencedResourceAssignments[index - 1]\r
+            }\r
+\r
+            var dependencyPresence = false\r
+            if (batchAssignmentName != null && resourceAssignment.dependencies != null) {\r
+                dependencyPresence = CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.dependencies)\r
+            }\r
+\r
+            log.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.name,\r
+                    batchAssignmentName, resourceAssignment.dependencies, dependencyPresence)\r
+\r
+            if (previousResourceAssignment != null && resourceAssignment.dictionarySource != null\r
+                    && resourceAssignment.dictionarySource!!.equals(previousResourceAssignment.dictionarySource, true)\r
+                    && !dependencyPresence) {\r
+                batchResourceAssignment!!.add(resourceAssignment)\r
+                batchAssignmentName!!.add(resourceAssignment.name)\r
+            } else {\r
+                if (batchResourceAssignment != null) {\r
+                    sequenceBatchResourceAssignment.add(batchResourceAssignment!!)\r
+                    log.trace("Created old Set ({})", batchAssignmentName)\r
+                }\r
+                batchResourceAssignment = arrayListOf()\r
+                batchResourceAssignment!!.add(resourceAssignment)\r
+\r
+                batchAssignmentName = arrayListOf()\r
+                batchAssignmentName!!.add(resourceAssignment.name)\r
+            }\r
+\r
+            if (index == sequencedResourceAssignments.size - 1) {\r
+                log.trace("Created old Set ({})", batchAssignmentName)\r
+                sequenceBatchResourceAssignment.add(batchResourceAssignment!!)\r
+            }\r
+        }\r
+        log.info("Batched Sequence : ({})", sequenceBatchResourceAssignment)\r
+\r
+        return sequenceBatchResourceAssignment\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
new file mode 100644 (file)
index 0000000..a3456cd
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ *  Copyright © 2018 IBM.
+ *
+ *  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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils
+
+import com.att.eelf.configuration.EELFLogger
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.NullNode
+import org.apache.commons.collections.MapUtils
+import org.apache.commons.lang3.StringUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
+import com.att.eelf.configuration.EELFManager
+
+
+object ResourceDictionaryUtils {
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils::class.java)
+
+    @JvmStatic
+    fun populateSourceMapping(resourceAssignment: ResourceAssignment,
+                              resourceDefinition: ResourceDefinition) {
+
+        if (StringUtils.isBlank(resourceAssignment.dictionarySource)) {
+
+            if (MapUtils.isNotEmpty(resourceDefinition.sources)) {
+                val source = findFirstSource(resourceDefinition.sources)
+
+                // Populate and Assign First Source
+                if (StringUtils.isNotBlank(source)) {
+                    // Set Dictionary Source
+                    resourceAssignment.dictionarySource = source
+                } else {
+                    resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT
+                }
+                log.info("auto map resourceAssignment : {}", resourceAssignment)
+            }else {
+                resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT
+            }
+        }
+    }
+
+    @JvmStatic
+    fun findFirstSource(sources: Map<String, NodeTemplate>): String? {
+        var source: String? = null
+        if (MapUtils.isNotEmpty(sources)) {
+            source = sources.keys.stream().findFirst().get()
+        }
+        return source
+    }
+
+    @JvmStatic
+    fun assignInputs(data: JsonNode, context: MutableMap<String, Any>) {
+        log.trace("assignInputs from input JSON ({})", data.toString())
+        data.fields().forEach { field ->
+            val valueNode: JsonNode = data.at("/".plus(field.key)) ?: NullNode.getInstance()
+
+            val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(field.key)
+            log.trace("setting path ({}), values ({})", path, valueNode)
+            context[path] = valueNode
+        }
+    }
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
new file mode 100644 (file)
index 0000000..fde8000
--- /dev/null
@@ -0,0 +1,60 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *  Modifications Copyright © 2018 IBM.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class ResourceDefinitionTest {\r
+    private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class);\r
+    private String basePath = "load/resource_dictionary";\r
+\r
+    @Test\r
+    public void testDictionaryDefinitionInputSource(){\r
+\r
+        String fileName = basePath + "/input-source.json";\r
+        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition);\r
+    }\r
+\r
+    @Test\r
+    public void testDictionaryDefinitionDefaultSource(){\r
+\r
+        String fileName = basePath + "/default-source.json";\r
+        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition);\r
+    }\r
+\r
+    @Test\r
+    public void testDictionaryDefinitionDBSource(){\r
+\r
+        String fileName = basePath + "/db-source.json";\r
+        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);\r
+    }\r
+\r
+    @Test\r
+    public void testDictionaryDefinitionMDSALSource(){\r
+        String fileName = basePath + "/mdsal-source.json";\r
+        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);\r
+        Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition);\r
+    }\r
+}\r
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java
new file mode 100644 (file)
index 0000000..57c8509
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * ResourceAssignmentEnhancerService.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+public class ResourceAssignmentEnhancerServiceTest {\r
+\r
+    @Test\r
+    public void testEnhanceBluePrint() throws BluePrintException {\r
+\r
+        List<ResourceAssignment> resourceAssignments = JacksonReactorUtils\r
+                .getListFromClassPathFile("enrich/simple-enrich.json", ResourceAssignment.class).block();\r
+        Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments);\r
+        ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load");\r
+        ResourceAssignmentEnhancerService resourceAssignmentEnhancerService =\r
+                new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService);\r
+        ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments);\r
+        Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate);\r
+    }\r
+}\r
+\r
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt
new file mode 100644 (file)
index 0000000..6216d5b
--- /dev/null
@@ -0,0 +1,57 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service\r
+\r
+import com.att.eelf.configuration.EELFLogger\r
+import org.junit.Assert\r
+import org.junit.Test\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
+import com.att.eelf.configuration.EELFManager\r
+/**\r
+ * ResourceAssignmentValidationServiceTest.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class ResourceAssignmentValidationServiceTest {\r
+    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java)\r
+    @Test\r
+    fun testValidateSuccess() {\r
+        log.info("**************** testValidateSuccess *****************")\r
+        val assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment::class.java)\r
+        val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService()\r
+        val result = resourceAssignmentValidator.validate(assignments!!)\r
+        Assert.assertTrue("Failed to Validate", result)\r
+    }\r
+\r
+    @Test(expected = BluePrintException::class)\r
+    fun testValidateDuplicate() {\r
+        log.info(" **************** testValidateDuplicate *****************")\r
+        val assignments = JacksonUtils.getListFromClassPathFile("validation/duplicate.json", ResourceAssignment::class.java)\r
+        val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService()\r
+        resourceAssignmentValidator.validate(assignments!!)\r
+    }\r
+\r
+    @Test(expected = BluePrintException::class)\r
+    fun testValidateCyclic() {\r
+        log.info(" ****************  testValidateCyclic *****************")\r
+        val assignments = JacksonUtils.getListFromClassPathFile("validation/cyclic.json", ResourceAssignment::class.java)\r
+        val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService()\r
+        resourceAssignmentValidator.validate(assignments!!)\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java
new file mode 100644 (file)
index 0000000..1772277
--- /dev/null
@@ -0,0 +1,36 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
+\r
+public class ResourceDefinitionRepoServiceTest {\r
+\r
+    @Test\r
+    public void testGetResourceDefinition() throws Exception{\r
+        ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load");\r
+        ResourceDefinition resourceDefinition = resourceDefinitionRepoService\r
+                .getResourceDefinition("db-source").block();\r
+        Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition);\r
+\r
+        NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db").block();\r
+        Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition);\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
new file mode 100644 (file)
index 0000000..ef30562
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *  Copyright © 2018 IBM.
+ *
+ *  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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
+
+public class ResourceDefinitionValidationServiceTest {
+    private String basePath = "load/model_type";
+    private String dictionaryPath = "load/resource_dictionary";
+    private BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath);
+
+    @Test
+    public void testValidateSource() throws Exception {
+
+        String inputFileName = dictionaryPath + "/db-source.json";
+        testValidate(inputFileName);
+
+        String dbFileName = dictionaryPath + "/db-source.json";
+        testValidate(dbFileName);
+
+        String defaultFileName = dictionaryPath + "/default-source.json";
+        testValidate(defaultFileName);
+
+        String restFileName = dictionaryPath + "/mdsal-source.json";
+        testValidate(restFileName);
+    }
+
+    private void testValidate(String fileName) throws Exception {
+
+        ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+        Assert.assertNotNull("Failed to populate dictionaryDefinition for  type", resourceDefinition);
+
+        ResourceDefinitionValidationService resourceDictionaryValidationService =
+                new ResourceDefinitionDefaultValidationService(bluePrintRepoFileService);
+        resourceDictionaryValidationService.validate(resourceDefinition);
+        Assert.assertNotNull(String.format("Failed to populate dictionaryDefinition for : %s", fileName), resourceDefinition);
+    }
+}
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java
new file mode 100644 (file)
index 0000000..c7444db
--- /dev/null
@@ -0,0 +1,37 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
+import java.util.List;\r
+/**\r
+ * BulkResourceSequencingUtils.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+public class BulkResourceSequencingUtilsTest {\r
+\r
+    @Test\r
+    public void testProcess(){\r
+        List<ResourceAssignment> assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment.class);\r
+        Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments);\r
+        BulkResourceSequencingUtils.process(assignments);\r
+    }\r
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
new file mode 100644 (file)
index 0000000..13bf819
--- /dev/null
@@ -0,0 +1,99 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;\r
+\r
+\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+/**\r
+ * ResourceDictionaryUtilsTest.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+public class ResourceDictionaryUtilsTest {\r
+    private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class);\r
+\r
+    @Test\r
+    public void testPopulateSourceMapping() {\r
+\r
+        ResourceAssignment resourceAssignment = new ResourceAssignment();\r
+        resourceAssignment.setName("sample-assignment");\r
+        ResourceDefinition resourceDefinition = new ResourceDefinition();\r
+        Map<String, NodeTemplate> sources = new HashMap<>();\r
+        resourceDefinition.setSources(sources);\r
+        // To Check Empty Source\r
+        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+        Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, resourceAssignment.getDictionarySource());\r
+\r
+        // To Check First Source\r
+        resourceAssignment.setDictionarySource(null);\r
+        sources.put(ResourceDictionaryConstants.SOURCE_DEFAULT, new NodeTemplate());\r
+        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+        Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource());\r
+\r
+        // To Check Assigned Source\r
+        resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_DB);\r
+        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+        Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_DB, resourceAssignment.getDictionarySource());\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testFindFirstSource() {\r
+        //To check if Empty Source\r
+        Map<String, NodeTemplate> sources = new HashMap<>();\r
+        String firstSource = ResourceDictionaryUtils.findFirstSource(sources);\r
+        Assert.assertNull("Source populated, which is not expected.", firstSource);\r
+\r
+        // TO check the first Source\r
+        sources.put(ResourceDictionaryConstants.SOURCE_INPUT, new NodeTemplate());\r
+        String inputFirstSource = ResourceDictionaryUtils.findFirstSource(sources);\r
+        Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource);\r
+\r
+        // TO check the multiple Source\r
+        sources.put(ResourceDictionaryConstants.SOURCE_DB, new NodeTemplate());\r
+        String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources);\r
+        Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource);\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testAssignInputs() {\r
+        JsonNode data = JacksonUtils.jsonNodeFromClassPathFile("data/resource-assignment-input.json");\r
+        Map<String, Object> context = new HashMap<>();\r
+        ResourceDictionaryUtils.assignInputs(data, context);\r
+        String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue");\r
+        log.info("populated context {}", context);\r
+        Assert.assertTrue(String.format("failed to get variable : %s",path),context.containsKey(path));\r
+\r
+    }\r
+\r
+\r
+}\r
diff --git a/components/resource-dict/src/test/resources/data/resource-assignment-input.json b/components/resource-dict/src/test/resources/data/resource-assignment-input.json
new file mode 100644 (file)
index 0000000..d79c906
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "intValue" : 1,
+  "floatValue" : 1.34,
+  "booleanValue" : true,
+  "stringValue" : "sample-String",
+  "timeValue" : "2018-09-29",
+  "arrayStringValue" : ["one", "two"],
+  "mapValue" : {"profile_name1":"profile_name1",
+    "profile_name2":"profile_name2"}
+}
\ No newline at end of file
diff --git a/components/resource-dict/src/test/resources/enrich/simple-enrich.json b/components/resource-dict/src/test/resources/enrich/simple-enrich.json
new file mode 100644 (file)
index 0000000..641da80
--- /dev/null
@@ -0,0 +1,37 @@
+[\r
+  {\r
+    "name": "rs-db-source",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "db-source",\r
+    "dictionary-source": "db",\r
+    "dependencies": [\r
+      "input-source"\r
+    ]\r
+  },\r
+  {\r
+    "name": "ra-default-source",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "default-source",\r
+    "dictionary-source": "default",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "ra-input-source",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "input-source",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  }\r
+]\r
diff --git a/components/resource-dict/src/test/resources/validation/cyclic.json b/components/resource-dict/src/test/resources/validation/cyclic.json
new file mode 100644 (file)
index 0000000..d837dc5
--- /dev/null
@@ -0,0 +1,111 @@
+[\r
+  {\r
+    "name": "vnf-id",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "vnf-id",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "service-instance-id",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "service-instance-id",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "bundle-id",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "bundle-id",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "vnf-id"\r
+    ]\r
+  },\r
+  {\r
+    "name": "bundle-ip",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "bundle-ip",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "vnf-id"\r
+    ]\r
+  },\r
+  {\r
+    "name": "bundle-mac",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "bundle-mac",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "vnf-id",\r
+      "bundle-id"\r
+    ]\r
+  },\r
+  {\r
+    "name": "managed-ip",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "managed-ip",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "loopback-ip"\r
+    ]\r
+  },\r
+  {\r
+    "name": "vnf-name",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "vnf-name",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "managed-ip1",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "managed-ip1",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "loopback-ip"\r
+    ]\r
+  },\r
+  {\r
+    "name": "loopback-ip",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "loopback-ip",\r
+    "dictionary-source": "db",\r
+    "dependencies": [\r
+      "bundle-mac",\r
+      "managed-ip1"\r
+    ]\r
+  }\r
+]\r
diff --git a/components/resource-dict/src/test/resources/validation/duplicate.json b/components/resource-dict/src/test/resources/validation/duplicate.json
new file mode 100644 (file)
index 0000000..330324c
--- /dev/null
@@ -0,0 +1,110 @@
+[\r
+  {\r
+    "name": "vnf-id",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "vnf-id",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "service-instance-id",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "service-instance-id",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "bundle-id",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "bundle-id",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "vnf-id"\r
+    ]\r
+  },\r
+  {\r
+    "name": "bundle-ip",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "bundle-ip",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "vnf-id"\r
+    ]\r
+  },\r
+  {\r
+    "name": "bundle-mac",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "bundle-mac",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "vnf-id",\r
+      "bundle-id"\r
+    ]\r
+  },\r
+  {\r
+    "name": "bundle-mac",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "bundle-mac",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "loopback-ip"\r
+    ]\r
+  },\r
+  {\r
+    "name": "vnf-name",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "vnf-name",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "managed-ip1",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "managed-ip1",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "loopback-ip"\r
+    ]\r
+  },\r
+  {\r
+    "name": "loopback-ip",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "loopback-ip",\r
+    "dictionary-source": "db",\r
+    "dependencies": [\r
+      "bundle-mac"\r
+    ]\r
+  }\r
+]\r
diff --git a/components/resource-dict/src/test/resources/validation/success.json b/components/resource-dict/src/test/resources/validation/success.json
new file mode 100644 (file)
index 0000000..3215d06
--- /dev/null
@@ -0,0 +1,110 @@
+[\r
+  {\r
+    "name": "vnf-id",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "vnf-id",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "service-instance-id",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "service-instance-id",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "bundle-id",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "bundle-id",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "vnf-id"\r
+    ]\r
+  },\r
+  {\r
+    "name": "bundle-ip",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "bundle-ip",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "vnf-id"\r
+    ]\r
+  },\r
+  {\r
+    "name": "bundle-mac",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "bundle-mac",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "vnf-id",\r
+      "bundle-id"\r
+    ]\r
+  },\r
+  {\r
+    "name": "managed-ip",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "managed-ip",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "loopback-ip"\r
+    ]\r
+  },\r
+  {\r
+    "name": "vnf-name",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string",\r
+      "required": true\r
+    },\r
+    "dictionary-name": "vnf-name",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  },\r
+  {\r
+    "name": "managed-ip1",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "managed-ip1",\r
+    "dictionary-source": "mdsal",\r
+    "dependencies": [\r
+      "loopback-ip"\r
+    ]\r
+  },\r
+  {\r
+    "name": "loopback-ip",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "loopback-ip",\r
+    "dictionary-source": "db",\r
+    "dependencies": [\r
+      "bundle-mac"\r
+    ]\r
+  }\r
+]\r