diff options
Diffstat (limited to 'catalog-model/src')
3 files changed, 72 insertions, 0 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 36d597e7be..0d7b14abd1 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 @@ -53,6 +53,7 @@ public class TopologyTemplate extends ToscaElement{ private Map<String, MapCapabilityProperty> calculatedCapabilitiesProperties; 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 9fe59d95f1..e01e02397f 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 @@ -172,6 +172,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); @@ -691,10 +698,46 @@ 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 = associateElementToData(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 041d3f0d77..3b2cb97132 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 @@ -180,6 +180,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); @@ -193,6 +194,17 @@ public class ModelConverter { convertAdditionalInformation(toscaElement, resource); 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) { @@ -881,6 +893,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); @@ -901,6 +914,14 @@ 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); |