diff options
Diffstat (limited to 'ms/controllerblueprints/modules/service/src')
5 files changed, 57 insertions, 55 deletions
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/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..4bb87d7f 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.
@@ -18,8 +19,10 @@ package org.onap.ccsdk.apps.controllerblueprints.service; 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;
@@ -108,24 +111,32 @@ public class ResourceDictionaryService { if (resourceDictionary != null) {
ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);
- DictionaryDefinition dictionaryDefinition =
- JacksonUtils.readValue(resourceDictionary.getDefinition(), DictionaryDefinition.class);
+ ResourceDefinition resourceDefinition =
+ JacksonUtils.readValue(resourceDictionary.getDefinition(), ResourceDefinition.class);
- if (dictionaryDefinition == null) {
+ if (resourceDefinition == 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());
+ resourceDefinition.setName(resourceDictionary.getName());
+ resourceDefinition.setResourcePath(resourceDictionary.getResourcePath());
+ resourceDefinition.setResourceType(resourceDictionary.getResourceType());
+
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ propertyDefinition.setType(resourceDictionary.getDataType());
+ propertyDefinition.setDescription(resourceDictionary.getDescription());
+ if(StringUtils.isNotBlank(resourceDictionary.getEntrySchema())){
+ EntrySchema entrySchema = new EntrySchema();
+ entrySchema.setType(resourceDictionary.getEntrySchema());
+ propertyDefinition.setEntrySchema(entrySchema);
+ }else{
+ propertyDefinition.setEntrySchema(null);
+ }
+ resourceDefinition.setTags(resourceDictionary.getTags());
+ resourceDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());
- String definitionContent = JacksonUtils.getJson(dictionaryDefinition, true);
+ String definitionContent = JacksonUtils.getJson(resourceDefinition, true);
resourceDictionary.setDefinition(definitionContent);
Optional<ResourceDictionary> dbResourceDictionaryData =
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..986ba706 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": "v4-aggregat-list",
+ "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": null,
+ "sources": {
+ "input": {
+ "type": "source-input"
+ }
+ }
}
\ No newline at end of file |