Merge "JUnit/SONAR/Checkstyle in ONAP-REST"
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / ConfigurationDataEntity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.rest.jpa;
23
24 import com.fasterxml.jackson.annotation.JsonBackReference;
25
26 /*
27  */
28 import java.io.Serializable;
29 import java.util.Date;
30
31 import javax.persistence.Column;
32 import javax.persistence.Entity;
33 import javax.persistence.GeneratedValue;
34 import javax.persistence.GenerationType;
35 import javax.persistence.Id;
36 import javax.persistence.Lob;
37 import javax.persistence.NamedQueries;
38 import javax.persistence.NamedQuery;
39 import javax.persistence.PrePersist;
40 import javax.persistence.PreUpdate;
41 import javax.persistence.Table;
42 import javax.persistence.Temporal;
43 import javax.persistence.TemporalType;
44 import javax.persistence.Version;
45 /*
46  * The Entity class to persist a policy object configuration data
47  */
48
49 import lombok.EqualsAndHashCode;
50
51 /**
52  * The Class ConfigurationDataEntity.
53  */
54 // @formatter:off
55 @Entity
56 @Table(name = "ConfigurationDataEntity")
57 @NamedQueries(
58     {
59         @NamedQuery(name = "ConfigurationDataEntity.findAll", query = "SELECT e FROM ConfigurationDataEntity e "),
60         @NamedQuery(name = "ConfigurationDataEntity.deleteAll", query = "DELETE FROM ConfigurationDataEntity WHERE 1=1")
61     }
62 )
63 @EqualsAndHashCode
64 //@formatter:on
65
66 public class ConfigurationDataEntity implements Serializable {
67     private static final long serialVersionUID = 1L;
68
69     @Id
70     @GeneratedValue(strategy = GenerationType.AUTO)
71     @Column(name = "configurationDataId")
72     @JsonBackReference
73     private long configurationDataId;
74
75     @Column(name = "configurationName", nullable = false, length = 255)
76     private String configurationName = "";
77
78     @Version
79     @Column(name = "version")
80     private int version;
81
82     @Column(name = "configType", nullable = false, length = 255)
83     private String configType = "NoType";
84
85     @Lob
86     @Column(name = "configBody", nullable = false, columnDefinition = "TEXT")
87     private String configBody = "NoBody";
88
89     @Column(name = "created_by", nullable = false, length = 255)
90     private String createdBy = "guest";
91
92     @Temporal(TemporalType.TIMESTAMP)
93     @Column(name = "created_date", updatable = false)
94     private Date createdDate;
95
96     @Column(name = "description", nullable = false, length = 2048)
97     private String description = "NoDescription";
98
99     @Column(name = "modified_by", nullable = false, length = 255)
100     private String modifiedBy = "guest";
101
102     @Temporal(TemporalType.TIMESTAMP)
103     @Column(name = "modified_date", nullable = false)
104     private Date modifiedDate;
105
106     @Column(name = "deleted", nullable = false)
107     private boolean deleted = false;
108
109     /**
110      * Instantiates a new configuration data entity.
111      */
112     public ConfigurationDataEntity() {
113         // An empty constructor
114     }
115
116     /**
117      * Pre persist.
118      */
119     @PrePersist
120     public void prePersist() {
121         Date date = new Date();
122         this.createdDate = date;
123         this.modifiedDate = date;
124     }
125
126     /**
127      * Pre update.
128      */
129     @PreUpdate
130     public void preUpdate() {
131         this.modifiedDate = new Date();
132     }
133
134     /**
135      * Gets the configuration data id.
136      *
137      * @return the configurationDataId
138      */
139     public long getConfigurationDataId() {
140         return configurationDataId;
141     }
142
143     /**
144      * Sets the configuration name.
145      *
146      * @param configurationName the new configuration name
147      */
148     public void setConfigurationName(String configurationName) {
149         this.configurationName = configurationName;
150     }
151
152     /**
153      * Gets the configuration name.
154      *
155      * @return the configuration name
156      */
157     public String getConfigurationName() {
158         return this.configurationName;
159     }
160
161     /**
162      * Gets the config type.
163      *
164      * @return the configType
165      */
166     public String getConfigType() {
167         return configType;
168     }
169
170     /**
171      * Sets the config type.
172      *
173      * @param configType the configType to set
174      */
175     public void setConfigType(String configType) {
176         this.configType = configType;
177     }
178
179     /**
180      * Gets the config body.
181      *
182      * @return the configBody
183      */
184     public String getConfigBody() {
185         return configBody;
186     }
187
188     /**
189      * Sets the config body.
190      *
191      * @param configBody the configBody to set
192      */
193     public void setConfigBody(String configBody) {
194         this.configBody = configBody;
195     }
196
197     /**
198      * Gets the created by.
199      *
200      * @return the createdBy
201      */
202     public String getCreatedBy() {
203         return createdBy;
204     }
205
206     /**
207      * Sets the created by.
208      *
209      * @param createdBy the createdBy to set
210      */
211     public void setCreatedBy(String createdBy) {
212         this.createdBy = createdBy;
213     }
214
215     /**
216      * Gets the description.
217      *
218      * @return the description
219      */
220     public String getDescription() {
221         return description;
222     }
223
224     /**
225      * Sets the description.
226      *
227      * @param description the description to set
228      */
229     public void setDescription(String description) {
230         this.description = description;
231     }
232
233     /**
234      * Gets the modified by.
235      *
236      * @return the modifiedBy
237      */
238     public String getModifiedBy() {
239         return modifiedBy;
240     }
241
242     /**
243      * Sets the modified by.
244      *
245      * @param modifiedBy the modifiedBy to set
246      */
247     public void setModifiedBy(String modifiedBy) {
248         this.modifiedBy = modifiedBy;
249     }
250
251     /**
252      * Gets the modified date.
253      *
254      * @return the modifiedDate
255      */
256     public Date getModifiedDate() {
257         return modifiedDate;
258     }
259
260     /**
261      * Sets the modified date.
262      *
263      * @param modifiedDate the modifiedDate to set
264      */
265     public void setModifiedDate(Date modifiedDate) {
266         this.modifiedDate = modifiedDate;
267     }
268
269     /**
270      * Gets the version.
271      *
272      * @return the version
273      */
274     public int getVersion() {
275         return version;
276     }
277
278     /**
279      * Gets the created date.
280      *
281      * @return the createdDate
282      */
283     public Date getCreatedDate() {
284         return createdDate;
285     }
286
287     /**
288      * Checks if is deleted.
289      *
290      * @return the deleted
291      */
292     public boolean isDeleted() {
293         return deleted;
294     }
295
296     /**
297      * Sets the deleted.
298      *
299      * @param deleted the deleted to set
300      */
301     public void setDeleted(boolean deleted) {
302         this.deleted = deleted;
303     }
304 }