add new devicemanager
[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      * @param nodeName name of mountpoint
46      * @param counter of notification
47      * @param timeStamp from ne
48      * @param objectIdRef from ne
49      * @param attributeName from ne
50      * @param newValue from ne
51      */
52     public AttributeValueChangedNotificationXml(String nodeName, Integer counter, InternalDateAndTime timeStamp, String objectIdRef,
53             String attributeName, String newValue) {
54         super(nodeName, counter, timeStamp, objectIdRef);
55         this.attributeName = attributeName;
56         this.newValue = newValue;
57     }
58
59     public AttributeValueChangedNotificationXml(EventlogEntity eventlogEntitiy) {
60         this(eventlogEntitiy.getNodeId(), eventlogEntitiy.getCounter(),
61                 InternalDateAndTime.valueOf(eventlogEntitiy.getTimestamp()), eventlogEntitiy.getObjectId(),
62                 eventlogEntitiy.getAttributeName(), eventlogEntitiy.getNewValue());
63     }
64
65
66     public String getAttributeName() {
67         return attributeName;
68     }
69
70     public String getNewValue() {
71         return newValue;
72     }
73
74     @Override
75     public String getEventType() {
76         return EVENTTYPE;
77     }
78
79     public EventlogEntity getEventlogEntity() {
80         return new EventlogBuilder().setAttributeName(attributeName).setNewValue(newValue)
81                 .setCounter(Integer.valueOf(this.getCounter()))
82                 .setNodeId(this.getNodeName()).setObjectId(this.getObjectId())
83                 .setTimestamp(new DateAndTime(this.getTimeStamp())).setSourceType(SourceType.Netconf).build();
84     }
85
86 }