Refactor TAPI topology ConvertORToTapiTopology 16/111216/10
authorguillaume.lambert <guillaume.lambert@orange.com>
Wed, 3 Apr 2024 10:49:05 +0000 (12:49 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Mon, 8 Apr 2024 11:12:54 +0000 (13:12 +0200)
JIRA: TRNSPRTPCE-735
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I2927cbf53b52126a56e590ff6dce7e5044efa502

tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORToTapiTopology.java

index bfe1afee4be1e6a2bba74b5c5b972792e200df09..209fef96739068372b5f716096a1eac2c689d890 100644 (file)
@@ -76,7 +76,6 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITAL
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.PhotonicMediaNodeEdgePointSpec;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.PhotonicMediaNodeEdgePointSpecBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.photonic.media.node.edge.point.spec.SpectrumCapabilityPacBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrum;
@@ -226,7 +225,7 @@ public class ConvertORToTapiTopology {
                 && networkPorts.contains(tp.getTpId().getValue()))
             .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
             .collect(Collectors.toList());
-        if (OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
+        if (this.ietfNodeType.equals(OpenroadmNodeType.TPDR)) {
             this.oorOduSwitchingPool = createOduSwitchingPoolForTp100G();
             List<TpId> tpList = this.oorOduSwitchingPool.getNonBlockingList().values().stream()
                 .flatMap(nbl -> nbl.getTpList().stream())
@@ -257,10 +256,9 @@ public class ConvertORToTapiTopology {
         Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(nodeIdXpdr).build();
         Name namePhot = new NameBuilder().setValueName("otsi node name").setValue(nodeIdXpdr).build();
         Name nameNodeType = new NameBuilder().setValueName("Node Type").setValue(this.ietfNodeType.getName()).build();
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
-                .topology.Node dsrNode =
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode =
             createTapiNode(
-                Map.of(nameDsr.key(), nameDsr, namePhot.key(), namePhot,nameNodeType.key(), nameNodeType),
+                Map.of(nameDsr.key(), nameDsr, namePhot.key(), namePhot, nameNodeType.key(), nameNodeType),
                 //dsrLayerProtocols
                 Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU,
                        LayerProtocolName.DIGITALOTN, LayerProtocolName.PHOTONICMEDIA));
@@ -278,11 +276,10 @@ public class ConvertORToTapiTopology {
             String subNodeName, List<OwnedNodeEdgePointKey> onepl, FORWARDINGRULE forwardingRule, int index) {
         Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
             org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
-            nepMap = new HashMap<>();
+                nepMap = new HashMap<>();
         for (OwnedNodeEdgePointKey onepKey : onepl) {
-            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
-                nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group
-                    .NodeEdgePointBuilder()
+            var nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+                    .node.rule.group.NodeEdgePointBuilder()
                 .setTopologyUuid(tapiTopoUuid)
                 .setNodeUuid(nodeUuid)
                 .setNodeEdgePointUuid(onepKey.getUuid())
@@ -290,47 +287,35 @@ public class ConvertORToTapiTopology {
             nepMap.put(nep.key(), nep);
         }
         String nrgNameValue = String.join("-", subNodeName, "node-rule-group-" + index);
-        //Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
-        Set<RuleType> ruleTypes = new HashSet<>(Set.of(RuleType.FORWARDING));
-        Map<RuleKey, Rule> ruleList = new HashMap<>();
         Rule rule = new RuleBuilder()
             .setLocalId("forward")
             .setForwardingRule(forwardingRule)
-            .setRuleType(ruleTypes)
-            .build();
-        ruleList.put(rule.key(), rule);
-        Name nrgName = new NameBuilder()
-            .setValueName("nrg name")
-            .setValue(nrgNameValue)
+            .setRuleType(new HashSet<RuleType>(Set.of(RuleType.FORWARDING)))
             .build();
+        Name nrgName = new NameBuilder().setValueName("nrg name").setValue(nrgNameValue).build();
         NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
             .setName(Map.of(nrgName.key(), nrgName))
-            .setUuid(new Uuid(UUID.nameUUIDFromBytes((nrgNameValue)
-                .getBytes(Charset.forName("UTF-8"))).toString()))
-            .setRule(ruleList)
+            .setUuid(new Uuid(UUID.nameUUIDFromBytes((nrgNameValue).getBytes(Charset.forName("UTF-8"))).toString()))
+            .setRule(new HashMap<RuleKey, Rule>(Map.of(rule.key(), rule)))
             .setNodeEdgePoint(nepMap)
             .build();
         return new HashMap<>(Map.of(nodeRuleGroup.key(), nodeRuleGroup));
     }
 
-    public Map<NodeRuleGroupKey, NodeRuleGroup> createAllNodeRuleGroupForRdmNode(String topoType, Uuid nodeUuid,
-            String orNodeId, Collection<OwnedNodeEdgePoint> onepl) {
-        List<OwnedNodeEdgePoint> otsNepList = new ArrayList<>();
-        LOG.info("Creating NRG for {} {}", topoType, otsNepList.toString());
-        if (topoType.equals("T0ML")) {
-            otsNepList = onepl.stream().collect(Collectors.toList());
-        } else {
-            otsNepList = onepl.stream()
-                .filter(onep -> onep.getName().keySet().contains(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
-                .collect(Collectors.toList());
-        }
+    public Map<NodeRuleGroupKey, NodeRuleGroup> createAllNodeRuleGroupForRdmNode(
+            String topoType, Uuid nodeUuid, String orNodeId, Collection<OwnedNodeEdgePoint> onepl) {
+        List<OwnedNodeEdgePoint> otsNepList = topoType.equals("T0ML") ? onepl.stream().collect(Collectors.toList())
+                : onepl.stream()
+                    .filter(onep -> onep.getName().keySet().contains(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
+                    .collect(Collectors.toList());
+        LOG.info("Creating NRG for {} {}", topoType, otsNepList);
         List<OwnedNodeEdgePointKey> degOnepKeyList = new ArrayList<>();
         List<String> srgNames = new ArrayList<>();
         Map<OwnedNodeEdgePointKey,String> srgMap = new HashMap<>();
         for (OwnedNodeEdgePoint onep : otsNepList) {
-            String onepName = onep.getName().get(new NameKey(
-                topoType.equals("T0ML") ? "NodeEdgePoint name"
-                    : "PHOTONIC_MEDIA_OTSNodeEdgePoint")).getValue();
+            String onepName = onep.getName()
+                .get(new NameKey(topoType.equals("T0ML") ? "NodeEdgePoint name" : "PHOTONIC_MEDIA_OTSNodeEdgePoint"))
+                .getValue();
             String subNodeName = topoType.equals("T0ML") ? "ROADMINFRA-SRG-PP"
                 : String.join("-", onepName.split("\\+")[0], onepName.split("\\+")[2]);
             if (subNodeName.contains("DEG")) {
@@ -347,23 +332,27 @@ public class ConvertORToTapiTopology {
         int index = 0;
         Map<NodeRuleGroupKey, NodeRuleGroup> globalNrgMap = new  HashMap<>();
         if (topoType.equals("Full")) {
-            globalNrgMap.putAll(
-                createNodeRuleGroupForRdmNode(topoType, nodeUuid, String.join("-", orNodeId, "DEG"), degOnepKeyList,
-                    FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, index));
+            globalNrgMap.putAll(createNodeRuleGroupForRdmNode(
+                    topoType, nodeUuid, String.join("-", orNodeId, "DEG"),
+                    degOnepKeyList, FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, index));
             index++;
         }
         for (String srgName : srgNames) {
-            globalNrgMap.putAll(createNodeRuleGroupForRdmNode(topoType, nodeUuid, srgName,
+            globalNrgMap.putAll(createNodeRuleGroupForRdmNode(
+                topoType,
+                nodeUuid,
+                srgName,
                 srgMap.entrySet().stream()
                     .filter(item -> item.getValue().equals(srgName))
                     .map(item -> item.getKey())
                     .collect(Collectors.toList()),
-                    // For T0ML we consider any port of ROADM INFRA can connect to potentially any other port
-                    //topoType.equals("T0ML") ? FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE
-                    topoType.equals("T0ML") ? FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE
-                    // Whereas for Abstracted or Full Topology we consider any port of the same SRG can not forward to
-                   // another port of the same SRG. Connectivity between SRGS will be defined through inter-rule-group
-                    : FORWARDINGRULECANNOTFORWARDACROSSGROUP.VALUE, index));
+                // For T0ML we consider any port of ROADM INFRA can connect to potentially any other port
+                //topoType.equals("T0ML") ? FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE
+                topoType.equals("T0ML") ? FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE
+                    : FORWARDINGRULECANNOTFORWARDACROSSGROUP.VALUE,
+                // Whereas for Abstracted or Full Topology we consider any port of the same SRG can not forward to
+                // another port of the same SRG. Connectivity between SRGS will be defined through inter-rule-group
+                index));
             index++;
             LOG.debug("AllNodeRuleGroup : creating a NRG for {}", srgName);
         }
@@ -371,7 +360,7 @@ public class ConvertORToTapiTopology {
     }
 
     public Map<InterRuleGroupKey, InterRuleGroup> createInterRuleGroupForRdmNode(
-                String topoType, Uuid nodeUuid,String orNodeId, List<NodeRuleGroupKey> nrgList) {
+            String topoType, Uuid nodeUuid,String orNodeId, List<NodeRuleGroupKey> nrgList) {
         Map<AssociatedNodeRuleGroupKey, AssociatedNodeRuleGroup> associatedNrgMap = new HashMap<>();
         for (NodeRuleGroupKey nrgKey : nrgList) {
             AssociatedNodeRuleGroup associatedNrg = new AssociatedNodeRuleGroupBuilder()
@@ -381,55 +370,36 @@ public class ConvertORToTapiTopology {
                 .build();
             associatedNrgMap.put(associatedNrg.key(), associatedNrg);
         }
-        String irgNameValue =
-            topoType.equals("Full")
-                ? orNodeId + " inter rule group-"
-                : "rdm infra inter rule group-";
-        Set<RuleType> ruleTypes = new HashSet<>(Set.of(RuleType.FORWARDING));
-        Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.RuleKey,
-            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.Rule> ruleMap
-            = new HashMap<>();
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.Rule rule
-            = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.RuleBuilder()
-                .setLocalId("forward")
-                .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
-                .setRuleType(ruleTypes)
-                .build();
-        ruleMap.put(rule.key(), rule);
-
-        Map<InterRuleGroupKey, InterRuleGroup> interRuleGroupMap = new HashMap<>();
-
-        Name irgName = new NameBuilder()
-            .setValueName("irg name")
-            .setValue(irgNameValue)
+        var rule = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
+                .inter.rule.group.RuleBuilder()
+            .setLocalId("forward")
+            .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
+            .setRuleType(new HashSet<RuleType>(Set.of(RuleType.FORWARDING)))
             .build();
+        String irgNameValue = topoType.equals("Full") ? orNodeId + " inter rule group-" : "rdm infra inter rule group-";
+        Name irgName = new NameBuilder().setValueName("irg name").setValue(irgNameValue).build();
         InterRuleGroup interRuleGroup = new InterRuleGroupBuilder()
-            .setUuid(new Uuid(UUID.nameUUIDFromBytes((irgNameValue)
-                .getBytes(Charset.forName("UTF-8"))).toString()))
+            .setUuid(new Uuid(UUID.nameUUIDFromBytes((irgNameValue).getBytes(Charset.forName("UTF-8"))).toString()))
             .setName(Map.of(irgName.key(), irgName))
-            .setRule(ruleMap)
+            .setRule(new HashMap<>(Map.of(rule.key(), rule)))
             .setAssociatedNodeRuleGroup(associatedNrgMap)
             .build();
-        interRuleGroupMap.put(new InterRuleGroupKey(interRuleGroup.getUuid()), interRuleGroup);
-        return interRuleGroupMap;
+        return new HashMap<>(Map.of(new InterRuleGroupKey(interRuleGroup.getUuid()), interRuleGroup));
     }
 
-    public Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(int nb,
-            LayerProtocolName layerProtocol, String tpId, String nodeid,
+    public Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(
+            int nb, LayerProtocolName layerProtocol, String tpId, String nodeid,
             Collection<SupportedInterfaceCapability> supportedInterfaceCapability,
             OperationalState operState, AdministrativeState adminState) {
         // add them to SIP context
         Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
         for (int i = 0; i < nb; i++) {
-            String sipName =
-                nb == 1
-                    ? String.join("+", "SIP", nodeid, tpId)
+            String sipName = nb == 1 ? String.join("+", "SIP", nodeid, tpId)
                     : String.join("+", "SIP", nodeid, tpId, "Nber", String.valueOf(i));
             LOG.info("SIP = {}", sipName);
             Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(sipName.getBytes(Charset.forName("UTF-8"))).toString());
-            MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
-                .setServiceInterfacePointUuid(sipUuid)
-                .build();
+            MappedServiceInterfacePoint msip =
+                new MappedServiceInterfacePointBuilder().setServiceInterfacePointUuid(sipUuid).build();
             ServiceInterfacePoint sip =
                 createSIP(sipUuid, layerProtocol, tpId, nodeid, supportedInterfaceCapability, operState, adminState);
             this.tapiSips.put(sip.key(), sip);
@@ -599,19 +569,29 @@ public class ConvertORToTapiTopology {
     public Map<Double, Double> getXpdrUsedWavelength(TerminationPoint tp) {
         var tpAug = tp.augmentation(
             org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
-        if (tpAug == null || tpAug.getXpdrNetworkAttributes() == null) {
+        if (tpAug == null) {
             return null;
         }
         XpdrNetworkAttributes xnatt = tpAug.getXpdrNetworkAttributes();
-        //Map<Double,Double> freqWidthMap = new HashMap<>();
-        var xnattWvlgth = tpAug.getXpdrNetworkAttributes().getWavelength();
-        return xnattWvlgth == null || xnattWvlgth.getFrequency() == null || xnattWvlgth.getWidth() == null
-            ? null
-            : new HashMap<>(Map.of(
-                (xnatt.getWavelength().getFrequency().getValue().doubleValue()
-                    - xnatt.getWavelength().getWidth().getValue().doubleValue() * 0.001 / 2),
-                (xnatt.getWavelength().getFrequency().getValue().doubleValue()
-                    - xnatt.getWavelength().getWidth().getValue().doubleValue() * 0.001 / 2)));
+        if (xnatt == null) {
+            return null;
+        }
+        var xnattWvlgth = xnatt.getWavelength();
+        if (xnattWvlgth == null) {
+            return null;
+        }
+        var freq = xnattWvlgth.getFrequency();
+        if (freq == null) {
+            return null;
+        }
+        var width = xnattWvlgth.getWidth();
+        if (width == null) {
+            return null;
+        }
+        Double freqValue = freq.getValue().doubleValue();
+        Double widthValue = width.getValue().doubleValue();
+        Double value = freqValue - widthValue * 0.001 / 2;
+        return new HashMap<>(Map.of(value, value));
     }
 
     public Map<Double, Double> getPPUsedWavelength(TerminationPoint tp) {
@@ -624,15 +604,14 @@ public class ConvertORToTapiTopology {
         if (ppAtt == null) {
             return null;
         }
-        if (ppAtt != null && ppAtt.getUsedWavelength() != null
-                && ppAtt.getUsedWavelength().entrySet().iterator().next() != null) {
-            Double centFreq = ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency()
-                .getValue().doubleValue();
-            Double width = ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getWidth()
-                .getValue().doubleValue();
-            return  new HashMap<>(Map.of(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2));
+        var usedWvl = ppAtt.getUsedWavelength();
+        if (usedWvl == null || usedWvl.isEmpty()) {
+            return null;
         }
-        return null;
+        var usedWvlfirstValue = usedWvl.entrySet().iterator().next().getValue();
+        Double centFreq = usedWvlfirstValue.getFrequency().getValue().doubleValue();
+        Double width = usedWvlfirstValue.getWidth().getValue().doubleValue();
+        return  new HashMap<>(Map.of(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2));
     }
 
     public Map<Double, Double> getTTPUsedFreqMap(TerminationPoint tp) {
@@ -640,26 +619,22 @@ public class ConvertORToTapiTopology {
         Arrays.fill(byteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE);
         var termPoint1 = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
             .TerminationPoint1.class);
-        if (termPoint1 == null || termPoint1.getTxTtpAttributes() == null) {
+        if (termPoint1 == null) {
             return null;
         }
         TxTtpAttributes txttpAtt = termPoint1.getTxTtpAttributes();
-        Map<Double,Double> freqMap = new HashMap<>();
-        if (txttpAtt.getUsedWavelengths() != null
-                && txttpAtt.getUsedWavelengths().entrySet().iterator().next() != null) {
-            for (Map.Entry<UsedWavelengthsKey, UsedWavelengths> usedLambdas :
-                    txttpAtt.getUsedWavelengths().entrySet()) {
-                Double centFreq = usedLambdas.getValue().getFrequency().getValue().doubleValue();
-                Double width = usedLambdas.getValue().getWidth()
-                    .getValue().doubleValue();
-                freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
+        if (txttpAtt  == null) {
+            return null;
+        }
+        var txttpAttUsedWvl = txttpAtt.getUsedWavelengths();
+        if (txttpAttUsedWvl == null || txttpAttUsedWvl.isEmpty()) {
+            var txttpAttAvlFreqMaps = txttpAtt.getAvailFreqMaps();
+            if (txttpAttAvlFreqMaps == null || !txttpAttAvlFreqMaps.keySet().toString().contains(GridConstant.C_BAND)) {
+                return null;
             }
-            return freqMap;
-        } else if (txttpAtt.getAvailFreqMaps() != null
-                && txttpAtt.getAvailFreqMaps().keySet().toString().contains(GridConstant.C_BAND)) {
             byte[] freqBitSet = new byte[GridConstant.NB_OCTECTS];
             LOG.debug("Creation of Bitset {}", freqBitSet);
-            freqBitSet = txttpAtt.getAvailFreqMaps().entrySet().stream()
+            freqBitSet = txttpAttAvlFreqMaps.entrySet().stream()
                 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
                 .findFirst().orElseThrow().getValue().getFreqMap();
             for (int i = 0; i < GridConstant.EFFECTIVE_BITS; i++) {
@@ -670,85 +645,98 @@ public class ConvertORToTapiTopology {
                 }
             }
             return getFreqMapFromBitSet(freqBitSet);
-        } else {
-            return null;
         }
+        Map<Double,Double> freqMap = new HashMap<>();
+        for (Map.Entry<UsedWavelengthsKey, UsedWavelengths> usedLambdas : txttpAttUsedWvl.entrySet()) {
+            Double centFreq = usedLambdas.getValue().getFrequency().getValue().doubleValue();
+            Double width = usedLambdas.getValue().getWidth().getValue().doubleValue();
+            freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
+        }
+        return freqMap;
     }
 
     public Map<Double, Double> getTTPAvailableFreqMap(TerminationPoint tp) {
         var termPoint1 = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
             .TerminationPoint1.class);
-        if (termPoint1 == null || termPoint1.getTxTtpAttributes() == null
-                || termPoint1.getTxTtpAttributes().getAvailFreqMaps() == null
-                || !(termPoint1.getTxTtpAttributes().getAvailFreqMaps().keySet().toString()
-                    .contains(GridConstant.C_BAND))) {
+        if (termPoint1 == null) {
+            return null;
+        }
+        TxTtpAttributes txttpAtt = termPoint1.getTxTtpAttributes();
+        if (txttpAtt == null) {
+            return null;
+        }
+        var avlFreqMaps = txttpAtt.getAvailFreqMaps();
+        if (avlFreqMaps == null || !avlFreqMaps.keySet().toString().contains(GridConstant.C_BAND)) {
             return null;
         }
         byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
         LOG.debug("Creation of Bitset {}", byteArray);
         return getFreqMapFromBitSet(
-            termPoint1.getTxTtpAttributes().getAvailFreqMaps().entrySet().stream()
+            avlFreqMaps.entrySet().stream()
                 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
                 .findFirst().orElseThrow().getValue().getFreqMap());
     }
 
     public Map<Double, Double> getTTP11AvailableFreqMap(
             org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 tp) {
-        if (tp == null || tp.getTxTtpAttributes() == null
-                || tp.getTxTtpAttributes().getAvailFreqMaps() == null
-                || !(tp.getTxTtpAttributes().getAvailFreqMaps().keySet().toString()
-                    .contains(GridConstant.C_BAND))) {
+        if (tp == null) {
+            return null;
+        }
+        TxTtpAttributes txttpAtt = tp.getTxTtpAttributes();
+        if (txttpAtt == null) {
+            return null;
+        }
+        var avlFreqMaps = txttpAtt.getAvailFreqMaps();
+        if (avlFreqMaps == null || !avlFreqMaps.keySet().toString().contains(GridConstant.C_BAND)) {
             return null;
         }
         byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
         LOG.debug("Creation of Bitset {}", byteArray);
         return getFreqMapFromBitSet(
-            tp.getTxTtpAttributes().getAvailFreqMaps().entrySet().stream()
+            avlFreqMaps.entrySet().stream()
                 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
                 .findFirst().orElseThrow().getValue().getFreqMap());
     }
 
     public Map<Double, Double> getPP11UsedWavelength(
             org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 tp) {
-        if (tp == null || tp.getPpAttributes() == null
-                || tp.getPpAttributes().getUsedWavelength() == null
-                || tp.getPpAttributes().getUsedWavelength().entrySet().iterator().next() == null) {
+        if (tp == null) {
             return null;
         }
         PpAttributes ppAtt = tp.getPpAttributes();
-        Map<Double,Double> freqMap = new HashMap<>();
-        Double centFreq = ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency()
-            .getValue().doubleValue();
-        Double width = ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getWidth()
-            .getValue().doubleValue();
-        freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
-        return freqMap;
+        if (ppAtt == null) {
+            return null;
+        }
+        var usedWvl = ppAtt.getUsedWavelength();
+        if (usedWvl == null || usedWvl.isEmpty()) {
+            return null;
+        }
+        var usedWvlFirstValue = usedWvl.entrySet().iterator().next().getValue();
+        Double centFreq = usedWvlFirstValue.getFrequency().getValue().doubleValue();
+        Double width = usedWvlFirstValue.getWidth().getValue().doubleValue();
+        return new HashMap<>(Map.of(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2));
     }
 
     public Map<Double, Double> getTTP11UsedFreqMap(
             org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 tp) {
         byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
         Arrays.fill(byteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE);
-        if (tp == null || tp.getTxTtpAttributes() == null) {
+        if (tp == null) {
             return null;
         }
         TxTtpAttributes txttpAtt = tp.getTxTtpAttributes();
-        Map<Double,Double> freqMap = new HashMap<>();
-        if (txttpAtt.getUsedWavelengths() != null
-                && txttpAtt.getUsedWavelengths().entrySet().iterator().next() != null) {
-            for (Map.Entry<UsedWavelengthsKey, UsedWavelengths> usedLambdas :
-                    txttpAtt.getUsedWavelengths().entrySet()) {
-                Double centFreq = usedLambdas.getValue().getFrequency().getValue().doubleValue();
-                Double width = usedLambdas.getValue().getWidth()
-                    .getValue().doubleValue();
-                freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
+        if (txttpAtt == null) {
+            return null;
+        }
+        var txttpAttUsedWvl = txttpAtt.getUsedWavelengths();
+        if (txttpAttUsedWvl == null || txttpAttUsedWvl.isEmpty()) {
+            var txttpAttAvlFreqMaps = txttpAtt.getAvailFreqMaps();
+            if (txttpAttAvlFreqMaps == null || !txttpAttAvlFreqMaps.keySet().toString().contains(GridConstant.C_BAND)) {
+                return null;
             }
-            return freqMap;
-        } else if (txttpAtt.getAvailFreqMaps() != null
-                && txttpAtt.getAvailFreqMaps().keySet().toString().contains(GridConstant.C_BAND)) {
             byte[] freqBitSet = new byte[GridConstant.NB_OCTECTS];
             LOG.debug("Creation of Bitset {}", freqBitSet);
-            freqBitSet = txttpAtt.getAvailFreqMaps().entrySet().stream()
+            freqBitSet = txttpAttAvlFreqMaps.entrySet().stream()
                 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
                 .findFirst().orElseThrow().getValue().getFreqMap();
             for (int i = 0; i < GridConstant.EFFECTIVE_BITS; i++) {
@@ -759,9 +747,15 @@ public class ConvertORToTapiTopology {
                 }
             }
             return getFreqMapFromBitSet(freqBitSet);
-        } else {
-            return null;
         }
+        Map<Double,Double> freqMap = new HashMap<>();
+        for (Map.Entry<UsedWavelengthsKey, UsedWavelengths> usedLambdas : txttpAttUsedWvl.entrySet()) {
+            var usedLambdasValue = usedLambdas.getValue();
+            Double centFreq = usedLambdasValue.getFrequency().getValue().doubleValue();
+            Double width = usedLambdasValue.getWidth().getValue().doubleValue();
+            freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
+        }
+        return freqMap;
     }
 
     public Map<Double, Double> getFreqMapFromBitSet(byte[] byteArray) {
@@ -777,22 +771,28 @@ public class ConvertORToTapiTopology {
             occupied = true;
         }
         for (int index = 0 ; index < GridConstant.EFFECTIVE_BITS ; index++) {
-            if (byteArray[index] == 1 && occupied) {
-                startFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
-                stopFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
-                occupied = false;
-            } else if (byteArray[index] == 0 && !occupied) {
-                stopFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
-                occupied = true;
-            }
-            if (stopFreq.doubleValue() > startFreq.doubleValue() && occupied) {
-                freqMap.put(startFreq, stopFreq);
-                startFreq = stopFreq;
+            if (occupied) {
+                if (byteArray[index] == 1) {
+                    startFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
+                    stopFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
+                    occupied = false;
+                }
+            } else {
+                if (byteArray[index] == 0) {
+                    stopFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
+                    occupied = true;
+                }
             }
-            if ((index == GridConstant.EFFECTIVE_BITS - 1) && (startFreq.doubleValue() == stopFreq.doubleValue())
-                    && !occupied) {
-                stopFreq = GridUtils.getStopFrequencyFromIndex(index).doubleValue();
-                freqMap.put(startFreq, stopFreq);
+            if (occupied) {
+                if (stopFreq.doubleValue() > startFreq.doubleValue()) {
+                    freqMap.put(startFreq, stopFreq);
+                    startFreq = stopFreq;
+                }
+            } else {
+                if (index == GridConstant.EFFECTIVE_BITS - 1 && startFreq.doubleValue() == stopFreq.doubleValue()) {
+                    stopFreq = GridUtils.getStopFrequencyFromIndex(index).doubleValue();
+                    freqMap.put(startFreq, stopFreq);
+                }
             }
         }
         return freqMap;
@@ -801,69 +801,65 @@ public class ConvertORToTapiTopology {
     public OwnedNodeEdgePointBuilder addPayloadStructureAndPhotSpecToOnep(String nodeId,
             Map<Double, Double> freqMap, List<OperationalModeKey> operModeList,
             Collection<SupportedInterfaceCapability> sicColl, OwnedNodeEdgePointBuilder onepBldr, String keyword) {
-        if (String.join("+", nodeId, TapiStringConstants.OTSI_MC).equals(keyword)
-                || String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)) {
-            LOG.debug("Entering LOOP Step1");
-            // Creating OTS & OTSI_MC NEP specific attributes
-            onepBldr.setSupportedPayloadStructure(createSupportedPayloadStructureForPhtncMedia(
-                sicColl,operModeList));
-            SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
-            OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
-            if (freqMap == null || freqMap.isEmpty()) {
+        if (!String.join("+", nodeId, TapiStringConstants.OTSI_MC).equals(keyword)
+                && !String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)) {
+            return onepBldr;
+        }
+        LOG.debug("Entering LOOP Step1");
+        double naz = 0.01;
+        Double lowSupFreq = GridConstant.START_EDGE_FREQUENCY * 1E09 ;
+        Double upSupFreq = lowSupFreq + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz;
+        lowSupFreq += naz;
+        // Creating OTS & OTSI_MC NEP specific attributes
+        onepBldr.setSupportedPayloadStructure(
+            createSupportedPayloadStructureForPhtncMedia(sicColl,operModeList));
+        SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
+        OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
+        if (freqMap == null || freqMap.isEmpty()) {
 //                TODO: verify if we need to fill OcupiedSpectrum as follows when no lambda provisioned
 //                ospecBd
 //                    .setUpperFrequency(Uint64.valueOf(0))
 //                    .setLowerFrequency(Uint64.valueOf(0));
-                onepBldr.setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(
-                    false, sicColl,operModeList));
-                double naz = 0.01;
-                AvailableSpectrum  aspec = new AvailableSpectrumBuilder()
-                    .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + naz)))
-                    .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
-                        + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz)))
-                    .build();
-                Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
-                aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(),
-                    aspec.getUpperFrequency()), aspec);
-                spectrumPac.setAvailableSpectrum(aspecMap);
-            } else {
-                LOG.debug("Entering LOOP Step2");
-                onepBldr.setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(
-                    true, sicColl,operModeList));
-                Map<OccupiedSpectrumKey, OccupiedSpectrum> ospecMap = new HashMap<>();
-                for (Map.Entry<Double, Double> frequency : freqMap.entrySet()) {
-                    ospecBd
-                        .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
-                        .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
-                }
-                OccupiedSpectrum ospec = ospecBd.build();
-                ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(), ospec.getUpperFrequency()), ospec);
-                spectrumPac.setOccupiedSpectrum(ospecMap);
-            }
-            LOG.debug("Entering LOOP Step3");
-            double nazz = 0.01;
-            SupportableSpectrum  sspec = new SupportableSpectrumBuilder()
-                .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + nazz)))
-                .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
-                    + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + nazz)))
-                .build();
-            Map<SupportableSpectrumKey, SupportableSpectrum> sspecMap = new HashMap<>();
-            sspecMap.put(new SupportableSpectrumKey(sspec.getLowerFrequency(),
-                sspec.getUpperFrequency()), sspec);
-            spectrumPac.setSupportableSpectrum(sspecMap);
-            LOG.debug("Entering LOOP Step4");
-            PhotonicMediaNodeEdgePointSpec pnepSpec = new PhotonicMediaNodeEdgePointSpecBuilder()
-                .setSpectrumCapabilityPac(spectrumPac.build())
+            onepBldr.setAvailablePayloadStructure(
+                createAvailablePayloadStructureForPhtncMedia(false, sicColl,operModeList));
+            AvailableSpectrum  aspec = new AvailableSpectrumBuilder()
+                .setLowerFrequency(Uint64.valueOf(Math.round(lowSupFreq)))
+                .setUpperFrequency(Uint64.valueOf(Math.round(upSupFreq)))
                 .build();
-            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.OwnedNodeEdgePoint1 onep1 =
-                new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
-                    .OwnedNodeEdgePoint1Builder()
-                .setPhotonicMediaNodeEdgePointSpec(pnepSpec)
-                .build();
-            LOG.debug("creating Photonic NEP SPEC for node {} and nep {}", nodeId, onep1);
-            onepBldr.addAugmentation(onep1);
-            LOG.debug("Entering LOOP Step5");
+            spectrumPac.setAvailableSpectrum(
+                new HashMap<AvailableSpectrumKey, AvailableSpectrum>(Map.of(
+                    new AvailableSpectrumKey(aspec.getLowerFrequency(), aspec.getUpperFrequency()), aspec)));
+        } else {
+            LOG.debug("Entering LOOP Step2");
+            onepBldr.setAvailablePayloadStructure(
+                createAvailablePayloadStructureForPhtncMedia(true, sicColl,operModeList));
+            for (Map.Entry<Double, Double> frequency : freqMap.entrySet()) {
+                ospecBd
+                    .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
+                    .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
+            }
+            OccupiedSpectrum ospec = ospecBd.build();
+            spectrumPac.setOccupiedSpectrum(
+                new HashMap<OccupiedSpectrumKey, OccupiedSpectrum>(Map.of(
+                    new OccupiedSpectrumKey(ospec.getLowerFrequency(), ospec.getUpperFrequency()), ospec)));
         }
+        LOG.debug("Entering LOOP Step3");
+        SupportableSpectrum  sspec = new SupportableSpectrumBuilder()
+            .setLowerFrequency(Uint64.valueOf(Math.round(lowSupFreq)))
+            .setUpperFrequency(Uint64.valueOf(Math.round(upSupFreq)))
+            .build();
+        spectrumPac.setSupportableSpectrum(
+            new HashMap<SupportableSpectrumKey, SupportableSpectrum>(Map.of(
+                new SupportableSpectrumKey(sspec.getLowerFrequency(), sspec.getUpperFrequency()), sspec)));
+        LOG.debug("Entering LOOP Step4");
+        var onep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
+                .OwnedNodeEdgePoint1Builder()
+            .setPhotonicMediaNodeEdgePointSpec(
+                new PhotonicMediaNodeEdgePointSpecBuilder().setSpectrumCapabilityPac(spectrumPac.build()).build())
+            .build();
+        LOG.debug("creating Photonic NEP SPEC for node {} and nep {}", nodeId, onep1);
+        onepBldr.addAugmentation(onep1);
+        LOG.debug("Entering LOOP Step5");
         return onepBldr;
     }
 
@@ -871,74 +867,62 @@ public class ConvertORToTapiTopology {
     public OwnedNodeEdgePointBuilder addPhotSpecToRoadmOnep(String nodeId,
             Map<Double, Double> usedFreqMap, Map<Double, Double> availableFreqMap,
             OwnedNodeEdgePointBuilder onepBldr, String keyword) {
-        if (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)
-                || String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OMS).equals(keyword)) {
-            // Creating OTS/OMS NEP specific attributes
-            SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
-            if ((usedFreqMap == null || usedFreqMap.isEmpty())
-                    && (availableFreqMap == null || availableFreqMap.isEmpty())) {
-                double naz = 0.01;
-                AvailableSpectrum  aspec = new AvailableSpectrumBuilder()
-                    .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + naz)))
-                    .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
-                        + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz)))
-                    .build();
-                Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
-                aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(),
-                    aspec.getUpperFrequency()), aspec);
-                spectrumPac.setAvailableSpectrum(aspecMap);
-            } else {
-                if (availableFreqMap != null && !availableFreqMap.isEmpty()) {
-                    Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
-                    AvailableSpectrumBuilder  aspecBd = new AvailableSpectrumBuilder();
-                    for (Map.Entry<Double, Double> frequency : availableFreqMap.entrySet()) {
-                        aspecBd
-                            .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
-                            .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
-                        AvailableSpectrum aspec = aspecBd.build();
-                        aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(),
-                            aspec.getUpperFrequency()), aspec);
-                    }
-                    spectrumPac.setAvailableSpectrum(aspecMap);
-                }
-                if (usedFreqMap != null && !usedFreqMap.isEmpty()) {
-                    Map<OccupiedSpectrumKey, OccupiedSpectrum> ospecMap = new HashMap<>();
-                    OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
-                    for (Map.Entry<Double, Double> frequency : usedFreqMap.entrySet()) {
-                        ospecBd
-                            .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
-                            .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
-                        OccupiedSpectrum ospec = ospecBd.build();
-                        ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(),
-                            ospec.getUpperFrequency()), ospec);
-                    }
-                    spectrumPac.setOccupiedSpectrum(ospecMap);
-                }
+        if (!String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)
+                && !String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OMS).equals(keyword)) {
+            return onepBldr;
+        }
+        // Creating OTS/OMS NEP specific attributes
+        double naz = 0.01;
+        Double lowSupFreq = GridConstant.START_EDGE_FREQUENCY * 1E09 ;
+        Double upSupFreq = lowSupFreq + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz;
+        lowSupFreq += naz;
+        SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
+        Map<Double, Double> freqMap = null;
+        if (usedFreqMap == null || usedFreqMap.isEmpty()) {
+            freqMap = Map.of(lowSupFreq, upSupFreq);
+        } else {
+            Map<OccupiedSpectrumKey, OccupiedSpectrum> ospecMap = new HashMap<>();
+            OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
+            for (Map.Entry<Double, Double> frequency : usedFreqMap.entrySet()) {
+                ospecBd
+                    .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
+                    .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
+                OccupiedSpectrum ospec = ospecBd.build();
+                ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(), ospec.getUpperFrequency()), ospec);
             }
-            double nazz = 0.01;
-            SupportableSpectrum  sspec = new SupportableSpectrumBuilder()
-                .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + nazz)))
-                .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
-                    + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + nazz)))
-                .build();
-            Map<SupportableSpectrumKey, SupportableSpectrum> sspecMap = new HashMap<>();
-            sspecMap.put(new SupportableSpectrumKey(sspec.getLowerFrequency(),
-                sspec.getUpperFrequency()), sspec);
-            spectrumPac.setSupportableSpectrum(sspecMap);
-
-            PhotonicMediaNodeEdgePointSpec pnepSpec = new PhotonicMediaNodeEdgePointSpecBuilder()
-                .setSpectrumCapabilityPac(spectrumPac.build())
-                .build();
-            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.OwnedNodeEdgePoint1 onep1 =
-                new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
-                        .OwnedNodeEdgePoint1Builder()
-                    .setPhotonicMediaNodeEdgePointSpec(pnepSpec)
-                    .build();
-            onepBldr.addAugmentation(onep1);
-            LOG.debug("Add Photonic Node Edge point Spec to {} including available Spectrum {} = ",
-                onepBldr.getName(),
-                onep1.getPhotonicMediaNodeEdgePointSpec().getSpectrumCapabilityPac().getAvailableSpectrum());
+            spectrumPac.setOccupiedSpectrum(ospecMap);
         }
+        if (availableFreqMap != null && !availableFreqMap.isEmpty()) {
+            freqMap = availableFreqMap;
+        }
+        if (freqMap != null) {
+            Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
+            AvailableSpectrumBuilder aspecBd = new AvailableSpectrumBuilder();
+            for (Map.Entry<Double, Double> frequency : availableFreqMap.entrySet()) {
+                aspecBd
+                    .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
+                    .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
+                AvailableSpectrum aspec = aspecBd.build();
+                aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(), aspec.getUpperFrequency()), aspec);
+            }
+            spectrumPac.setAvailableSpectrum(aspecMap);
+        }
+        SupportableSpectrum  sspec = new SupportableSpectrumBuilder()
+            .setLowerFrequency(Uint64.valueOf(Math.round(lowSupFreq)))
+            .setUpperFrequency(Uint64.valueOf(Math.round(upSupFreq)))
+            .build();
+        spectrumPac.setSupportableSpectrum(
+            new HashMap<SupportableSpectrumKey, SupportableSpectrum>(Map.of(
+                new SupportableSpectrumKey(sspec.getLowerFrequency(), sspec.getUpperFrequency()), sspec)));
+        var onep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
+                .OwnedNodeEdgePoint1Builder()
+            .setPhotonicMediaNodeEdgePointSpec(
+                new PhotonicMediaNodeEdgePointSpecBuilder().setSpectrumCapabilityPac(spectrumPac.build()).build())
+            .build();
+        onepBldr.addAugmentation(onep1);
+        LOG.debug("Add Photonic Node Edge point Spec to {} including available Spectrum {} = ",
+            onepBldr.getName(),
+            onep1.getPhotonicMediaNodeEdgePointSpec().getSpectrumCapabilityPac().getAvailableSpectrum());
         return onepBldr;
     }
 
@@ -977,9 +961,8 @@ public class ConvertORToTapiTopology {
                 .build();
             nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, new HashMap<>(Map.of(rule.key(), rule)));
         } else {
-            LOG.error("Undefined LayerProtocolName for {} node {}",
-                nodeNames.get(nodeNames.keySet().iterator().next()).getValueName(),
-                nodeNames.get(nodeNames.keySet().iterator().next()).getValue());
+            var nodeName = nodeNames.get(nodeNames.keySet().iterator().next());
+            LOG.error("Undefined LayerProtocolName for {} node {}", nodeName.getValueName(), nodeName.getValue());
         }
      // Empty random creation of mandatory fields for avoiding errors....
         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
@@ -1129,20 +1112,22 @@ public class ConvertORToTapiTopology {
             LOG.debug("UUidMap={}", this.uuidMap.keySet());
             LOG.debug("TP list = {}", nbl.getTpList());
             for (TpId tp : nbl.getTpList()) {
-                LOG.debug("TP={}", tp.getValue());
-                String ietfEoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU, tp.getValue());
+                String tpValue = tp.getValue();
+                LOG.debug("TP={}", tpValue);
+                String ietfEoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU, tpValue);
                 LOG.debug("UuidKey={}", ietfEoduTp);
-                String ietfIoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU, tp.getValue());
-                if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, TapiStringConstants.DSR, tp.getValue()))
+                String ietfIoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU, tpValue);
+                if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, TapiStringConstants.DSR, tpValue))
                         || this.uuidMap.containsKey(ietfIoduTp)) {
-                    String qual = tp.getValue().contains("CLIENT")
-                        ? TapiStringConstants.DSR : TapiStringConstants.I_ODU;
                     var nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
                                 .node.rule.group.NodeEdgePointBuilder()
                             .setTopologyUuid(tapiTopoUuid)
                             .setNodeUuid(this.uuidMap.get(ietfXpdr))
                             .setNodeEdgePointUuid(this.uuidMap.get(
-                                String.join("+", this.ietfNodeId, qual, tp.getValue())))
+                                String.join("+",
+                                    this.ietfNodeId,
+                                    tpValue.contains("CLIENT") ? TapiStringConstants.DSR : TapiStringConstants.I_ODU,
+                                    tpValue)))
                             .build();
                     nepList.put(nep.key(), nep);
                 }
@@ -1219,24 +1204,23 @@ public class ConvertORToTapiTopology {
             LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip, String keyword) {
         var tp1 = oorTp.augmentation(
             org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.TerminationPoint1.class);
+        var oorTpId = oorTp.getTpId();
+        var oorTpIdValue = oorTpId.getValue();
         if (tp1.getTpSupportedInterfaces() == null) {
-            LOG.warn("Tp supported interface doesnt exist on TP {}", oorTp.getTpId().getValue());
+            LOG.warn("Tp supported interface doesnt exist on TP {}", oorTpIdValue);
             return null;
         }
+        TerminationPoint1 oorTpAug = oorTp.augmentation(TerminationPoint1.class);
+        var oorTpAugAdmState = oorTpAug.getAdministrativeState();
         AdministrativeState adminState =
-            oorTp.augmentation(TerminationPoint1.class).getAdministrativeState() == null
-                ? null
-                : transformAsToTapiAdminState(
-                    oorTp.augmentation(TerminationPoint1.class).getAdministrativeState().getName());
+            oorTpAugAdmState == null ? null : transformAsToTapiAdminState(oorTpAugAdmState.getName());
+        var oorTpAugOprState = oorTpAug.getOperationalState();
         OperationalState operState =
-            oorTp.augmentation(TerminationPoint1.class).getOperationalState() == null
-                ? null
-                : transformOsToTapiOperationalState(
-                    oorTp.augmentation(TerminationPoint1.class).getOperationalState().getName());
+            oorTpAugOprState == null ? null : transformOsToTapiOperationalState(oorTpAugOprState.getName());
         Collection<SupportedInterfaceCapability> sicColl =
             tp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values();
         OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
-            .setUuid(this.uuidMap.get(String.join("+", keyword, oorTp.getTpId().getValue())))
+            .setUuid(this.uuidMap.get(String.join("+", keyword, oorTpIdValue)))
             .setLayerProtocolName(nepProtocol)
             .setName(nepNames)
             .setSupportedCepLayerProtocolQualifierInstances(
@@ -1248,24 +1232,28 @@ public class ConvertORToTapiTopology {
             .setLifecycleState(LifecycleState.INSTALLED);
         if (withSip) {
             onepBldr.setMappedServiceInterfacePoint(
-                createMSIP(1, nepProtocol, oorTp.getTpId().getValue(), keyword, sicColl, operState, adminState));
+                createMSIP(1, nepProtocol, oorTpIdValue, keyword, sicColl, operState, adminState));
         }
-        if (oorTp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
+        if (oorTpAug.getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
             List<OperationalModeKey> opModeList = new ArrayList<>();
             var tp11 = oorTp.augmentation(
                 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
             if (tp11 == null || tp11.getXpdrNetworkAttributes() == null) {
                 for (SupportedInterfaceCapability sic : sicColl) {
                     String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
-                    if (("IfOCHOTUCnODUCn").equals(ifCapType) || ("IfOCHOTUCnODUCnUniregen").equals(ifCapType)
-                            || ("IfOCHOTUCnODUCnRegen").equals(ifCapType)) {
-                        opModeList.add(new OperationalModeKey("400G"));
-                        LOG.warn(TopologyUtils.NOOPMODEDECLARED + "400G rate available", oorTp.getTpId());
-                        break;
+                    switch (ifCapType) {
+                        case "IfOCHOTUCnODUCn":
+                        case "IfOCHOTUCnODUCnUniregen":
+                        case "IfOCHOTUCnODUCnRegen":
+                            opModeList.add(new OperationalModeKey("400G"));
+                            LOG.warn(TopologyUtils.NOOPMODEDECLARED + "400G rate available", oorTpId);
+                            break;
+                        default:
+                            break;
                     }
                 }
                 opModeList.add(new OperationalModeKey("100G"));
-                LOG.warn(TopologyUtils.NOOPMODEDECLARED + "100G rate available", oorTp.getTpId());
+                LOG.warn(TopologyUtils.NOOPMODEDECLARED + "100G rate available", oorTpId);
             } else {
                 opModeList = tp11.getXpdrNetworkAttributes().getSupportedOperationalModes().getOperationalMode()
                     .keySet().stream().toList();
@@ -1273,8 +1261,9 @@ public class ConvertORToTapiTopology {
             onepBldr = addPayloadStructureAndPhotSpecToOnep(
                 this.ietfNodeId, getXpdrUsedWavelength(oorTp), opModeList, sicColl, onepBldr, keyword);
         }
-        LOG.debug("ConvertORToTapiTopology 1360, onep = {}", onepBldr.build());
-        return onepBldr.build();
+        OwnedNodeEdgePoint onep = onepBldr.build();
+        LOG.debug("ConvertORToTapiTopology 1360, onep = {}", onep);
+        return onep;
     }
 
     private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpId,
@@ -1347,16 +1336,14 @@ public class ConvertORToTapiTopology {
     }
 
     public AdministrativeState transformAsToTapiAdminState(String adminState) {
-        return adminState == null
-            ? null
+        return adminState == null ? null
             : adminState.equals(AdminStates.InService.getName())
                     || adminState.equals(AdministrativeState.UNLOCKED.getName())
                 ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
     }
 
     public OperationalState transformOsToTapiOperationalState(String operState) {
-        return operState == null
-            ? null
+        return operState == null ? null
             : operState.equals("inService") || operState.equals(OperationalState.ENABLED.getName())
                 ? OperationalState.ENABLED : OperationalState.DISABLED;
     }