From 3943534cd3409c0cca6588f36527df34345d74f2 Mon Sep 17 00:00:00 2001 From: KrupaNagabhushan Date: Wed, 26 Oct 2022 17:26:54 +0100 Subject: Download data type from UI Issue-ID: SDC-4332 Signed-off-by: KrupaNagabhushan Change-Id: If31f7a95eb2d568e716760a33ef2641bad09cf68 --- .../sdc/be/model/operations/impl/DataTypeOperation.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'catalog-model/src/main') 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 7cd042a27d..d75302fc5d 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 @@ -28,6 +28,7 @@ import java.util.Map; 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.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.janusgraph.core.JanusGraph; @@ -42,6 +43,7 @@ import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.exception.supplier.DataTypeOperationExceptionSupplier; +import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.dto.PropertyDefinitionDto; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.exception.OperationException; @@ -208,6 +210,18 @@ public class DataTypeOperation extends AbstractOperation { return propertyDefinitions; } + public Optional handleDataTypeDownloadRequestById(final String dataTypeId) { + if (StringUtils.isNotEmpty(dataTypeId)) { + Optional dataTypeDataDefinition = getDataTypeByUid(dataTypeId); + if (dataTypeDataDefinition.isPresent()) { + DataTypeDefinition dataTypeDefinition = new DataTypeDefinition(dataTypeDataDefinition.get()); + dataTypeDefinition.setProperties(findAllProperties(dataTypeId)); + return Optional.of(dataTypeDefinition); + } + } + return Optional.empty(); + } + public PropertyDefinitionDto createProperty(final String dataTypeId, final PropertyDefinitionDto propertyDefinitionDto) { final String propertyName = propertyDefinitionDto.getName(); LOGGER.debug("Adding property '{}' to data type '{}'.", propertyName, dataTypeId); -- cgit 1.2.3-korg