aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2023-01-27 11:51:47 +0000
committerMichael Morris <michael.morris@est.tech>2023-01-27 16:24:04 +0000
commite3a17890903ee443d0b5d0ee872e316e4369318d (patch)
treedac7db5e9ce634944f9fcb98846618735e098fd2
parenta522b7eb8346617883227c0a6621420cfdf44dc5 (diff)
Error importing data type in the UI
Fix error importing a file with 'tosca_definitions_version' tag Issue-ID: SDC-4351 Signed-off-by: franciscovila <javier.paradela.vila@est.tech> Change-Id: I61f6dba8c15dd73de99cbf2cfb857e271f37665d
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java10
-rw-r--r--catalog-ui/src/app/utils/service-data-type-reader.ts2
2 files changed, 9 insertions, 3 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
index 2e35c30e06..311b4719bd 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
@@ -297,7 +297,10 @@ public class ModelOperation {
rebuiltModelImportList = new ArrayList<>(modelImportList);
}
- final Map<String, Object> typesYamlMap = new Yaml().loadAs(typesYaml, Map.class);
+ Map<String, Object> typesYamlMap = new Yaml().loadAs(typesYaml, Map.class);
+ if (typesYamlMap.containsKey("data_types")){
+ typesYamlMap = (Map<String, Object>) typesYamlMap.get("data_types");
+ }
removeExistingTypesFromDefaultImports(elementTypeEnum, typesYamlMap, rebuiltModelImportList);
final Map<String, Object> originalContent = new Yaml().load(additionalTypeDefinitionsImport.getContent());
@@ -396,7 +399,10 @@ public class ModelOperation {
final Map<String, Object> typesToUpate = new HashMap<>();
- final Map<String, Object> newTypesYaml = new Yaml().load(typesYaml);
+ Map<String, Object> newTypesYaml = new Yaml().load(typesYaml);
+ if (newTypesYaml.containsKey("data_types")){
+ newTypesYaml = (Map<String, Object>) newTypesYaml.get("data_types");
+ }
newTypesYaml.entrySet().stream().filter(entry -> existingTypeNames.contains(entry.getKey())).forEach(newTypeToUpdate -> {
final Map<String, Object> propertiesInNewDef = (Map<String, Object>) ((Map<String, Object>) newTypeToUpdate.getValue()).get("properties");
diff --git a/catalog-ui/src/app/utils/service-data-type-reader.ts b/catalog-ui/src/app/utils/service-data-type-reader.ts
index fd5ee2fc19..99b3d3ae63 100644
--- a/catalog-ui/src/app/utils/service-data-type-reader.ts
+++ b/catalog-ui/src/app/utils/service-data-type-reader.ts
@@ -34,7 +34,7 @@ export class ServiceDataTypeReader {
const result = <String>reader.result;
const loadedContent = load(result);
console.log("Readed content: " + loadedContent);
- this.readName(loadedContent);
+ this.readName(this.getDataType(loadedContent));
this.readDerivedFrom(this.getDataType(loadedContent));
this.readDescription(this.getDataType(loadedContent));
this.readProperties(this.getDataType(loadedContent));