summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dt5972@att.com>2018-09-04 14:49:46 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-04 14:49:46 +0000
commite3f0432162e3d7008469f593e6b777cff5ce32e5 (patch)
tree382bc486052fd084196348962e6ae467cd1952da
parent4acd931b6c96ce604726dfd21ccf9b3cad02b30c (diff)
parentafee4df36caa1a979586c8badf160c3ff49b97a0 (diff)
Merge "Controller Blueprints Microservice"
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt12
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt18
-rw-r--r--ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt5
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt133
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt14
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt56
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/cyclic.json111
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/duplicate.json110
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/success.json110
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java22
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java25
11 files changed, 583 insertions, 33 deletions
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
index 8c4446183..8c2547324 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
@@ -61,12 +61,12 @@ class BluePrintRepoFileService(val basePath: String) : BluePrintRepoService {
private val log: Logger = LoggerFactory.getLogger(BluePrintRepoFileService::class.java)
- val dataTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
- val nodeTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
- val artifactTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
- val capabilityTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)
- val relationshipTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
- val extension = ".json"
+ private val dataTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ private val nodeTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
+ private val artifactTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
+ private val capabilityTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)
+ private val relationshipTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
+ private val extension = ".json"
override fun getDataType(dataTypeName: String): Mono<DataType>? {
val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index 697a71001..886c3d2aa 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -103,6 +103,20 @@ object JacksonUtils {
}
@JvmStatic
+ fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {
+ val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
+ ?: throw BluePrintException(format("Failed to read json file : {}", fileName))
+ return getListFromJson(content, valueType)
+ }
+
+ @JvmStatic
+ fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
+ val content: String = IOUtils.toString(JacksonUtils::class.java.classLoader.getResourceAsStream(fileName), Charset.defaultCharset())
+ ?: throw BluePrintException(String.format("Failed to read json file : %s", fileName))
+ return getListFromJson(content, valueType)
+ }
+
+ @JvmStatic
fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {
val objectMapper = jacksonObjectMapper()
val typeRef = object : TypeReference<MutableMap<String, T>>() {}
@@ -110,13 +124,13 @@ object JacksonUtils {
}
@JvmStatic
- fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode) : Boolean {
+ fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
} else if (BluePrintTypes.validCollectionTypes().contains(type)) {
return checkJsonNodeValueOfCollectionType(type, jsonNode)
}
- return false;
+ return false
}
@JvmStatic
diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
index 4731935e6..081f4fe3b 100644
--- a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
+++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
@@ -29,31 +29,28 @@ import kotlin.test.assertNotNull
class BluePrintRepoFileServiceTest {
val basePath = "load/model_type"
+ private val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
@Test
fun testGetDataType() {
- val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")
assertNotNull(dataType, "Failed to get DataType from repo")
}
@Test
fun testGetNodeType() {
- val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")
assertNotNull(nodeType, "Failed to get NodeType from repo")
}
@Test
fun testGetArtifactType() {
- val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")
assertNotNull(nodeType, "Failed to get ArtifactType from repo")
}
@Test(expected = FileNotFoundException::class)
fun testModelNotFound() {
- val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")
assertNotNull(dataType, "Failed to get DataType from repo")
}
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
index 000000000..6809831f9
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
@@ -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
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt
index 81bb37d02..e4835a06d 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt
@@ -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
index 000000000..4d8301f4e
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt
@@ -0,0 +1,56 @@
+/*
+ * 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.junit.Assert
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.slf4j.LoggerFactory
+/**
+ * ResourceAssignmentValidationServiceTest.
+ *
+ * @author Brinda Santh
+ */
+class ResourceAssignmentValidationServiceTest {
+ private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceTest::class.java)
+ @Test
+ fun testValidateSuccess() {
+ log.info("**************** testValidateSuccess *****************")
+ val assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment::class.java)
+ val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService()
+ val result = resourceAssignmentValidator.validate(assignments!!)
+ Assert.assertTrue("Failed to Validate", result)
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testValidateDuplicate() {
+ log.info(" **************** testValidateDuplicate *****************")
+ val assignments = JacksonUtils.getListFromClassPathFile("validation/duplicate.json", ResourceAssignment::class.java)
+ val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService()
+ resourceAssignmentValidator.validate(assignments!!)
+ }
+
+ @Test(expected = BluePrintException::class)
+ fun testValidateCyclic() {
+ log.info(" **************** testValidateCyclic *****************")
+ val assignments = JacksonUtils.getListFromClassPathFile("validation/cyclic.json", ResourceAssignment::class.java)
+ val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService()
+ resourceAssignmentValidator.validate(assignments!!)
+ }
+} \ 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
index 000000000..d837dc5d8
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/cyclic.json
@@ -0,0 +1,111 @@
+[
+ {
+ "name": "vnf-id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "vnf-id",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "service-instance-id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "bundle-id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "bundle-id",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "vnf-id"
+ ]
+ },
+ {
+ "name": "bundle-ip",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "bundle-ip",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "vnf-id"
+ ]
+ },
+ {
+ "name": "bundle-mac",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "bundle-mac",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "vnf-id",
+ "bundle-id"
+ ]
+ },
+ {
+ "name": "managed-ip",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "managed-ip",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "loopback-ip"
+ ]
+ },
+ {
+ "name": "vnf-name",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "vnf-name",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "managed-ip1",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "managed-ip1",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "loopback-ip"
+ ]
+ },
+ {
+ "name": "loopback-ip",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "loopback-ip",
+ "dictionary-source": "db",
+ "dependencies": [
+ "bundle-mac",
+ "managed-ip1"
+ ]
+ }
+]
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
index 000000000..330324cda
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/duplicate.json
@@ -0,0 +1,110 @@
+[
+ {
+ "name": "vnf-id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "vnf-id",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "service-instance-id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "bundle-id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "bundle-id",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "vnf-id"
+ ]
+ },
+ {
+ "name": "bundle-ip",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "bundle-ip",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "vnf-id"
+ ]
+ },
+ {
+ "name": "bundle-mac",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "bundle-mac",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "vnf-id",
+ "bundle-id"
+ ]
+ },
+ {
+ "name": "bundle-mac",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "bundle-mac",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "loopback-ip"
+ ]
+ },
+ {
+ "name": "vnf-name",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "vnf-name",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "managed-ip1",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "managed-ip1",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "loopback-ip"
+ ]
+ },
+ {
+ "name": "loopback-ip",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "loopback-ip",
+ "dictionary-source": "db",
+ "dependencies": [
+ "bundle-mac"
+ ]
+ }
+]
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
index 000000000..3215d06d7
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/success.json
@@ -0,0 +1,110 @@
+[
+ {
+ "name": "vnf-id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "vnf-id",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "service-instance-id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "bundle-id",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "bundle-id",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "vnf-id"
+ ]
+ },
+ {
+ "name": "bundle-ip",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "bundle-ip",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "vnf-id"
+ ]
+ },
+ {
+ "name": "bundle-mac",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "bundle-mac",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "vnf-id",
+ "bundle-id"
+ ]
+ },
+ {
+ "name": "managed-ip",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "managed-ip",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "loopback-ip"
+ ]
+ },
+ {
+ "name": "vnf-name",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "vnf-name",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "managed-ip1",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "managed-ip1",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "loopback-ip"
+ ]
+ },
+ {
+ "name": "loopback-ip",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "loopback-ip",
+ "dictionary-source": "db",
+ "dependencies": [
+ "bundle-mac"
+ ]
+ }
+]
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
index ae4fed9f4..c4aebe52c 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
@@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
@@ -36,36 +37,37 @@ import java.util.Optional;
* @author Brinda Santh
*/
@Service
+@SuppressWarnings("unused")
public class BluePrintRepoDBService implements BluePrintRepoService {
private ModelTypeRepository modelTypeRepository;
-
+ @SuppressWarnings("unused")
public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) {
this.modelTypeRepository = modelTypeRepository;
}
@Override
- public Mono<NodeType> getNodeType(String nodeTypeName) throws BluePrintException {
+ public Mono<NodeType> getNodeType(@NotNull String nodeTypeName) throws BluePrintException {
return getModelType(nodeTypeName, NodeType.class);
}
@Override
- public Mono<DataType> getDataType(String dataTypeName) throws BluePrintException {
+ public Mono<DataType> getDataType(@NotNull String dataTypeName) throws BluePrintException {
return getModelType(dataTypeName, DataType.class);
}
@Override
- public Mono<ArtifactType> getArtifactType(String artifactTypeName) throws BluePrintException {
+ public Mono<ArtifactType> getArtifactType(@NotNull String artifactTypeName) throws BluePrintException {
return getModelType(artifactTypeName, ArtifactType.class);
}
@Override
- public Mono<RelationshipType> getRelationshipType(String relationshipTypeName) throws BluePrintException {
+ public Mono<RelationshipType> getRelationshipType(@NotNull String relationshipTypeName) throws BluePrintException {
return getModelType(relationshipTypeName, RelationshipType.class);
}
@Override
- public Mono<CapabilityDefinition> getCapabilityDefinition(String capabilityDefinitionName) throws BluePrintException {
+ public Mono<CapabilityDefinition> getCapabilityDefinition(@NotNull String capabilityDefinitionName) throws BluePrintException {
return getModelType(capabilityDefinitionName, CapabilityDefinition.class);
}
@@ -73,15 +75,15 @@ public class BluePrintRepoDBService implements BluePrintRepoService {
Preconditions.checkArgument(StringUtils.isNotBlank(modelName),
"Failed to get model from repo, model name is missing");
- return getModelDefinitions(modelName).map(content -> {
- Preconditions.checkArgument(StringUtils.isNotBlank(content),
- String.format("Failed to get model content for model name (%s)", modelName));
+ return getModelDefinition(modelName).map(content -> {
+ Preconditions.checkArgument(StringUtils.isNotBlank(content),
+ String.format("Failed to get model content for model name (%s)", modelName));
return JacksonUtils.readValue(content, valueClass);
}
);
}
- private Mono<String> getModelDefinitions(String modelName) throws BluePrintException {
+ private Mono<String> getModelDefinition(String modelName) throws BluePrintException {
String modelDefinition;
Optional<ModelType> modelTypeDb = modelTypeRepository.findByModelName(modelName);
if (modelTypeDb.isPresent()) {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java
index 51ae752f9..27823ef33 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java
@@ -37,15 +37,23 @@ public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
/**
* This is a findByModelName method
*
- * @param modelName
+ * @param modelName Model Name
* @return Optional<ModelType>
*/
Optional<ModelType> findByModelName(String modelName);
/**
+ * This is a findByModelNameIn method
+ *
+ * @param modelNames Model Names
+ * @return List<ModelType>
+ */
+ List<ModelType> findByModelNameIn(List<String> modelNames);
+
+ /**
* This is a findByDerivedFrom method
*
- * @param derivedFrom
+ * @param derivedFrom Derived From
* @return List<ModelType>
*/
List<ModelType> findByDerivedFrom(String derivedFrom);
@@ -54,15 +62,16 @@ public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
/**
* This is a findByDerivedFromIn method
*
- * @param derivedFroms
+ * @param derivedFroms Derived Froms
* @return List<ModelType>
*/
+ @SuppressWarnings("unused")
List<ModelType> findByDerivedFromIn(List<String> derivedFroms);
/**
* This is a findByDefinitionType method
*
- * @param definitionType
+ * @param definitionType Definition Type
* @return List<ModelType>
*/
List<ModelType> findByDefinitionType(String definitionType);
@@ -70,16 +79,17 @@ public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
/**
* This is a findByDefinitionTypeIn method
*
- * @param definitionTypes
+ * @param definitionTypes Definition Types
* @return List<ModelType>
*/
+ @SuppressWarnings("unused")
List<ModelType> findByDefinitionTypeIn(List<String> definitionTypes);
/**
* This is a findByTagsContainingIgnoreCase method
*
- * @param tags
+ * @param tags Tags
* @return Optional<ModelType>
*/
List<ModelType> findByTagsContainingIgnoreCase(String tags);
@@ -88,8 +98,7 @@ public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
/**
* This is a deleteByModelName method
*
- * @param modelName
- * @return Optional<ModelType>
+ * @param modelName ModelName
*/
void deleteByModelName(String modelName);