From: franciscovila Date: Fri, 27 Jan 2023 11:51:47 +0000 (+0000) Subject: Error importing data type in the UI X-Git-Tag: 1.12.1~3 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;ds=sidebyside;h=e3a17890903ee443d0b5d0ee872e316e4369318d;p=sdc.git 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 Change-Id: I61f6dba8c15dd73de99cbf2cfb857e271f37665d --- 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 typesYamlMap = new Yaml().loadAs(typesYaml, Map.class); + Map typesYamlMap = new Yaml().loadAs(typesYaml, Map.class); + if (typesYamlMap.containsKey("data_types")){ + typesYamlMap = (Map) typesYamlMap.get("data_types"); + } removeExistingTypesFromDefaultImports(elementTypeEnum, typesYamlMap, rebuiltModelImportList); final Map originalContent = new Yaml().load(additionalTypeDefinitionsImport.getContent()); @@ -396,7 +399,10 @@ public class ModelOperation { final Map typesToUpate = new HashMap<>(); - final Map newTypesYaml = new Yaml().load(typesYaml); + Map newTypesYaml = new Yaml().load(typesYaml); + if (newTypesYaml.containsKey("data_types")){ + newTypesYaml = (Map) newTypesYaml.get("data_types"); + } newTypesYaml.entrySet().stream().filter(entry -> existingTypeNames.contains(entry.getKey())).forEach(newTypeToUpdate -> { final Map propertiesInNewDef = (Map) ((Map) 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 = 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));