summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints/modules')
-rw-r--r--ms/controllerblueprints/modules/core/pom.xml15
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt10
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt (renamed from ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/OrchestratorException.kt)3
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt5
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt19
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoService.kt92
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt9
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt114
-rw-r--r--ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt9
-rw-r--r--ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt3
-rw-r--r--ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt (renamed from ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoFileServiceTest.kt)19
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-component-java.json31
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-db.json44
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-default.json18
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-input.json18
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-rest.json61
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json5
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json25
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json28
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json16
-rw-r--r--ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json54
-rw-r--r--ms/controllerblueprints/modules/resource-dict/pom.xml7
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java167
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java6
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDependency.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java3
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java3
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java129
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt34
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt95
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt81
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt62
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java (renamed from ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java)34
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java56
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java164
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java79
-rw-r--r--ms/controllerblueprints/modules/service/load/model_type/node_type/source-db.json44
-rw-r--r--ms/controllerblueprints/modules/service/load/model_type/node_type/source-default.json18
-rw-r--r--ms/controllerblueprints/modules/service/load/model_type/node_type/source-input.json18
-rw-r--r--ms/controllerblueprints/modules/service/load/model_type/node_type/source-rest.json61
-rw-r--r--ms/controllerblueprints/modules/service/load/model_type/node_type/tosca.nodes.ResourceSource.json5
-rw-r--r--ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json25
-rw-r--r--ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json18
-rw-r--r--ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json29
-rw-r--r--ms/controllerblueprints/modules/service/pom.xml17
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java7
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java100
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java5
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java94
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java25
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java111
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java31
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java52
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java9
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json34
60 files changed, 1297 insertions, 936 deletions
diff --git a/ms/controllerblueprints/modules/core/pom.xml b/ms/controllerblueprints/modules/core/pom.xml
index 5782c60f..ba38de63 100644
--- a/ms/controllerblueprints/modules/core/pom.xml
+++ b/ms/controllerblueprints/modules/core/pom.xml
@@ -2,6 +2,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
@@ -42,9 +44,22 @@
<artifactId>jackson-module-jsonSchema</artifactId>
</dependency>
<dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-core</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
index 1bdd5307..85f1579e 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -73,12 +74,21 @@ object BluePrintConstants {
const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"
const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"
+ const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"
+ const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"
+ const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"
+ @Deprecated("Artifacts will be attached to Node Template")
+ const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"
+ const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource"
+
const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java"
const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"
const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"
const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"
const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
+ const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
+
const val EXPRESSION_GET_INPUT: String = "get_input"
const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"
const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/OrchestratorException.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt
index 68abad15..50717031 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/OrchestratorException.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -20,7 +21,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core
*
* @author Brinda Santh
*/
-class OrchestratorException : Exception {
+class BluePrintProcessorException : Exception {
var code: Int = 100
constructor(message: String, cause: Throwable) : super(message, cause)
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
index 97826912..84592204 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -26,12 +27,8 @@ object ConfigModelConstant {
const val MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON"
const val MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE"
- const val MODEL_TYPE_DATA_TYPE = "tosca.datatypes.Root"
const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
- const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"
- const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"
- const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"
const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"
const val MODEL_TYPE_CAPABILITY_NETCONF = "tosca.capability.Netconf"
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
index a10f6d30..b78a594f 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -19,6 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.data
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.JsonNode
+import io.swagger.annotations.ApiModelProperty
/**
*
@@ -59,7 +61,7 @@ A constraint clause defines an operation along with one or more compatible value
*/
class ConstraintClause {
@get:JsonProperty("equal")
- var equal: Any? = null
+ var equal: JsonNode? = null
@get:JsonProperty("greater_than")
var greaterThan: Any? = null
@get:JsonProperty("greater_or_equal")
@@ -71,15 +73,15 @@ class ConstraintClause {
@get:JsonProperty("in_range")
var inRange: Any? = null
@get:JsonProperty("valid_values")
- var validValues: MutableList<Any>? = null
+ var validValues: MutableList<JsonNode>? = null
@get:JsonProperty("length")
var length: Any? = null
@get:JsonProperty("min_length")
var minLength: Any? = null
@get:JsonProperty("max_length")
var maxLength: Any? = null
- @get:JsonProperty("pattern")
var pattern: String? = null
+ var schema: String? = null
}
/*
@@ -157,12 +159,13 @@ class PropertyDefinition {
var required: Boolean? = null
lateinit var type: String
@get:JsonProperty("default")
- var defaultValue: Any? = null
+ var defaultValue: JsonNode? = null
var status: String? = null
var constraints: MutableList<ConstraintClause>? = null
@get:JsonProperty("entry_schema")
var entrySchema: EntrySchema? = null
- var value: Any? = null
+ @get:ApiModelProperty(notes = "Property Value, It may be raw JSON or primitive data type values")
+ var value: JsonNode? = null
}
@@ -182,7 +185,7 @@ class AttributeDefinition {
var description: String? = null
lateinit var type: String
@JsonProperty("default")
- var _default: Any? = null
+ var _default: JsonNode? = null
var status: String? = null
@JsonProperty("entry_schema")
var entry_schema: String? = null
@@ -346,7 +349,7 @@ A Data Type definition defines the schema for new named datatypes in TOSCA.
*/
class DataType : EntityType(){
- var constraints: MutableList<MutableMap<String, Any>>? = null
+ var constraints: MutableList<ConstraintClause>? = null
}
/*
@@ -481,7 +484,7 @@ class SubstitutionMapping {
class EntrySchema {
lateinit var type: String
- var constraints: MutableList<MutableMap<String, Any>>? = null
+ var constraints: MutableList<ConstraintClause>? = null
}
class InterfaceAssignment {
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoService.kt
deleted file mode 100644
index 5369d509..00000000
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoService.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.core.service
-
-import org.apache.commons.io.FileUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.data.*
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import java.io.File
-import java.io.Serializable
-import java.nio.charset.Charset
-
-/**
- * BluePrintEnhancerRepoFileService
- * @author Brinda Santh
- *
- */
-
-interface BluePrintEnhancerRepoService : Serializable {
-
- @Throws(BluePrintException::class)
- fun getNodeType(nodeTypeName: String): NodeType?
-
- @Throws(BluePrintException::class)
- fun getDataType(dataTypeName: String): DataType?
-
- @Throws(BluePrintException::class)
- fun getArtifactType(artifactTypeName: String): ArtifactType?
-
- @Throws(BluePrintException::class)
- fun getRelationshipType(relationshipTypeName: String): RelationshipType?
-
- @Throws(BluePrintException::class)
- fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition?
-
-}
-
-
-class BluePrintEnhancerRepoFileService(val basePath: String) : BluePrintEnhancerRepoService {
-
- 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"
-
- override fun getDataType(dataTypeName: String): DataType? {
- val content = FileUtils.readFileToString(File(dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(dataTypeName).plus(extension)), Charset.defaultCharset())
- return JacksonUtils.readValue(content)
- }
-
- override fun getNodeType(nodeTypeName: String): NodeType? {
- val content = FileUtils.readFileToString(File(nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(nodeTypeName).plus(extension)), Charset.defaultCharset())
- return JacksonUtils.readValue(content)
- }
-
- override fun getArtifactType(artifactTypeName: String): ArtifactType? {
- val content = FileUtils.readFileToString(File(artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(artifactTypeName).plus(extension)), Charset.defaultCharset())
- return JacksonUtils.readValue(content)
- }
-
- override fun getRelationshipType(relationshipTypeName: String): RelationshipType? {
- val content = FileUtils.readFileToString(File(relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(relationshipTypeName).plus(extension)), Charset.defaultCharset())
- return JacksonUtils.readValue(content)
- }
-
- override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition? {
- val content = FileUtils.readFileToString(File(capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(capabilityDefinitionName).plus(extension)), Charset.defaultCharset())
- return JacksonUtils.readValue(content)
- }
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
index 8f172876..8bc0e6e0 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -44,7 +45,7 @@ interface BluePrintEnhancerService : Serializable {
fun enhance(fileName: String, basePath: String): ServiceTemplate
}
-open class BluePrintEnhancerDefaultService(val bluePrintEnhancerRepoService: BluePrintEnhancerRepoService) : BluePrintEnhancerService {
+open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {
private val log: Logger = LoggerFactory.getLogger(BluePrintEnhancerDefaultService::class.java)
@@ -216,21 +217,21 @@ open class BluePrintEnhancerDefaultService(val bluePrintEnhancerRepoService: Blu
}
open fun populateNodeType(nodeTypeName: String): NodeType {
- val nodeType = bluePrintEnhancerRepoService.getNodeType(nodeTypeName)
+ val nodeType = bluePrintRepoService.getNodeType(nodeTypeName)?.block()
?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
return nodeType
}
open fun populateArtifactType(artifactTypeName: String): ArtifactType {
- val artifactType = bluePrintEnhancerRepoService.getArtifactType(artifactTypeName)
+ val artifactType = bluePrintRepoService.getArtifactType(artifactTypeName)?.block()
?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))
serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
return artifactType
}
open fun populateDataTypes(dataTypeName: String): DataType {
- val dataType = bluePrintEnhancerRepoService.getDataType(dataTypeName)
+ val dataType = bluePrintRepoService.getDataType(dataTypeName)?.block()
?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))
serviceTemplate.dataTypes?.put(dataTypeName, dataType)
return dataType
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
new file mode 100644
index 00000000..8c444618
--- /dev/null
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.service
+
+import com.google.common.base.Preconditions
+import org.apache.commons.io.FileUtils
+import org.apache.commons.lang3.StringUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import reactor.core.publisher.Mono
+import java.io.File
+import java.io.Serializable
+import java.nio.charset.Charset
+
+/**
+ * BluePrintRepoFileService
+ * @author Brinda Santh
+ *
+ */
+
+interface BluePrintRepoService : Serializable {
+
+ @Throws(BluePrintException::class)
+ fun getNodeType(nodeTypeName: String): Mono<NodeType>?
+
+ @Throws(BluePrintException::class)
+ fun getDataType(dataTypeName: String): Mono<DataType>?
+
+ @Throws(BluePrintException::class)
+ fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>?
+
+ @Throws(BluePrintException::class)
+ fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>?
+
+ @Throws(BluePrintException::class)
+ fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>?
+
+}
+
+
+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"
+
+ override fun getDataType(dataTypeName: String): Mono<DataType>? {
+ val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(dataTypeName).plus(extension)
+ return getModelType(fileName, DataType::class.java)
+ }
+
+ override fun getNodeType(nodeTypeName: String): Mono<NodeType>? {
+ val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension)
+ return getModelType(fileName, NodeType::class.java)
+ }
+
+ override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>? {
+ val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(artifactTypeName).plus(extension)
+ return getModelType(fileName, ArtifactType::class.java)
+ }
+
+ override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>? {
+ val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(relationshipTypeName).plus(extension)
+ return getModelType(fileName, RelationshipType::class.java)
+ }
+
+ override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>? {
+ val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(capabilityDefinitionName).plus(extension)
+ return getModelType(fileName, CapabilityDefinition::class.java)
+ }
+
+ private fun <T> getModelType(fileName: String, valueType: Class<T>): Mono<T> {
+ return getFileContent(fileName).map { content ->
+ Preconditions.checkArgument(StringUtils.isNotBlank(content),
+ String.format("Failed to get model content for file (%s)", fileName))
+
+ JacksonUtils.readValue(content, valueType)
+ ?: throw BluePrintException(String.format("Failed to get model file from content for file (%s)", fileName))
+
+ }
+ }
+
+ private fun getFileContent(fileName: String): Mono<String> {
+ return Mono.just(FileUtils.readFileToString(File(fileName), Charset.defaultCharset()))
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
index 213f5f40..b03fdf92 100644
--- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -20,7 +21,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.OrchestratorException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
@@ -64,8 +65,8 @@ class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var contex
resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)
} else {
// Assign default value to the Operation
- nodeTypeProperty.defaultValue?.let {
- resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!)
+ nodeTypeProperty.defaultValue?.let { defaultValue ->
+ resolvedValue = defaultValue
}
}
// Set for Return of method
@@ -154,7 +155,7 @@ class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var contex
val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)
val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName)
- ?: throw OrchestratorException(String.format("failed to get artifat definition {} from the node template"
+ ?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template"
, artifactName))
val propertyAssignmentExpression = PropertyAssignmentService( context, this)
return propertyAssignmentExpression.artifactContent(artifactDefinition)
diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt
index 6fc18532..8e6d5efd 100644
--- a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt
+++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -30,7 +31,7 @@ class BluePrintEnhancerServiceTest {
@Test
fun testEnrichBlueprint() {
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val bluePrintEnhancerService: BluePrintEnhancerService = BluePrintEnhancerDefaultService(bluePrintEnhancerRepoFileService)
val serviceTemplate = ServiceTemplateUtils.getServiceTemplate("load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json")
diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoFileServiceTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
index ef4384ff..4731935e 100644
--- a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoFileServiceTest.kt
+++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -17,35 +18,43 @@
package org.onap.ccsdk.apps.controllerblueprints.core.service
import org.junit.Test
+import java.io.FileNotFoundException
import kotlin.test.assertNotNull
/**
- * BluePrintEnhancerRepoFileServiceTest
+ * BluePrintRepoFileServiceTest
* @author Brinda Santh
*
*/
-class BluePrintEnhancerRepoFileServiceTest {
+class BluePrintRepoFileServiceTest {
val basePath = "load/model_type"
@Test
fun testGetDataType() {
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")
assertNotNull(dataType, "Failed to get DataType from repo")
}
@Test
fun testGetNodeType() {
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")
assertNotNull(nodeType, "Failed to get NodeType from repo")
}
@Test
fun testGetArtifactType() {
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)
+ 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")
+ }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-component-java.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-component-java.json
new file mode 100644
index 00000000..95a9801d
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-component-java.json
@@ -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/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-db.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-db.json
new file mode 100644
index 00000000..661a9503
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-db.json
@@ -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/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-default.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-default.json
new file mode 100644
index 00000000..13e234e1
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-default.json
@@ -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/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-input.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-input.json
new file mode 100644
index 00000000..126ea30b
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-input.json
@@ -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/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-rest.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-rest.json
new file mode 100644
index 00000000..f8dd8b6f
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-rest.json
@@ -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/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json
new file mode 100644
index 00000000..2ef553e2
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json
@@ -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/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json
index 8b97cdeb..cd4e282b 100644
--- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json
@@ -1,20 +1,25 @@
{
"name": "bundle-id",
- "description": "name of the ",
+ "property" :{
+ "description": "name of the ",
+ "type": "string"
+ },
"resource-type": "ONAP",
"resource-path": "vnf/bundle-id",
"updated-by": "brindasanth@onap.com",
- "data-type": "String",
"tags": "bundle-id, brindasanth@onap.com",
- "source": {
+ "sources": {
"db": {
- "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
- "input-key-mapping": {
- "profile_name": "profile_name"
- },
- "output-key-mapping": {
- "db-country": "country",
- "db-state": "state"
+ "type": "source-db",
+ "properties": {
+ "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
+ "input-key-mapping": {
+ "profile_name": "profile_name"
+ },
+ "output-key-mapping": {
+ "db-country": "country",
+ "db-state": "state"
+ }
}
}
},
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json
index ac23292e..91921b64 100644
--- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json
@@ -1,14 +1,18 @@
{
- "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
- "name": "v4-ip-type",
- "description": "To be provided",
- "updated-by": "brindasanth@onap.com",
- "resource-type": "ONAP",
- "resource-path": "vnf/v4-ip-type",
- "data-type": "string",
- "source": {
- "default": {
-
- }
- }
+ "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
+ "name": "v4-ip-type",
+ "property" :{
+ "description": "name of the ",
+ "type": "string"
+ },
+ "updated-by": "brindasanth@onap.com",
+ "resource-type": "ONAP",
+ "resource-path": "vnf/v4-ip-type",
+ "sources": {
+ "default": {
+ "type": "source-default",
+ "properties": {
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json
index 35736b66..c34c252b 100644
--- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json
@@ -1,17 +1,19 @@
{
"name": "action-name",
+ "property" :{
+ "description": "name of the ",
+ "type": "string"
+ },
"resource-path": "action-name",
"resource-type": "ONAP",
- "description": "To be provided",
- "valid-values": null,
- "sample-value": null,
"updated-by": "brindasanth@onap.com",
"tags": null,
- "default": null,
- "data-type": "string",
- "source": {
+ "sources": {
"input": {
- "key": "action-name"
+ "type": "source-input",
+ "properties": {
+ "key": "action-name"
+ }
}
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json
index c103f94d..413d9044 100644
--- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json
+++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json
@@ -1,36 +1,36 @@
{
- "tags": "oam-local-ipv4-address, tosca.datatypes.Root, data_type, st1848@att.com",
+ "tags": "oam-local-ipv4-address",
"name": "oam-local-ipv4-address",
- "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",
- "updated-by": "st1848@att.com",
+ "property" :{
+ "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",
+ "type": "string"
+ },
+ "updated-by": "brindasanth@onap.com",
"resource-type": "ATT",
"resource-path": "vnf/oam-local-ipv4-address",
- "data-type": "string",
- "source": {
+ "sources": {
"mdsal": {
- "base": "sdnc-gc",
- "type": "JSON",
- "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",
- "path": "/v4-assigned-ip-list/0/v4-ip-prefix",
- "input-key-mapping": {
- "service-instance-id": "service-instance-id",
- "network-role": "network-role",
- "v4-ip-type": "v4-ip-type",
- "vm-type": "vm-type"
- },
- "output-key-mapping": {
- "oam-local-ipv4-address": "v4-ip-prefix"
+ "type": "source-rest",
+ "properties": {
+ "type": "JSON",
+ "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",
+ "path": "/v4-assigned-ip-list/0/v4-ip-prefix",
+ "input-key-mapping": {
+ "service-instance-id": "service-instance-id",
+ "network-role": "network-role",
+ "v4-ip-type": "v4-ip-type",
+ "vm-type": "vm-type"
+ },
+ "output-key-mapping": {
+ "oam-local-ipv4-address": "v4-ip-prefix"
+ },
+ "key-dependencies": [
+ "service-instance-id",
+ "network-role",
+ "v4-ip-type",
+ "vm-type"
+ ]
}
}
- },
- "candidate-dependency": {
- "mdsal": {
- "names": [
- "service-instance-id",
- "network-role",
- "v4-ip-type",
- "vm-type"
- ]
- }
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/pom.xml b/ms/controllerblueprints/modules/resource-dict/pom.xml
index 4f226185..dbc920fd 100644
--- a/ms/controllerblueprints/modules/resource-dict/pom.xml
+++ b/ms/controllerblueprints/modules/resource-dict/pom.xml
@@ -2,6 +2,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
@@ -33,6 +35,11 @@
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
deleted file mode 100644
index f85e5ebc..00000000
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * 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;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * ResourceAssignment.java Purpose: Provide ResourceAssignment Custom TOSCO Model POJO bean.
- *
- * @author Brinda Santh
- * @version 1.0
- */
-public class ResourceAssignment {
- @JsonProperty(value = "name", required = true)
- private String name;
-
- @JsonProperty(value = "property", required = true)
- private PropertyDefinition property;
-
- @JsonProperty("input-param")
- private Boolean inputParameter;
-
- @JsonProperty("dictionary-name")
- private String dictionaryName;
-
- @JsonProperty("dictionary-source")
- private String dictionarySource;
-
- @JsonProperty("dependencies")
- private List<String> dependencies;
-
- @JsonProperty("version")
- private int version;
-
- @JsonProperty("status")
- private String status;
-
- @JsonProperty("message")
- private String message;
-
- @JsonProperty("updated-date")
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- private Date updatedDate;
-
- @JsonProperty("updated-by")
- private String updatedBy;
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder("[");
- builder.append("name = " + name);
- builder.append(", source = " + dictionarySource);
- if (dependencies != null) {
- builder.append(", dependencies = " + dependencies);
- }
- builder.append("]");
- return builder.toString();
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public PropertyDefinition getProperty() {
- return property;
- }
-
- public void setProperty(PropertyDefinition property) {
- this.property = property;
- }
-
- public Boolean getInputParameter() {
- return inputParameter;
- }
-
- public void setInputParameter(Boolean inputParameter) {
- this.inputParameter = inputParameter;
- }
-
- public String getDictionaryName() {
- return dictionaryName;
- }
-
- public void setDictionaryName(String dictionaryName) {
- this.dictionaryName = dictionaryName;
- }
-
- public String getDictionarySource() {
- return dictionarySource;
- }
-
- public void setDictionarySource(String dictionarySource) {
- this.dictionarySource = dictionarySource;
- }
-
- public List<String> getDependencies() {
- return dependencies;
- }
-
- public void setDependencies(List<String> dependencies) {
- this.dependencies = dependencies;
- }
-
- public int getVersion() {
- return version;
- }
-
- public void setVersion(int version) {
- this.version = version;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public Date getUpdatedDate() {
- return updatedDate;
- }
-
- public void setUpdatedDate(Date updatedDate) {
- this.updatedDate = updatedDate;
- }
-
- public String getUpdatedBy() {
- return updatedBy;
- }
-
- public void setUpdatedBy(String updatedBy) {
- this.updatedBy = updatedBy;
- }
-
-}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
index 1af42c59..48b89bd6 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -21,4 +22,9 @@ public class ResourceDictionaryConstants {
public static final String SOURCE_DEFAULT = "default";
public static final String SOURCE_DB = "db";
public static final String SOURCE_MDSAL = "mdsal";
+
+ public static final String PROPERTY_TYPE = "type";
+ public static final String PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping";
+ public static final String PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping";
+ public static final String PROPERTY_KEY_DEPENDENCIES = "key-dependencies";
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
index 7c2d926f..92178673 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -26,6 +27,7 @@ import java.util.Map;
* DictionaryDefinition.java Purpose:
* @author Brinda Santh
*/
+@Deprecated
public class DictionaryDefinition {
@JsonProperty(value = "name", required = true)
private String name;
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDependency.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDependency.java
index acb71058..6ffbca26 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDependency.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDependency.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -22,6 +23,7 @@ import java.util.List;
* DictionaryDependency
* @author Brinda Santh
*/
+@Deprecated
public class DictionaryDependency {
private List<String> names;
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java
index 735832cb..1ef69fa9 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java
@@ -17,6 +17,6 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
import java.io.Serializable;
-
+@Deprecated
public interface ResourceSource extends Serializable {
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
index 724d0224..fbeab52f 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -24,6 +25,7 @@ import java.util.Map;
* SourceDb
* @author Brinda Santh
*/
+@Deprecated
public class SourceDb implements ResourceSource{
@JsonProperty(value = "base", required = true)
private String base;
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
index d165192e..e0f83bb8 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -20,6 +21,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
* SourceDefault
* @author Brinda Santh
*/
+@Deprecated
public class SourceDefault implements ResourceSource {
private String key;
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java
index 86476e1c..a097c56d 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -29,7 +30,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-
+@Deprecated
public class SourceDeserializer extends JsonDeserializer<Map<String, ResourceSource>> {
private static final Logger log = LoggerFactory.getLogger(SourceDeserializer.class);
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
index 87184f22..8ab16ecb 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -20,6 +21,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
* SourceInput
* @author Brinda Santh
*/
+@Deprecated
public class SourceInput implements ResourceSource {
private String key;
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
index 8a066e91..379f6e91 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -23,7 +24,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
-
+@Deprecated
public class SourceMdsal implements ResourceSource {
@JsonProperty(value = "base", required = true)
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
deleted file mode 100644
index 4f9467f0..00000000
--- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.utils;
-
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.EntrySchema;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDependency;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.ResourceSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.Supplier;
-
-/**
- * ResourceDictionaryUtils.java Purpose to provide ResourceDictionaryUtils
- *
- * @author Brinda Santh
- * @version 1.0
- */
-public class ResourceDictionaryUtils {
-
- private ResourceDictionaryUtils() {
- // Do nothing
- }
-
- private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtils.class);
-
- /**
- * This Method is to assign the source name to the Dictionary Definition Check to see if the source
- * definition is not present then assign, if more than one source then assign only one first source.
- *
- * @param resourceAssignment
- * @param dictionaryDefinition
- */
- @SuppressWarnings("squid:S3776")
- public static void populateSourceMapping(ResourceAssignment resourceAssignment,
- DictionaryDefinition dictionaryDefinition) {
-
- if (resourceAssignment != null && dictionaryDefinition != null
- && StringUtils.isBlank(resourceAssignment.getDictionarySource())) {
-
- // Overwrite the Property Definitions from Dictionary
- setProperty(resourceAssignment, dictionaryDefinition);
-
- Map<String, ResourceSource> dictionarySource = dictionaryDefinition.getSource();
- Map<String, DictionaryDependency> dictionaryDependencyMap = dictionaryDefinition.getDependency();
-
- if (MapUtils.isNotEmpty(dictionarySource)) {
- String source = findFirstSource(dictionarySource);
-
- // Populate and Assign First Source
- if (StringUtils.isNotBlank(source)) {
- // Set Dictionary Source
- resourceAssignment.setDictionarySource(source);
-
- if (MapUtils.isNotEmpty(dictionaryDependencyMap)) {
- // Set Dependencies
- DictionaryDependency dictionaryDependency = dictionaryDependencyMap.get(source);
- if (dictionaryDependency != null) {
- resourceAssignment.setDependencies(dictionaryDependency.getNames());
- }
- }
- } else {
- resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_INPUT);
- }
- log.info("auto map resourceAssignment : {}", resourceAssignment);
- }
- }
- }
-
- public static <T> Optional<T> resolve(Supplier<T> resolver) {
- try {
- T result = resolver.get();
- return Optional.ofNullable(result);
- } catch (NullPointerException e) {
- return Optional.empty();
- }
- }
-
- private static String findFirstSource(Map<String, ResourceSource> dictionarySource) {
- String source = null;
- if (MapUtils.isNotEmpty(dictionarySource)) {
- source = dictionarySource.keySet().stream().findFirst().get();
- }
- return source;
- }
-
- /**
- * Overriding ResourceAssignment Properties with properties defined in Dictionary
- */
- private static void setProperty(ResourceAssignment resourceAssignment, DictionaryDefinition dictionaryDefinition) {
- if (StringUtils.isNotBlank(dictionaryDefinition.getDataType())) {
- PropertyDefinition property = resourceAssignment.getProperty();
- if (property == null) {
- property = new PropertyDefinition();
- }
- property.setDefaultValue(dictionaryDefinition.getDefaultValue());
- property.setType(dictionaryDefinition.getDataType());
- if (StringUtils.isNotBlank(dictionaryDefinition.getEntrySchema())) {
- EntrySchema entrySchema = new EntrySchema();
- entrySchema.setType(dictionaryDefinition.getEntrySchema());
- property.setEntrySchema(entrySchema);
- }
- resourceAssignment.setProperty(property);
- }
- }
-
-}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt
new file mode 100644
index 00000000..a6802f67
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt
@@ -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/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt
new file mode 100644
index 00000000..525ed9a4
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt
@@ -0,0 +1,95 @@
+/*
+ * 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 org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DecryptionRule
+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>
+
+ @JsonProperty("decryption-rules")
+ var decryptionRules: MutableList<DecryptionRule>? = null
+
+}
+
+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
+}
+
+/**
+ * Interface for Source Definitions (ex Input Source,
+ * Default Source, Database Source, Rest Sources, etc)
+ */
+interface ResourceSource : Serializable
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
new file mode 100644
index 00000000..5a1e3812
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt
@@ -0,0 +1,81 @@
+/*
+ * 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.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.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.resource.dict.ResourceDefinition
+import org.slf4j.LoggerFactory
+import java.io.Serializable
+
+interface ResourceDictionaryValidationService : Serializable {
+
+ @Throws(BluePrintException::class)
+ fun validate(resourceDefinition: ResourceDefinition)
+
+}
+
+open class ResourceDictionaryDefaultValidationService(val bluePrintRepoService: BluePrintRepoService) : ResourceDictionaryValidationService {
+
+ private val log = LoggerFactory.getLogger(ResourceDictionaryDefaultValidationService::class.java)
+
+ override fun validate(resourceDefinition: ResourceDefinition) {
+ Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition")
+
+ resourceDefinition.sources.forEach { (name, nodeTemplate) ->
+ val sourceType = nodeTemplate.type
+
+ val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)?.block()
+ ?: throw BluePrintException(format("Failed to get node type definition for source({})", 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)
+ }
+ }
+ }
+
+ open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, jsonNode: JsonNode) {
+ //log.info("validating Property {}, name ({}) value ({})", propertyDefinition, propertyName, jsonNode)
+ //TODO
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
new file mode 100644
index 00000000..e08c09c8
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
@@ -0,0 +1,62 @@
+/*
+ * 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 org.apache.commons.collections.MapUtils
+import org.apache.commons.lang3.StringUtils
+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 org.slf4j.LoggerFactory
+
+
+object ResourceDictionaryUtils {
+ private val log = LoggerFactory.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
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
index 851ba125..3e68d099 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -14,57 +15,46 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class DictionaryDefinitionTest {
- private Logger log = LoggerFactory.getLogger(DictionaryDefinitionTest.class);
+public class ResourceDefinitionTest {
+ private Logger log = LoggerFactory.getLogger(ResourceDefinitionTest.class);
String basePath = "load/resource_dictionary";
- @Before
- public void setup(){
- SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DB, SourceDb.class);
- SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_INPUT, SourceInput.class);
- SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_MDSAL, SourceMdsal.class);
- SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DEFAULT,SourceDefault.class);
- }
-
@Test
public void testDictionaryDefinitionInputSource(){
String fileName = basePath + "/input-source.json";
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
- Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", dictionaryDefinition);
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition);
}
@Test
public void testDictionaryDefinitionDefaultSource(){
String fileName = basePath + "/default-source.json";
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
- Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", dictionaryDefinition);
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition);
}
@Test
public void testDictionaryDefinitionDBSource(){
String fileName = basePath + "/db-source.json";
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
- Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", dictionaryDefinition);
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);
}
@Test
public void testDictionaryDefinitionMDSALSource(){
String fileName = basePath + "/mdsal-source.json";
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class);
- Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", dictionaryDefinition);
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition);
}
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java
new file mode 100644
index 00000000..b50c0e44
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java
@@ -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 ResourceDictionaryValidationServiceTest {
+ private String basePath = "load/model_type";
+ String dictionaryPath = "load/resource_dictionary";
+ 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);
+
+ ResourceDictionaryValidationService resourceDictionaryValidationService =
+ new ResourceDictionaryDefaultValidationService(bluePrintRepoFileService);
+ resourceDictionaryValidationService.validate(resourceDefinition);
+ Assert.assertNotNull(String.format("Failed to populate dictionaryDefinition for : %s", fileName), resourceDefinition);
+ }
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
deleted file mode 100644
index 0c9a1c5d..00000000
--- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * 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.util;
-
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-public class ResourceDictionaryUtilsTest {
- private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtilsTest.class);
-
- @Test
- public void validateSingleInputSource() {
- try {
- log.info(" **************** Validating validateSingleSource *****************");
- ResourceAssignment resourceAssignment = new ResourceAssignment();
- resourceAssignment.setName("test-input-key");
- DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
- dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
-
- Map<String, ResourceSource> source = new HashMap<>();
- SourceInput sourceInput = new SourceInput();
- source.put(ResourceDictionaryConstants.SOURCE_INPUT, sourceInput);
- dictionaryDefinition.setSource(source);
-
- ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
- Assert.assertNotNull("Resource assignment input source is missing ",
- resourceAssignment.getDictionarySource());
- Assert.assertNotNull("Resource assignment input source property is missing ",
- resourceAssignment.getProperty());
- Assert.assertNotNull("Resource assignment input source property type is missing ",
- resourceAssignment.getProperty().getType());
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void validateSingleDbSource() {
- try {
- log.info(" **************** Validating validateSingleSource *****************");
- ResourceAssignment resourceAssignment = new ResourceAssignment();
- resourceAssignment.setName("test-db-key");
- DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
- dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
-
- Map<String, ResourceSource> source = new HashMap<>();
- SourceDb sourceDb = new SourceDb();
- sourceDb.setBase("sdnc_connection");
- source.put(ResourceDictionaryConstants.SOURCE_DB, sourceDb);
- dictionaryDefinition.setSource(source);
-
- Map<String, DictionaryDependency> dependency = new HashMap<>();
- DictionaryDependency dependencyDb = new DictionaryDependency();
- dependencyDb.setNames(Arrays.asList("vnf-id", "vnf-name"));
- dependency.put(ResourceDictionaryConstants.SOURCE_DB, dependencyDb);
- dictionaryDefinition.setDependency(dependency);
-
- DecryptionRule decryptionRule = new DecryptionRule();
- decryptionRule.setDecryptType("sample Type");
- decryptionRule.setPath("$.");
- decryptionRule.setRule("Sample Rule");
- decryptionRule.setSources(Arrays.asList("vnf-id"));
- dictionaryDefinition.setDecryptionRules(Arrays.asList(decryptionRule));
-
- ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
- Assert.assertNotNull("Resource assignment db source source is missing ",
- resourceAssignment.getDictionarySource());
- Assert.assertNotNull("Resource assignment db source source property is missing ",
- resourceAssignment.getProperty());
- Assert.assertNotNull("Resource assignment db source source property type is missing ",
- resourceAssignment.getProperty().getType());
-
- Assert.assertNotNull("Resource assignment db dependecy is missing ", resourceAssignment.getDependencies());
- Assert.assertEquals("Resource assignment db dependecy count mismatch ", 2,
- resourceAssignment.getDependencies().size());
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testSourceDefault() {
- ResourceAssignment resourceAssignment = new ResourceAssignment();
- resourceAssignment.setName("test-input-key");
-
- DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
- dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
-
- Map<String, ResourceSource> source = new HashMap<>();
- SourceDefault sourceDefault = new SourceDefault();
- source.put(ResourceDictionaryConstants.SOURCE_DEFAULT, sourceDefault);
- dictionaryDefinition.setSource(source);
-
- Map<String, DictionaryDependency> dependency = new HashMap<>();
- DictionaryDependency dependencyDefault = new DictionaryDependency();
- dependencyDefault.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));
- dependency.put(ResourceDictionaryConstants.SOURCE_DEFAULT, dependencyDefault);
- dictionaryDefinition.setDependency(dependency);
-
- ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
-
- Assert.assertNotNull("Resource assignment default source is missing ",
- resourceAssignment.getDictionarySource());
- Assert.assertNotNull("Resource assignment default source property is missing ",
- resourceAssignment.getProperty());
- Assert.assertNotNull("Resource assignment default source property type is missing ",
- resourceAssignment.getProperty().getType());
- }
-
- @Test
- public void testSourceMdsal() {
- ResourceAssignment resourceAssignment = new ResourceAssignment();
- resourceAssignment.setName("test-input-key");
- DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
- dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
-
- Map<String, ResourceSource> source = new HashMap<>();
- SourceMdsal sourceMdsal = new SourceMdsal();
- source.put(ResourceDictionaryConstants.SOURCE_MDSAL,sourceMdsal);
- dictionaryDefinition.setSource(source);
-
- Map<String, DictionaryDependency> dependency = new HashMap<>();
- DictionaryDependency dependencyMdsal = new DictionaryDependency();
- dependencyMdsal.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));
- dependency.put(ResourceDictionaryConstants.SOURCE_MDSAL, dependencyMdsal);
- dictionaryDefinition.setDependency(dependency);
-
- ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
-
- Assert.assertNotNull("Resource assignment mdsal source is missing ", resourceAssignment.getDictionarySource());
- Assert.assertNotNull("Resource assignment mdsal source property is missing ", resourceAssignment.getProperty());
- Assert.assertNotNull("Resource assignment mdsal source property type is missing ",
- resourceAssignment.getProperty().getType());
- }
-
-}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
new file mode 100644
index 00000000..2a207e09
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;
+
+
+import org.junit.Assert;
+import org.junit.Test;
+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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ResourceDictionaryUtilsTest {
+ private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtilsTest.class);
+
+ @Test
+ public void testPopulateSourceMapping() {
+
+ ResourceAssignment resourceAssignment = new ResourceAssignment();
+ ResourceDefinition resourceDefinition = new ResourceDefinition();
+ Map<String, NodeTemplate> sources = new HashMap<>();
+ resourceDefinition.setSources(sources);
+ // To Check Empty Source
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);
+ Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, resourceAssignment.getDictionarySource());
+
+ // To Check First Source
+ resourceAssignment.setDictionarySource(null);
+ sources.put(ResourceDictionaryConstants.SOURCE_DEFAULT, new NodeTemplate());
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);
+ Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource());
+
+ // To Check Assigned Source
+ resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_DB);
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);
+ Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_DB, resourceAssignment.getDictionarySource());
+
+ }
+
+ @Test
+ public void testFindFirstSource() {
+ //To check if Empty Source
+ Map<String, NodeTemplate> sources = new HashMap<>();
+ String firstSource = ResourceDictionaryUtils.findFirstSource(sources);
+ Assert.assertNull("Source populated, which is not expected.", firstSource);
+
+ // TO check the first Source
+ sources.put(ResourceDictionaryConstants.SOURCE_INPUT, new NodeTemplate());
+ String inputFirstSource = ResourceDictionaryUtils.findFirstSource(sources);
+ Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource);
+
+ // TO check the multiple Source
+ sources.put(ResourceDictionaryConstants.SOURCE_DB, new NodeTemplate());
+ String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources);
+ Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource);
+
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/source-db.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-db.json
new file mode 100644
index 00000000..661a9503
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-db.json
@@ -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/ms/controllerblueprints/modules/service/load/model_type/node_type/source-default.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-default.json
new file mode 100644
index 00000000..13e234e1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-default.json
@@ -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/ms/controllerblueprints/modules/service/load/model_type/node_type/source-input.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-input.json
new file mode 100644
index 00000000..126ea30b
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-input.json
@@ -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/ms/controllerblueprints/modules/service/load/model_type/node_type/source-rest.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-rest.json
new file mode 100644
index 00000000..f8dd8b6f
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-rest.json
@@ -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/ms/controllerblueprints/modules/service/load/model_type/node_type/tosca.nodes.ResourceSource.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/tosca.nodes.ResourceSource.json
new file mode 100644
index 00000000..2ef553e2
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/load/model_type/node_type/tosca.nodes.ResourceSource.json
@@ -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/ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json
index 86252354..cd4e282b 100644
--- a/ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json
+++ b/ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json
@@ -1,20 +1,25 @@
{
"name": "bundle-id",
- "description": "name of the ",
+ "property" :{
+ "description": "name of the ",
+ "type": "string"
+ },
"resource-type": "ONAP",
"resource-path": "vnf/bundle-id",
"updated-by": "brindasanth@onap.com",
- "data-type": "String",
"tags": "bundle-id, brindasanth@onap.com",
- "source": {
+ "sources": {
"db": {
- "query": "SELECT bundle-id FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
- "input-key-mapping": {
- "profile_name": "profile_name"
- },
- "output-key-mapping": {
- "db-country": "country",
- "db-state": "state"
+ "type": "source-db",
+ "properties": {
+ "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",
+ "input-key-mapping": {
+ "profile_name": "profile_name"
+ },
+ "output-key-mapping": {
+ "db-country": "country",
+ "db-state": "state"
+ }
}
}
},
diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json
index 35736b66..610e8fc0 100644
--- a/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json
+++ b/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json
@@ -1,17 +1,19 @@
{
"name": "action-name",
+ "property" :{
+ "description": "name of the ",
+ "type": "string"
+ },
"resource-path": "action-name",
"resource-type": "ONAP",
- "description": "To be provided",
- "valid-values": null,
- "sample-value": null,
"updated-by": "brindasanth@onap.com",
- "tags": null,
- "default": null,
- "data-type": "string",
- "source": {
+ "tags": "action-name, brindasanth",
+ "sources": {
"input": {
- "key": "action-name"
+ "type": "source-input",
+ "properties": {
+ "key": "action-name"
+ }
}
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json
index c6c0f985..e7e06000 100644
--- a/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json
+++ b/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json
@@ -1,14 +1,19 @@
{
- "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
- "name": "v4-ip-type",
- "description": "To be provided",
- "updated-by": "brindasanth@onap.com",
- "resource-type": "ONAP",
- "resource-path": "vnf/v4-ip-type",
- "data-type": "string",
- "source": {
- "input": {
-
- }
- }
+ "name": "v4-ip-type",
+ "property": {
+ "description": "name of the ",
+ "type": "string"
+ },
+ "resource-path": "vnf/v4-ip-type",
+ "resource-type": "ONAP",
+ "updated-by": "brindasanth@onap.com",
+ "tags": "v4-ip-type, source-input, brindasanth",
+ "sources": {
+ "input": {
+ "type": "source-input",
+ "properties": {
+ "key": "v4-ip-type"
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml
index 6a40a4a7..9efadd18 100644
--- a/ms/controllerblueprints/modules/service/pom.xml
+++ b/ms/controllerblueprints/modules/service/pom.xml
@@ -2,6 +2,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
@@ -67,10 +69,25 @@
<!--</dependency>-->
<dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java
index 6b09c81f..2c443783 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -22,7 +23,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
@@ -102,7 +103,7 @@ public class AutoResourceMappingService {
ResourceDictionary dbDataDictionary = dictionaryMap.get(resourceAssignment.getName());
if (dbDataDictionary != null && StringUtils.isNotBlank(dbDataDictionary.getDefinition())) {
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValue(dbDataDictionary.getDefinition(), DictionaryDefinition.class);
+ ResourceDefinition dictionaryDefinition = JacksonUtils.readValue(dbDataDictionary.getDefinition(), ResourceDefinition.class);
if (dictionaryDefinition != null && StringUtils.isNotBlank(dictionaryDefinition.getName())
&& StringUtils.isBlank(resourceAssignment.getDictionaryName())) {
@@ -186,7 +187,7 @@ public class AutoResourceMappingService {
}
if (dictionaries != null) {
for (ResourceDictionary resourcedictionary : dictionaries) {
- DictionaryDefinition dictionaryDefinition = JacksonUtils.readValue(resourcedictionary.getDefinition(), DictionaryDefinition.class);
+ ResourceDefinition dictionaryDefinition = JacksonUtils.readValue(resourcedictionary.getDefinition(), ResourceDefinition.class);
PropertyDefinition property = new PropertyDefinition();
property.setRequired(true);
ResourceAssignment resourceAssignment = new ResourceAssignment();
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java
deleted file mode 100644
index a2e5b104..00000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.service;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;
-import org.springframework.stereotype.Service;
-
-import java.util.Optional;
-
-/**
- * BluePrintEnhancerRepoDBService
- *
- * @author Brinda Santh
- */
-@Service
-public class BluePrintEnhancerRepoDBService implements BluePrintEnhancerRepoService {
-
- private ModelTypeRepository modelTypeRepository;
-
- public BluePrintEnhancerRepoDBService(ModelTypeRepository modelTypeRepository) {
- this.modelTypeRepository = modelTypeRepository;
- }
-
-
- @Override
- public NodeType getNodeType(String nodeTypeName) throws BluePrintException {
- Preconditions.checkArgument(StringUtils.isNotBlank(nodeTypeName), "NodeType name is missing");
- String content = getModelDefinitions(nodeTypeName);
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "NodeType content is missing");
- return JacksonUtils.readValue(content, NodeType.class);
- }
-
-
- @Override
- public DataType getDataType(String dataTypeName) throws BluePrintException {
- Preconditions.checkArgument(StringUtils.isNotBlank(dataTypeName), "DataType name is missing");
- String content = getModelDefinitions(dataTypeName);
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "DataType content is missing");
- return JacksonUtils.readValue(content, DataType.class);
- }
-
-
- @Override
- public ArtifactType getArtifactType(String artifactTypeName) throws BluePrintException {
- Preconditions.checkArgument(StringUtils.isNotBlank(artifactTypeName), "ArtifactType name is missing");
- String content = getModelDefinitions(artifactTypeName);
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "ArtifactType content is missing");
- return JacksonUtils.readValue(content, ArtifactType.class);
- }
-
-
- @Override
- public RelationshipType getRelationshipType(String relationshipTypeName) throws BluePrintException {
- Preconditions.checkArgument(StringUtils.isNotBlank(relationshipTypeName), "RelationshipType name is missing");
- String content = getModelDefinitions(relationshipTypeName);
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "RelationshipType content is missing");
- return JacksonUtils.readValue(content, RelationshipType.class);
- }
-
-
- @Override
- public CapabilityDefinition getCapabilityDefinition(String capabilityDefinitionName) throws BluePrintException {
- Preconditions.checkArgument(StringUtils.isNotBlank(capabilityDefinitionName), "CapabilityDefinition name is missing");
- String content = getModelDefinitions(capabilityDefinitionName);
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "CapabilityDefinition content is missing");
- return JacksonUtils.readValue(content, CapabilityDefinition.class);
- }
-
- private String getModelDefinitions(String modelName) throws BluePrintException {
- String modelDefinition = null;
- Optional<ModelType> modelTypedb = modelTypeRepository.findByModelName(modelName);
- if (modelTypedb.isPresent()) {
- modelDefinition = modelTypedb.get().getDefinition();
- } else {
- throw new BluePrintException(String.format("failed to get model definition (%s) from repo", modelName));
- }
- return modelDefinition;
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
index afd12f21..0cf846c7 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -24,7 +25,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;
+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.ResourceAssignment;
import org.slf4j.Logger;
@@ -48,7 +49,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
private HashMap<String, DataType> recipeDataTypes = new HashMap<>();
- public BluePrintEnhancerService(BluePrintEnhancerRepoService bluePrintEnhancerRepoDBService) {
+ public BluePrintEnhancerService(BluePrintRepoService bluePrintEnhancerRepoDBService) {
super(bluePrintEnhancerRepoDBService);
}
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
new file mode 100644
index 00000000..4c11d8c6
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang3.StringUtils;
+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;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;
+import org.springframework.stereotype.Service;
+import reactor.core.publisher.Mono;
+
+import java.util.Optional;
+
+/**
+ * BluePrintRepoDBService
+ *
+ * @author Brinda Santh
+ */
+@Service
+public class BluePrintRepoDBService implements BluePrintRepoService {
+
+ private ModelTypeRepository modelTypeRepository;
+
+ public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) {
+ this.modelTypeRepository = modelTypeRepository;
+ }
+
+ @Override
+ public Mono<NodeType> getNodeType(String nodeTypeName) throws BluePrintException {
+ return getModelType(nodeTypeName, NodeType.class);
+ }
+
+ @Override
+ public Mono<DataType> getDataType(String dataTypeName) throws BluePrintException {
+ return getModelType(dataTypeName, DataType.class);
+ }
+
+ @Override
+ public Mono<ArtifactType> getArtifactType(String artifactTypeName) throws BluePrintException {
+ return getModelType(artifactTypeName, ArtifactType.class);
+ }
+
+ @Override
+ public Mono<RelationshipType> getRelationshipType(String relationshipTypeName) throws BluePrintException {
+ return getModelType(relationshipTypeName, RelationshipType.class);
+ }
+
+ @Override
+ public Mono<CapabilityDefinition> getCapabilityDefinition(String capabilityDefinitionName) throws BluePrintException {
+ return getModelType(capabilityDefinitionName, CapabilityDefinition.class);
+ }
+
+ private <T> Mono<T> getModelType(String modelName, Class<T> valueClass) throws BluePrintException {
+ 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 JacksonUtils.readValue(content, valueClass);
+ }
+ );
+ }
+
+ private Mono<String> getModelDefinitions(String modelName) throws BluePrintException {
+ String modelDefinition = null;
+ Optional<ModelType> modelTypeDb = modelTypeRepository.findByModelName(modelName);
+ if (modelTypeDb.isPresent()) {
+ modelDefinition = modelTypeDb.get().getDefinition();
+ } else {
+ throw new BluePrintException(String.format("failed to get model definition (%s) from repo", modelName));
+ }
+ return Mono.just(modelDefinition);
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java
index 9ab319cb..3a5c4fde 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -16,6 +17,7 @@
package org.onap.ccsdk.apps.controllerblueprints.service;
+import com.google.common.base.Preconditions;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@@ -26,7 +28,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
@@ -160,26 +162,21 @@ public class DataBaseInitService {
fileName = file.getFilename();
log.trace("Loading : {}", fileName);
String definitionContent = getResourceContent(file);
- DictionaryDefinition dictionaryDefinition =
- JacksonUtils.readValue(definitionContent, DictionaryDefinition.class);
+ ResourceDefinition dictionaryDefinition =
+ JacksonUtils.readValue(definitionContent, ResourceDefinition.class);
if (dictionaryDefinition != null) {
+ Preconditions.checkNotNull(dictionaryDefinition.getProperty(), "Failed to get Property Definition");
ResourceDictionary resourceDictionary = new ResourceDictionary();
resourceDictionary.setResourcePath(dictionaryDefinition.getResourcePath());
resourceDictionary.setName(dictionaryDefinition.getName());
resourceDictionary.setDefinition(definitionContent);
- if (dictionaryDefinition.getValidValues() != null)
- resourceDictionary
- .setValidValues(String.valueOf(dictionaryDefinition.getValidValues()));
-
- if (dictionaryDefinition.getSampleValue() != null)
- resourceDictionary
- .setValidValues(String.valueOf(dictionaryDefinition.getSampleValue()));
-
resourceDictionary.setResourceType(dictionaryDefinition.getResourceType());
- resourceDictionary.setDataType(dictionaryDefinition.getDataType());
- resourceDictionary.setEntrySchema(dictionaryDefinition.getEntrySchema());
- resourceDictionary.setDescription(dictionaryDefinition.getDescription());
+ resourceDictionary.setDescription(dictionaryDefinition.getProperty().getDescription());
+ resourceDictionary.setDataType(dictionaryDefinition.getProperty().getType());
+ if(dictionaryDefinition.getProperty().getEntrySchema() != null){
+ resourceDictionary.setEntrySchema(dictionaryDefinition.getProperty().getEntrySchema().getType());
+ }
resourceDictionary.setUpdatedBy(dictionaryDefinition.getUpdatedBy());
if (StringUtils.isBlank(dictionaryDefinition.getTags())) {
resourceDictionary.setTags(
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
index b9567db1..629b94c0 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -16,10 +17,13 @@
package org.onap.ccsdk.apps.controllerblueprints.service;
+import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.EntrySchema;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator;
@@ -40,19 +44,23 @@ public class ResourceDictionaryService {
private ResourceDictionaryRepository resourceDictionaryRepository;
+ private ResourceDictionaryValidationService resourceDictionaryValidationService;
+
/**
* This is a DataDictionaryService, used to save and get the Resource Mapping stored in database
- *
+ *
* @param dataDictionaryRepository
- *
+ * @param resourceDictionaryValidationService
*/
- public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository) {
+ public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository,
+ ResourceDictionaryValidationService resourceDictionaryValidationService) {
this.resourceDictionaryRepository = dataDictionaryRepository;
+ this.resourceDictionaryValidationService = resourceDictionaryValidationService;
}
/**
* This is a getDataDictionaryByName service
- *
+ *
* @param name
* @return DataDictionary
* @throws BluePrintException
@@ -67,7 +75,7 @@ public class ResourceDictionaryService {
/**
* This is a searchResourceDictionaryByNames service
- *
+ *
* @param names
* @return List<ResourceDictionary>
* @throws BluePrintException
@@ -83,7 +91,7 @@ public class ResourceDictionaryService {
/**
* This is a searchResourceDictionaryByTags service
- *
+ *
* @param tags
* @return List<ResourceDictionary>
* @throws BluePrintException
@@ -98,63 +106,64 @@ public class ResourceDictionaryService {
/**
* This is a saveDataDictionary service
- *
+ *
* @param resourceDictionary
* @return DataDictionary
* @throws BluePrintException
*/
public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary)
throws BluePrintException {
- if (resourceDictionary != null) {
- ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);
-
- DictionaryDefinition dictionaryDefinition =
- JacksonUtils.readValue(resourceDictionary.getDefinition(), DictionaryDefinition.class);
-
- if (dictionaryDefinition == null) {
- throw new BluePrintException(
- "Resource dictionary definition is not valid content " + resourceDictionary.getDefinition());
- }
-
- dictionaryDefinition.setName(resourceDictionary.getName());
- dictionaryDefinition.setResourcePath(resourceDictionary.getResourcePath());
- dictionaryDefinition.setResourceType(resourceDictionary.getResourceType());
- dictionaryDefinition.setDataType(resourceDictionary.getDataType());
- dictionaryDefinition.setEntrySchema(resourceDictionary.getEntrySchema());
- dictionaryDefinition.setTags(resourceDictionary.getTags());
- dictionaryDefinition.setDescription(resourceDictionary.getDescription());
- dictionaryDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());
-
- String definitionContent = JacksonUtils.getJson(dictionaryDefinition, true);
- resourceDictionary.setDefinition(definitionContent);
-
- Optional<ResourceDictionary> dbResourceDictionaryData =
- resourceDictionaryRepository.findByName(resourceDictionary.getName());
- if (dbResourceDictionaryData.isPresent()) {
- ResourceDictionary dbResourceDictionary = dbResourceDictionaryData.get();
-
- dbResourceDictionary.setName(resourceDictionary.getName());
- dbResourceDictionary.setDefinition(resourceDictionary.getDefinition());
- dbResourceDictionary.setDescription(resourceDictionary.getDescription());
- dbResourceDictionary.setResourceType(resourceDictionary.getResourceType());
- dbResourceDictionary.setResourcePath(resourceDictionary.getResourcePath());
- dbResourceDictionary.setDataType(resourceDictionary.getDataType());
- dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema());
- dbResourceDictionary.setTags(resourceDictionary.getTags());
- dbResourceDictionary.setValidValues(resourceDictionary.getValidValues());
- resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary);
- } else {
- resourceDictionary = resourceDictionaryRepository.save(resourceDictionary);
- }
+ Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");
+ Preconditions.checkArgument(StringUtils.isNotBlank(resourceDictionary.getDefinition()),
+ "Resource Dictionary definition information is missing");
+
+ ResourceDefinition resourceDefinition =
+ JacksonUtils.readValue(resourceDictionary.getDefinition(), ResourceDefinition.class);
+ // Validate the Resource Definitions
+ resourceDictionaryValidationService.validate(resourceDefinition);
+
+ resourceDictionary.setResourceType(resourceDefinition.getResourceType());
+ resourceDictionary.setResourcePath(resourceDefinition.getResourcePath());
+ resourceDictionary.setTags(resourceDefinition.getTags());
+ resourceDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());
+ // Set the Property Definitions
+ PropertyDefinition propertyDefinition = resourceDefinition.getProperty();
+ resourceDictionary.setDescription(propertyDefinition.getDescription());
+ resourceDictionary.setDataType(propertyDefinition.getType());
+ if(propertyDefinition.getEntrySchema() != null){
+ resourceDictionary.setEntrySchema(propertyDefinition.getEntrySchema().getType());
+ }
+
+ String definitionContent = JacksonUtils.getJson(resourceDefinition, true);
+ resourceDictionary.setDefinition(definitionContent);
+
+ ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);
+
+ Optional<ResourceDictionary> dbResourceDictionaryData =
+ resourceDictionaryRepository.findByName(resourceDictionary.getName());
+ if (dbResourceDictionaryData.isPresent()) {
+ ResourceDictionary dbResourceDictionary = dbResourceDictionaryData.get();
+
+ dbResourceDictionary.setName(resourceDictionary.getName());
+ dbResourceDictionary.setDefinition(resourceDictionary.getDefinition());
+ dbResourceDictionary.setDescription(resourceDictionary.getDescription());
+ dbResourceDictionary.setResourceType(resourceDictionary.getResourceType());
+ dbResourceDictionary.setResourcePath(resourceDictionary.getResourcePath());
+ dbResourceDictionary.setTags(resourceDictionary.getTags());
+ dbResourceDictionary.setUpdatedBy(resourceDictionary.getUpdatedBy());
+ dbResourceDictionary.setDataType(resourceDictionary.getDataType());
+ dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema());
+ resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary);
} else {
- throw new BluePrintException("Resource Dictionary information is missing");
+ resourceDictionary = resourceDictionaryRepository.save(resourceDictionary);
}
+
return resourceDictionary;
}
/**
* This is a deleteResourceDictionary service
- *
+ *
* @param name
* @throws BluePrintException
*/
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java
new file mode 100644
index 00000000..7de7fc4c
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java
@@ -0,0 +1,31 @@
+/*
+ * 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.service;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDictionaryDefaultValidationService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ResourceDictionaryValidationService extends ResourceDictionaryDefaultValidationService {
+
+ private BluePrintRepoService bluePrintRepoService;
+
+ public ResourceDictionaryValidationService(BluePrintRepoService bluePrintRepoService) {
+ super(bluePrintRepoService);
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
index 85f256ea..1201f6b4 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -19,7 +20,6 @@ package org.onap.ccsdk.apps.controllerblueprints.service.validator;
import org.apache.commons.lang3.StringUtils;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
import org.onap.ccsdk.apps.controllerblueprints.core.data.CapabilityDefinition;
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
@@ -53,54 +53,6 @@ public class ModelTypeValidator {
return validTypes;
}
- @Deprecated
- private static List<String> getValidModelDerivedFrom(String definitionType) {
- List<String> validTypes = new ArrayList<>();
- if (StringUtils.isNotBlank(definitionType)) {
- if (BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE.equalsIgnoreCase(definitionType)) {
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_DG);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_VNF);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT);
- } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE.equalsIgnoreCase(definitionType)) {
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_NETCONF);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SSH);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SFTP);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_CHEF);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_ANSIBLEF);
- } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE.equalsIgnoreCase(definitionType)) {
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON);
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON);
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO);
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO);
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO);
- }
-
- }
- return validTypes;
- }
-
- /**
- * This is a validateNodeType
- *
- * @param definitionType
- * @param derivedFrom
- * @return boolean
- * @throws BluePrintException
- */
- public static boolean validateNodeType(String definitionType, String derivedFrom) throws BluePrintException {
- boolean valid = true;
- if (!BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)
- && !BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE.equalsIgnoreCase(definitionType)) {
- List<String> validTypes = getValidModelDerivedFrom(definitionType);
- if (!validTypes.contains(derivedFrom)) {
- throw new BluePrintException(
- "Not Valid Model Type (" + derivedFrom + "), It sould be " + validTypes);
- }
- }
- return valid;
- }
-
/**
* This is a validateModelTypeDefinition
*
@@ -187,8 +139,6 @@ public class ModelTypeValidator {
validateModelTypeDefinition(modelType.getDefinitionType(), modelType.getDefinition());
- validateNodeType(modelType.getDefinitionType(), modelType.getDerivedFrom());
-
} else {
throw new BluePrintException("Model Type Information is missing.");
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
index 73d6eca9..8257dc36 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
@@ -1,5 +1,6 @@
/*
* 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.
@@ -50,14 +51,6 @@ public class ResourceDictionaryRestTest {
@Autowired
protected ResourceDictionaryRest resourceDictionaryRest;
- @Before
- public void setUp() {
- SourceDeserializer.registerSource("db", SourceDb.class);
- SourceDeserializer.registerSource("input", SourceInput.class);
- SourceDeserializer.registerSource("mdsal", SourceMdsal.class);
- SourceDeserializer.registerSource("default", SourceDefault.class);
- }
-
@Test
public void test01SaveDataDictionary() throws Exception {
String definition = IOUtils.toString(
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json
index 2b392054..198823bb 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json
+++ b/ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json
@@ -1,19 +1,19 @@
{
- "name": "v4-aggregat-list",
- "description": "This collection v4-aggregate list",
- "valid-values": null,
- "sample-value": null,
- "updated-by": "Brinda Santh (bs2796)",
- "resource-type": "ONAP",
- "resource-path": "/v4-aggregat-list",
- "data-type": "list",
- "entry-schema": "dt-v4-aggregate",
- "tags": null,
- "default": null,
- "source": {
- "input": {
-
- }
- },
- "candidate-dependency": null
+ "name": "ipaddress",
+ "property": {
+ "description": "name of the ",
+ "type": "list",
+ "entry_schema": {
+ "type": "dt-v4-aggregate"
+ }
+ },
+ "updated-by": "Brinda Santh (bs2796)",
+ "resource-type": "ONAP",
+ "resource-path": "/v4-aggregat-list",
+ "tags": "ipaddress",
+ "sources": {
+ "input": {
+ "type": "source-input"
+ }
+ }
} \ No newline at end of file