Error importing data type in the UI 48/133048/3
authorfranciscovila <javier.paradela.vila@est.tech>
Fri, 27 Jan 2023 11:51:47 +0000 (11:51 +0000)
committerMichael Morris <michael.morris@est.tech>
Fri, 27 Jan 2023 16:24:04 +0000 (16:24 +0000)
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

catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
catalog-ui/src/app/utils/service-data-type-reader.ts

index 2e35c30..311b471 100644 (file)
@@ -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");
index fd5ee2f..99b3d3a 100644 (file)
@@ -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));