Update nf_type for PNF in AAI
[so.git] / bpmn / MSOCommonBPMN / src / main / java / org / onap / so / bpmn / servicedecomposition / tasks / BBInputSetupMapperLayer.java
index 6f37108..759c9ec 100644 (file)
 
 package org.onap.so.bpmn.servicedecomposition.tasks;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
 import org.modelmapper.ModelMapper;
 import org.modelmapper.convention.MatchingStrategies;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.AggregateRoute;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
@@ -40,6 +35,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Entitlement;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Evc;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ForwarderEvc;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.LagInterface;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
@@ -48,6 +44,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
@@ -55,7 +52,9 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
 import org.onap.so.bpmn.servicedecomposition.generalobjects.License;
 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
@@ -66,7 +65,9 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.CollectionResource;
@@ -79,6 +80,8 @@ import org.onap.so.db.catalog.beans.InstanceGroupType;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.OrchestrationStatus;
 import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
 import org.onap.so.serviceinstancebeans.CloudConfiguration;
@@ -86,6 +89,12 @@ import org.onap.so.serviceinstancebeans.RequestDetails;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 
 @Component("BBInputSetupMapperLayer")
 public class BBInputSetupMapperLayer {
@@ -126,12 +135,30 @@ public class BBInputSetupMapperLayer {
         return modelMapper.map(aaiSegmentationAssignment, SegmentationAssignment.class);
     }
 
+    protected AggregateRoute mapAAIAggregateRoute(org.onap.aai.domain.yang.AggregateRoute aaiAggregateRoute) {
+        return modelMapper.map(aaiAggregateRoute, AggregateRoute.class);
+    }
+
     protected CtagAssignment mapAAICtagAssignment(org.onap.aai.domain.yang.CtagAssignment aaiCtagAssignment) {
         return modelMapper.map(aaiCtagAssignment, CtagAssignment.class);
     }
 
     protected Subnet mapAAISubnet(org.onap.aai.domain.yang.Subnet aaiSubnet) {
-        return modelMapper.map(aaiSubnet, Subnet.class);
+        Subnet subnet = modelMapper.map(aaiSubnet, Subnet.class);
+        mapAllHostRoutesIntoSubnet(aaiSubnet, subnet);
+        return subnet;
+    }
+
+    protected void mapAllHostRoutesIntoSubnet(org.onap.aai.domain.yang.Subnet aaiSubnet, Subnet subnet) {
+        if (aaiSubnet.getHostRoutes() != null) {
+            for (org.onap.aai.domain.yang.HostRoute aaiHostRoute : aaiSubnet.getHostRoutes().getHostRoute()) {
+                subnet.getHostRoutes().add(mapAAIHostRoute(aaiHostRoute));
+            }
+        }
+    }
+
+    protected HostRoute mapAAIHostRoute(org.onap.aai.domain.yang.HostRoute aaiHostRoute) {
+        return modelMapper.map(aaiHostRoute, HostRoute.class);
     }
 
     protected License mapAAILicense(org.onap.aai.domain.yang.License aaiLicense) {
@@ -162,6 +189,9 @@ public class BBInputSetupMapperLayer {
 
     protected VolumeGroup mapAAIVolumeGroup(org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup) {
         VolumeGroup volumeGroup = modelMapper.map(aaiVolumeGroup, VolumeGroup.class);
+        ModelInfoVfModule modelInfo = new ModelInfoVfModule();
+        modelInfo.setModelCustomizationUUID(aaiVolumeGroup.getModelCustomizationId());
+        volumeGroup.setModelInfoVfModule(modelInfo);
         volumeGroup.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiVolumeGroup.getOrchestrationStatus()));
         return volumeGroup;
     }
@@ -243,10 +273,21 @@ public class BBInputSetupMapperLayer {
         mapAllSubnetsIntoL3Network(aaiL3Network, network);
         mapAllCtagAssignmentsIntoL3Network(aaiL3Network, network);
         mapAllSegmentationAssignmentsIntoL3Network(aaiL3Network, network);
+        mapAllAggregateRoutesIntoL3Network(aaiL3Network, network);
         network.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiL3Network.getOrchestrationStatus()));
         return network;
     }
 
+    protected void mapAllAggregateRoutesIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network,
+            L3Network network) {
+        if (aaiL3Network.getAggregateRoutes() != null) {
+            for (org.onap.aai.domain.yang.AggregateRoute aaiAggregateRoute : aaiL3Network.getAggregateRoutes()
+                    .getAggregateRoute()) {
+                network.getAggregateRoutes().add(mapAAIAggregateRoute(aaiAggregateRoute));
+            }
+        }
+    }
+
     protected void mapAllSegmentationAssignmentsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network,
             L3Network network) {
         if (aaiL3Network.getSegmentationAssignments() != null) {
@@ -285,6 +326,10 @@ public class BBInputSetupMapperLayer {
         return genericVnf;
     }
 
+    protected Pnf mapAAIPnfIntoPnf(org.onap.aai.domain.yang.Pnf aaiPnf) {
+        return modelMapper.map(aaiPnf, Pnf.class);
+    }
+
     protected void mapAllLicensesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf,
             GenericVnf genericVnf) {
         if (aaiGenericVnf.getLicenses() != null) {
@@ -437,6 +482,12 @@ public class BBInputSetupMapperLayer {
         return modelInfoVnf;
     }
 
+    protected ModelInfoPnf mapCatalogPnfToPnf(PnfResourceCustomization pnfResourceCustomization) {
+        ModelInfoPnf modelInfoPnf = modelMapper.map(pnfResourceCustomization, ModelInfoPnf.class);
+        modelMapper.map(pnfResourceCustomization.getPnfResources(), modelInfoPnf);
+        return modelInfoPnf;
+    }
+
     protected ModelInfoVfModule mapCatalogVfModuleToVfModule(VfModuleCustomization vfResourceCustomization) {
         ModelInfoVfModule modelInfoVfModule = modelMapper.map(vfResourceCustomization, ModelInfoVfModule.class);
         modelMapper.map(vfResourceCustomization.getVfModule(), modelInfoVfModule);
@@ -502,13 +553,18 @@ public class BBInputSetupMapperLayer {
     protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration(
             ConfigurationResourceCustomization configurationResourceCustomization,
             CvnfcConfigurationCustomization cvnfcConfigurationCustomization) {
+
         ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
         modelInfoConfiguration
                 .setModelVersionId(configurationResourceCustomization.getConfigurationResource().getModelUUID());
         modelInfoConfiguration.setModelCustomizationId(configurationResourceCustomization.getModelCustomizationUUID());
         modelInfoConfiguration.setModelInvariantId(
                 configurationResourceCustomization.getConfigurationResource().getModelInvariantUUID());
-        modelInfoConfiguration.setPolicyName(cvnfcConfigurationCustomization.getPolicyName());
+        modelInfoConfiguration.setConfigurationRole(configurationResourceCustomization.getRole());
+        modelInfoConfiguration.setConfigurationType(configurationResourceCustomization.getType());
+        if (cvnfcConfigurationCustomization != null) {
+            modelInfoConfiguration.setPolicyName(cvnfcConfigurationCustomization.getPolicyName());
+        }
         return modelInfoConfiguration;
     }
 
@@ -534,4 +590,32 @@ public class BBInputSetupMapperLayer {
     public Vnfc mapAAIVnfc(org.onap.aai.domain.yang.Vnfc vnfcAAI) {
         return modelMapper.map(vnfcAAI, Vnfc.class);
     }
+
+    public VpnBinding mapAAIVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) {
+        VpnBinding vpnBinding = modelMapper.map(aaiVpnBinding, VpnBinding.class);
+        mapAllRouteTargetsToAAIVpnBinding(aaiVpnBinding, vpnBinding);
+        return vpnBinding;
+    }
+
+    protected void mapAllRouteTargetsToAAIVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding,
+            VpnBinding vpnBinding) {
+        if (aaiVpnBinding.getRouteTargets() != null) {
+            for (org.onap.aai.domain.yang.RouteTarget aaiRouteTarget : aaiVpnBinding.getRouteTargets()
+                    .getRouteTarget()) {
+                vpnBinding.getRouteTargets().add(mapAAIRouteTarget(aaiRouteTarget));
+            }
+        }
+    }
+
+    public RouteTarget mapAAIRouteTarget(org.onap.aai.domain.yang.RouteTarget aaiRouteTarget) {
+        return modelMapper.map(aaiRouteTarget, RouteTarget.class);
+    }
+
+    protected ModelInfoServiceProxy mapServiceProxyCustomizationToServiceProxy(
+            ServiceProxyResourceCustomization serviceProxyCustomization) {
+        ModelInfoServiceProxy modelInfoServiceProxy =
+                modelMapper.map(serviceProxyCustomization.getSourceService(), ModelInfoServiceProxy.class);
+        modelInfoServiceProxy.setModelInstanceName(serviceProxyCustomization.getModelInstanceName());
+        return modelInfoServiceProxy;
+    }
 }