YANG Model update for A1 Adapter
[ccsdk/features.git] / sdnr / wt / devicemanager / provider / src / main / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / base / netconf / wrapperc / WrapperMicrowaveModelRev180907.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.base.netconf.wrapperc;
19
20
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 import java.lang.reflect.Constructor;
26 import java.lang.reflect.InvocationTargetException;
27 import java.util.ArrayList;
28 import java.util.List;
29
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
31 import org.opendaylight.yangtools.yang.binding.NotificationListener;
32 import org.opendaylight.yangtools.yang.common.QName;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementCoreData;
36 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType1211;
37 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName;
38 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
39 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
40 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
41 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
42 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
43 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
44
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceCurrentProblemTypeG;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceDiversityCurrentProblemTypeG;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceHistoricalPerformanceTypeG;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerCurrentProblemTypeG;
52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerHistoricalPerformanceTypeG;
53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MicrowaveModelListener;
54 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPac;
55 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPacKey;
56 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePac;
57 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePacKey;
58 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPac;
59 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPacKey;
60 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePac;
61 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePacKey;
62 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePac;
63 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePacKey;
64 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPac;
65 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPacKey;
66 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.StructureCurrentProblemTypeG;
67 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
68 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceConfiguration;
69 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceCurrentProblems;
70 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
71 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
72 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
73 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
74 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
75 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.tdm.container.pac.TdmContainerCurrentProblems;
76 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AttributeValueChangedNotification;
77 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ObjectCreationNotification;
78 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ObjectDeletionNotification;
79 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ProblemNotification;
80
81
82 public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, MicrowaveModelListener {
83
84     private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev180907.class);
85
86     public static final QName QNAME = MwAirInterfacePac.QNAME;
87
88
89     private ONFCoreNetworkElementCoreData coreData;
90
91         private OnfMicrowaveModelNotification microwaveModelListener;
92
93
94     /*-----------------------------------------------------------------------------
95      * Setter/Getter
96      */
97
98     @Override
99     public void setCoreData(ONFCoreNetworkElementCoreData coreData) {
100                 this.coreData = coreData;
101         }
102
103         public ONFCoreNetworkElementCoreData getCoreData() {
104                 return coreData;
105         }
106
107         @Override
108         public void setOnfMicrowaveModelListener(OnfMicrowaveModelNotification microwaveModelListener) {
109                 this.microwaveModelListener = microwaveModelListener;
110         }
111
112         @SuppressWarnings("unchecked")
113         @Override
114         public <T extends NotificationListener> T getNotificationListener() {
115                 return (T) this;
116         }
117
118     /*-----------------------------------------------------------------------------
119      * Interfacefunctions
120      */
121
122     @Override
123     public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
124                 List<ProblemNotificationXml> resultList) {
125
126         switch (lpName) {
127         case MWAirInterface:
128                 readTheFaultsOfMwAirInterfacePac(uuid, resultList);
129                 break;
130
131         case EthernetContainer12:
132                 readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
133                 break;
134
135         case TDMContainer:
136                 readTheFaultsOfMwTdmContainerPac(uuid, resultList);
137                 break;
138
139         case Structure:
140                 if (lpClass == MwHybridMwStructurePac.class) {
141                         readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
142
143                 } else if (lpClass == MwAirInterfaceDiversityPac.class) {
144                         readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
145
146                 } else if (lpClass == MwPureEthernetStructurePac.class) {
147                         readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
148
149                 } else {
150                         LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
151                 }
152                 break;
153         case Ethernet:
154             // No alarms supported
155             break;
156         case EthernetContainer10:
157         default:
158             LOG.warn("Unassigned or not expected lp in model {}", lpName);
159         }
160     }
161
162         @Override
163     public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) {
164         switch (lpName) {
165         case MWAirInterface:
166                 return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp);
167
168         case EthernetContainer12:
169                 return readTheHistoricalPerformanceDataOfEthernetContainer(lp);
170
171         case EthernetContainer10:
172         case EthernetPhysical:
173         case Ethernet:
174         case TDMContainer:
175         case Structure:
176         case Unknown:
177                 LOG.debug("Do not read HistoricalPM data for {} {}", lpName, lp.getUuid().getValue());
178                 break;
179         }
180         return new ArrayList<>();
181     }
182
183         @Override
184     public Class<?> getClassForLtpExtension(QName qName) {
185         Class<?> res = null;
186         if (qName.equals(MwAirInterfacePac.QNAME)) {
187             res = MwAirInterfacePac.class;
188         } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
189             res = MwAirInterfaceDiversityPac.class;
190         } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
191             res = MwPureEthernetStructurePac.class;
192         } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
193             res = MwHybridMwStructurePac.class;
194         } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
195             res = MwEthernetContainerPac.class;
196         } else if (qName.equals(MwTdmContainerPac.QNAME)) {
197             res = MwTdmContainerPac.class;
198         }
199         LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
200                 return res;
201         }
202
203     /*-----------------------------------------------------------------------------
204      * Reading problems for specific interface pacs
205      */
206
207     /**
208      * Read problems of specific interfaces
209      *
210      * @param uuId Universal Id String of the interface
211      * @return number of alarms
212      */
213     private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
214             List<ProblemNotificationXml> resultList) {
215
216         final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
217         // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class;
218         // final Class<AirInterfaceCurrentProblems> clazzProblems =
219         // AirInterfaceCurrentProblems.class;
220         // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem =
221         // AirInterfaceCurrentProblemTypeG.class;
222
223         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
224                         coreData.getMountpoint(), interfacePacUuid.getValue());
225
226         // Step 2.2: construct data and the relative iid
227         InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
228                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
229                 .child(AirInterfaceCurrentProblems.class).build();
230
231         // Step 2.3: read to the config data store
232         AirInterfaceCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
233                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
234
235         if (problems == null) {
236             LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
237         } else if (problems.getCurrentProblemList() == null) {
238             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
239         } else {
240             for (AirInterfaceCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
241                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
242                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
243                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
244             }
245         }
246         return resultList;
247     }
248
249     /**
250      * Read problems of specific interfaces
251      *
252      * @param uuId Universal index of Interfacepac
253      * @return number of alarms
254      */
255     private List<ProblemNotificationXml> readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
256             List<ProblemNotificationXml> resultList) {
257
258         final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
259         // final Class<MwEthernetContainerPacKey> clazzPacKey =
260         // MwEthernetContainerPacKey.class;
261         // final Class<EthernetContainerCurrentProblems> clazzProblems =
262         // EthernetContainerCurrentProblems.class;
263         // final Class<ContainerCurrentProblemTypeG> clazzProblem =
264         // ContainerCurrentProblemTypeG.class;
265
266         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
267                 coreData.getMountpoint(), interfacePacUuid.getValue());
268
269         InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
270                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
271                 .child(EthernetContainerCurrentProblems.class).build();
272
273         EthernetContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
274                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
275         if (problems == null) {
276             LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
277         } else if (problems.getCurrentProblemList() == null) {
278             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
279         } else {
280             for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
281                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
282                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
283                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
284             }
285         }
286         return resultList;
287     }
288
289     /**
290      * Read problems of specific interfaces
291      *
292      * @param uuId Universal index of Interfacepac
293      * @return number of alarms
294      */
295     private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
296             List<ProblemNotificationXml> resultList) {
297
298         final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
299         // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey =
300         // MwAirInterfaceDiversityPacKey.class;
301         final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
302         // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem =
303         // AirInterfaceDiversityCurrentProblemTypeG.class;
304
305         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
306                 coreData.getMountpoint(), interfacePacUuid.getValue());
307
308         InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
309                 .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
310
311         AirInterfaceDiversityCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
312                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
313         if (problems == null) {
314             LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
315         } else if (problems.getCurrentProblemList() == null) {
316             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
317         } else {
318             for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
319                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
320                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
321                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
322             }
323         }
324         return resultList;
325     }
326
327     /**
328      * Read problems of specific interfaces
329      *
330      * @param uuId Universal index of Interfacepac
331      * @return number of alarms
332      */
333     private List<ProblemNotificationXml> readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
334             List<ProblemNotificationXml> resultList) {
335
336         final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
337         // final Class<MwPureEthernetStructurePacKey> clazzPacKey =
338         // MwPureEthernetStructurePacKey.class;
339         final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
340         // final Class<StructureCurrentProblemTypeG> clazzProblem =
341         // StructureCurrentProblemTypeG.class;
342
343         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
344                 coreData.getMountpoint(), interfacePacUuid.getValue());
345
346         InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
347                 .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
348
349         PureEthernetStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
350                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
351         if (problems == null) {
352             LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
353         } else if (problems.getCurrentProblemList() == null) {
354             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
355         } else {
356             for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
357                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
358                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
359                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
360             }
361         }
362         return resultList;
363     }
364
365     /**
366      * Read problems of specific interfaces
367      *
368      * @param uuId Universal index of Interfacepac
369      * @return number of alarms
370      */
371     private List<ProblemNotificationXml> readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
372             List<ProblemNotificationXml> resultList) {
373
374         final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
375         // final Class<MwHybridMwStructurePacKey> clazzPacKey =
376         // MwHybridMwStructurePacKey.class;
377         final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
378         // final Class<HybridMwStructureCurrentProblemsG> clazzProblem =
379         // HybridMwStructureCurrentProblemsG.class;
380
381         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
382                 coreData.getMountpoint(), interfacePacUuid.getValue());
383
384         InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
385                 .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
386
387         HybridMwStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
388                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
389         if (problems == null) {
390             LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
391         } else if (problems.getCurrentProblemList() == null) {
392             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
393         } else {
394             for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
395                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
396                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
397                         problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
398             }
399         }
400         return resultList;
401     }
402
403     /**
404      * Read problems of specific interfaces. TODO Goal for future implementation
405      * without usage of explicit new. Key is generated by newInstance() function
406      * here to verify this approach.
407      *
408      * @param uuId Universal index of Interfacepac
409      * @return number of alarms
410      * @throws SecurityException
411      * @throws NoSuchMethodException
412      * @throws InvocationTargetException
413      * @throws IllegalArgumentException
414      * @throws IllegalAccessException
415      * @throws InstantiationException
416      */
417     private List<ProblemNotificationXml> readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
418             List<ProblemNotificationXml> resultList) {
419
420         final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
421         final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
422         final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
423         // final Class<ContainerCurrentProblemTypeG> clazzProblem =
424         // ContainerCurrentProblemTypeG.class;
425
426         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
427                 coreData.getMountpoint(), interfacePacUuid.getValue());
428
429         try {
430             // -- Specific part 1
431             Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
432             InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
433                     .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
434
435             // -- Specific part 2
436             TdmContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
437                     LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
438             if (problems == null) {
439                 LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
440             } else if (problems.getCurrentProblemList() == null) {
441                 LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
442             } else {
443                 // -- Specific part 3
444                 for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
445                     resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
446                             problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
447                             problem.getSequenceNumber().toString(),
448                             InternalDateAndTime.valueOf(problem.getTimeStamp())));
449                 }
450             }
451         } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
452                 | IllegalArgumentException | InvocationTargetException e) {
453             LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
454         }
455         return resultList;
456     }
457
458     /*-----------------------------------------------------------------------------
459      * Performance related data
460      */
461
462     /**
463      * PM MwAirInterfacePac
464      *
465      * @param lp
466      * @return
467      */
468     private List<ExtendedAirInterfaceHistoricalPerformanceType1211> readTheHistoricalPerformanceDataOfMwAirInterfacePac(
469             Lp lp) {
470
471         String uuId = lp.getUuid().getValue();
472
473         List<ExtendedAirInterfaceHistoricalPerformanceType1211> resultList = new ArrayList<>();
474         LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), uuId);
475         // ----
476         UniversalId mwAirInterfacePacuuId = new UniversalId(uuId);
477         // Step 2.1: construct data and the relative iid
478         InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
479                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
480                 .child(AirInterfaceConfiguration.class).build();
481         AirInterfaceConfiguration airConfiguration = GenericTransactionUtils.readData(coreData.getDataBroker(),
482                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
483
484         if (airConfiguration == null) {
485             LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
486
487         } else {
488             // Step 2.2: construct data and the relative iid
489             InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
490                     .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
491                     .child(AirInterfaceHistoricalPerformances.class).build();
492
493             // Step 2.3: read to the config data store
494             AirInterfaceHistoricalPerformances airHistoricalPerformanceData = GenericTransactionUtils.readData(
495                         coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
496
497             if (airHistoricalPerformanceData == null) {
498                 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
499                         mwAirInterfacePacuuId);
500             } else {
501                 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
502                 List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
503                         .getHistoricalPerformanceDataList();
504                 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
505                         airHistPMList.size());
506                 if (airHistPMList != null) {
507                     for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
508                             .getHistoricalPerformanceDataList()) {
509                         resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType1211(pmRecord, airConfiguration));
510                     }
511                 }
512             }
513         }
514         LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size());
515         return resultList;
516     }
517
518     private List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) {
519
520         final String myName = "MWEthernetContainerPac";
521         String uuId = lp.getUuid().getValue();
522
523         List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>();
524         LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, uuId);
525         // ----
526         UniversalId ethContainerPacuuId = new UniversalId(uuId);
527         // Step 2.2: construct data and the relative iid
528         InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
529                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
530                 .child(EthernetContainerHistoricalPerformances.class).build();
531
532         // Step 2.3: read to the config data store
533         EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = GenericTransactionUtils
534                 .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
535
536         if (ethContainerHistoricalPerformanceData == null) {
537             LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
538         } else {
539             // import
540             // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList
541              List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
542                     .getHistoricalPerformanceDataList();
543             LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
544             if (airHistPMList != null) {
545                 for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
546                     resultList.add(pmRecord);
547                 }
548             }
549         }
550         LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size());
551         return resultList;
552     }
553
554     @Override
555     public void onObjectCreationNotification(ObjectCreationNotification notification) {
556         LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
557
558         ObjectCreationNotificationXml notificationXml = new ObjectCreationNotificationXml(coreData.getMountpoint(),
559                 notification.getCounter().toString(),
560                 InternalDateAndTime.valueOf(notification.getTimeStamp()),
561                 notification.getObjectIdRef().getValue());
562         microwaveModelListener.onObjectCreationNotification(notificationXml);
563         }
564
565     @Override
566     public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
567         LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
568
569         ObjectDeletionNotificationXml notificationXml = new ObjectDeletionNotificationXml(coreData.getMountpoint(),
570                 notification.getCounter().toString(),
571                 InternalDateAndTime.valueOf(notification.getTimeStamp()),
572                 notification.getObjectIdRef().getValue()
573                 );
574         microwaveModelListener.onObjectDeletionNotification(notificationXml);
575         }
576
577     @Override
578     public void onProblemNotification(ProblemNotification notification) {
579
580         LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
581
582         ProblemNotificationXml notificationXml = new ProblemNotificationXml(coreData.getMountpoint(), notification.getObjectIdRef().getValue(),
583                 notification.getProblem(), InternalSeverity.valueOf(notification.getSeverity()),
584                 notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp()));
585
586         microwaveModelListener.onProblemNotification(notificationXml);
587         }
588
589     @Override
590     public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
591         LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
592
593         AttributeValueChangedNotificationXml notificationXml = new AttributeValueChangedNotificationXml(coreData.getMountpoint(),
594                 String.valueOf(notification.getCounter()), InternalDateAndTime.valueOf(notification.getTimeStamp()),
595                 notification.getObjectIdRef().getValue(), notification.getAttributeName(), notification.getNewValue());
596
597         microwaveModelListener.onAttributeValueChangedNotification(notificationXml);
598         }
599
600 }