f316686d65ec1172811e626881b870cf65779c3d
[ccsdk/features.git] / sdnr / wt / devicemanager / provider / src / main / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / impl / xml / AttributeValueChangedNotificationXml.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.impl.xml;
19
20 import javax.xml.bind.annotation.XmlElement;
21 import javax.xml.bind.annotation.XmlRootElement;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
27
28 @XmlRootElement(name = "AttributeValueChangedNotification")
29 public class AttributeValueChangedNotificationXml extends MwtNotificationBase implements GetEventType {
30
31     private static String EVENTTYPE = "AttributeValueChangedNotification";
32
33     @XmlElement(name = "attributeName")
34     private String attributeName;
35
36     @XmlElement(name = "newValue")
37     private String newValue;
38
39     public AttributeValueChangedNotificationXml() {
40
41     }
42
43     /**
44      * Normalized notification
45      * 
46      * @param nodeName name of mountpoint
47      * @param counter of notification
48      * @param timeStamp from ne
49      * @param objectIdRef from ne
50      * @param attributeName from ne
51      * @param newValue from ne
52      */
53     public AttributeValueChangedNotificationXml(String nodeName, Integer counter, InternalDateAndTime timeStamp,
54             String objectIdRef, String attributeName, String newValue) {
55         super(nodeName, counter, timeStamp, objectIdRef);
56         this.attributeName = attributeName;
57         this.newValue = newValue;
58     }
59
60     public AttributeValueChangedNotificationXml(EventlogEntity eventlogEntitiy) {
61         this(eventlogEntitiy.getNodeId(), eventlogEntitiy.getCounter(),
62                 InternalDateAndTime.valueOf(eventlogEntitiy.getTimestamp()), eventlogEntitiy.getObjectId(),
63                 eventlogEntitiy.getAttributeName(), eventlogEntitiy.getNewValue());
64     }
65
66
67     public String getAttributeName() {
68         return attributeName;
69     }
70
71     public String getNewValue() {
72         return newValue;
73     }
74
75     @Override
76     public String getEventType() {
77         return EVENTTYPE;
78     }
79
80     public EventlogEntity getEventlogEntity() {
81         return new EventlogBuilder().setAttributeName(attributeName).setNewValue(newValue)
82                 .setCounter(Integer.valueOf(this.getCounter())).setNodeId(this.getNodeName())
83                 .setObjectId(this.getObjectId()).setTimestamp(new DateAndTime(this.getTimeStamp()))
84                 .setSourceType(SourceType.Netconf).build();
85     }
86
87 }