From 53df976426f8845adf58e8ff9355764343a38549 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Wed, 16 Jun 2021 23:21:04 +0100 Subject: Specify model at service creation Allows a user to select a model when designing a service Issue-ID: SDC-3621 Signed-off-by: aribeiro Change-Id: I386e43ddeb649a4ba0805f153e4b47e8a528cff0 --- .../src/main/java/org/openecomp/sdc/be/model/Component.java | 1 + .../sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java | 2 +- .../model/jsonjanusgraph/operations/TopologyTemplateOperation.java | 6 +++++- .../be/model/jsonjanusgraph/operations/ToscaElementOperation.java | 6 +++--- .../openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java | 4 +++- .../java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java | 1 + .../java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java | 2 ++ .../main/java/org/openecomp/sdc/be/ui/model/UiServiceMetadata.java | 2 ++ 8 files changed, 18 insertions(+), 6 deletions(-) (limited to 'catalog-model') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java index 1b5038efde..e0ca719005 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java @@ -90,6 +90,7 @@ public abstract class Component implements PropertiesOwner { private Map interfaces; private List dataTypes; private SubstitutionFilterDataDefinition substitutionFilter; + private String model; protected Component(ComponentMetadataDefinition componentMetadataDefinition) { this.componentMetadataDefinition = componentMetadataDefinition; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java index 21c25a2289..b74b290295 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java @@ -137,7 +137,7 @@ public class NodeTypeOperation extends ToscaElementOperation { if (addAdditionalInformation != StorageOperationStatus.OK) { return Either.right(addAdditionalInformation); } - final StorageOperationStatus associateNodeTypeToModel = associateResourceMetadataToModel(nodeTypeVertex, nodeType); + final StorageOperationStatus associateNodeTypeToModel = associateComponentToModel(nodeTypeVertex, nodeType, EdgeLabelEnum.MODEL_ELEMENT); if (associateNodeTypeToModel != StorageOperationStatus.OK) { return Either.right(associateNodeTypeToModel); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java index 3827cc5999..78aa4c7cf1 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java @@ -89,7 +89,6 @@ import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.jsongraph.util.CommonUtility; import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum; import org.openecomp.sdc.common.log.elements.ErrorLogOptionalData; -import org.openecomp.sdc.common.log.enums.EcompErrorSeverity; import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.ValidationUtils; @@ -188,6 +187,11 @@ public class TopologyTemplateOperation extends ToscaElementOperation { if (associateCapProperties != StorageOperationStatus.OK) { return Either.right(associatePathProperties); } + final StorageOperationStatus associateServiceToModel = associateComponentToModel(topologyTemplateVertex, topologyTemplate, + EdgeLabelEnum.MODEL); + if (associateServiceToModel != StorageOperationStatus.OK) { + return Either.right(associateServiceToModel); + } return Either.left(topologyTemplate); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java index eb85090755..d08d705a2b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java @@ -425,13 +425,13 @@ public abstract class ToscaElementOperation extends BaseOperation { return StorageOperationStatus.OK; } - protected StorageOperationStatus associateResourceMetadataToModel(final GraphVertex nodeTypeVertex, final ToscaElement nodeType) { + protected StorageOperationStatus associateComponentToModel(final GraphVertex nodeTypeVertex, final ToscaElement nodeType, + final EdgeLabelEnum edgeLabelEnum) { if (nodeType.getMetadataValue(JsonPresentationFields.MODEL) == null) { return StorageOperationStatus.OK; } final String model = ((String) nodeType.getMetadataValue(JsonPresentationFields.MODEL)); - final JanusGraphOperationStatus createEdge = janusGraphDao - .createEdge(getModelVertex(model), nodeTypeVertex, EdgeLabelEnum.MODEL_ELEMENT, new HashMap<>()); + final JanusGraphOperationStatus createEdge = janusGraphDao.createEdge(getModelVertex(model), nodeTypeVertex, edgeLabelEnum, new HashMap<>()); if (createEdge != JanusGraphOperationStatus.OK) { log.trace("Failed to associate resource {} to model {}", nodeType.getUniqueId(), model); return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(createEdge); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java index 193270974e..079f5a41fd 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java @@ -736,7 +736,6 @@ public class ModelConverter { resource.setToscaResourceName((String) toscaElement.getMetadataValue(JsonPresentationFields.TOSCA_RESOURCE_NAME)); resource.setVendorName((String) toscaElement.getMetadataValue(JsonPresentationFields.VENDOR_NAME)); resource.setVendorRelease((String) toscaElement.getMetadataValue(JsonPresentationFields.VENDOR_RELEASE)); - resource.setModel((String) toscaElement.getMetadataValue(JsonPresentationFields.MODEL)); // field isn't mandatory , but shouldn't be null(should be an empty string instead) if (((String) toscaElement.getMetadataValue(JsonPresentationFields.RESOURCE_VENDOR_MODEL_NUMBER)) != null) { resource.setResourceVendorModelNumber((String) toscaElement.getMetadataValue(JsonPresentationFields.RESOURCE_VENDOR_MODEL_NUMBER)); @@ -769,6 +768,7 @@ public class ModelConverter { component.setContactId((String) toscaElement.getMetadataValue(JsonPresentationFields.CONTACT_ID)); component.setUUID((String) toscaElement.getMetadataValue(JsonPresentationFields.UUID)); component.setIsDeleted((Boolean) toscaElement.getMetadataValue(JsonPresentationFields.IS_DELETED)); + component.setModel((String) toscaElement.getMetadataValue(JsonPresentationFields.MODEL)); component.setToscaType(toscaElement.getToscaType().getValue()); final List metadataKeys = getCategorySpecificMetadataKeys(toscaElement); if (CollectionUtils.isNotEmpty(metadataKeys)) { @@ -1331,6 +1331,8 @@ public class ModelConverter { toscaElement.setMetadataValue(JsonPresentationFields.TAGS, component.getTags()); toscaElement.setMetadataValue(JsonPresentationFields.INVARIANT_UUID, component.getInvariantUUID()); toscaElement.setMetadataValue(JsonPresentationFields.CONTACT_ID, component.getContactId()); + toscaElement.setMetadataValue(JsonPresentationFields.MODEL, component.getModel()); + toscaElement.setModel(component.getModel()); for (final String key : component.getCategorySpecificMetadata().keySet()) { toscaElement.setMetadataValue(key, component.getCategorySpecificMetadata().get(key)); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java index 96c1613d5a..474a66e49b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java @@ -80,5 +80,6 @@ public class UiComponentDataTransfer { private Map> componentInstancesInterfaces; private String derivedFromGenericType; private String derivedFromGenericVersion; + private String model; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java index 09cee8bc2c..a0d7873d2d 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java @@ -63,6 +63,7 @@ public abstract class UiComponentMetadata { private Boolean isArchived; private Long archiveTime; private Boolean isVspArchived; + private String model; public UiComponentMetadata() { } @@ -98,5 +99,6 @@ public abstract class UiComponentMetadata { this.isArchived = metadata.isArchived(); this.archiveTime = metadata.getArchiveTime(); this.isVspArchived = metadata.isVspArchived(); + this.model = metadata.getModel(); } } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiServiceMetadata.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiServiceMetadata.java index e6c0a2d7ae..a44aa44a01 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiServiceMetadata.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiServiceMetadata.java @@ -39,6 +39,7 @@ public class UiServiceMetadata extends UiComponentMetadata { private String instantiationType; private String serviceFunction; private Map categorySpecificMetadata; + private String model; public UiServiceMetadata(List categories, ServiceMetadataDataDefinition metadata) { super(categories, metadata); @@ -51,5 +52,6 @@ public class UiServiceMetadata extends UiComponentMetadata { this.instantiationType = metadata.getInstantiationType(); this.serviceFunction = metadata.getServiceFunction(); this.categorySpecificMetadata = metadata.getCategorySpecificMetadata(); + this.model = metadata.getModel(); } } -- cgit 1.2.3-korg