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