Controller Blueprints Microservice
authorBrinda Santh <brindasanth@in.ibm.com>
Sun, 26 Aug 2018 20:20:04 +0000 (16:20 -0400)
committerBrinda Santh <brindasanth@in.ibm.com>
Sun, 26 Aug 2018 20:20:04 +0000 (16:20 -0400)
Add Standardized resource definition in Initial data loading and Dictionary management services.

Change-Id: Ib33ba2ecf3cb1e1fb9b5dea71532e6bc8280bcbb
Issue-ID: CCSDK-487
Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
24 files changed:
ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-db.json
ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-default.json
ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-input.json
ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-rest.json
ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java
ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java [deleted file]
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt [new file with mode: 0644]
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java [deleted file]
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java [new file with mode: 0644]
ms/controllerblueprints/modules/service/load/model_type/node_type/source-db.json [new file with mode: 0644]
ms/controllerblueprints/modules/service/load/model_type/node_type/source-default.json [new file with mode: 0644]
ms/controllerblueprints/modules/service/load/model_type/node_type/source-input.json [new file with mode: 0644]
ms/controllerblueprints/modules/service/load/model_type/node_type/source-rest.json [new file with mode: 0644]
ms/controllerblueprints/modules/service/load/model_type/node_type/tosca.nodes.ResourceSource.json [new file with mode: 0644]
ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json
ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json
ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java
ms/controllerblueprints/modules/service/src/test/resources/resourcedictionary/default_definition.json

index a10f6d3..b78a594 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -19,6 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.data
 import com.fasterxml.jackson.annotation.JsonIgnore\r
 import com.fasterxml.jackson.annotation.JsonProperty\r
 import com.fasterxml.jackson.databind.JsonNode\r
+import io.swagger.annotations.ApiModelProperty\r
 \r
 /**\r
  *\r
@@ -59,7 +61,7 @@ A constraint clause defines an operation along with one or more compatible value
  */\r
 class ConstraintClause {\r
     @get:JsonProperty("equal")\r
-    var equal: Any? = null\r
+    var equal: JsonNode? = null\r
     @get:JsonProperty("greater_than")\r
     var greaterThan: Any? = null\r
     @get:JsonProperty("greater_or_equal")\r
@@ -71,15 +73,15 @@ class ConstraintClause {
     @get:JsonProperty("in_range")\r
     var inRange: Any? = null\r
     @get:JsonProperty("valid_values")\r
-    var validValues: MutableList<Any>? = null\r
+    var validValues: MutableList<JsonNode>? = null\r
     @get:JsonProperty("length")\r
     var length: Any? = null\r
     @get:JsonProperty("min_length")\r
     var minLength: Any? = null\r
     @get:JsonProperty("max_length")\r
     var maxLength: Any? = null\r
-    @get:JsonProperty("pattern")\r
     var pattern: String? = null\r
+    var schema: String? = null\r
 }\r
 \r
 /*\r
@@ -157,12 +159,13 @@ class PropertyDefinition {
     var required: Boolean? = null\r
     lateinit var type: String\r
     @get:JsonProperty("default")\r
-    var defaultValue: Any? = null\r
+    var defaultValue: JsonNode? = null\r
     var status: String? = null\r
     var constraints: MutableList<ConstraintClause>? = null\r
     @get:JsonProperty("entry_schema")\r
     var entrySchema: EntrySchema? = null\r
-    var value: Any? = null\r
+    @get:ApiModelProperty(notes = "Property Value, It may be raw JSON or primitive data type values")\r
+    var value: JsonNode? = null\r
 }\r
 \r
 \r
@@ -182,7 +185,7 @@ class AttributeDefinition {
     var description: String? = null\r
     lateinit var type: String\r
     @JsonProperty("default")\r
-    var _default: Any? = null\r
+    var _default: JsonNode? = null\r
     var status: String? = null\r
     @JsonProperty("entry_schema")\r
     var entry_schema: String? = null\r
@@ -346,7 +349,7 @@ A Data Type definition defines the schema for new named datatypes in TOSCA.
  */\r
 \r
 class DataType : EntityType(){\r
-    var constraints: MutableList<MutableMap<String, Any>>? = null\r
+    var constraints: MutableList<ConstraintClause>? = null\r
 }\r
 \r
 /*\r
@@ -481,7 +484,7 @@ class SubstitutionMapping {
 \r
 class EntrySchema {\r
     lateinit var type: String\r
-    var constraints: MutableList<MutableMap<String, Any>>? = null\r
+    var constraints: MutableList<ConstraintClause>? = null\r
 }\r
 \r
 class InterfaceAssignment {\r
index 7ebeaa8..661a950 100644 (file)
@@ -7,7 +7,7 @@
       "type": "string",
       "constraints": [
         {
-          "validValues": [
+          "valid_values": [
             "SQL",
             "PLSQL"
           ]
@@ -33,7 +33,7 @@
       }
     },
     "key-dependencies": {
-      "required": false,
+      "required": true,
       "type": "list",
       "entry_schema": {
         "type": "string"
index dd0bffc..13e234e 100644 (file)
@@ -7,7 +7,7 @@
       "type": "string"
     },
     "key-dependencies": {
-      "required": false,
+      "required": true,
       "type": "list",
       "entry_schema": {
         "type": "string"
index 99c4691..126ea30 100644 (file)
@@ -7,7 +7,7 @@
       "type": "string"
     },
     "key-dependencies": {
-      "required": false,
+      "required": true,
       "type": "list",
       "entry_schema": {
         "type": "string"
index e77020e..f8dd8b6 100644 (file)
@@ -8,8 +8,7 @@
       "default": "JSON",
       "constraints": [
         {
-          "validValues": [
-            "XML",
+          "valid_values": [
             "JSON"
           ]
         }
@@ -29,7 +28,7 @@
       "default": "JSON_PATH",
       "constraints": [
         {
-          "validValues": [
+          "valid_values": [
             "JSON_PATH",
             "JSON_POINTER"
           ]
@@ -51,7 +50,7 @@
       }
     },
     "key-dependencies": {
-      "required": false,
+      "required": true,
       "type": "list",
       "entry_schema": {
         "type": "string"
index 1af42c5..96ab1ee 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *  Modifications Copyright © 2018 IBM.\r
  *\r
  *  Licensed under the Apache License, Version 2.0 (the "License");\r
  *  you may not use this file except in compliance with the License.\r
@@ -21,4 +22,8 @@ public class ResourceDictionaryConstants {
     public static final String SOURCE_DEFAULT = "default";\r
     public static final String SOURCE_DB = "db";\r
     public static final String SOURCE_MDSAL = "mdsal";\r
+\r
+    public static final String PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping";\r
+    public static final String PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping";\r
+    public static final String PROPERTY_KEY_DEPENDENCY = "key-dependency";\r
 }\r
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 (file)
index 4f9467f..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;\r
-\r
-import org.apache.commons.collections.MapUtils;\r
-import org.apache.commons.lang3.StringUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.EntrySchema;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDependency;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.ResourceSource;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import java.util.Map;\r
-import java.util.Optional;\r
-import java.util.function.Supplier;\r
-\r
-/**\r
- * ResourceDictionaryUtils.java Purpose to provide ResourceDictionaryUtils\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-public class ResourceDictionaryUtils {\r
-\r
-    private ResourceDictionaryUtils() {\r
-        // Do nothing\r
-    }\r
-\r
-    private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtils.class);\r
-\r
-    /**\r
-     * This Method is to assign the source name to the Dictionary Definition Check to see if the source\r
-     * definition is not present then assign, if more than one source then assign only one first source.\r
-     *\r
-     * @param resourceAssignment\r
-     * @param dictionaryDefinition\r
-     */\r
-    @SuppressWarnings("squid:S3776")\r
-    public static void populateSourceMapping(ResourceAssignment resourceAssignment,\r
-                                             DictionaryDefinition dictionaryDefinition) {\r
-\r
-        if (resourceAssignment != null && dictionaryDefinition != null\r
-                && StringUtils.isBlank(resourceAssignment.getDictionarySource())) {\r
-\r
-            // Overwrite the Property Definitions from Dictionary\r
-            setProperty(resourceAssignment, dictionaryDefinition);\r
-\r
-            Map<String, ResourceSource> dictionarySource = dictionaryDefinition.getSource();\r
-            Map<String, DictionaryDependency> dictionaryDependencyMap = dictionaryDefinition.getDependency();\r
-\r
-            if (MapUtils.isNotEmpty(dictionarySource)) {\r
-                String source = findFirstSource(dictionarySource);\r
-\r
-                // Populate and Assign First Source\r
-                if (StringUtils.isNotBlank(source)) {\r
-                    // Set Dictionary Source\r
-                    resourceAssignment.setDictionarySource(source);\r
-\r
-                    if (MapUtils.isNotEmpty(dictionaryDependencyMap)) {\r
-                        // Set Dependencies\r
-                        DictionaryDependency dictionaryDependency = dictionaryDependencyMap.get(source);\r
-                        if (dictionaryDependency != null) {\r
-                            resourceAssignment.setDependencies(dictionaryDependency.getNames());\r
-                        }\r
-                    }\r
-                } else {\r
-                    resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_INPUT);\r
-                }\r
-                log.info("auto map resourceAssignment : {}", resourceAssignment);\r
-            }\r
-        }\r
-    }\r
-\r
-    public static <T> Optional<T> resolve(Supplier<T> resolver) {\r
-        try {\r
-            T result = resolver.get();\r
-            return Optional.ofNullable(result);\r
-        } catch (NullPointerException e) {\r
-            return Optional.empty();\r
-        }\r
-    }\r
-\r
-    private static String findFirstSource(Map<String, ResourceSource> dictionarySource) {\r
-        String source = null;\r
-        if (MapUtils.isNotEmpty(dictionarySource)) {\r
-            source = dictionarySource.keySet().stream().findFirst().get();\r
-        }\r
-        return source;\r
-    }\r
-\r
-    /**\r
-     * Overriding ResourceAssignment Properties with properties defined in Dictionary\r
-     */\r
-    private static void setProperty(ResourceAssignment resourceAssignment, DictionaryDefinition dictionaryDefinition) {\r
-        if (StringUtils.isNotBlank(dictionaryDefinition.getDataType())) {\r
-            PropertyDefinition property = resourceAssignment.getProperty();\r
-            if (property == null) {\r
-                property = new PropertyDefinition();\r
-            }\r
-            property.setDefaultValue(dictionaryDefinition.getDefaultValue());\r
-            property.setType(dictionaryDefinition.getDataType());\r
-            if (StringUtils.isNotBlank(dictionaryDefinition.getEntrySchema())) {\r
-                EntrySchema entrySchema = new EntrySchema();\r
-                entrySchema.setType(dictionaryDefinition.getEntrySchema());\r
-                property.setEntrySchema(entrySchema);\r
-            }\r
-            resourceAssignment.setProperty(property);\r
-        }\r
-    }\r
-\r
-}\r
index c2c8094..525ed9a 100644 (file)
@@ -44,7 +44,7 @@ open class ResourceDefinition{
     lateinit var resourcePath: String
 
     @JsonProperty(value = "sources", required = true)
-    var sources: MutableMap<String, NodeTemplate>? = null
+    lateinit var sources: MutableMap<String, NodeTemplate>
 
     @JsonProperty("decryption-rules")
     var decryptionRules: MutableList<DecryptionRule>? = null
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 (file)
index 0000000..e08c09c
--- /dev/null
@@ -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/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 (file)
index b6ac103..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;\r
-\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-public class ResourceDictionaryUtilsTest {\r
-    private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtilsTest.class);\r
-\r
-    @Test\r
-    public void validateSingleInputSource() {\r
-        try {\r
-            ResourceAssignment resourceAssignment = new ResourceAssignment();\r
-            resourceAssignment.setName("test-input-key");\r
-            PropertyDefinition propertyDefinition = new PropertyDefinition();\r
-            propertyDefinition.setType("string");\r
-            resourceAssignment.setProperty(propertyDefinition);\r
-            DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
-            dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
-\r
-            Map<String, ResourceSource> source = new HashMap<>();\r
-            SourceInput sourceInput = new SourceInput();\r
-            source.put(ResourceDictionaryConstants.SOURCE_INPUT, sourceInput);\r
-            dictionaryDefinition.setSource(source);\r
-\r
-            ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);\r
-            Assert.assertNotNull("Resource assignment input source is missing ",\r
-                    resourceAssignment.getDictionarySource());\r
-            Assert.assertNotNull("Resource assignment input source property is missing ",\r
-                    resourceAssignment.getProperty());\r
-            Assert.assertNotNull("Resource assignment input source property type is missing ",\r
-                    resourceAssignment.getProperty().getType());\r
-\r
-        } catch (Exception e) {\r
-            e.printStackTrace();\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void validateSingleDbSource() {\r
-        try {\r
-            ResourceAssignment resourceAssignment = new ResourceAssignment();\r
-            resourceAssignment.setName("test-db-key");\r
-            PropertyDefinition propertyDefinition = new PropertyDefinition();\r
-            propertyDefinition.setType("string");\r
-            resourceAssignment.setProperty(propertyDefinition);\r
-\r
-            DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
-            dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
-\r
-            Map<String, ResourceSource> source = new HashMap<>();\r
-            SourceDb sourceDb = new SourceDb();\r
-            sourceDb.setBase("sdnc_connection");\r
-            source.put(ResourceDictionaryConstants.SOURCE_DB, sourceDb);\r
-            dictionaryDefinition.setSource(source);\r
-\r
-            Map<String, DictionaryDependency> dependency = new HashMap<>();\r
-            DictionaryDependency dependencyDb = new DictionaryDependency();\r
-            dependencyDb.setNames(Arrays.asList("vnf-id", "vnf-name"));\r
-            dependency.put(ResourceDictionaryConstants.SOURCE_DB, dependencyDb);\r
-            dictionaryDefinition.setDependency(dependency);\r
-\r
-            DecryptionRule decryptionRule = new DecryptionRule();\r
-            decryptionRule.setDecryptType("sample Type");\r
-            decryptionRule.setPath("$.");\r
-            decryptionRule.setRule("Sample Rule");\r
-            decryptionRule.setSources(Arrays.asList("vnf-id"));\r
-            dictionaryDefinition.setDecryptionRules(Arrays.asList(decryptionRule));\r
-\r
-            ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);\r
-            Assert.assertNotNull("Resource assignment db source source is missing ",\r
-                    resourceAssignment.getDictionarySource());\r
-            Assert.assertNotNull("Resource assignment db source source property is missing ",\r
-                    resourceAssignment.getProperty());\r
-            Assert.assertNotNull("Resource assignment db source source property type is missing ",\r
-                    resourceAssignment.getProperty().getType());\r
-\r
-            Assert.assertNotNull("Resource assignment db dependecy is missing ", resourceAssignment.getDependencies());\r
-            Assert.assertEquals("Resource assignment db dependecy count mismatch ", 2,\r
-                    resourceAssignment.getDependencies().size());\r
-\r
-        } catch (Exception e) {\r
-            e.printStackTrace();\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void testSourceDefault() {\r
-        ResourceAssignment resourceAssignment = new ResourceAssignment();\r
-        resourceAssignment.setName("test-input-key");\r
-        PropertyDefinition propertyDefinition = new PropertyDefinition();\r
-        propertyDefinition.setType("string");\r
-        resourceAssignment.setProperty(propertyDefinition);\r
-\r
-        DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
-        dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
-\r
-        Map<String, ResourceSource> source = new HashMap<>();\r
-        SourceDefault sourceDefault = new SourceDefault();\r
-        source.put(ResourceDictionaryConstants.SOURCE_DEFAULT, sourceDefault);\r
-        dictionaryDefinition.setSource(source);\r
-\r
-        Map<String, DictionaryDependency> dependency = new HashMap<>();\r
-        DictionaryDependency dependencyDefault = new DictionaryDependency();\r
-        dependencyDefault.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));\r
-        dependency.put(ResourceDictionaryConstants.SOURCE_DEFAULT, dependencyDefault);\r
-        dictionaryDefinition.setDependency(dependency);\r
-\r
-        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);\r
-\r
-        Assert.assertNotNull("Resource assignment default source is missing ",\r
-                resourceAssignment.getDictionarySource());\r
-        Assert.assertNotNull("Resource assignment default source property is missing ",\r
-                resourceAssignment.getProperty());\r
-        Assert.assertNotNull("Resource assignment default source property type is missing ",\r
-                resourceAssignment.getProperty().getType());\r
-    }\r
-\r
-    @Test\r
-    public void testSourceMdsal() {\r
-        ResourceAssignment resourceAssignment = new ResourceAssignment();\r
-        resourceAssignment.setName("test-input-key");\r
-        PropertyDefinition propertyDefinition = new PropertyDefinition();\r
-        propertyDefinition.setType("string");\r
-        resourceAssignment.setProperty(propertyDefinition);\r
-\r
-        DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();\r
-        dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);\r
-\r
-        Map<String, ResourceSource> source = new HashMap<>();\r
-        SourceMdsal sourceMdsal = new SourceMdsal();\r
-        source.put(ResourceDictionaryConstants.SOURCE_MDSAL,sourceMdsal);\r
-        dictionaryDefinition.setSource(source);\r
-\r
-        Map<String, DictionaryDependency> dependency = new HashMap<>();\r
-        DictionaryDependency dependencyMdsal = new DictionaryDependency();\r
-        dependencyMdsal.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));\r
-        dependency.put(ResourceDictionaryConstants.SOURCE_MDSAL, dependencyMdsal);\r
-        dictionaryDefinition.setDependency(dependency);\r
-\r
-        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);\r
-\r
-        Assert.assertNotNull("Resource assignment mdsal source is missing ", resourceAssignment.getDictionarySource());\r
-        Assert.assertNotNull("Resource assignment mdsal source property is missing ", resourceAssignment.getProperty());\r
-        Assert.assertNotNull("Resource assignment mdsal source property type is missing ",\r
-                resourceAssignment.getProperty().getType());\r
-    }\r
-\r
-}\r
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 (file)
index 0000000..2a207e0
--- /dev/null
@@ -0,0 +1,79 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;\r
+\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+public class ResourceDictionaryUtilsTest {\r
+    private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtilsTest.class);\r
+\r
+    @Test\r
+    public void testPopulateSourceMapping() {\r
+\r
+        ResourceAssignment resourceAssignment = new ResourceAssignment();\r
+        ResourceDefinition resourceDefinition = new ResourceDefinition();\r
+        Map<String, NodeTemplate> sources = new HashMap<>();\r
+        resourceDefinition.setSources(sources);\r
+        // To Check Empty Source\r
+        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+        Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, resourceAssignment.getDictionarySource());\r
+\r
+        // To Check First Source\r
+        resourceAssignment.setDictionarySource(null);\r
+        sources.put(ResourceDictionaryConstants.SOURCE_DEFAULT, new NodeTemplate());\r
+        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+        Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource());\r
+\r
+        // To Check Assigned Source\r
+        resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_DB);\r
+        ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition);\r
+        Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_DB, resourceAssignment.getDictionarySource());\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testFindFirstSource() {\r
+        //To check if Empty Source\r
+        Map<String, NodeTemplate> sources = new HashMap<>();\r
+        String firstSource = ResourceDictionaryUtils.findFirstSource(sources);\r
+        Assert.assertNull("Source populated, which is not expected.", firstSource);\r
+\r
+        // TO check the first Source\r
+        sources.put(ResourceDictionaryConstants.SOURCE_INPUT, new NodeTemplate());\r
+        String inputFirstSource = ResourceDictionaryUtils.findFirstSource(sources);\r
+        Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource);\r
+\r
+        // TO check the multiple Source\r
+        sources.put(ResourceDictionaryConstants.SOURCE_DB, new NodeTemplate());\r
+        String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources);\r
+        Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource);\r
+\r
+    }\r
+\r
+}\r
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 (file)
index 0000000..661a950
--- /dev/null
@@ -0,0 +1,44 @@
+{
+  "description": "This is Database Resource Source Node Type",
+  "version": "1.0.0",
+  "properties": {
+    "type": {
+      "required": true,
+      "type": "string",
+      "constraints": [
+        {
+          "valid_values": [
+            "SQL",
+            "PLSQL"
+          ]
+        }
+      ]
+    },
+    "query": {
+      "required": true,
+      "type": "string"
+    },
+    "input-key-mapping": {
+      "required": false,
+      "type": "map",
+      "entry_schema": {
+        "type": "string"
+      }
+    },
+    "output-key-mapping": {
+      "required": false,
+      "type": "map",
+      "entry_schema": {
+        "type": "string"
+      }
+    },
+    "key-dependencies": {
+      "required": true,
+      "type": "list",
+      "entry_schema": {
+        "type": "string"
+      }
+    }
+  },
+  "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
diff --git a/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 (file)
index 0000000..13e234e
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "description": "This is Default Resource Source Node Type",
+  "version": "1.0.0",
+  "properties": {
+    "key": {
+      "required": false,
+      "type": "string"
+    },
+    "key-dependencies": {
+      "required": true,
+      "type": "list",
+      "entry_schema": {
+        "type": "string"
+      }
+    }
+  },
+  "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
diff --git a/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 (file)
index 0000000..126ea30
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "description": "This is Input Resource Source Node Type",
+  "version": "1.0.0",
+  "properties": {
+    "key": {
+      "required": false,
+      "type": "string"
+    },
+    "key-dependencies": {
+      "required": true,
+      "type": "list",
+      "entry_schema": {
+        "type": "string"
+      }
+    }
+  },
+  "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
diff --git a/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 (file)
index 0000000..f8dd8b6
--- /dev/null
@@ -0,0 +1,61 @@
+{
+  "description": "This is Rest Resource Source Node Type",
+  "version": "1.0.0",
+  "properties": {
+    "type": {
+      "required": false,
+      "type": "string",
+      "default": "JSON",
+      "constraints": [
+        {
+          "valid_values": [
+            "JSON"
+          ]
+        }
+      ]
+    },
+    "url-path": {
+      "required": true,
+      "type": "string"
+    },
+    "path": {
+      "required": true,
+      "type": "string"
+    },
+    "expression-type": {
+      "required": false,
+      "type": "string",
+      "default": "JSON_PATH",
+      "constraints": [
+        {
+          "valid_values": [
+            "JSON_PATH",
+            "JSON_POINTER"
+          ]
+        }
+      ]
+    },
+    "input-key-mapping": {
+      "required": false,
+      "type": "map",
+      "entry_schema": {
+        "type": "string"
+      }
+    },
+    "output-key-mapping": {
+      "required": false,
+      "type": "map",
+      "entry_schema": {
+        "type": "string"
+      }
+    },
+    "key-dependencies": {
+      "required": true,
+      "type": "list",
+      "entry_schema": {
+        "type": "string"
+      }
+    }
+  },
+  "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
diff --git a/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 (file)
index 0000000..2ef553e
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "description": "TOSCA base type for Resource Sources",
+  "version": "1.0.0",
+  "derived_from": "tosca.nodes.Root"
+}
\ No newline at end of file
index 8625235..cd4e282 100644 (file)
@@ -1,20 +1,25 @@
 {\r
   "name": "bundle-id",\r
-  "description": "name of the ",\r
+  "property" :{\r
+    "description": "name of the ",\r
+    "type": "string"\r
+  },\r
   "resource-type": "ONAP",\r
   "resource-path": "vnf/bundle-id",\r
   "updated-by": "brindasanth@onap.com",\r
-  "data-type": "String",\r
   "tags": "bundle-id, brindasanth@onap.com",\r
-  "source": {\r
+  "sources": {\r
     "db": {\r
-      "query": "SELECT bundle-id FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
-      "input-key-mapping": {\r
-        "profile_name": "profile_name"\r
-      },\r
-      "output-key-mapping": {\r
-        "db-country": "country",\r
-        "db-state": "state"\r
+      "type": "source-db",\r
+      "properties": {\r
+        "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name",\r
+        "input-key-mapping": {\r
+          "profile_name": "profile_name"\r
+        },\r
+        "output-key-mapping": {\r
+          "db-country": "country",\r
+          "db-state": "state"\r
+        }\r
       }\r
     }\r
   },\r
index 35736b6..c34c252 100644 (file)
@@ -1,17 +1,19 @@
 {\r
        "name": "action-name",\r
+       "property" :{\r
+               "description": "name of the ",\r
+               "type": "string"\r
+       },\r
        "resource-path": "action-name",\r
        "resource-type": "ONAP",\r
-       "description": "To be provided",\r
-       "valid-values": null,\r
-       "sample-value": null,\r
        "updated-by": "brindasanth@onap.com",\r
        "tags": null,\r
-       "default": null,\r
-       "data-type": "string",\r
-       "source": {\r
+       "sources": {\r
                "input": {\r
-                       "key": "action-name"\r
+                       "type": "source-input",\r
+                       "properties": {\r
+                               "key": "action-name"\r
+                       }\r
                }\r
        }\r
 }
\ No newline at end of file
index c6c0f98..349183b 100644 (file)
@@ -1,14 +1,19 @@
 {\r
-       "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",\r
-       "name": "v4-ip-type",\r
-       "description": "To be provided",\r
-       "updated-by": "brindasanth@onap.com",\r
-       "resource-type": "ONAP",\r
-       "resource-path": "vnf/v4-ip-type",\r
-       "data-type": "string",\r
-       "source": {\r
-               "input": {\r
-                       \r
-               }\r
-       }\r
+  "name": "v4-ip-type",\r
+  "property": {\r
+    "description": "name of the ",\r
+    "type": "string"\r
+  },\r
+  "resource-path": "vnf/v4-ip-type",\r
+  "resource-type": "ONAP",\r
+  "updated-by": "brindasanth@onap.com",\r
+  "tags": null,\r
+  "sources": {\r
+    "input": {\r
+      "type": "source-input",\r
+      "properties": {\r
+        "key": "v4-ip-type"\r
+      }\r
+    }\r
+  }\r
 }
\ No newline at end of file
index 6b09c81..2c44378 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -22,7 +23,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
 import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;\r
@@ -102,7 +103,7 @@ public class AutoResourceMappingService {
         ResourceDictionary dbDataDictionary = dictionaryMap.get(resourceAssignment.getName());\r
         if (dbDataDictionary != null && StringUtils.isNotBlank(dbDataDictionary.getDefinition())) {\r
 \r
-            DictionaryDefinition dictionaryDefinition = JacksonUtils.readValue(dbDataDictionary.getDefinition(), DictionaryDefinition.class);\r
+            ResourceDefinition dictionaryDefinition = JacksonUtils.readValue(dbDataDictionary.getDefinition(), ResourceDefinition.class);\r
 \r
             if (dictionaryDefinition != null && StringUtils.isNotBlank(dictionaryDefinition.getName())\r
                     && StringUtils.isBlank(resourceAssignment.getDictionaryName())) {\r
@@ -186,7 +187,7 @@ public class AutoResourceMappingService {
         }\r
         if (dictionaries != null) {\r
             for (ResourceDictionary resourcedictionary : dictionaries) {\r
-                DictionaryDefinition dictionaryDefinition = JacksonUtils.readValue(resourcedictionary.getDefinition(), DictionaryDefinition.class);\r
+                ResourceDefinition dictionaryDefinition = JacksonUtils.readValue(resourcedictionary.getDefinition(), ResourceDefinition.class);\r
                 PropertyDefinition property = new PropertyDefinition();\r
                                property.setRequired(true);\r
                                ResourceAssignment resourceAssignment = new ResourceAssignment();\r
index 9ab319c..3a5c4fd 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -16,6 +17,7 @@
 \r
 package org.onap.ccsdk.apps.controllerblueprints.service;\r
 \r
+import com.google.common.base.Preconditions;\r
 import org.apache.commons.collections.CollectionUtils;\r
 import org.apache.commons.io.IOUtils;\r
 import org.apache.commons.lang3.StringUtils;\r
@@ -26,7 +28,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
 import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
@@ -160,26 +162,21 @@ public class DataBaseInitService {
                         fileName = file.getFilename();\r
                         log.trace("Loading : {}", fileName);\r
                         String definitionContent = getResourceContent(file);\r
-                        DictionaryDefinition dictionaryDefinition =\r
-                                JacksonUtils.readValue(definitionContent, DictionaryDefinition.class);\r
+                        ResourceDefinition dictionaryDefinition =\r
+                                JacksonUtils.readValue(definitionContent, ResourceDefinition.class);\r
                         if (dictionaryDefinition != null) {\r
+                            Preconditions.checkNotNull(dictionaryDefinition.getProperty(), "Failed to get Property Definition");\r
                             ResourceDictionary resourceDictionary = new ResourceDictionary();\r
                             resourceDictionary.setResourcePath(dictionaryDefinition.getResourcePath());\r
                             resourceDictionary.setName(dictionaryDefinition.getName());\r
                             resourceDictionary.setDefinition(definitionContent);\r
 \r
-                            if (dictionaryDefinition.getValidValues() != null)\r
-                                resourceDictionary\r
-                                        .setValidValues(String.valueOf(dictionaryDefinition.getValidValues()));\r
-\r
-                            if (dictionaryDefinition.getSampleValue() != null)\r
-                                resourceDictionary\r
-                                        .setValidValues(String.valueOf(dictionaryDefinition.getSampleValue()));\r
-\r
                             resourceDictionary.setResourceType(dictionaryDefinition.getResourceType());\r
-                            resourceDictionary.setDataType(dictionaryDefinition.getDataType());\r
-                            resourceDictionary.setEntrySchema(dictionaryDefinition.getEntrySchema());\r
-                            resourceDictionary.setDescription(dictionaryDefinition.getDescription());\r
+                            resourceDictionary.setDescription(dictionaryDefinition.getProperty().getDescription());\r
+                            resourceDictionary.setDataType(dictionaryDefinition.getProperty().getType());\r
+                            if(dictionaryDefinition.getProperty().getEntrySchema() != null){\r
+                                resourceDictionary.setEntrySchema(dictionaryDefinition.getProperty().getEntrySchema().getType());\r
+                            }\r
                             resourceDictionary.setUpdatedBy(dictionaryDefinition.getUpdatedBy());\r
                             if (StringUtils.isBlank(dictionaryDefinition.getTags())) {\r
                                 resourceDictionary.setTags(\r
index b9567db..4bb87d7 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -18,8 +19,10 @@ package org.onap.ccsdk.apps.controllerblueprints.service;
 \r
 import org.apache.commons.lang3.StringUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.EntrySchema;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator;\r
@@ -108,24 +111,32 @@ public class ResourceDictionaryService {
         if (resourceDictionary != null) {\r
             ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);\r
 \r
-            DictionaryDefinition dictionaryDefinition =\r
-                    JacksonUtils.readValue(resourceDictionary.getDefinition(), DictionaryDefinition.class);\r
+            ResourceDefinition resourceDefinition =\r
+                    JacksonUtils.readValue(resourceDictionary.getDefinition(), ResourceDefinition.class);\r
 \r
-            if (dictionaryDefinition == null) {\r
+            if (resourceDefinition == null) {\r
                 throw new BluePrintException(\r
                         "Resource dictionary definition is not valid content " + resourceDictionary.getDefinition());\r
             }\r
 \r
-            dictionaryDefinition.setName(resourceDictionary.getName());\r
-            dictionaryDefinition.setResourcePath(resourceDictionary.getResourcePath());\r
-            dictionaryDefinition.setResourceType(resourceDictionary.getResourceType());\r
-            dictionaryDefinition.setDataType(resourceDictionary.getDataType());\r
-            dictionaryDefinition.setEntrySchema(resourceDictionary.getEntrySchema());\r
-            dictionaryDefinition.setTags(resourceDictionary.getTags());\r
-            dictionaryDefinition.setDescription(resourceDictionary.getDescription());\r
-            dictionaryDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());\r
+            resourceDefinition.setName(resourceDictionary.getName());\r
+            resourceDefinition.setResourcePath(resourceDictionary.getResourcePath());\r
+            resourceDefinition.setResourceType(resourceDictionary.getResourceType());\r
+\r
+            PropertyDefinition propertyDefinition = new PropertyDefinition();\r
+            propertyDefinition.setType(resourceDictionary.getDataType());\r
+            propertyDefinition.setDescription(resourceDictionary.getDescription());\r
+            if(StringUtils.isNotBlank(resourceDictionary.getEntrySchema())){\r
+                EntrySchema entrySchema = new EntrySchema();\r
+                entrySchema.setType(resourceDictionary.getEntrySchema());\r
+                propertyDefinition.setEntrySchema(entrySchema);\r
+            }else{\r
+                propertyDefinition.setEntrySchema(null);\r
+            }\r
+            resourceDefinition.setTags(resourceDictionary.getTags());\r
+            resourceDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());\r
 \r
-            String definitionContent = JacksonUtils.getJson(dictionaryDefinition, true);\r
+            String definitionContent = JacksonUtils.getJson(resourceDefinition, true);\r
             resourceDictionary.setDefinition(definitionContent);\r
 \r
             Optional<ResourceDictionary> dbResourceDictionaryData =\r
index 73d6eca..8257dc3 100644 (file)
@@ -1,5 +1,6 @@
 /*\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -50,14 +51,6 @@ public class ResourceDictionaryRestTest {
     @Autowired\r
     protected ResourceDictionaryRest resourceDictionaryRest;\r
 \r
-    @Before\r
-    public void setUp() {\r
-        SourceDeserializer.registerSource("db", SourceDb.class);\r
-        SourceDeserializer.registerSource("input", SourceInput.class);\r
-        SourceDeserializer.registerSource("mdsal", SourceMdsal.class);\r
-        SourceDeserializer.registerSource("default", SourceDefault.class);\r
-    }\r
-\r
     @Test\r
     public void test01SaveDataDictionary() throws Exception {\r
         String definition = IOUtils.toString(\r
index 2b39205..986ba70 100644 (file)
@@ -1,19 +1,19 @@
 {\r
-       "name": "v4-aggregat-list",\r
-       "description": "This collection v4-aggregate list",\r
-       "valid-values": null,\r
-       "sample-value": null,\r
-       "updated-by": "Brinda Santh (bs2796)",\r
-       "resource-type": "ONAP",\r
-       "resource-path": "/v4-aggregat-list",\r
-       "data-type": "list",\r
-       "entry-schema": "dt-v4-aggregate",\r
-       "tags": null,\r
-       "default": null,\r
-       "source": {\r
-               "input": {\r
-                       \r
-               }\r
-       },\r
-       "candidate-dependency": null\r
+  "name": "v4-aggregat-list",\r
+  "property": {\r
+    "description": "name of the ",\r
+    "type": "list",\r
+    "entry_schema": {\r
+      "type": "dt-v4-aggregate"\r
+    }\r
+  },\r
+  "updated-by": "Brinda Santh (bs2796)",\r
+  "resource-type": "ONAP",\r
+  "resource-path": "/v4-aggregat-list",\r
+  "tags": null,\r
+  "sources": {\r
+    "input": {\r
+      "type": "source-input"\r
+    }\r
+  }\r
 }
\ No newline at end of file