Adding Copyright Missing files
[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;\r
20 \r
21 import com.google.gson.Gson;\r
22 \r
23 import java.util.Date;\r
24 import java.util.Map;\r
25 \r
26 import javax.persistence.Column;\r
27 import javax.persistence.Entity;\r
28 import javax.persistence.GeneratedValue;\r
29 import javax.persistence.GenerationType;\r
30 import javax.persistence.Id;\r
31 import javax.persistence.Table;\r
32 import javax.persistence.Transient;\r
33 import javax.persistence.UniqueConstraint;\r
34 \r
35 /**\r
36  * \r
37  * @version 1.0\r
38  * @since May 21, 2020\r
39  * @author Prashant Kumar\r
40  */\r
41 \r
42 @Entity\r
43 @Table(name = "VES_DEVICE_DATA",\r
44     uniqueConstraints = @UniqueConstraint(columnNames = {"DEVICE_ID", "ATTR_GROUP"}))\r
45 public class DeviceDataEntity {\r
46 \r
47   @Id\r
48   @Column(name = "ID")\r
49   @GeneratedValue(strategy = GenerationType.AUTO)\r
50   private Long id;\r
51 \r
52   @Column(name = "DEVICE_ID", length = 30)\r
53   private String deviceId;\r
54 \r
55   @Column(name = "ENODEB_NAME", length = 100)\r
56   private String eNodeBName;\r
57 \r
58   @Column(name = "OUI", length = 30)\r
59   private String oui;\r
60 \r
61   @Column(name = "PRODUCT_CLASS", length = 100)\r
62   private String productClass;\r
63 \r
64   @Column(name = "ATTR_JSON", length = 4000)\r
65   private String attrJson;\r
66 \r
67   @Column(name = "ATTR_GROUP", length = 255)\r
68   private String attrGroup;\r
69 \r
70   @Column(name = "LAST_UPDATED_TIME")\r
71   private Date lastUpdateTime = new Date();\r
72 \r
73   public Long getId() {\r
74     return id;\r
75   }\r
76 \r
77   public void setId(Long id) {\r
78     this.id = id;\r
79   }\r
80 \r
81   public String getDeviceId() {\r
82     return deviceId;\r
83   }\r
84 \r
85   public void setDeviceId(String deviceId) {\r
86     this.deviceId = deviceId;\r
87   }\r
88 \r
89   public String geteNodeBName() {\r
90     return eNodeBName;\r
91   }\r
92 \r
93   public void seteNodeBName(String eNodeBName) {\r
94     this.eNodeBName = eNodeBName;\r
95   }\r
96 \r
97   public String getOui() {\r
98     return oui;\r
99   }\r
100 \r
101   public void setOui(String oui) {\r
102     this.oui = oui;\r
103   }\r
104 \r
105   public String getProductClass() {\r
106     return productClass;\r
107   }\r
108 \r
109   public void setProductClass(String productClass) {\r
110     this.productClass = productClass;\r
111   }\r
112 \r
113   public String getAttrJson() {\r
114     return attrJson;\r
115   }\r
116 \r
117   public void setAttrJson(String attrJson) {\r
118     this.attrJson = attrJson;\r
119   }\r
120 \r
121   public String getAttrGroup() {\r
122     return attrGroup;\r
123   }\r
124 \r
125   public void setAttrGroup(String attrGroup) {\r
126     this.attrGroup = attrGroup;\r
127   }\r
128 \r
129   public Date getLastUpdateTime() {\r
130     return lastUpdateTime;\r
131   }\r
132 \r
133   public void setLastUpdateTime(Date lastUpdateTime) {\r
134     this.lastUpdateTime = lastUpdateTime;\r
135   }\r
136 \r
137   @Transient\r
138   public void setAttributesMap(Map<String, String> attributesMap) {\r
139     if (null == attributesMap || attributesMap.isEmpty()) {\r
140       return;\r
141     }\r
142 \r
143     this.attrJson = new Gson().toJson(attributesMap);\r
144 \r
145   }\r
146 \r
147   @Transient\r
148   public Map<String, String> getAttributesMap() {\r
149     Map<String, String> attributesMap = null;\r
150     if (null != this.attrJson && !this.attrJson.isEmpty()) {\r
151       attributesMap = new Gson().fromJson(this.attrJson, Map.class);\r
152     }\r
153     return attributesMap;\r
154   }\r
155 }\r