From 7457ecefb624682f6dddc558111b1d38f2a2ca83 Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Thu, 19 Jan 2023 14:43:33 +0000 Subject: Fix ability to add property to data type of different model Issue-ID: SDC-4339 Signed-off-by: JvD_Ericsson Change-Id: Ibc5b57a042ffc4e7f914d46ad264a0e16081b863 --- .../sdc/be/model/operations/impl/DataTypeOperation.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'catalog-model/src/main/java/org') 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 d75302fc5d..36dcaf44ba 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 @@ -189,6 +189,22 @@ public class DataTypeOperation extends AbstractOperation { return Optional.of(dataTypeEither.left().value().getDataTypeDataDefinition()); } + public Optional getDataTypeByNameAndModel(final String name, String model) { + final Either dataTypeEither = janusGraphGenericDao + .getNode("name", name, DataTypeData.class, model); + if (dataTypeEither.isRight()) { + if (JanusGraphOperationStatus.NOT_FOUND.equals(dataTypeEither.right().value())) { + return Optional.empty(); + } + final StorageOperationStatus storageOperationStatus + = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(dataTypeEither.right().value()); + LOGGER.warn("Failed to fetch data type '{}' from JanusGraph. Status is: {}", name, storageOperationStatus); + throw new OperationException(ActionStatus.GENERAL_ERROR, + String.format("Failed to fetch data type '%s' from JanusGraph. Status is: %s", name, storageOperationStatus)); + } + return Optional.of(dataTypeEither.left().value().getDataTypeDataDefinition()); + } + public List findAllProperties(final String uniqueId) { final Either, JanusGraphOperationStatus> propertiesEither = propertyOperation.findPropertiesOfNode(NodeTypeEnum.DataType, uniqueId); -- cgit 1.2.3-korg