Development of NETCONF RPCs for tr-069 adapter to
[oam/tr069-adapter.git] / ves-agent / src / main / java / org / commscope / tr069adapter / vesagent / entity / DeviceDataEntity.java
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : tr-069-adapter
4  * =================================================================================================
5  * Copyright (C) 2020 CommScope Inc Intellectual Property.
6  * =================================================================================================
7  * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
9  * may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ===============LICENSE_END=======================================================================
17  */
18
19 package org.commscope.tr069adapter.vesagent.entity;
20
21 import com.google.gson.Gson;
22
23 import java.util.Date;
24 import java.util.Map;
25
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.GeneratedValue;
29 import javax.persistence.GenerationType;
30 import javax.persistence.Id;
31 import javax.persistence.Table;
32 import javax.persistence.Transient;
33 import javax.persistence.UniqueConstraint;
34
35 @Entity
36 @Table(name = "VES_DEVICE_DATA",
37     uniqueConstraints = @UniqueConstraint(columnNames = {"DEVICE_ID", "ATTR_GROUP"}))
38 public class DeviceDataEntity {
39
40   @Id
41   @Column(name = "ID")
42   @GeneratedValue(strategy = GenerationType.AUTO)
43   private Long id;
44
45   @Column(name = "DEVICE_ID", length = 30)
46   private String deviceId;
47
48   @Column(name = "ENODEB_NAME", length = 100)
49   private String eNodeBName;
50
51   @Column(name = "OUI", length = 30)
52   private String oui;
53
54   @Column(name = "PRODUCT_CLASS", length = 100)
55   private String productClass;
56
57   @Column(name = "ATTR_JSON", length = 4000)
58   private String attrJson;
59
60   @Column(name = "ATTR_GROUP", length = 255)
61   private String attrGroup;
62
63   @Column(name = "LAST_UPDATED_TIME")
64   private Date lastUpdateTime = new Date();
65
66   public Long getId() {
67     return id;
68   }
69
70   public void setId(Long id) {
71     this.id = id;
72   }
73
74   public String getDeviceId() {
75     return deviceId;
76   }
77
78   public void setDeviceId(String deviceId) {
79     this.deviceId = deviceId;
80   }
81
82   public String geteNodeBName() {
83     return eNodeBName;
84   }
85
86   public void seteNodeBName(String eNodeBName) {
87     this.eNodeBName = eNodeBName;
88   }
89
90   public String getOui() {
91     return oui;
92   }
93
94   public void setOui(String oui) {
95     this.oui = oui;
96   }
97
98   public String getProductClass() {
99     return productClass;
100   }
101
102   public void setProductClass(String productClass) {
103     this.productClass = productClass;
104   }
105
106   public String getAttrJson() {
107     return attrJson;
108   }
109
110   public void setAttrJson(String attrJson) {
111     this.attrJson = attrJson;
112   }
113
114   public String getAttrGroup() {
115     return attrGroup;
116   }
117
118   public void setAttrGroup(String attrGroup) {
119     this.attrGroup = attrGroup;
120   }
121
122   public Date getLastUpdateTime() {
123     return lastUpdateTime;
124   }
125
126   public void setLastUpdateTime(Date lastUpdateTime) {
127     this.lastUpdateTime = lastUpdateTime;
128   }
129
130   @Transient
131   private Long startEpochMicrosec;
132
133   public Long getStartEpochMicrosec() {
134     return startEpochMicrosec;
135   }
136
137   public void setStartEpochMicrosec(Long startEpochMicrosec) {
138     this.startEpochMicrosec = startEpochMicrosec;
139   }
140
141   @Transient
142   public void setAttributesMap(Map<String, String> attributesMap) {
143     if (null == attributesMap || attributesMap.isEmpty()) {
144       return;
145     }
146
147     this.attrJson = new Gson().toJson(attributesMap);
148
149   }
150
151   @Transient
152   public Map<String, String> getAttributesMap() {
153     Map<String, String> attributesMap = null;
154     if (null != this.attrJson && !this.attrJson.isEmpty()) {
155       attributesMap = new Gson().fromJson(this.attrJson, Map.class);
156     }
157     return attributesMap;
158   }
159 }