Migration to TAPI 2.4 Step2
[transportpce.git] / nbinotifications / src / main / java / org / opendaylight / transportpce / nbinotifications / serialization / NotificationServiceDeserializer.java
index 81f02ac9451f230d62e4dfdf127b8c90b339efb8..1a6f996f6119e162ce739f5eb6f88969210806a9 100644 (file)
@@ -11,17 +11,17 @@ import java.nio.charset.StandardCharsets;
 import java.util.Map;
 import org.apache.kafka.common.serialization.Deserializer;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.service.output.NotificationService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.get.notifications.service.output.NotificationServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationProcessService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.get.notifications.process.service.output.NotificationsProcessService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.get.notifications.process.service.output.NotificationsProcessServiceBuilder;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NotificationServiceDeserializer implements Deserializer<NotificationService> {
+public class NotificationServiceDeserializer implements Deserializer<NotificationsProcessService> {
     private static final Logger LOG = LoggerFactory.getLogger(NotificationServiceDeserializer.class);
-    private JsonStringConverter<org.opendaylight.yang.gen.v1
-        .nbi.notifications.rev210628.NotificationService> converter;
+    private JsonStringConverter<NotificationProcessService> converter;
 
     @SuppressWarnings("unchecked")
     @Override
@@ -29,39 +29,44 @@ public class NotificationServiceDeserializer implements Deserializer<Notificatio
         LOG.info("Deserializer configuration {}", configs);
         if (configs.containsKey(ConfigConstants.CONVERTER)
                 && configs.get(ConfigConstants.CONVERTER) instanceof JsonStringConverter<?>) {
-            converter = (JsonStringConverter<org.opendaylight.yang.gen.v1
-                    .nbi.notifications.rev210628.NotificationService>) configs
-                    .get(ConfigConstants.CONVERTER);
+            converter = (JsonStringConverter<NotificationProcessService>) configs.get(ConfigConstants.CONVERTER);
         }
     }
 
     @Override
-    public NotificationService deserialize(String topic, byte[] data) {
+    public NotificationsProcessService deserialize(String topic, byte[] data) {
         if (converter == null) {
             throw new IllegalArgumentException(
                     "Converter should be configured through configure method of deserializer");
         }
         String value = new String(data, StandardCharsets.UTF_8);
         // The message published is
-        // org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationService
+        // org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService
         // we have to map it to
         // org.opendaylight.yang.gen
-        // .v1.nbi.notifications.rev201130.get.notifications.service.output.NotificationService
-        org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService mappedString = converter
-                .createDataObjectFromJsonString(YangInstanceIdentifier.of(
-                        org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService.QNAME),
-                        value,
-                        JSONCodecFactorySupplier.RFC7951);
-        if (mappedString != null) {
-            LOG.info("Reading event {}", mappedString);
-            return new NotificationServiceBuilder().setCommonId(mappedString.getCommonId())
-                    .setConnectionType(mappedString.getConnectionType()).setMessage(mappedString.getMessage())
-                    .setOperationalState(mappedString.getOperationalState())
-                    .setResponseFailed(mappedString.getResponseFailed()).setServiceName(mappedString.getServiceName())
-                    .setServiceAEnd(mappedString.getServiceAEnd()).setServiceZEnd(mappedString.getServiceZEnd())
+        // .v1.nbi.notifications.rev210813.get.notifications.service.output.NotificationService
+        NotificationProcessService mappedString = converter.createDataObjectFromJsonString(
+                YangInstanceIdentifier.of(NotificationProcessService.QNAME), value, JSONCodecFactorySupplier.RFC7951);
+        if (mappedString == null) {
+            return null;
+        }
+        LOG.info("Reading event {}", mappedString);
+        NotificationsProcessServiceBuilder notificationsProcessServiceBuilder = new NotificationsProcessServiceBuilder()
+                .setCommonId(mappedString.getCommonId())
+                .setConnectionType(mappedString.getConnectionType())
+                .setMessage(mappedString.getMessage())
+                .setOperationalState(mappedString.getOperationalState())
+                .setResponseFailed(mappedString.getResponseFailed())
+                .setServiceName(mappedString.getServiceName())
+                .setServiceAEnd(mappedString.getServiceAEnd())
+                .setServiceZEnd(mappedString.getServiceZEnd());
+        if (mappedString.getIsTempService()) {
+            return notificationsProcessServiceBuilder
+                    .setAToZ(mappedString.getAToZ())
+                    .setZToA(mappedString.getZToA())
                     .build();
         }
-        return null;
+        return notificationsProcessServiceBuilder.build();
     }
 
 }