diff options
author | franciscovila <javier.paradela.vila@est.tech> | 2022-11-24 10:29:04 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-01-26 23:32:10 +0000 |
commit | 701e441228724c5b701d94cc3f1e520ce656398a (patch) | |
tree | 5900482086d86f8b8e465e6d4b57db4bd7a94184 /catalog-model/src | |
parent | 1bbecd7edbdd907a53812d303d378236d23d071e (diff) |
Import data type in UI
Develop all necessary changes in the UI to allow importing a data type from a yaml file
Issue-ID: SDC-4279
Signed-off-by: franciscovila <javier.paradela.vila@est.tech>
Change-Id: Id413386fad8b362e8c4a1d25c859a22178189074
Diffstat (limited to 'catalog-model/src')
2 files changed, 17 insertions, 1 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java index 36dcaf44ba..7d01f3f273 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java @@ -29,6 +29,7 @@ import java.util.Optional; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.janusgraph.core.JanusGraph; @@ -37,6 +38,7 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; +import org.openecomp.sdc.be.dao.janusgraph.QueryType; import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition; @@ -124,6 +126,20 @@ public class DataTypeOperation extends AbstractOperation { return dataTypesFound; } + public List<String> getAllDataTypeModels(final String dataTypeName) { + final List<String> models = new ArrayList<>(); + ImmutableTriple<QueryType, String, Object> criteria = + new ImmutableTriple<>(QueryType.HAS, GraphPropertiesDictionary.NAME.getProperty(), dataTypeName); + + final Either<List<DataTypeData>, JanusGraphOperationStatus> getAllDataTypesForModel = + janusGraphGenericDao.getByCriteria(NodeTypeEnum.DataType, DataTypeData.class, List.of(criteria)); + final var dataTypesValidated = validateDataType(getAllDataTypesForModel, null); + for (DataTypeData dataType : dataTypesValidated) { + models.add(dataType.getDataTypeDataDefinition().getModel()); + } + return models; + } + private List<DataTypeData> getAllDataTypesWithModel(final String modelName) { final Either<List<DataTypeData>, JanusGraphOperationStatus> getAllDataTypesByModel = janusGraphGenericDao .getByCriteriaForModel(NodeTypeEnum.DataType, null, modelName, DataTypeData.class); 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 0d462c9874..8baa9a73c0 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 @@ -296,7 +296,7 @@ public class ModelOperation { rebuiltModelImportList = new ArrayList<>(modelImportList); } - final Map<String, Object> typesYamlMap = new Yaml().load(typesYaml); + final Map<String, Object> typesYamlMap = new Yaml().loadAs(typesYaml, Map.class); removeExistingTypesFromDefaultImports(elementTypeEnum, typesYamlMap, rebuiltModelImportList); final Map<String, Object> originalContent = new Yaml().load(additionalTypeDefinitionsImport.getContent()); |