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