Merge "Controller Blueprints Microservice"
authorDan Timoney <dt5972@att.com>
Tue, 4 Sep 2018 14:49:46 +0000 (14:49 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 4 Sep 2018 14:49:46 +0000 (14:49 +0000)
ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt [new file with mode: 0644]
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt [new file with mode: 0644]
ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/cyclic.json [new file with mode: 0644]
ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/duplicate.json [new file with mode: 0644]
ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/success.json [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java

index 8c44461..8c25473 100644 (file)
@@ -61,12 +61,12 @@ class BluePrintRepoFileService(val basePath: String) : BluePrintRepoService {
 \r
     private val log: Logger = LoggerFactory.getLogger(BluePrintRepoFileService::class.java)\r
 \r
-    val dataTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)\r
-    val nodeTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)\r
-    val artifactTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)\r
-    val capabilityTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)\r
-    val relationshipTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)\r
-    val extension = ".json"\r
+    private val dataTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)\r
+    private val nodeTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)\r
+    private val artifactTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)\r
+    private val capabilityTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)\r
+    private val relationshipTypePath = basePath.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
index 697a710..886c3d2 100644 (file)
@@ -102,6 +102,20 @@ object JacksonUtils {
         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 = IOUtils.toString(JacksonUtils::class.java.classLoader.getResourceAsStream(fileName), Charset.defaultCharset())\r
+                ?: throw BluePrintException(String.format("Failed to read json file : %s", 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
@@ -110,13 +124,13 @@ object JacksonUtils {
     }\r
 \r
     @JvmStatic\r
-    fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode) : Boolean {\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
+        return false\r
     }\r
 \r
     @JvmStatic\r
index 4731935..081f4fe 100644 (file)
@@ -29,31 +29,28 @@ import kotlin.test.assertNotNull
 class BluePrintRepoFileServiceTest {\r
 \r
     val basePath = "load/model_type"\r
+    private val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\r
 \r
     @Test\r
     fun testGetDataType() {\r
-        val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\r
         val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")\r
         assertNotNull(dataType, "Failed to get DataType from repo")\r
     }\r
 \r
     @Test\r
     fun testGetNodeType() {\r
-        val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\r
         val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")\r
         assertNotNull(nodeType, "Failed to get NodeType from repo")\r
     }\r
 \r
     @Test\r
     fun testGetArtifactType() {\r
-        val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\r
         val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")\r
         assertNotNull(nodeType, "Failed to get ArtifactType from repo")\r
     }\r
 \r
     @Test(expected = FileNotFoundException::class)\r
     fun testModelNotFound() {\r
-        val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\r
         val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")\r
         assertNotNull(dataType, "Failed to get DataType from repo")\r
     }\r
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
new file mode 100644 (file)
index 0000000..6809831
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ *  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 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 org.onap.ccsdk.apps.controllerblueprints.resource.dict.validator.ResourceAssignmentValidator
+import org.slf4j.LoggerFactory
+import org.apache.commons.collections.CollectionUtils
+import org.apache.commons.lang3.StringUtils
+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 = LoggerFactory.getLogger(ResourceAssignmentValidator::class.java)
+    open var resourceAssignments: List<ResourceAssignment> = arrayListOf()
+    open var resourceAssignmentMap: MutableMap<String, ResourceAssignment> = hashMapOf()
+    open val validationMessage = StrBuilder()
+
+    override fun validate(resourceAssignments: List<ResourceAssignment>): Boolean {
+        this.resourceAssignments = resourceAssignments
+        validateSources(resourceAssignments)
+        validateDuplicateDictionaryKeys()
+        validateCyclicDependency()
+        if (StringUtils.isNotBlank(validationMessage)) {
+            throw BluePrintException("Resource Assignment Validation :" + validationMessage.toString())
+        }
+        return true
+    }
+
+    open fun validateSources(resourceAssignments: List<ResourceAssignment>) {
+        log.info("validating resource assignment sources")
+    }
+
+    open fun validateDuplicateDictionaryKeys() {
+        val uniqueDictionaryKeys = hashSetOf<String>()
+
+        this.resourceAssignments.forEach { resourceAssignment ->
+            // Check Duplicate Names
+            if (!resourceAssignmentMap.containsKey(resourceAssignment.name)) {
+                resourceAssignmentMap[resourceAssignment.name] = resourceAssignment
+            } else {
+                validationMessage.appendln(String.format("Duplicate Assignment Template Key (%s) is Present",
+                        resourceAssignment.name))
+            }
+            // Check duplicate Dictionary Keys
+            if (!uniqueDictionaryKeys.contains(resourceAssignment.dictionaryName!!)) {
+                uniqueDictionaryKeys.add(resourceAssignment.dictionaryName!!)
+            } else {
+                validationMessage.appendln(
+                        String.format("Duplicate Assignment Dictionary Key (%s) present with Template Key (%s)",
+                                resourceAssignment.dictionaryName, resourceAssignment.name))
+            }
+        }
+    }
+
+    open fun validateCyclicDependency() {
+        val startResourceAssignment = ResourceAssignment()
+        startResourceAssignment.name = "*"
+
+        val topologySorting = TopologicalSortingUtils<ResourceAssignment>()
+        this.resourceAssignmentMap.forEach { assignmentKey, assignment ->
+            if (CollectionUtils.isNotEmpty(assignment.dependencies)) {
+                for (dependency in assignment.dependencies!!) {
+                    topologySorting.add(resourceAssignmentMap[dependency]!!, assignment)
+                }
+            } else {
+                topologySorting.add(startResourceAssignment, assignment)
+            }
+        }
+
+        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
index 81bb37d..e4835a0 100644 (file)
@@ -31,15 +31,23 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
 import org.slf4j.LoggerFactory
 import java.io.Serializable
-
+/**
+ * ResourceDictionaryValidationService.
+ *
+ * @author Brinda Santh
+ */
 interface ResourceDictionaryValidationService : Serializable {
 
     @Throws(BluePrintException::class)
     fun validate(resourceDefinition: ResourceDefinition)
 
 }
-
-open class ResourceDictionaryDefaultValidationService(val bluePrintRepoService: BluePrintRepoService) : ResourceDictionaryValidationService {
+/**
+ * ResourceDictionaryDefaultValidationService.
+ *
+ * @author Brinda Santh
+ */
+open class ResourceDictionaryDefaultValidationService(private val bluePrintRepoService: BluePrintRepoService) : ResourceDictionaryValidationService {
 
     private val log = LoggerFactory.getLogger(ResourceDictionaryDefaultValidationService::class.java)
 
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt
new file mode 100644 (file)
index 0000000..4d8301f
--- /dev/null
@@ -0,0 +1,56 @@
+/*\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.utils.JacksonUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
+import org.slf4j.LoggerFactory\r
+/**\r
+ * ResourceAssignmentValidationServiceTest.\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+class ResourceAssignmentValidationServiceTest {\r
+    private val log = LoggerFactory.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/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/cyclic.json b/ms/controllerblueprints/modules/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/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/duplicate.json b/ms/controllerblueprints/modules/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/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/success.json b/ms/controllerblueprints/modules/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
index ae4fed9..c4aebe5 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service;
 \r
 import com.google.common.base.Preconditions;\r
 import org.apache.commons.lang3.StringUtils;\r
+import org.jetbrains.annotations.NotNull;\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.service.BluePrintRepoService;\r
@@ -36,36 +37,37 @@ import java.util.Optional;
  * @author Brinda Santh\r
  */\r
 @Service\r
+@SuppressWarnings("unused")\r
 public class BluePrintRepoDBService implements BluePrintRepoService {\r
 \r
     private ModelTypeRepository modelTypeRepository;\r
-\r
+    @SuppressWarnings("unused")\r
     public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) {\r
         this.modelTypeRepository = modelTypeRepository;\r
     }\r
 \r
     @Override\r
-    public Mono<NodeType> getNodeType(String nodeTypeName) throws BluePrintException {\r
+    public Mono<NodeType> getNodeType(@NotNull String nodeTypeName) throws BluePrintException {\r
         return getModelType(nodeTypeName, NodeType.class);\r
     }\r
 \r
     @Override\r
-    public Mono<DataType> getDataType(String dataTypeName) throws BluePrintException {\r
+    public Mono<DataType> getDataType(@NotNull String dataTypeName) throws BluePrintException {\r
         return getModelType(dataTypeName, DataType.class);\r
     }\r
 \r
     @Override\r
-    public Mono<ArtifactType> getArtifactType(String artifactTypeName) throws BluePrintException {\r
+    public Mono<ArtifactType> getArtifactType(@NotNull String artifactTypeName) throws BluePrintException {\r
         return getModelType(artifactTypeName, ArtifactType.class);\r
     }\r
 \r
     @Override\r
-    public Mono<RelationshipType> getRelationshipType(String relationshipTypeName) throws BluePrintException {\r
+    public Mono<RelationshipType> getRelationshipType(@NotNull String relationshipTypeName) throws BluePrintException {\r
         return getModelType(relationshipTypeName, RelationshipType.class);\r
     }\r
 \r
     @Override\r
-    public Mono<CapabilityDefinition> getCapabilityDefinition(String capabilityDefinitionName) throws BluePrintException {\r
+    public Mono<CapabilityDefinition> getCapabilityDefinition(@NotNull String capabilityDefinitionName) throws BluePrintException {\r
         return getModelType(capabilityDefinitionName, CapabilityDefinition.class);\r
     }\r
 \r
@@ -73,15 +75,15 @@ public class BluePrintRepoDBService implements BluePrintRepoService {
         Preconditions.checkArgument(StringUtils.isNotBlank(modelName),\r
                 "Failed to get model from repo, model name is missing");\r
 \r
-        return getModelDefinitions(modelName).map(content -> {\r
-            Preconditions.checkArgument(StringUtils.isNotBlank(content),\r
-                    String.format("Failed to get model content for model name (%s)", modelName));\r
+        return getModelDefinition(modelName).map(content -> {\r
+                    Preconditions.checkArgument(StringUtils.isNotBlank(content),\r
+                            String.format("Failed to get model content for model name (%s)", modelName));\r
                     return JacksonUtils.readValue(content, valueClass);\r
                 }\r
         );\r
     }\r
 \r
-    private Mono<String> getModelDefinitions(String modelName) throws BluePrintException {\r
+    private Mono<String> getModelDefinition(String modelName) throws BluePrintException {\r
         String modelDefinition;\r
         Optional<ModelType> modelTypeDb = modelTypeRepository.findByModelName(modelName);\r
         if (modelTypeDb.isPresent()) {\r
index 51ae752..27823ef 100644 (file)
@@ -37,15 +37,23 @@ public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
     /**\r
      * This is a findByModelName method\r
      * \r
-     * @param modelName\r
+     * @param modelName Model Name\r
      * @return Optional<ModelType>\r
      */\r
     Optional<ModelType> findByModelName(String modelName);\r
 \r
+    /**\r
+     * This is a findByModelNameIn method\r
+     *\r
+     * @param modelNames Model Names\r
+     * @return List<ModelType>\r
+     */\r
+    List<ModelType> findByModelNameIn(List<String> modelNames);\r
+\r
     /**\r
      * This is a findByDerivedFrom method\r
      * \r
-     * @param derivedFrom\r
+     * @param derivedFrom Derived From\r
      * @return List<ModelType>\r
      */\r
     List<ModelType> findByDerivedFrom(String derivedFrom);\r
@@ -54,15 +62,16 @@ public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
     /**\r
      * This is a findByDerivedFromIn method\r
      * \r
-     * @param derivedFroms\r
+     * @param derivedFroms Derived Froms\r
      * @return List<ModelType>\r
      */\r
+    @SuppressWarnings("unused")\r
     List<ModelType> findByDerivedFromIn(List<String> derivedFroms);\r
 \r
     /**\r
      * This is a findByDefinitionType method\r
      * \r
-     * @param definitionType\r
+     * @param definitionType Definition Type\r
      * @return List<ModelType>\r
      */\r
     List<ModelType> findByDefinitionType(String definitionType);\r
@@ -70,16 +79,17 @@ public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
     /**\r
      * This is a findByDefinitionTypeIn method\r
      * \r
-     * @param definitionTypes\r
+     * @param definitionTypes Definition Types\r
      * @return List<ModelType>\r
      */\r
+    @SuppressWarnings("unused")\r
     List<ModelType> findByDefinitionTypeIn(List<String> definitionTypes);\r
 \r
 \r
     /**\r
      * This is a findByTagsContainingIgnoreCase method\r
      * \r
-     * @param tags\r
+     * @param tags Tags\r
      * @return Optional<ModelType>\r
      */\r
     List<ModelType> findByTagsContainingIgnoreCase(String tags);\r
@@ -88,8 +98,7 @@ public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
     /**\r
      * This is a deleteByModelName method\r
      * \r
-     * @param modelName\r
-     * @return Optional<ModelType>\r
+     * @param modelName ModelName\r
      */\r
     void deleteByModelName(String modelName);\r
 \r