Merge "Refactor ORDM Full TAPI topology conversion"
authorGilles Thouenon <gilles.thouenon@orange.com>
Thu, 4 Apr 2024 15:39:44 +0000 (15:39 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 4 Apr 2024 15:39:44 +0000 (15:39 +0000)
16 files changed:
common/pom.xml
features/odl-transportpce-inventory/pom.xml
features/odl-transportpce-tapi/pom.xml
features/odl-transportpce/pom.xml
inventory/pom.xml
networkmodel/pom.xml
tapi/pom.xml
tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetConnectivityServiceListImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetLinkDetailsImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetNodeDetailsImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetNodeEdgePointDetailsImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetServiceInterfacePointDetailsImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/rpc/GetTopologyDetailsImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/ConvertORTopoToTapiTopo.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/utils/TapiListener.java
test-common/pom.xml

index 372309cddf112c8e4803dd4b917ee1fe613d55d8..e9d0ffa17ecf025c93c5c414d253de537ae9ce5d 100644 (file)
@@ -35,7 +35,7 @@
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>7.0.3</version>
+        <version>7.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
index b1eebf8bdfba607eaba52c1ca5ba9aa342376163..c3b80ffe46b5f7b5689682c3d921f40f041599d8 100644 (file)
@@ -21,7 +21,7 @@
 
   <properties>
     <mdsal.version>13.0.1</mdsal.version>
-    <netconf.version>7.0.3</netconf.version>
+    <netconf.version>7.0.4</netconf.version>
     <transportpce.models.version>20.0.0-SNAPSHOT</transportpce.models.version>
     <transportpce.db.host>localhost:3306</transportpce.db.host>
     <transportpce.db.database>transportpce</transportpce.db.database>
index da985caeb37dfb8463456f364ff58afeebe5a08e..e93c2f16c1e425abaf4e78411b6771c8b935902a 100644 (file)
@@ -24,7 +24,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
 
   <properties>
     <mdsal.version>13.0.1</mdsal.version>
-    <netconf.version>7.0.3</netconf.version>
+    <netconf.version>7.0.4</netconf.version>
     <transportpce.models.version>20.0.0-SNAPSHOT</transportpce.models.version>
     <skip.karaf.featureTest>false</skip.karaf.featureTest>
   </properties>
index 254504b5d511cb486f2cd9f1b0a92bfc4b8f535f..c66df045801417cb250bd1baac921e0840f1c6a1 100644 (file)
@@ -23,7 +23,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   <name>OpenDaylight :: transportpce</name>
 
   <properties>
-    <netconf.version>7.0.3</netconf.version>
+    <netconf.version>7.0.4</netconf.version>
     <transportpce.models.version>20.0.0-SNAPSHOT</transportpce.models.version>
     <configfile.directory>etc/opendaylight/karaf</configfile.directory>
     <skip.karaf.featureTest>false</skip.karaf.featureTest>
index 06d7513ec107416c73860a4b4b22b51ac7b616ec..3bd4326953dd2efb7e7d78084a6af8544c2740d9 100644 (file)
@@ -35,7 +35,7 @@
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>7.0.3</version>
+        <version>7.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
index 1f5a5b765941ee34a577c8d2b98dce33a232c688..ec57f59b28feb15b35772c3a1d76a2fe48f86a39 100644 (file)
@@ -52,7 +52,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>7.0.3</version>
+        <version>7.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
index 1a40951a8eec0cc9355352e21712a2557ac9f9ce..e7bab95dfd0fbbd65dc3bf8a966f26e908f9f8a7 100644 (file)
@@ -40,7 +40,7 @@ Author: Martial Coulibaly <martial.coulibaly@gfi.com> on behalf of Orange
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>7.0.3</version>
+        <version>7.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
index 3091214f38c5c23ca518a7ce775bcd970d8533e3..724cae4ddd30db53a545d90c458d2dbd37a8e05a 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev22112
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityService;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.get.connectivity.service.list.output.Service;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.get.connectivity.service.list.output.ServiceBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.get.connectivity.service.list.output.ServiceKey;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -48,13 +49,12 @@ public class GetConnectivityServiceListImpl implements GetConnectivityServiceLis
 
         Map<ServiceKey, Service> serviceMap = new HashMap<>();
         for (ConnectivityService connectivityService: connMap.values()) {
-            Service service = new org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.connectivity.rev221121.get.connectivity.service.list.output.ServiceBuilder(
-                    connectivityService).build();
+            Service service = new ServiceBuilder(connectivityService).build();
             serviceMap.put(service.key(), service);
         }
-        return RpcResultBuilder.success(new GetConnectivityServiceListOutputBuilder().setService(serviceMap)
-            .build()).buildFuture();
+        return RpcResultBuilder
+            .success(new GetConnectivityServiceListOutputBuilder().setService(serviceMap).build())
+            .buildFuture();
     }
 
 }
index c10050da4c970bbc8a83983d8d0390176f399106..ba2240bec478dd96e85042f2a6c70e6c518ed37e 100644 (file)
@@ -9,12 +9,12 @@ package org.opendaylight.transportpce.tapi.impl.rpc;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.transportpce.tapi.utils.TapiContext;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetails;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetailsInput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetailsOutput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetailsOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.link.details.output.LinkBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -33,18 +33,15 @@ public class GetLinkDetailsImpl implements GetLinkDetails {
     @Override
     public ListenableFuture<RpcResult<GetLinkDetailsOutput>> invoke(GetLinkDetailsInput input) {
         // TODO Auto-generated method stub
-        Uuid topoUuid = input.getTopologyId();
         // Link id: same as OR link id
-        Uuid linkUuid = input.getLinkId();
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link link = this.tapiContext
-                .getTapiLink(topoUuid, linkUuid);
+        Link link = this.tapiContext.getTapiLink(input.getTopologyId(), input.getLinkId());
         if (link == null) {
             LOG.error("Invalid TAPI link name");
             return RpcResultBuilder.<GetLinkDetailsOutput>failed()
                 .withError(ErrorType.RPC, "Invalid Link name")
                 .buildFuture();
         }
-        LOG.info("debug link is : {}", link.getName().toString());
+        LOG.info("debug link is : {}", link.getName());
         return RpcResultBuilder
                 .success(new GetLinkDetailsOutputBuilder().setLink(new LinkBuilder(link).build()).build())
                 .buildFuture();
index 434033bf3f1a85e619cfb5b5c250c4fcb4f5f19c..80cf31db683fb7f50a7e5f1b170625536222f9dd 100644 (file)
@@ -9,11 +9,12 @@ package org.opendaylight.transportpce.tapi.impl.rpc;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.transportpce.tapi.utils.TapiContext;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetails;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsInput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsOutput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetailsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.node.details.output.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -33,21 +34,19 @@ public class GetNodeDetailsImpl implements GetNodeDetails {
     public ListenableFuture<RpcResult<GetNodeDetailsOutput>> invoke(GetNodeDetailsInput input) {
         // TODO Auto-generated method stub
         // TODO -> maybe we get errors when having CEPs?
-        Uuid topoUuid = input.getTopologyId();
         // Node id: if roadm -> ROADM+PHOTONIC_MEDIA. if xpdr -> XPDR-XPDR+DSR/OTSi
-        Uuid nodeUuid = input.getNodeId();
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node = this.tapiContext
-                .getTapiNode(topoUuid, nodeUuid);
+        Node node = this.tapiContext.getTapiNode(input.getTopologyId(), input.getNodeId());
         if (node == null) {
             LOG.error("Invalid TAPI node name");
             return RpcResultBuilder.<GetNodeDetailsOutput>failed()
                 .withError(ErrorType.RPC, "Invalid Tapi Node name")
                 .buildFuture();
         }
-        return RpcResultBuilder.success(new GetNodeDetailsOutputBuilder()
-                .setNode(new org.opendaylight.yang.gen.v1.urn
-                        .onf.otcc.yang.tapi.topology.rev221121.get.node.details.output.NodeBuilder(node).build())
-                .build()).buildFuture();
+        return RpcResultBuilder
+            .success(new GetNodeDetailsOutputBuilder()
+                .setNode(new NodeBuilder(node).build())
+                .build())
+            .buildFuture();
     }
 
 }
index 382cc1ef47300c871371bbdeafaf672a42c9bf29..f26606fa3f1eb819f2bdf9263db4fb4d2b59ba59 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.transportpce.tapi.impl.rpc;
 
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.transportpce.tapi.utils.TapiContext;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetails;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsInput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetailsOutput;
@@ -35,13 +34,11 @@ public class GetNodeEdgePointDetailsImpl implements GetNodeEdgePointDetails {
     public ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> invoke(GetNodeEdgePointDetailsInput input) {
         // TODO Auto-generated method stub
         // TODO -> maybe we get errors when having CEPs?
-        Uuid topoUuid = input.getTopologyId();
         // Node id: if roadm -> ROADMid+PHOTONIC_MEDIA. if xpdr -> XPDRid-XPDRnbr+DSR/OTSi
-        Uuid nodeUuid = input.getNodeId();
         // NEP id: if roadm -> ROADMid+PHOTONIC_MEDIA/MC/OTSiMC+TPid.
         // if xpdr -> XPDRid-XPDRnbr+DSR/eODU/iODU/iOTSi/eOTSi/PHOTONIC_MEDIA+TPid
-        Uuid nepUuid = input.getNodeEdgePointId();
-        OwnedNodeEdgePoint nep = this.tapiContext.getTapiNEP(topoUuid, nodeUuid, nepUuid);
+        OwnedNodeEdgePoint nep =
+            this.tapiContext.getTapiNEP(input.getTopologyId(), input.getNodeId(), input.getNodeEdgePointId());
         if (nep == null) {
             LOG.error("Invalid TAPI nep name");
             return RpcResultBuilder.<GetNodeEdgePointDetailsOutput>failed()
@@ -50,7 +47,8 @@ public class GetNodeEdgePointDetailsImpl implements GetNodeEdgePointDetails {
         }
         return RpcResultBuilder
                 .success(new GetNodeEdgePointDetailsOutputBuilder()
-                        .setNodeEdgePoint(new NodeEdgePointBuilder(nep).build()).build())
+                        .setNodeEdgePoint(new NodeEdgePointBuilder(nep).build())
+                        .build())
                 .buildFuture();
     }
 
index 4eb28a7b88c0a98abe2fdd86edb85434c6b51561..fc10f05a76aee6238eb3aafb2a2d893d09950639 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetS
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsInput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsOutput;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetailsOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.SipBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey;
 import org.opendaylight.yangtools.yang.common.ErrorType;
@@ -35,7 +35,6 @@ public class GetServiceInterfacePointDetailsImpl implements GetServiceInterfaceP
     @Override
     public ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> invoke(
             GetServiceInterfacePointDetailsInput input) {
-        Uuid sipUuid = input.getUuid();
         Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips =
             this.tapiContext.getTapiContext().getServiceInterfacePoint();
         if (sips == null || sips.isEmpty()) {
@@ -43,17 +42,16 @@ public class GetServiceInterfacePointDetailsImpl implements GetServiceInterfaceP
                 .withError(ErrorType.RPC, "No sips in datastore")
                 .buildFuture();
         }
-        if (!sips.containsKey(new ServiceInterfacePointKey(sipUuid))) {
+        var sipKey = new ServiceInterfacePointKey(input.getUuid());
+        if (!sips.containsKey(sipKey)) {
             return RpcResultBuilder.<GetServiceInterfacePointDetailsOutput>failed()
                 .withError(ErrorType.RPC, "Sip doesnt exist in datastore")
                 .buildFuture();
         }
-        var outSip = new org.opendaylight.yang.gen.v1.urn
-                    .onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.SipBuilder(
-                        sips.get(new ServiceInterfacePointKey(sipUuid)))
-                    .build();
         return RpcResultBuilder
-                .success(new GetServiceInterfacePointDetailsOutputBuilder().setSip(outSip).build())
+                .success(new GetServiceInterfacePointDetailsOutputBuilder()
+                    .setSip(new SipBuilder(sips.get(sipKey)).build())
+                    .build())
                 .buildFuture();
     }
 
index e2da5de36121309de1963e02f7f5cbb898516018..7395f961e10263ab715aa5e46f9402e664d89fd2 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.InstanceIdentifiers;
@@ -53,7 +52,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.top
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
@@ -75,15 +73,17 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.no
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -111,34 +111,39 @@ public class GetTopologyDetailsImpl implements GetTopologyDetails {
 
     @Override
     public ListenableFuture<RpcResult<GetTopologyDetailsOutput>> invoke(GetTopologyDetailsInput input) {
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology topology;
-        Uuid topologyUuidFull = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
-            Charset.forName("UTF-8"))).toString());
-        if (input.getTopologyId().equals(topologyUuidFull)) {
-            Context context = this.tapiContext.getTapiContext();
-            Map<TopologyKey,
-                org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology>
-                topologyMap = context.augmentation(Context1.class).getTopologyContext().getTopology();
+        var topoId = input.getTopologyId();
+        Uuid topologyUuidFull = new Uuid(UUID.nameUUIDFromBytes(
+                TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8")))
+            .toString());
+        if (topologyUuidFull.equals(topoId)) {
+            Map<TopologyKey, Topology> topologyMap =
+                this.tapiContext.getTapiContext().augmentation(Context1.class).getTopologyContext().getTopology();
             if (topologyMap == null || !topologyMap.containsKey(new TopologyKey(topologyUuidFull))) {
-                LOG.error("Topology {} not found in datastore", input.getTopologyId());
+                LOG.error("Topology {} not found in datastore", topoId);
                 return RpcResultBuilder.<GetTopologyDetailsOutput>failed()
                     .withError(ErrorType.RPC, "Invalid Topology name")
                     .buildFuture();
             }
-            topology = topologyMap.get(new TopologyKey(input.getTopologyId()));
-            return RpcResultBuilder.success(new GetTopologyDetailsOutputBuilder()
-                .setTopology(this.topologyUtils.transformTopology(topology))
-                .build())
+            return RpcResultBuilder
+                .success(
+                    new GetTopologyDetailsOutputBuilder()
+                        .setTopology(
+                            this.topologyUtils.transformTopology(
+                                topologyMap.get(new TopologyKey(topoId))))
+                        .build())
                 .buildFuture();
         }
-        Uuid topologyUuidTapiAbs = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_TAPI_MULTILAYER.getBytes(
-            Charset.forName("UTF-8"))).toString());
-        if (input.getTopologyId().equals(topologyUuidTapiAbs)) {
+        if (new Uuid(UUID.nameUUIDFromBytes(
+                        TapiStringConstants.T0_TAPI_MULTILAYER.getBytes(Charset.forName("UTF-8")))
+                    .toString())
+                .equals(topoId)) {
             try {
-                LOG.info("Building TAPI Topology abstraction for {}", input.getTopologyId());
-                topology = createAbsTopologyFromTapiTopo();
-                return RpcResultBuilder.success(new GetTopologyDetailsOutputBuilder()
-                    .setTopology(this.topologyUtils.transformTopology(topology)).build())
+                LOG.info("Building TAPI Topology abstraction for {}", topoId);
+                return RpcResultBuilder
+                    .success(
+                        new GetTopologyDetailsOutputBuilder()
+                            .setTopology(this.topologyUtils.transformTopology(createAbsTopologyFromTapiTopo()))
+                            .build())
                     .buildFuture();
             } catch (TapiTopologyException e) {
                 LOG.error("error building TAPI topology");
@@ -147,63 +152,73 @@ public class GetTopologyDetailsImpl implements GetTopologyDetails {
                     .buildFuture();
             }
         }
-        Uuid topologyUuid100G = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(
-            Charset.forName("UTF-8"))).toString());
-        Uuid topologyUuidAbs = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
-            Charset.forName("UTF-8"))).toString());
-        if (topologyUuid100G.equals(input.getTopologyId()) || topologyUuidAbs.equals(input.getTopologyId())) {
-            try {
-                LOG.info("Building TAPI Topology abstraction for {}", input.getTopologyId());
-                topology = createAbstractedOtnTopology();
-                if (input.getTopologyId().equals(topologyUuidAbs)) {
-                    return RpcResultBuilder.success(new GetTopologyDetailsOutputBuilder()
-                        .setTopology(this.topologyUtils.transformTopology(topology)).build())
-                        .buildFuture();
-                }
-                topology = createAbstracted100GTpdrTopology(topology);
-                return RpcResultBuilder.success(new GetTopologyDetailsOutputBuilder()
-                    .setTopology(this.topologyUtils.transformTopology(topology)).build())
+        try {
+            if (new Uuid(UUID.nameUUIDFromBytes(
+                            TapiStringConstants.T0_MULTILAYER.getBytes(Charset.forName("UTF-8")))
+                        .toString())
+                    .equals(topoId)) {
+                LOG.info("Building TAPI Topology abstraction for {}", topoId);
+                return RpcResultBuilder
+                    .success(
+                        new GetTopologyDetailsOutputBuilder()
+                            .setTopology(this.topologyUtils.transformTopology(createAbstractedOtnTopology()))
+                            .build())
                     .buildFuture();
-            } catch (TapiTopologyException e) {
-                LOG.error("error building TAPI topology");
-                return RpcResultBuilder.<GetTopologyDetailsOutput>failed()
-                    .withError(ErrorType.RPC, "Error building topology")
+            }
+            if (new Uuid(UUID.nameUUIDFromBytes(
+                            TapiStringConstants.TPDR_100G.getBytes(Charset.forName("UTF-8")))
+                        .toString())
+                    .equals(topoId)) {
+                LOG.info("Building TAPI Topology abstraction for {}", topoId);
+                return RpcResultBuilder
+                    .success(
+                        new GetTopologyDetailsOutputBuilder()
+                            .setTopology(
+                                this.topologyUtils.transformTopology(
+                                    createAbstracted100GTpdrTopology(createAbstractedOtnTopology())))
+                            .build())
                     .buildFuture();
             }
+            return RpcResultBuilder.<GetTopologyDetailsOutput>failed()
+                .withError(ErrorType.RPC, "Invalid Topology name")
+                .buildFuture();
+        } catch (TapiTopologyException e) {
+            LOG.error("error building TAPI topology");
+            return RpcResultBuilder.<GetTopologyDetailsOutput>failed()
+                .withError(ErrorType.RPC, "Error building topology")
+                .buildFuture();
         }
-        return RpcResultBuilder.<GetTopologyDetailsOutput>failed()
-            .withError(ErrorType.RPC, "Invalid Topology name")
-            .buildFuture();
     }
 
-    public org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology
-            createAbstracted100GTpdrTopology(org.opendaylight.yang.gen.v1.urn
-                    .onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology topology) {
-        List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> dsrNodes = topology
-                .nonnullNode().values().stream()
-                .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
-                .collect(Collectors.toList());
+    public Topology createAbstracted100GTpdrTopology(Topology topology) {
         List<OwnedNodeEdgePoint> nep100GTpdrList = new ArrayList<>();
-        for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node2 : dsrNodes) {
+        for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node2 :
+                topology.nonnullNode().values().stream()
+                    .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.DSR))
+                    .collect(Collectors.toList())) {
             List<OwnedNodeEdgePoint> nepList = node2.getOwnedNodeEdgePoint().values().stream()
                     .filter(nep -> nep.getName().containsKey(new NameKey("100G-tpdr")))
                     .collect(Collectors.toList());
             nep100GTpdrList.addAll(nepList);
         }
-        Name topoName = new NameBuilder().setValue(TapiStringConstants.TPDR_100G).setValueName("TAPI Topology Name")
+        Name topoName = new NameBuilder()
+                .setValue(TapiStringConstants.TPDR_100G)
+                .setValueName("TAPI Topology Name")
                 .build();
-        Uuid topoUuid = new Uuid(
-                UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(Charset.forName("UTF-8"))).toString());
+        Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(
+                TapiStringConstants.TPDR_100G.getBytes(Charset.forName("UTF-8")))
+            .toString());
         org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node =
-                createTapiNode(nep100GTpdrList, topoUuid);
-        return new org.opendaylight.yang.gen.v1.urn
-                    .onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyBuilder()
-                .setName(Map.of(topoName.key(), topoName)).setUuid(topoUuid).setNode(Map.of(node.key(), node))
-                .setLayerProtocolName(Set.of(LayerProtocolName.DSR, LayerProtocolName.ETH)).build();
+            createTapiNode(nep100GTpdrList, topoUuid);
+        return new TopologyBuilder()
+            .setName(Map.of(topoName.key(), topoName))
+            .setUuid(topoUuid)
+            .setNode(Map.of(node.key(), node))
+            .setLayerProtocolName(Set.of(LayerProtocolName.DSR, LayerProtocolName.ETH))
+            .build();
     }
 
-    public org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology
-            createAbstractedOtnTopology() throws TapiTopologyException {
+    public Topology createAbstractedOtnTopology() throws TapiTopologyException {
         // read openroadm-topology
         Network openroadmTopo = readTopology(InstanceIdentifiers.OVERLAY_NETWORK_II);
         List<Link> linkList = new ArrayList<>();
@@ -245,8 +260,9 @@ public class GetTopologyDetailsImpl implements GetTopologyDetails {
                 = new HashMap<>();
         Map<LinkKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link> tapiLinkList
                 = new HashMap<>();
-        Uuid topoUuid = new Uuid(UUID
-                .nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(Charset.forName("UTF-8"))).toString());
+        Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(
+                TapiStringConstants.T0_MULTILAYER.getBytes(Charset.forName("UTF-8")))
+            .toString());
         ConvertORTopoToTapiTopo tapiAbstractFactory = new ConvertORTopoToTapiTopo(topoUuid, this.tapiLink);
         ConvertORToTapiTopology tapiFactory = new ConvertORToTapiTopology(topoUuid);
         Iterator<Entry<String, List<String>>> it = networkPortMap.entrySet().iterator();
@@ -268,29 +284,28 @@ public class GetTopologyDetailsImpl implements GetTopologyDetails {
             LOG.warn("Unable to abstract an ROADM infrasctructure from openroadm-topology");
         }
         if (otnTopo.augmentation(Network1.class) != null) {
-            Map<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
-                    .ietf.network.topology.rev180226.networks.network.LinkKey, Link> otnLinkMap =
-                otnTopo.augmentation(Network1.class).getLink();
-            tapiAbstractFactory.convertLinks(otnLinkMap);
+            tapiAbstractFactory.convertLinks(otnTopo.augmentation(Network1.class).getLink());
             tapiLinkList.putAll(tapiAbstractFactory.getTapiLinks());
         }
-        Name name = new NameBuilder().setValue(TapiStringConstants.T0_MULTILAYER).setValueName("TAPI Topology Name")
-                .build();
-        LOG.info("TOPOABSTRACTED : the list of node is as follows {}", tapiNodeList.toString());
+        Name name = new NameBuilder().setValue(
+                TapiStringConstants.T0_MULTILAYER).setValueName("TAPI Topology Name")
+            .build();
+        LOG.info("TOPOABSTRACTED : the list of node is as follows {}", tapiNodeList);
         this.tapiSips.putAll(tapiAbstractFactory.getTapiSips());
-        return new org.opendaylight.yang.gen.v1.urn
-                .onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyBuilder()
-            .setName(Map.of(name.key(), name)).setUuid(topoUuid).setNode(tapiNodeList)
+        return new TopologyBuilder()
+            .setName(Map.of(name.key(), name))
+            .setUuid(topoUuid)
+            .setNode(tapiNodeList)
             .setLayerProtocolName(Set.of(LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.DIGITALOTN))
             .setLink(tapiLinkList)
             .build();
     }
 
-    public org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology
-            createAbsTopologyFromTapiTopo() throws TapiTopologyException {
-        Uuid refTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
-            .getBytes(Charset.forName("UTF-8"))).toString());
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology tapiFullTopo =
+    public Topology createAbsTopologyFromTapiTopo() throws TapiTopologyException {
+        Uuid refTopoUuid = new Uuid(UUID.nameUUIDFromBytes(
+                    TapiStringConstants.T0_FULL_MULTILAYER.getBytes(Charset.forName("UTF-8")))
+            .toString());
+        Topology tapiFullTopo =
             this.tapiContext
                 .getTopologyContext().entrySet().stream().filter(topo -> topo.getKey().getUuid().equals(refTopoUuid))
                 .findAny().orElseThrow().getValue();
@@ -300,25 +315,21 @@ public class GetTopologyDetailsImpl implements GetTopologyDetails {
         absTapiTopo.convertRoadmInfrastructure();
 
         Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node>
-            tapiNodeList = new HashMap<>();
-        Map<LinkKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link>
-            tapiLinkList = new HashMap<>();
-        tapiNodeList.putAll(absTapiTopo.getTapiNodes());
-        tapiLinkList.putAll(absTapiTopo.getTapiLinks());
+            tapiNodeList = new HashMap<>(absTapiTopo.getTapiNodes());
+        LOG.info("ABSTRACTED TAPI TOPOLOGY : the list of node is as follows {}", tapiNodeList);
         Name name = new NameBuilder()
             .setValue(TapiStringConstants.T0_MULTILAYER)
             .setValueName("TAPI Topology Name")
             .build();
-        Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_TAPI_MULTILAYER
-            .getBytes(Charset.forName("UTF-8"))).toString());
-        LOG.info("ABSTRACTED TAPI TOPOLOGY : the list of node is as follows {}", tapiNodeList);
-        return new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context
-                .TopologyBuilder()
+        return new TopologyBuilder()
             .setName(Map.of(name.key(), name))
-            .setUuid(topoUuid)
+            .setUuid(
+                new Uuid(UUID.nameUUIDFromBytes(
+                        TapiStringConstants.T0_TAPI_MULTILAYER.getBytes(Charset.forName("UTF-8")))
+                    .toString()))
             .setNode(tapiNodeList)
             .setLayerProtocolName(Set.of(LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.DIGITALOTN))
-            .setLink(tapiLinkList)
+            .setLink(new HashMap<>(absTapiTopo.getTapiLinks()))
             .build();
     }
 
@@ -347,51 +358,53 @@ public class GetTopologyDetailsImpl implements GetTopologyDetails {
             onepMap.put(ownedNodeEdgePoint.key(), ownedNodeEdgePoint);
         }
         Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(name.getValue().getBytes(Charset.forName("UTF-8"))).toString());
-        return new NodeBuilder().setUuid(nodeUuid).setName(Map.of(name.key(), name))
+        return new NodeBuilder()
+                .setUuid(nodeUuid)
+                .setName(Map.of(name.key(), name))
                 .setLayerProtocolName(Set.of(LayerProtocolName.ETH))
-                .setAdministrativeState(AdministrativeState.UNLOCKED).setOperationalState(OperationalState.ENABLED)
-                .setLifecycleState(LifecycleState.INSTALLED).setOwnedNodeEdgePoint(onepMap)
-                .setNodeRuleGroup(createNodeRuleGroupFor100gTpdrNode(topoUuid, nodeUuid, nepList)).build();
+                .setAdministrativeState(AdministrativeState.UNLOCKED)
+                .setOperationalState(OperationalState.ENABLED)
+                .setLifecycleState(LifecycleState.INSTALLED)
+                .setOwnedNodeEdgePoint(onepMap)
+                .setNodeRuleGroup(createNodeRuleGroupFor100gTpdrNode(topoUuid, nodeUuid, nepList))
+                .build();
     }
 
-    private boolean checkTp(String nodeIdTopo, String nodeIdPortMap, TerminationPoint tp, List<Link> xpdOut,
-            List<Link> xpdIn) {
-        String networkLcp;
-        if (tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERCLIENT)) {
-            networkLcp = tp.augmentation(
+    private boolean checkTp(
+            String nodeIdTopo, String nodeIdPortMap, TerminationPoint tp, List<Link> xpdOut, List<Link> xpdIn) {
+        String networkLcp =
+            tp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERCLIENT)
+                ? tp.augmentation(
                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1.class)
-                    .getAssociatedConnectionMapTp().iterator().next().getValue();
-        } else {
-            networkLcp = tp.getTpId().getValue();
+                    .getAssociatedConnectionMapTp().iterator().next().getValue()
+                : tp.getTpId().getValue();
+        ListenableFuture<Optional<Mapping>> mappingOpt =
+            networkTransactionService.read(
+                LogicalDatastoreType.CONFIGURATION,
+                InstanceIdentifier.create(
+                    org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.Network.class)
+                        .child(Nodes.class, new NodesKey(nodeIdPortMap))
+                        .child(Mapping.class, new MappingKey(networkLcp)));
+        if (!mappingOpt.isDone()) {
+            LOG.error("Impossible to get mapping of associated network port {} of tp {}",
+                    networkLcp, tp.getTpId().getValue());
+            return false;
         }
-        @NonNull
-        KeyedInstanceIdentifier<Mapping, MappingKey> pmIID = InstanceIdentifier.create(
-                org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.Network.class)
-                .child(Nodes.class, new NodesKey(nodeIdPortMap)).child(Mapping.class, new MappingKey(networkLcp));
-        ListenableFuture<Optional<Mapping>> mappingOpt = networkTransactionService
-                .read(LogicalDatastoreType.CONFIGURATION, pmIID);
-        Mapping mapping = null;
-        if (mappingOpt.isDone()) {
-            try {
-                mapping = mappingOpt.get().orElseThrow();
-            } catch (InterruptedException | ExecutionException e) {
-                LOG.error("Error getting mapping for {}", networkLcp, e);
-                return false;
-            }
-        } else {
-            LOG.error("Impossible to get mapping of associated network port {} of tp {}", networkLcp,
-                    tp.getTpId().getValue());
+        Mapping mapping;
+        try {
+            mapping = mappingOpt.get().orElseThrow();
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Error getting mapping for {}", networkLcp, e);
             return false;
         }
-        String networkPortDirection = mapping.getPortDirection();
         long count = 0;
-        switch (networkPortDirection) {
+        switch (mapping.getPortDirection()) {
             case "bidirectional":
                 count += xpdOut.stream().filter(lk -> lk.getSource().getSourceNode().getValue().equals(nodeIdTopo)
                         && lk.getSource().getSourceTp().getValue().equals(networkLcp)).count();
                 count += xpdIn.stream().filter(lk -> lk.getDestination().getDestNode().getValue().equals(nodeIdTopo)
                         && lk.getDestination().getDestTp().getValue().equals(networkLcp)).count();
-                return (count == 2);
+                return count == 2;
             case "tx":
             case "rx":
                 @Nullable
@@ -408,40 +421,39 @@ public class GetTopologyDetailsImpl implements GetTopologyDetails {
                     count += xpdOut.stream().filter(lk -> lk.getSource().getSourceNode().getValue().equals(nodeIdTopo)
                             && lk.getSource().getSourceTp().getValue().equals(partnerLcp)).count();
                 }
-                return (count == 2);
+                return count == 2;
             default:
                 LOG.error("Invalid port direction for {}", networkLcp);
                 return false;
         }
     }
 
-    private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupFor100gTpdrNode(Uuid topoUuid, Uuid nodeUuid,
-            Collection<OwnedNodeEdgePoint> onepl) {
-
+    private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupFor100gTpdrNode(
+            Uuid topoUuid, Uuid nodeUuid, Collection<OwnedNodeEdgePoint> onepl) {
         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<>();
         for (OwnedNodeEdgePoint onep : onepl) {
-            var nep = new org.opendaylight.yang.gen.v1.urn
-                    .onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointBuilder()
+            var nep = new NodeEdgePointBuilder()
                 .setTopologyUuid(topoUuid)
                 .setNodeUuid(nodeUuid)
                 .setNodeEdgePointUuid(onep.key().getUuid())
                 .build();
             nepMap.put(nep.key(), nep);
         }
-        Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
-        Map<RuleKey, Rule> ruleList = new HashMap<>();
-        Set<RuleType> ruleTypes = new HashSet<>();
-        ruleTypes.add(RuleType.FORWARDING);
-        Rule rule = new RuleBuilder().setLocalId("forward").setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
-                .setRuleType(ruleTypes).build();
-        ruleList.put(rule.key(), rule);
-        NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder().setUuid(new Uuid(
-                UUID.nameUUIDFromBytes(("rdm infra node rule group").getBytes(Charset.forName("UTF-8"))).toString()))
-                .setRule(ruleList).setNodeEdgePoint(nepMap).build();
-        nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
-        return nodeRuleGroupMap;
+        Rule rule = new RuleBuilder()
+                .setLocalId("forward")
+                .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
+                .setRuleType(new HashSet<RuleType>(Set.of(RuleType.FORWARDING)))
+                .build();
+        NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
+                .setUuid(new Uuid(UUID.nameUUIDFromBytes(
+                        ("rdm infra node rule group").getBytes(Charset.forName("UTF-8")))
+                    .toString()))
+                .setRule(new HashMap<RuleKey, Rule>(Map.of(rule.key(), rule)))
+                .setNodeEdgePoint(nepMap)
+                .build();
+        return new HashMap<NodeRuleGroupKey, NodeRuleGroup>(Map.of(nodeRuleGroup.key(), nodeRuleGroup));
     }
 
 }
index 6e9476adf3ec6aad3f4ce72e8d8bb4bc79837766..e1cffb7982e1d9f8d10c448378562184530f0403 100644 (file)
@@ -41,16 +41,12 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.link.NodeEdgePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.link.NodeEdgePointBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.link.NodeEdgePointKey;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroup;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroupKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupKey;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPac;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristic;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristicBuilder;
@@ -88,87 +84,85 @@ public class ConvertORTopoToTapiTopo {
     }
 
     public void convertLinks(Map<
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
-                .LinkKey,
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
-                .Link> otnLinkMap) {
-        List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
-            .Link> otnLinkList = new ArrayList<>(otnLinkMap.values());
-        Collections.sort(otnLinkList, (l1, l2) -> l1.getLinkId().getValue()
-            .compareTo(l2.getLinkId().getValue()));
+            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                .networks.network.LinkKey,
+            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                .networks.network.Link> otnLinkMap) {
+        List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                .networks.network.Link> otnLinkList = new ArrayList<>(otnLinkMap.values());
+        Collections.sort(otnLinkList, (l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue()));
         List<String> linksToNotConvert = new ArrayList<>();
         LOG.info("creation of {} otn links", otnLinkMap.size() / 2);
-        for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
-                .Link otnlink : otnLinkList) {
-            if (!linksToNotConvert.contains(otnlink.getLinkId().getValue())) {
-                org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks
-                    .network.Link oppositeLink = otnLinkMap.get(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns
-                        .yang.ietf.network.topology.rev180226.networks.network.LinkKey(otnlink.augmentation(Link1.class)
-                    .getOppositeLink()));
-
-                AdminStates oppLnkAdmState = null;
-                State oppLnkOpState = null;
-                String oppositeLinkId = null;
-                if (oppositeLink != null) {
-                    oppLnkAdmState = oppositeLink.augmentation(Link1.class).getAdministrativeState();
-                    oppLnkOpState = oppositeLink.augmentation(Link1.class).getOperationalState();
-                    oppositeLinkId = oppositeLink.getLinkId().getValue();
-                }
-                String adminState =
-                    otnlink.augmentation(Link1.class).getAdministrativeState() == null
-                        || oppLnkAdmState == null
-                    ? null
+        for (var otnlink : otnLinkList) {
+            String otnlinkId = otnlink.getLinkId().getValue();
+            if (linksToNotConvert.contains(otnlinkId)) {
+                continue;
+            }
+            var otnlinkAug = otnlink.augmentation(Link1.class);
+            var oppositeLink = otnLinkMap.get(
+                new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226
+                    .networks.network.LinkKey(otnlinkAug.getOppositeLink()));
+            AdminStates oppLnkAdmState = null;
+            State oppLnkOpState = null;
+            String oppositeLinkId = null;
+            if (oppositeLink != null) {
+                var oppositeLinkAug = oppositeLink.augmentation(Link1.class);
+                oppLnkAdmState = oppositeLinkAug.getAdministrativeState();
+                oppLnkOpState = oppositeLinkAug.getOperationalState();
+                oppositeLinkId = oppositeLink.getLinkId().getValue();
+            }
+            // TODO: Handle not only OTU4 but also other cases
+            String prefix = otnlinkId.split("-")[0];
+            String tpsQual = prefix.equals("OTU4") ? TapiStringConstants.I_OTSI : TapiStringConstants.E_ODU;
+            LayerProtocolName layerProtocolName =
+                prefix.equals("OTU4") ? LayerProtocolName.PHOTONICMEDIA : LayerProtocolName.ODU;
+            var otnlinkSrc = otnlink.getSource();
+            var otnlinkDst = otnlink.getDestination();
+            Link tapLink = this.tapiLink.createTapiLink(
+                otnlinkSrc.getSourceNode().getValue(),
+                otnlinkSrc.getSourceTp().getValue(),
+                otnlinkDst.getDestNode().getValue(),
+                otnlinkDst.getDestTp().getValue(),
+                TapiStringConstants.OTN_XPDR_XPDR_LINK,
+                // nodesQual, nodesQual,
+                TapiStringConstants.XPDR, TapiStringConstants.XPDR,
+                tpsQual, tpsQual,
+                otnlinkAug.getAdministrativeState() == null || oppLnkAdmState == null ? null
                     : this.tapiLink.setTapiAdminState(
-                        otnlink.augmentation(Link1.class).getAdministrativeState(), oppLnkAdmState).getName();
-                String operState = otnlink.augmentation(Link1.class).getOperationalState() == null
-                        || oppLnkOpState == null
-                    ? null
+                        otnlinkAug.getAdministrativeState(), oppLnkAdmState).getName(),
+                otnlinkAug.getOperationalState() == null || oppLnkOpState == null ? null
                     : this.tapiLink.setTapiOperationalState(
-                        otnlink.augmentation(Link1.class).getOperationalState(), oppLnkOpState).getName();
-                // TODO: Handle not only OTU4 but also other cases
-                String prefix = otnlink.getLinkId().getValue().split("-")[0];
-                String nodesQual = TapiStringConstants.XPDR;
-                String tpsQual = prefix.equals("OTU4") ? TapiStringConstants.I_OTSI : TapiStringConstants.E_ODU;
-                LayerProtocolName layerProtocolName = prefix.equals("OTU4") ? LayerProtocolName.PHOTONICMEDIA
-                    : LayerProtocolName.ODU;
-
-                Link tapLink = this.tapiLink.createTapiLink(otnlink.getSource().getSourceNode().getValue(),
-                    otnlink.getSource().getSourceTp().getValue(), otnlink.getDestination().getDestNode().getValue(),
-                    otnlink.getDestination().getDestTp().getValue(), TapiStringConstants.OTN_XPDR_XPDR_LINK, nodesQual,
-                    nodesQual, tpsQual, tpsQual, adminState, operState, Set.of(layerProtocolName),
-                    Set.of(layerProtocolName.getName()), this.tapiTopoUuid);
-                linksToNotConvert.add(oppositeLinkId);
-                tapiLinks.put(tapLink.key(), tapLink);
-                LOG.debug("Links converted are as follow  {}", tapiLinks.toString());
-            }
+                        otnlinkAug.getOperationalState(), oppLnkOpState).getName(),
+                Set.of(layerProtocolName),
+                Set.of(layerProtocolName.getName()),
+                this.tapiTopoUuid);
+            linksToNotConvert.add(oppositeLinkId);
+            tapiLinks.put(tapLink.key(), tapLink);
+            LOG.debug("Links converted are as follow  {}", tapiLinks);
         }
     }
 
     public void convertRoadmInfrastructure() {
         LOG.info("abstraction of the ROADM infrastructure towards a photonic node");
-        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.RDM_INFRA
-            .getBytes(Charset.forName("UTF-8"))).toString());
+        Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(
+                    TapiStringConstants.RDM_INFRA.getBytes(Charset.forName("UTF-8")))
+                .toString());
         Name nodeName =
             new NameBuilder().setValueName("otsi node name").setValue(TapiStringConstants.RDM_INFRA).build();
         Name nodeName2 =
             new NameBuilder().setValueName("roadm node name").setValue(TapiStringConstants.RDM_INFRA).build();
-        Name nameNodeType = new NameBuilder().setValueName("Node Type")
-            .setValue(OpenroadmNodeType.ROADM.getName()).build();
+        Name nameNodeType =
+            new NameBuilder().setValueName("Node Type").setValue(OpenroadmNodeType.ROADM.getName()).build();
         Set<LayerProtocolName> nodeLayerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA);
-        List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiPhotonicNodes
-            = pruneTapiPhotonicNodes();
         //At that stage, there is no Roadm in the tapiPhotonicNodes Map / only the transponders
-        Map<String, String> photonicNepUuisMap = convertListNodeWithListNepToMapForUuidAndName(tapiPhotonicNodes);
+        Map<String, String> photonicNepUuisMap =
+            convertListNodeWithListNepToMapForUuidAndName(pruneTapiPhotonicNodes());
         // nep creation for rdm infra abstraction node
         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = createNepForRdmNode(photonicNepUuisMap.size());
         // node rule group creation
         var tapiFactory = new ConvertORToTapiTopology(this.tapiTopoUuid);
         Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap
             = tapiFactory.createAllNodeRuleGroupForRdmNode("T0ML", nodeUuid, null, onepMap.values());
-        Map<InterRuleGroupKey, InterRuleGroup> interRuleGroupMap
-            = tapiFactory.createInterRuleGroupForRdmNode("T0ML", nodeUuid, null,
-                nodeRuleGroupMap.entrySet().stream().map(e -> e.getKey()).collect(Collectors.toList()));
-
         // Empty random creation of mandatory fields for avoiding errors....
         CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
             .setCostAlgorithm("Restricted Shortest Path - RSP")
@@ -186,11 +180,8 @@ public class ConvertORTopoToTapiTopo {
             .setRiskCharacteristicName("risk characteristic")
             .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
             .build();
-        RiskParameterPac riskParamPac = new RiskParameterPacBuilder()
-            .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
-            .build();
         // build RDM infra node abstraction
-        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node rdmNode = new NodeBuilder()
+        var rdmNode = new NodeBuilder()
             .setUuid(nodeUuid)
             .setName(Map.of(nodeName.key(), nodeName, nodeName2.key(), nodeName2, nameNodeType.key(), nameNodeType))
             .setLayerProtocolName(nodeLayerProtocols)
@@ -199,10 +190,15 @@ public class ConvertORTopoToTapiTopo {
             .setLifecycleState(LifecycleState.INSTALLED)
             .setOwnedNodeEdgePoint(onepMap)
             .setNodeRuleGroup(nodeRuleGroupMap)
-            .setInterRuleGroup(interRuleGroupMap)
+            .setInterRuleGroup(
+                tapiFactory.createInterRuleGroupForRdmNode("T0ML", nodeUuid, null,
+                    nodeRuleGroupMap.entrySet().stream().map(e -> e.getKey()).collect(Collectors.toList())))
             .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
             .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
-            .setRiskParameterPac(riskParamPac)
+            .setRiskParameterPac(
+                new RiskParameterPacBuilder()
+                    .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
+                    .build())
             .build();
         tapiNodes.put(rdmNode.key(), rdmNode);
     // OTS link creation between photonic nodes and RDM infra abstraction node :
@@ -211,9 +207,7 @@ public class ConvertORTopoToTapiTopo {
       //rdmInfraNepUuisMap is a Map <ROADMnodeUuuid--NepUuid; ROADMnodeName--nepName> built from onepMap
       //photonicNepUuisMap is a Map <TSPnodeUuuid--eNepUuid; TSPnodeName--nepName> built from TapiPhotonicNode
         Map<String, String> rdmInfraNepUuisMap = convertListNodeWithListNepToMapForUuidAndName(List.of(rdmNode));
-        if (photonicNepUuisMap.size() != rdmInfraNepUuisMap.size()) {
-            LOG.warn("Unable to build OTS links between photonics nodes and RDM infrasctructure abstraction");
-        } else {
+        if (photonicNepUuisMap.size() == rdmInfraNepUuisMap.size()) {
             //Tapi OtsLinks are created between Neps corresponding to the eNEPs of transponders (existing network ports)
             //and Generic NEPS with abstracted names created in the ROADM infrastructure corresponding to tps mirroring
             //transponders NETWORK PORTs. There is a simplification here considering that any network port of
@@ -221,6 +215,8 @@ public class ConvertORTopoToTapiTopo {
             // TODO: Do not understand that we build OTS link without checking that existing transponder ports
             //are effectively connected. Need some consolidation
             createTapiOtsLinks(photonicNepUuisMap, rdmInfraNepUuisMap);
+        } else {
+            LOG.warn("Unable to build OTS links between photonics nodes and RDM infrasctructure abstraction");
         }
     }
 
@@ -228,12 +224,10 @@ public class ConvertORTopoToTapiTopo {
             pruneTapiPhotonicNodes() {
         List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node>
             prunedTapiPhotonicNodes = new ArrayList<>();
-        List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> tapiPhotonicNodes
-            = this.tapiNodes.values().stream()
-                .filter(n -> n.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
-                .collect(Collectors.toList());
-        for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node
-            : tapiPhotonicNodes) {
+        for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node :
+                this.tapiNodes.values().stream()
+                    .filter(n -> n.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA))
+                    .collect(Collectors.toList())) {
             Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepM = new HashMap<>();
             for (Map.Entry<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> entry : node.getOwnedNodeEdgePoint().entrySet()) {
                 if (entry.getValue().getName().values().stream()
@@ -241,25 +235,23 @@ public class ConvertORTopoToTapiTopo {
                     onepM.put(entry.getKey(), entry.getValue());
                 }
             }
-            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node prunedNode
-                = new NodeBuilder(node).setOwnedNodeEdgePoint(onepM).build();
-            prunedTapiPhotonicNodes.add(prunedNode);
+            prunedTapiPhotonicNodes.add(new NodeBuilder(node).setOwnedNodeEdgePoint(onepM).build());
         }
         return prunedTapiPhotonicNodes;
     }
 
     private Map<String, String> convertListNodeWithListNepToMapForUuidAndName(
-        List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodes) {
+            List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node> nodes) {
         Map<String, String> uuidNameMap = new HashMap<>();
-        for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node : nodes) {
+        for (var node : nodes) {
+            String nodeName = node.getName().get(new NameKey("otsi node name")).getValue();
+            String nodeUuid = node.getUuid().getValue();
             for (OwnedNodeEdgePoint nep : node.nonnullOwnedNodeEdgePoint().values()) {
-                String nodeUuid = node.getUuid().getValue();
-                String nepUuid = nep.getUuid().getValue();
-                String nodeName = node.getName().get(new NameKey("otsi node name")).getValue();
-                String nepName = nep.getName().get(new NameKey(nep.getName().keySet().stream().findFirst()
-                        .orElseThrow()))
-                    .getValue();
-                uuidNameMap.put(String.join("--", nodeUuid, nepUuid), String.join("--", nodeName, nepName));
+                uuidNameMap.put(
+                    String.join("--", nodeUuid, nep.getUuid().getValue()),
+                    String.join("--", nodeName,
+                        nep.getName().get(new NameKey(nep.getName().keySet().stream().findFirst().orElseThrow()))
+                            .getValue()));
             }
         }
         return uuidNameMap;
@@ -268,22 +260,22 @@ public class ConvertORTopoToTapiTopo {
     private Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> createNepForRdmNode(int nbNep) {
         Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepMap = new HashMap<>();
         for (int i = 1; i <= nbNep; i++) {
-            Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "roadm node", "nep", String.valueOf(i)))
-                .getBytes(Charset.forName("UTF-8"))).toString());
             Name nepName = new NameBuilder()
                 .setValueName("NodeEdgePoint name")
                 .setValue(new StringBuilder("NodeEdgePoint_").append(i).toString())
                 .build();
-            List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
-            sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
-                .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
-                .setNumberOfCepInstances(Uint64.valueOf(1))
-                .build());
             OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder()
-                .setUuid(nepUuid)
+                .setUuid(new Uuid(UUID.nameUUIDFromBytes(
+                        (String.join("+", "roadm node", "nep", String.valueOf(i))).getBytes(Charset.forName("UTF-8")))
+                    .toString()))
                 .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA)
                 .setName(Map.of(nepName.key(), nepName))
-                .setSupportedCepLayerProtocolQualifierInstances(sclpqiList)
+                .setSupportedCepLayerProtocolQualifierInstances(
+                    new ArrayList<>(List.of(
+                        new SupportedCepLayerProtocolQualifierInstancesBuilder()
+                            .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
+                            .setNumberOfCepInstances(Uint64.valueOf(1))
+                            .build())))
                 .setDirection(Direction.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC)
                 .setAdministrativeState(AdministrativeState.UNLOCKED).setOperationalState(OperationalState.ENABLED)
                 .setLifecycleState(LifecycleState.INSTALLED)
@@ -294,39 +286,34 @@ public class ConvertORTopoToTapiTopo {
     }
 
     private void createTapiOtsLinks(Map<String, String> photonicNepUuisMap, Map<String, String> rdmInfraNepUuisMap) {
-        Iterator<Entry<String, String>> it1 = photonicNepUuisMap.entrySet().iterator();
         Iterator<Entry<String, String>> it2 = rdmInfraNepUuisMap.entrySet().iterator();
-        while (it1.hasNext()) {
-            Map<NodeEdgePointKey, NodeEdgePoint> nepMap = new HashMap<>();
-            Map.Entry<String, String> photonicEntry = it1.next();
+        for (Map.Entry<String, String> photonicEntry : photonicNepUuisMap.entrySet()) {
             Map.Entry<String, String> rdmEntry = it2.next();
-            Uuid sourceUuidTp = new Uuid(photonicEntry.getKey().split("--")[1]);
-            Uuid sourceUuidNode = new Uuid(photonicEntry.getKey().split("--")[0]);
-            Uuid destUuidTp = new Uuid(rdmEntry.getKey().split("--")[1]);
-            Uuid destUuidNode = new Uuid(rdmEntry.getKey().split("--")[0]);
+            String photonicEntryKey = photonicEntry.getKey();
             NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
                 .setTopologyUuid(this.tapiTopoUuid)
-                .setNodeUuid(sourceUuidNode)
-                .setNodeEdgePointUuid(sourceUuidTp)
+                .setNodeUuid(new Uuid(photonicEntryKey.split("--")[0]))
+                .setNodeEdgePointUuid(new Uuid(photonicEntryKey.split("--")[1]))
                 .build();
-            nepMap.put(sourceNep.key(), sourceNep);
+            String rdmEntryKey = rdmEntry.getKey();
             NodeEdgePoint destNep = new NodeEdgePointBuilder()
                 .setTopologyUuid(this.tapiTopoUuid)
-                .setNodeUuid(destUuidNode)
-                .setNodeEdgePointUuid(destUuidTp)
+                .setNodeUuid(new Uuid(rdmEntryKey.split("--")[0]))
+                .setNodeEdgePointUuid(new Uuid(rdmEntryKey.split("--")[1]))
                 .build();
-            nepMap.put(destNep.key(), destNep);
-            Name linkName = new NameBuilder().setValueName("OTS link name")
-                .setValue(String.join(" and ", photonicEntry.getValue(), rdmEntry.getValue()))
+            String linkNameValue = String.join(" and ", photonicEntry.getValue(), rdmEntry.getValue());
+            Name linkName = new NameBuilder()
+                .setValueName("OTS link name")
+                .setValue(linkNameValue)
                 .build();
             Link otsLink = new LinkBuilder()
-                .setUuid(new Uuid(
-                    UUID.nameUUIDFromBytes((String.join(" and ", photonicEntry.getValue(), rdmEntry.getValue()))
-                            .getBytes(Charset.forName("UTF-8")))
-                        .toString()))
+                .setUuid(new Uuid(UUID.nameUUIDFromBytes(linkNameValue.getBytes(Charset.forName("UTF-8")))
+                    .toString()))
                 .setName(Map.of(linkName.key(), linkName))
                 .setLayerProtocolName(Set.of(LayerProtocolName.PHOTONICMEDIA))
-                .setNodeEdgePoint(nepMap)
+                .setNodeEdgePoint(
+                    new HashMap<NodeEdgePointKey, NodeEdgePoint>(Map.of(
+                        sourceNep.key(), sourceNep, destNep.key(), destNep)))
                 .setDirection(ForwardingDirection.BIDIRECTIONAL)
                 .build();
             this.tapiLinks.put(otsLink.key(), otsLink);
index ee0d4a3b5bd70c1087b71b72471e5a2d75a96902..1a3521661abad576b2c1b64a2323c9da495812e1 100644 (file)
@@ -7,14 +7,11 @@
  */
 package org.opendaylight.transportpce.tapi.utils;
 
-import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.binding.api.DataObjectModification;
 import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
 import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev230728.ServiceInterfacePoints;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev230728.service._interface.points.ServiceEndPoint;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -24,6 +21,9 @@ import org.slf4j.LoggerFactory;
 public class TapiListener implements DataTreeChangeListener<ServiceInterfacePoints> {
 
     private static final Logger LOG = LoggerFactory.getLogger(TapiListener.class);
+    private static final String SE_JAVA_INTF =
+        "interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928"
+            + ".service._interface.points.ServiceEndPoint";
 
     @Override
     public void onDataTreeChanged(@NonNull List<DataTreeModification<ServiceInterfacePoints>> changes) {
@@ -33,44 +33,30 @@ public class TapiListener implements DataTreeChangeListener<ServiceInterfacePoin
             switch (rootSIP.modificationType()) {
                 case WRITE:
                     LOG.info("onDataTreeChanged in TapiListener : WRITE");
-                    ServiceInterfacePoints data = rootSIP.dataAfter();
-                    List<ServiceEndPoint> listSEP = new ArrayList<>(data.getServiceEndPoint().values());
                     MappingUtils.deleteMap();
-                    for (ServiceEndPoint sep : listSEP) {
+                    for (ServiceEndPoint sep : rootSIP.dataAfter().getServiceEndPoint().values()) {
                         MappingUtils.addMapSEP(sep);
                     }
                     MappingUtils.afficheMap();
                     break;
                 case SUBTREE_MODIFIED:
                     LOG.info("onDataTreeChanged in TapiListener : SUBTREE_MODIFIED");
-                    Iterator<? extends DataObjectModification<? extends DataObject>> iterator = rootSIP
-                        .getModifiedChildren(ServiceEndPoint.class).iterator();
-                    while (iterator.hasNext()) {
-                        DataObjectModification<? extends DataObject> dom = iterator.next();
+                    for (DataObjectModification<? extends DataObject> dom :
+                            rootSIP.getModifiedChildren(ServiceEndPoint.class)) {
                         // to delete existing child entry
-                        if (dom.dataAfter() == null) {
-                            DataObject dataObject = dom.dataBefore();
-                            ServiceEndPoint sep = null;
-                            sep = (ServiceEndPoint) dataObject;
-                            Uuid uuid = sep.getUuid();
-                            MappingUtils.deleteMapEntry(uuid);
+                        DataObject dataAfter = dom.dataAfter();
+                        if (dataAfter == null) {
+                            MappingUtils.deleteMapEntry(((ServiceEndPoint) dom.dataBefore()).getUuid());
                             MappingUtils.afficheMap();
-                            break;
+                            continue;
                         }
-
                         // to add new child entry
-                        if (dom.dataType().toString().compareTo("interface org.opendaylight.yang.gen.v1.urn.opendayl"
-                            + "ight.params.xml.ns.yang.tapi.rev180928.service._interface.points.ServiceEndPoint") == 0
-                            && dom.dataBefore() == null) {
-                            DataObject dataObject = dom.dataAfter();
-                            ServiceEndPoint sep = null;
-                            sep = (ServiceEndPoint) dataObject;
-                            MappingUtils.addMapSEP(sep);
-                            MappingUtils.afficheMap();
-                        } else {
+                        if (dom.dataBefore() != null || dom.dataType().toString().compareTo(SE_JAVA_INTF) != 0) {
                             LOG.error("data input type is not a valid 'service-end-point'");
+                            continue;
                         }
-                        break;
+                        MappingUtils.addMapSEP((ServiceEndPoint) dataAfter);
+                        MappingUtils.afficheMap();
                     }
                     break;
                 case DELETE:
index ab12e4e16cbe54762b7f552ce7bad1d34a33aae0..7157139fb71dade5c803cd443fea4f4bbffbba7c 100644 (file)
@@ -37,7 +37,7 @@
       <dependency>
         <groupId>org.opendaylight.netconf</groupId>
         <artifactId>netconf-artifacts</artifactId>
-        <version>7.0.3</version>
+        <version>7.0.4</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>