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() {
93 //An empty constructor
97 public void prePersist() {
98 Date date = new Date();
99 this.createdDate = date;
100 this.modifiedDate = date;
104 public void preUpdate() {
105 this.modifiedDate = new Date();
108 * @return the configurationDataId
110 public long getActionBodyId() {
114 * @param name the configuration body name to set
116 public void setActionBodyName(String name) {
117 this.actionBodyName = name;
119 public String getActionBodyName(){
120 return this.actionBodyName;
124 * @return the actionBody
126 public String getActionBody() {
130 * @param body the configBody to set
132 public void setActionBody(String body) {
133 this.actionBody = body;
136 * @return the createdBy
138 public String getCreatedBy() {
142 * @param createdBy the createdBy to set
144 public void setCreatedBy(String createdBy) {
145 this.createdBy = createdBy;
149 * @return the modifiedBy
151 public String getModifiedBy() {
155 * @param modifiedBy the modifiedBy to set
157 public void setModifiedBy(String modifiedBy) {
158 this.modifiedBy = modifiedBy;
161 * @return the modifiedDate
163 public Date getModifiedDate() {
167 * @param modifiedDate the modifiedDate to set
169 public void setModifiedDate(Date modifiedDate) {
170 this.modifiedDate = modifiedDate;
173 * @return the version
175 public int getVersion() {
179 * @return the createdDate
181 public Date getCreatedDate() {
186 * @return the deleted
188 public boolean isDeleted() {
193 * @param deleted the deleted to set
195 public void setDeleted(boolean deleted) {
196 this.deleted = deleted;
200 public int hashCode() {
201 return Objects.hash(actionBodyId, actionBodyName, version, actionBody,
202 createdBy, createdDate, modifiedBy, modifiedDate, deleted);
206 public boolean equals(Object obj) {
213 if(!(obj instanceof ActionBodyEntity)){
217 return 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;