Refactor some small TAPI rpcs 02/111102/6
authorguillaume.lambert <guillaume.lambert@orange.com>
Wed, 27 Mar 2024 08:59:15 +0000 (09:59 +0100)
committerGilles Thouenon <gilles.thouenon@orange.com>
Wed, 3 Apr 2024 16:04:17 +0000 (18:04 +0200)
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I5ed08975b462d2e01eb053ddd2f30d4a7d6c3a17

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

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();
     }