2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.rest.jpa;
24 import java.io.Serializable;
25 import java.util.Date;
26 import java.util.Objects;
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;
43 * The Entity class to persist a policy object configuration data
47 import com.fasterxml.jackson.annotation.JsonBackReference;
50 @Table(name="ConfigurationDataEntity")
52 @NamedQuery(name="ConfigurationDataEntity.findAll", query="SELECT e FROM ConfigurationDataEntity e "),
53 @NamedQuery(name="ConfigurationDataEntity.deleteAll", query="DELETE FROM ConfigurationDataEntity WHERE 1=1")
56 public class ConfigurationDataEntity implements Serializable {
57 private static final long serialVersionUID = 1L;
60 @GeneratedValue(strategy = GenerationType.AUTO)
61 @Column(name="configurationDataId")
63 private long configurationDataId;
65 @Column(name="configurationName", nullable=false, length=255)
66 private String configurationName = "";
69 @Column(name="version")
72 @Column(name="configType", nullable=false, length=255)
73 private String configType = "NoType";
76 @Column(name="configBody", nullable=false, columnDefinition="TEXT")
77 private String configBody = "NoBody";
79 @Column(name="created_by", nullable=false, length=255)
80 private String createdBy = "guest";
82 @Temporal(TemporalType.TIMESTAMP)
83 @Column(name="created_date", updatable=false)
84 private Date createdDate;
86 @Column(name="description", nullable=false, length=2048)
87 private String description = "NoDescription";
89 @Column(name="modified_by", nullable=false, length=255)
90 private String modifiedBy = "guest";
92 @Temporal(TemporalType.TIMESTAMP)
93 @Column(name="modified_date", nullable=false)
94 private Date modifiedDate;
96 @Column(name="deleted", nullable=false)
97 private boolean deleted = false;
99 public ConfigurationDataEntity() {
103 public void prePersist() {
104 Date date = new Date();
105 this.createdDate = date;
106 this.modifiedDate = date;
110 public void preUpdate() {
111 this.modifiedDate = new Date();
114 * @return the configurationDataId
116 public long getConfigurationDataId() {
117 return configurationDataId;
120 * @param configurationDataId the configurationDataId to set
122 public void setConfigurationName(String configurationName) {
123 this.configurationName = configurationName;
125 public String getConfigurationName(){
126 return this.configurationName;
129 * @return the configType
131 public String getConfigType() {
135 * @param configType the configType to set
137 public void setConfigType(String configType) {
138 this.configType = configType;
141 * @return the configBody
143 public String getConfigBody() {
147 * @param configBody the configBody to set
149 public void setConfigBody(String configBody) {
150 this.configBody = configBody;
153 * @return the createdBy
155 public String getCreatedBy() {
159 * @param createdBy the createdBy to set
161 public void setCreatedBy(String createdBy) {
162 this.createdBy = createdBy;
165 * @return the description
167 public String getDescription() {
171 * @param description the description to set
173 public void setDescription(String description) {
174 this.description = description;
177 * @return the modifiedBy
179 public String getModifiedBy() {
183 * @param modifiedBy the modifiedBy to set
185 public void setModifiedBy(String modifiedBy) {
186 this.modifiedBy = modifiedBy;
189 * @return the modifiedDate
191 public Date getModifiedDate() {
195 * @param modifiedDate the modifiedDate to set
197 public void setModifiedDate(Date modifiedDate) {
198 this.modifiedDate = modifiedDate;
201 * @return the version
203 public int getVersion() {
207 * @return the createdDate
209 public Date getCreatedDate() {
214 * @return the deleted
216 public boolean isDeleted() {
221 * @param deleted the deleted to set
223 public void setDeleted(boolean deleted) {
224 this.deleted = deleted;
228 public int hashCode() {
229 return Objects.hash(configurationDataId, configurationName, version, configType,
230 configBody, createdBy, createdDate, description, modifiedBy, modifiedDate, deleted);
234 public boolean equals(Object obj) {
241 if(!(obj instanceof ConfigurationDataEntity)){
246 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