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=========================================================
20 package org.onap.policy.rest.jpa;
23 import java.io.Serializable;
24 import java.util.Date;
25 import java.util.Objects;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.GeneratedValue;
30 import javax.persistence.GenerationType;
31 import javax.persistence.Id;
32 import javax.persistence.Lob;
33 import javax.persistence.NamedQueries;
34 import javax.persistence.NamedQuery;
35 import javax.persistence.PrePersist;
36 import javax.persistence.PreUpdate;
37 import javax.persistence.Table;
38 import javax.persistence.Temporal;
39 import javax.persistence.TemporalType;
40 import javax.persistence.Version;
42 * The Entity class to persist a policy object Action Body
46 import com.fasterxml.jackson.annotation.JsonBackReference;
49 @Table(name="ActionBodyEntity")
51 @NamedQuery(name=" ActionBodyEntity.findAll", query="SELECT e FROM ActionBodyEntity e "),
52 @NamedQuery(name="ActionBodyEntity.deleteAll", query="DELETE FROM ActionBodyEntity WHERE 1=1")
55 public class ActionBodyEntity implements Serializable {
56 private static final long serialVersionUID = 1L;
59 @GeneratedValue(strategy = GenerationType.AUTO)
60 @Column(name="actionBodyId")
62 private long actionBodyId;
64 @Column(name="actionBodyName", nullable=false, length=255)
65 private String actionBodyName = "";
68 @Column(name="version")
72 @Column(name="actionBody", nullable=false, columnDefinition="TEXT")
73 private String actionBody = "NoBody";
75 @Column(name="created_by", nullable=false, length=255)
76 private String createdBy = "guest";
78 @Temporal(TemporalType.TIMESTAMP)
79 @Column(name="created_date", updatable=false)
80 private Date createdDate;
82 @Column(name="modified_by", nullable=false, length=255)
83 private String modifiedBy = "guest";
85 @Temporal(TemporalType.TIMESTAMP)
86 @Column(name="modified_date", nullable=false)
87 private Date modifiedDate;
89 @Column(name="deleted", nullable=false)
90 private boolean deleted = false;
92 public ActionBodyEntity() {
96 public void prePersist() {
97 Date date = new Date();
98 this.createdDate = date;
99 this.modifiedDate = date;
103 public void preUpdate() {
104 this.modifiedDate = new Date();
107 * @return the configurationDataId
109 public long getActionBodyId() {
113 * @param configurationDataId the configurationDataId to set
115 public void setActionBodyName(String name) {
116 this.actionBodyName = name;
118 public String getActionBodyName(){
119 return this.actionBodyName;
123 * @return the actionBody
125 public String getActionBody() {
129 * @param configBody the configBody to set
131 public void setActionBody(String body) {
132 this.actionBody = body;
135 * @return the createdBy
137 public String getCreatedBy() {
141 * @param createdBy the createdBy to set
143 public void setCreatedBy(String createdBy) {
144 this.createdBy = createdBy;
148 * @return the modifiedBy
150 public String getModifiedBy() {
154 * @param modifiedBy the modifiedBy to set
156 public void setModifiedBy(String modifiedBy) {
157 this.modifiedBy = modifiedBy;
160 * @return the modifiedDate
162 public Date getModifiedDate() {
166 * @param modifiedDate the modifiedDate to set
168 public void setModifiedDate(Date modifiedDate) {
169 this.modifiedDate = modifiedDate;
172 * @return the version
174 public int getVersion() {
178 * @return the createdDate
180 public Date getCreatedDate() {
185 * @return the deleted
187 public boolean isDeleted() {
192 * @param deleted the deleted to set
194 public void setDeleted(boolean deleted) {
195 this.deleted = deleted;
199 public int hashCode() {
200 return Objects.hash(actionBodyId, actionBodyName, version, actionBody,
201 createdBy, createdDate, modifiedBy, modifiedDate, deleted);
205 public boolean equals(Object obj) {
212 if(!(obj instanceof ActionBodyEntity)){
217 actionBodyId == ((ActionBodyEntity) obj).actionBodyId &&
218 actionBodyName.equals(((ActionBodyEntity) obj).actionBodyName) &&
219 version == ((ActionBodyEntity) obj).version &&
220 actionBody.equals(((ActionBodyEntity) obj).actionBody) &&
221 createdBy.equals(((ActionBodyEntity) obj).createdBy) &&
222 createdDate.equals(((ActionBodyEntity) obj).createdDate) &&
223 modifiedBy.equals(((ActionBodyEntity) obj).modifiedBy) &&
224 modifiedDate.equals(((ActionBodyEntity) obj).modifiedDate) &&
225 deleted == ((ActionBodyEntity) obj).deleted