Update devicemanager components
[ccsdk/features.git] / sdnr / wt / devicemanager-onf / provider / src / main / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / onf / ifpac / microwave / WrapperMicrowaveModelRev181010.java
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave;
19
20
21
22 import java.lang.reflect.Constructor;
23 import java.lang.reflect.InvocationTargetException;
24 import java.util.List;
25 import java.util.Optional;
26 import org.eclipse.jdt.annotation.NonNull;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.pm.PerformanceDataAirInterface181010Builder;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationWorker;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp;
35 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
37 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
38 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceCurrentProblemTypeG;
42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceDiversityCurrentProblemTypeG;
43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceHistoricalPerformanceTypeG;
44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AttributeValueChangedNotification;
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerCurrentProblemTypeG;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerHistoricalPerformanceTypeG;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MicrowaveModelListener;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPac;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPacKey;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePac;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePacKey;
52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPac;
53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPacKey;
54 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePac;
55 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePacKey;
56 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePac;
57 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePacKey;
58 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPac;
59 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPacKey;
60 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectCreationNotification;
61 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectDeletionNotification;
62 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ProblemNotification;
63 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.StructureCurrentProblemTypeG;
64 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
65 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfiguration;
66 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceCurrentProblems;
67 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
68 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
69 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
70 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
71 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
72 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.tdm.container.pac.TdmContainerCurrentProblems;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
75 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
76 import org.opendaylight.yangtools.yang.binding.NotificationListener;
77 import org.opendaylight.yangtools.yang.common.QName;
78 import org.slf4j.Logger;
79 import org.slf4j.LoggerFactory;
80
81
82 public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, MicrowaveModelListener {
83
84     private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev181010.class);
85
86     public static final QName QNAME = MwAirInterfacePac.QNAME;
87
88
89     private final NetconfAccessor acessor;
90     private final NotificationService microwaveModelListener;
91     private final TransactionUtils genericTransactionUtils;
92     private final String mountpointId;
93     private final @NonNull FaultService faultService;
94
95     private Optional<NotificationWorker<EventlogEntity>> notificationQueue;
96
97     /**
98      * Handle specific version of microwave model
99      * @param acessor to access device
100      * @param serviceProvider for devicemanager services
101      */
102     public WrapperMicrowaveModelRev181010(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) {
103         this.acessor = acessor;
104         this.genericTransactionUtils = acessor.getTransactionUtils();
105         this.mountpointId = acessor.getNodeId().getValue();
106         this.microwaveModelListener = serviceProvider.getNotificationService();
107         this.faultService = serviceProvider.getFaultService();
108         this.notificationQueue = Optional.empty();
109     }
110
111     /*-----------------------------------------------------------------------------
112      * Setter/Getter
113      */
114
115     @SuppressWarnings("unchecked")
116     @Override
117     public <T extends NotificationListener> T getNotificationListener() {
118         return (T) this;
119     }
120
121     @Override
122     public void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue) {
123         this.notificationQueue = Optional.of(notificationQueue);
124     }
125
126     /*-----------------------------------------------------------------------------
127      * Interfacefunctions
128      */
129
130     @Override
131     public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
132             FaultData resultList) {
133
134         switch (lpName) {
135         case MWAIRINTERFACE:
136             readTheFaultsOfMwAirInterfacePac(uuid, resultList);
137             break;
138
139         case ETHERNETCONTAINER12:
140             readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
141             break;
142
143         case TDMCONTAINER:
144             readTheFaultsOfMwTdmContainerPac(uuid, resultList);
145             break;
146
147         case STRUCTURE:
148             if (lpClass == MwHybridMwStructurePac.class) {
149                 readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
150
151             } else if (lpClass == MwAirInterfaceDiversityPac.class) {
152                 readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
153
154             } else if (lpClass == MwPureEthernetStructurePac.class) {
155                 readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
156
157             } else {
158                 LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
159             }
160             break;
161         case ETHERNET:
162             // No alarms supported
163             break;
164         case ETHERNETCONTAINER10:
165         default:
166             LOG.warn("Unassigned or not expected lp in model {}", lpName);
167         }
168     }
169
170     @Override
171     public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) {
172         PerformanceDataLtp res = new PerformanceDataLtp();
173         switch (lpName) {
174         case MWAIRINTERFACE:
175             return readAirInterfacePerformanceData(lp, res);
176
177         case ETHERNETCONTAINER12:
178             return readEthernetContainerPerformanceData(lp, res);
179
180         case ETHERNETCONTAINER10:
181         case ETHERNETPHYSICAL:
182         case ETHERNET:
183         case TDMCONTAINER:
184         case STRUCTURE:
185         case UNKNOWN:
186             LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue());
187         }
188         return res;
189     }
190
191     @Override
192     public Class<?> getClassForLtpExtension(QName qName) {
193         Class<?> res = null;
194         if (qName.equals(MwAirInterfacePac.QNAME)) {
195             res = MwAirInterfacePac.class;
196         } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
197             res = MwAirInterfaceDiversityPac.class;
198         } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
199             res = MwPureEthernetStructurePac.class;
200         } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
201             res = MwHybridMwStructurePac.class;
202         } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
203             res = MwEthernetContainerPac.class;
204         } else if (qName.equals(MwTdmContainerPac.QNAME)) {
205             res = MwTdmContainerPac.class;
206         }
207         LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
208         return res;
209     }
210
211     @Override
212     public void onObjectCreationNotification(ObjectCreationNotification notification) {
213         LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
214         if (notification != null) {
215             microwaveModelListener.creationNotification(acessor.getNodeId(), notification.getCounter(),
216                     notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue());
217         }
218     }
219
220     @Override
221     public void onObjectDeletionNotification( ObjectDeletionNotification notification) {
222         LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
223         if (notification != null) {
224             microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(),
225                     notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue());
226         }
227     }
228
229     @Override
230     public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
231         LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
232         EventlogEntity beventlogEntity = new EventlogBuilder().setNodeId(acessor.getNodeId().getValue())
233                 .setCounter(notification.getCounter()).setTimestamp(notification.getTimeStamp())
234                 .setObjectId(Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue())
235                 .setAttributeName(notification.getAttributeName()).setNewValue(notification.getNewValue()).build();
236         microwaveModelListener.eventNotification(beventlogEntity);
237         if (notificationQueue.isPresent()) {
238             notificationQueue.get().put(beventlogEntity);
239         }
240     }
241
242     @Override
243     public void onProblemNotification(ProblemNotification notification) {
244
245         LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
246
247         faultService.faultNotification(acessor.getNodeId(), notification.getCounter(),
248                 notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(),
249                 notification.getProblem(), mapSeverity(notification.getSeverity()));
250     }
251
252     /*-----------------------------------------------------------------------------
253      * Reading problems for specific interface pacs
254      */
255
256     /**
257      * Read problems of specific interfaces
258      *
259      * @param uuId Universal Id String of the interface
260      * @return number of alarms
261      */
262     private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
263             FaultData resultList) {
264
265         final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
266     
267         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
268                 mountpointId, interfacePacUuid.getValue());
269
270         // Step 2.2: construct data and the relative iid
271         InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
272                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
273                 .child(AirInterfaceCurrentProblems.class).build();
274
275         // Step 2.3: read to the config data store
276         AirInterfaceCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
277                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
278
279         if (problems == null) {
280             LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
281         } else if (problems.getCurrentProblemList() == null) {
282             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
283         } else {
284             for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
285                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
286                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
287             }
288         }
289         return resultList;
290     }
291
292     /**
293      * Read problems of specific interfaces
294      *
295      * @param uuId Universal index of Interfacepac
296      * @return number of alarms
297      */
298     private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
299             FaultData resultList) {
300
301         final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
302     
303         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
304                 mountpointId, interfacePacUuid.getValue());
305
306         InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
307                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
308                 .child(EthernetContainerCurrentProblems.class).build();
309
310         EthernetContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
311                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
312         if (problems == null) {
313             LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
314         } else if (problems.getCurrentProblemList() == null) {
315             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
316         } else {
317             for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
318                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
319                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
320             }
321         }
322         return resultList;
323     }
324
325     /**
326      * Read problems of specific interfaces
327      *
328      * @param uuId Universal index of Interfacepac
329      * @return number of alarms
330      */
331     private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
332             FaultData resultList) {
333
334         final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
335         final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
336      
337         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
338                 mountpointId, interfacePacUuid.getValue());
339
340         InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
341                 .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
342
343         AirInterfaceDiversityCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
344                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
345         if (problems == null) {
346             LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
347         } else if (problems.getCurrentProblemList() == null) {
348             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
349         } else {
350             for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
351                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
352                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
353             }
354         }
355         return resultList;
356     }
357
358     /**
359      * Read problems of specific interfaces
360      *
361      * @param uuId Universal index of Interfacepac
362      * @return number of alarms
363      */
364     private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
365             FaultData resultList) {
366
367         final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
368         final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
369      
370         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
371                 mountpointId, interfacePacUuid.getValue());
372
373         InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
374                 .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
375
376         PureEthernetStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
377                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
378         if (problems == null) {
379             LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
380         } else if (problems.getCurrentProblemList() == null) {
381             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
382         } else {
383             for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
384                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
385                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
386             }
387         }
388         return resultList;
389     }
390
391     /**
392      * Read problems of specific interfaces
393      *
394      * @param uuId Universal index of Interfacepac
395      * @return number of alarms
396      */
397     private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
398             FaultData resultList) {
399
400         final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
401         final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
402      
403         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
404                 mountpointId, interfacePacUuid.getValue());
405
406         InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
407                 .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
408
409         HybridMwStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
410                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
411         if (problems == null) {
412             LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
413         } else if (problems.getCurrentProblemList() == null) {
414             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
415         } else {
416             for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
417                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
418                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
419             }
420         }
421         return resultList;
422     }
423
424     /**
425      * Read problems of specific interfaces. TODO Goal for future implementation
426      * without usage of explicit new. Key is generated by newInstance() function
427      * here to verify this approach.
428      *
429      * @param uuId Universal index of Interfacepac
430      * @return number of alarms
431      * @throws SecurityException
432      * @throws NoSuchMethodException
433      * @throws InvocationTargetException
434      * @throws IllegalArgumentException
435      * @throws IllegalAccessException
436      * @throws InstantiationException
437      */
438     private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
439             FaultData resultList) {
440
441         final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
442         final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
443         final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
444       
445         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
446                 mountpointId, interfacePacUuid.getValue());
447
448         try {
449             // -- Specific part 1
450             Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
451             InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
452                     .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
453
454             // -- Specific part 2
455             TdmContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
456                     LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
457             if (problems == null) {
458                 LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
459             } else {
460                 // -- Specific part 3
461                 for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
462                     resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
463                             interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
464                 }
465             }
466         } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
467                 | IllegalArgumentException | InvocationTargetException e) {
468             LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
469         }
470         return resultList;
471     }
472
473     /*-----------------------------------------------------------------------------
474      * Performance related data
475      */
476
477     /**
478      * Read and add performance data
479      * @param lp to read from
480      * @param result Object to be filled with data
481      * @return result
482      */
483     private @NonNull PerformanceDataLtp readAirInterfacePerformanceData(Lp lp, PerformanceDataLtp result) {
484
485         LOG.debug("DBRead Get {} MWAirInterfacePac: {}", acessor.getNodeId(), lp.getUuid());
486         // ----
487         UniversalId mwAirInterfacePacuuId = lp.getUuid();
488         // Step 2.1: construct data and the relative iid
489         InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
490                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
491                 .child(AirInterfaceConfiguration.class).build();
492         AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(),
493                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
494
495         if (airConfiguration == null) {
496             LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
497
498         } else {
499             // Step 2.2: construct data and the relative iid
500             InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
501                     .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
502                     .child(AirInterfaceHistoricalPerformances.class).build();
503
504             // Step 2.3: read to the config data store
505             AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData(
506                     acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
507
508             if (airHistoricalPerformanceData == null) {
509                 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
510                         mwAirInterfacePacuuId);
511             } else {
512                 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
513                 List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
514                         .nonnullHistoricalPerformanceDataList();
515                 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
516                         airHistPMList.size());
517                 for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
518                         .nonnullHistoricalPerformanceDataList()) {
519                     result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord, airConfiguration));
520                 }
521             }
522         }
523         LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, result.size());
524         return result;
525     }
526
527     private @NonNull PerformanceDataLtp readEthernetContainerPerformanceData(Lp lp, PerformanceDataLtp result) {
528         final String myName = "MWEthernetContainerPac";
529
530         LOG.debug("DBRead Get {} : {}", mountpointId, myName, lp.getUuid());
531         // ----
532         UniversalId ethContainerPacuuId = lp.getUuid();
533         // Step 2.2: construct data and the relative iid
534         InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
535                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
536                 .child(EthernetContainerHistoricalPerformances.class).build();
537
538         // Step 2.3: read to the config data store
539         EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = acessor.getTransactionUtils()
540                 .readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
541
542         if (ethContainerHistoricalPerformanceData == null) {
543             LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
544         } else {
545             List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
546                     .nonnullHistoricalPerformanceDataList();
547             LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
548             for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
549                 result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord));
550             }
551         }
552         LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, result.size());
553         return result;
554     }
555
556     public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity( SeverityType severity) {
557
558         Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res =
559                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.forName(severity.name());
560         return res.orElse(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);
561     }
562
563
564
565 }