summaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2018-04-10 12:32:47 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2018-04-22 08:45:17 +0000
commiteb4b9fb0f4d3b62f3b9e2da81ebe581e7d0fc6eb (patch)
tree99563378878da01bfe708ea55be3db2b5982ea43 /catalog-model
parent4182fc36985570881dba09680d4a4bbd8d946a79 (diff)
Fixed Review Comments - operation Business logic
Added interface operation Business logic and amended validation logic Change-Id: Ia98c625d732a31b03dec2d24504ecabb367e0582 Issue-ID: SDC-1060 Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java65
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java22
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java8
4 files changed, 102 insertions, 1 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java
index 6b5f1157fc..bb36595578 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java
@@ -55,6 +55,7 @@ public class TopologyTemplate extends ToscaElement{
private Map<String, MapArtifactDataDefinition> instDeploymentArtifacts;
private Map<String, MapArtifactDataDefinition> instanceArtifacts;
+ private Map<String, InterfaceDataDefinition> interfaces;
//Component Instances External References (instanceId -> ExternalRefsMap)
//-----------------------------------------------------------------------
@@ -67,6 +68,13 @@ public class TopologyTemplate extends ToscaElement{
}
//-----------------------------------------------------------------------
+ public Map<String, InterfaceDataDefinition> getInterfaces() {
+ return interfaces;
+ }
+
+ public void setInterfaces(Map<String, InterfaceDataDefinition> interfaces) {
+ this.interfaces = interfaces;
+ }
public Map<String, PropertyDataDefinition> getInputs() {
return inputs;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java
index 9ad3053d66..355a6e28a5 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java
@@ -30,7 +30,21 @@ import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.*;
+import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapCapabiltyProperty;
+import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapListCapabiltyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
@@ -175,6 +189,13 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
result = Either.right(associateCapProperties);
return result;
}
+
+ StorageOperationStatus associateInterfaces = associateInterfacesToResource(topologyTemplateVertex, topologyTemplate);
+ if (associateInterfaces != StorageOperationStatus.OK) {
+ result = Either.right(associateInterfaces);
+ return result;
+ }
+
StorageOperationStatus associatePathProperties = associateForwardingPathToResource(topologyTemplateVertex, topologyTemplate);
if (associateCapProperties != StorageOperationStatus.OK) {
result = Either.right(associatePathProperties);
@@ -665,9 +686,51 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
}
}
+ if (!componentParametersView.isIgnoreInterfaces()) {
+ TitanOperationStatus storageStatus = setInterfcesFromGraph(componentV, toscaElement);
+ if (storageStatus != TitanOperationStatus.OK) {
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(storageStatus));
+ }
+ }
+
return Either.left(toscaElement);
}
+ private TitanOperationStatus setInterfcesFromGraph(GraphVertex componentV,
+ TopologyTemplate topologyTemplate) {
+ Either<Map<String, InterfaceDataDefinition>, TitanOperationStatus> result = getDataFromGraph
+ (componentV,
+ EdgeLabelEnum.INTERFACE_ARTIFACTS);
+ if (result.isLeft()) {
+ topologyTemplate.setInterfaces(result.left().value());
+ } else {
+ if (result.right().value() != TitanOperationStatus.NOT_FOUND) {
+ return result.right().value();
+ }
+ }
+ return TitanOperationStatus.OK;
+ }
+
+ private StorageOperationStatus associateInterfacesToResource(GraphVertex topologyTemplateVertex,
+ TopologyTemplate topologyTemplate) {
+ Map<String, InterfaceDataDefinition> interfaces = topologyTemplate.getInterfaces();
+ return associateInterfacesToComponent(topologyTemplateVertex,interfaces);
+ }
+
+ public StorageOperationStatus associateInterfacesToComponent(GraphVertex nodeTypeVertex,
+ Map<String, InterfaceDataDefinition>
+ interfaceMap) {
+ if (interfaceMap != null && !interfaceMap.isEmpty()) {
+ Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData
+ (nodeTypeVertex, VertexTypeEnum.INTERFACE_ARTIFACTS, EdgeLabelEnum.INTERFACE_ARTIFACTS, interfaceMap);
+ if (assosiateElementToData.isRight()) {
+ return assosiateElementToData.right().value();
+ }
+ }
+ return StorageOperationStatus.OK;
+ }
+
+
private TitanOperationStatus setPoliciesFromGraph(GraphVertex componentV, TopologyTemplate toscaElement) {
Either<Map<String, PolicyDataDefinition>, TitanOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.POLICIES);
if (result.isLeft()) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
index 71f0b77902..023d3fe2bd 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
@@ -222,6 +222,7 @@ public class ModelConverter {
resource.setCsarUUID((String) topologyTemplate.getMetadataValue(JsonPresentationFields.CSAR_UUID));
resource.setCsarVersion((String) topologyTemplate.getMetadataValue(JsonPresentationFields.CSAR_VERSION));
resource.setImportedToscaChecksum((String) topologyTemplate.getMetadataValue(JsonPresentationFields.IMPORTED_TOSCA_CHECKSUM));
+ convertInterfaces(topologyTemplate, resource);
}
convertComponentInstances(topologyTemplate, resource);
@@ -236,6 +237,17 @@ public class ModelConverter {
return resource;
}
+ private static void convertInterfaces(TopologyTemplate toscaElement, Resource resource) {
+ Map<String, InterfaceDataDefinition> interfaces = toscaElement.getInterfaces();
+ Map<String, InterfaceDefinition> copy;
+ if (interfaces != null) {
+ copy = interfaces.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new InterfaceDefinition(e.getValue())));
+ } else {
+ copy = new HashMap<>();
+ }
+ resource.setInterfaces(copy);
+ }
+
private static void convertAttributes(NodeType nodeType, Resource resource) {
Map<String, PropertyDataDefinition> attributes = nodeType.getAttributes();
if (attributes != null) {
@@ -897,6 +909,7 @@ public class ModelConverter {
topologyTemplate.setMetadataValue(JsonPresentationFields.CSAR_UUID, resource.getCsarUUID());
topologyTemplate.setMetadataValue(JsonPresentationFields.CSAR_VERSION, resource.getCsarVersion());
topologyTemplate.setMetadataValue(JsonPresentationFields.IMPORTED_TOSCA_CHECKSUM, resource.getImportedToscaChecksum());
+ convertInterfaces(resource, topologyTemplate);
}
if (componentType == ComponentTypeEnum.SERVICE) {
convertServiceSpecificEntities((Service) component, topologyTemplate);
@@ -917,6 +930,15 @@ public class ModelConverter {
return topologyTemplate;
}
+ private static void convertInterfaces(Resource resource, TopologyTemplate topologyTemplate) {
+ Map<String, InterfaceDefinition> interfaces = resource.getInterfaces();
+ if (interfaces != null && !interfaces.isEmpty()) {
+ Map<String, InterfaceDataDefinition> copy = interfaces.entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> new InterfaceDataDefinition(e.getValue())));
+ topologyTemplate.setInterfaces(copy);
+ }
+ }
+
private static void convertServiceSpecificEntities(Service service, TopologyTemplate topologyTemplate) {
convertServiceMetaData(service, topologyTemplate);
convertServiceApiArtifacts(service, topologyTemplate);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java
index 5eef21b3a5..9c0d25b228 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java
@@ -23,6 +23,7 @@ package org.openecomp.sdc.be.ui.model;
import java.util.List;
import java.util.Map;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationDataDefinition;
import org.openecomp.sdc.be.model.AdditionalInformationDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -44,6 +45,7 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer{
private List<String> defaultCapabilities;
private List<AdditionalInformationDefinition> additionalInformation;
+ private Map<String, InterfaceOperationDataDefinition> interfaceOperations;
public UiResourceDataTransfer(){}
@@ -110,5 +112,11 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer{
public void setDefaultCapabilities(List<String> defaultCapabilities) {
this.defaultCapabilities = defaultCapabilities;
}
+ public Map<String, InterfaceOperationDataDefinition> getInterfaceOperations() {
+ return interfaceOperations;
+ }
+ public void setInterfaceOperations(Map<String, InterfaceOperationDataDefinition> interfaceOperations) {
+ this.interfaceOperations = interfaceOperations;
+ }
}