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