diff options
author | Einat Vinouze <einat.vinouze@intl.att.com> | 2019-07-16 17:17:36 +0300 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-07-30 06:01:44 +0300 |
commit | e601bbdc43bae9a08e2e10c5139a6f76b47860d7 (patch) | |
tree | 1913f0b369ead3f2ea5557e5649d8281eca9871c /vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java | |
parent | 76c6ee4a697617ec4cdee2f3b48bc83136c858c5 (diff) |
Implant vid-app-common org.onap.vid.job (main and test)
Issue-ID: VID-378
Change-Id: I41b0bdc2c4e3635f3f3319b1cd63cefc61912dfc
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java | 116 |
1 files changed, 108 insertions, 8 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java index e80e57520..6b3023332 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,21 +20,121 @@ package org.onap.vid.model.aaiTree; -import org.onap.vid.aai.util.AAITreeConverter; - +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; +import static org.onap.vid.aai.util.AAITreeConverter.NETWORK_ROLE; import static org.onap.vid.aai.util.AAITreeConverter.NETWORK_TYPE; +import static org.onap.vid.aai.util.AAITreeConverter.PHYSICAL_NETWORK_NAME; +import static org.onap.vid.aai.util.AAITreeConverter.SERVICE_INSTANCE; +import static org.onap.vid.aai.util.AAITreeConverter.SERVICE_INSTANCE_SERVICE_INSTANCE_ID; +import static org.onap.vid.aai.util.AAITreeConverter.SERVICE_INSTANCE_SERVICE_INSTANCE_NAME; +import static org.onap.vid.aai.util.AAITreeConverter.TENANT; +import static org.onap.vid.aai.util.AAITreeConverter.TENANT_TENANT_NAME; +import static org.onap.vid.aai.util.AAITreeConverter.VPN_BINDING; + +import com.fasterxml.jackson.annotation.JsonInclude; +import org.apache.commons.collections.CollectionUtils; +import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship; +import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList; +import org.onap.vid.aai.util.AAITreeNodeUtils; +@JsonInclude(NON_NULL) public class Network extends Node { - public Network(AAITreeNode node) { - super(node, AAITreeConverter.ModelType.network); + private String role; + private String physicalName; + private String serviceName; + private String serviceUUID; + private String tenantName; + private Boolean isBoundToVpn; + private RouteTarget routeTarget; + + public Network(){} + + private Network(AAITreeNode node) { + super(node); + fillCloudConfigurationProperties(this, node.getCloudConfiguration()); } public static Network from(AAITreeNode node) { Network network = new Network(node); - if (node.getAdditionalProperties().get(NETWORK_TYPE) != null) { - network.setInstanceType(node.getAdditionalProperties().get(NETWORK_TYPE).toString()); + network.setInstanceType(readValueAsStringFromAdditionalProperties(node, NETWORK_TYPE)); + network.setRole(readValueAsStringFromAdditionalProperties(node, NETWORK_ROLE)); + network.setPhysicalName(readValueAsStringFromAdditionalProperties(node, PHYSICAL_NETWORK_NAME)); + RelationshipList relationshipList = node.getRelationshipList(); + Relationship serviceInstanceRelationship = AAITreeNodeUtils.findFirstRelationshipByRelatedTo(relationshipList, SERVICE_INSTANCE).orElse(null); + if (serviceInstanceRelationship != null) { + network.setServiceName(AAITreeNodeUtils.findFirstValue(serviceInstanceRelationship.getRelatedToPropertyList(), SERVICE_INSTANCE_SERVICE_INSTANCE_NAME).orElse(null)); + network.setServiceUUID(AAITreeNodeUtils.findFirstValue(serviceInstanceRelationship.getRelationDataList(), SERVICE_INSTANCE_SERVICE_INSTANCE_ID).orElse(null)); } + AAITreeNodeUtils.findFirstRelationshipByRelatedTo(relationshipList, TENANT).ifPresent( + tenantRelationship -> network.setTenantName(AAITreeNodeUtils.findFirstValue(tenantRelationship.getRelatedToPropertyList(), TENANT_TENANT_NAME).orElse(null)) + ); + // We are ignoring "is-bound-to-vpn" parameter from additionalProperties because there is a requirement to define vpn binding presence from by related-to: vpn-binding + network.setBoundToVpn(AAITreeNodeUtils.findFirstRelationshipByRelatedTo(relationshipList, VPN_BINDING).isPresent()); + + //get the route target + node.getChildren().stream() + .filter(x->x.getType()== NodeType.VPN_BINDING) // get all VPN_BINDING related to the network + .map(x->VpnBindingKt.from(x)) // create VPN_BINDING nodes + .filter(x-> CollectionUtils.isNotEmpty(x.getRouteTargets())) // get the RouteTargets that are not empty + .findFirst() // get the first one + .ifPresent(x->network.setRouteTarget(x.getRouteTargets().get(0))); // If there is a route target - add it to the network return network; } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getPhysicalName() { + return physicalName; + } + + public void setPhysicalName(String physicalName) { + this.physicalName = physicalName; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getServiceUUID() { + return serviceUUID; + } + + public void setServiceUUID(String serviceUUID) { + this.serviceUUID = serviceUUID; + } + + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public Boolean isBoundToVpn() { + return isBoundToVpn; + } + + public void setBoundToVpn(Boolean boundToVpn) { + isBoundToVpn = boundToVpn; + } + + public RouteTarget getRouteTarget() { + return routeTarget; + } + + public void setRouteTarget(RouteTarget routeTarget) { + this.routeTarget = routeTarget; + } } |