Convert tabs to spaces basic refactoring
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / ActionBodyEntity.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 package org.onap.policy.rest.jpa;
21 /*
22  */
23 import java.io.Serializable;
24 import java.util.Date;
25 import java.util.Objects;
26
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;
41 /*
42  * The Entity class to persist a policy object Action Body
43  */
44
45
46 import com.fasterxml.jackson.annotation.JsonBackReference;
47
48 @Entity
49 @Table(name="ActionBodyEntity")
50 @NamedQueries({
51     @NamedQuery(name=" ActionBodyEntity.findAll", query="SELECT e FROM ActionBodyEntity e "),
52     @NamedQuery(name="ActionBodyEntity.deleteAll", query="DELETE FROM ActionBodyEntity WHERE 1=1")
53 })
54
55 public class ActionBodyEntity implements Serializable {
56     private static final long serialVersionUID = 1L;
57
58     @Id
59     @GeneratedValue(strategy = GenerationType.AUTO)
60     @Column(name="actionBodyId")
61     @JsonBackReference
62     private long actionBodyId;
63
64     @Column(name="actionBodyName", nullable=false, length=255)
65     private String actionBodyName = "";
66
67     @Version
68     @Column(name="version")
69     private int version;
70
71     @Lob
72     @Column(name="actionBody", nullable=false, columnDefinition="TEXT")
73     private String actionBody = "NoBody";
74
75     @Column(name="created_by", nullable=false, length=255)
76     private String createdBy = "guest";
77
78     @Temporal(TemporalType.TIMESTAMP)
79     @Column(name="created_date", updatable=false)
80     private Date createdDate;
81
82     @Column(name="modified_by", nullable=false, length=255)
83     private String modifiedBy = "guest";
84
85     @Temporal(TemporalType.TIMESTAMP)
86     @Column(name="modified_date", nullable=false)
87     private Date modifiedDate;
88
89     @Column(name="deleted", nullable=false)
90     private boolean deleted = false;
91
92     public ActionBodyEntity() {
93         //An empty constructor
94     }
95
96     @PrePersist
97     public void prePersist() {
98         Date date = new Date();
99         this.createdDate = date;
100         this.modifiedDate = date;
101     }
102
103     @PreUpdate
104     public void preUpdate() {
105         this.modifiedDate = new Date();
106     }
107     /**
108      * @return the configurationDataId
109      */
110     public long getActionBodyId() {
111         return actionBodyId;
112     }
113     /**
114      * @param name the configuration body name to set
115      */
116     public void setActionBodyName(String name) {
117         this.actionBodyName = name;
118     }
119     public String getActionBodyName(){
120         return this.actionBodyName;
121     }
122
123     /**
124      * @return the actionBody
125      */
126     public String getActionBody() {
127         return actionBody;
128     }
129     /**
130      * @param body the configBody to set
131      */
132     public void setActionBody(String body) {
133         this.actionBody = body;
134     }
135     /**
136      * @return the createdBy
137      */
138     public String getCreatedBy() {
139         return createdBy;
140     }
141     /**
142      * @param createdBy the createdBy to set
143      */
144     public void setCreatedBy(String createdBy) {
145         this.createdBy = createdBy;
146     }
147
148     /**
149      * @return the modifiedBy
150      */
151     public String getModifiedBy() {
152         return modifiedBy;
153     }
154     /**
155      * @param modifiedBy the modifiedBy to set
156      */
157     public void setModifiedBy(String modifiedBy) {
158         this.modifiedBy = modifiedBy;
159     }
160     /**
161      * @return the modifiedDate
162      */
163     public Date getModifiedDate() {
164         return modifiedDate;
165     }
166     /**
167      * @param modifiedDate the modifiedDate to set
168      */
169     public void setModifiedDate(Date modifiedDate) {
170         this.modifiedDate = modifiedDate;
171     }
172     /**
173      * @return the version
174      */
175     public int getVersion() {
176         return version;
177     }
178     /**
179      * @return the createdDate
180      */
181     public Date getCreatedDate() {
182         return createdDate;
183     }
184
185     /**
186      * @return the deleted
187      */
188     public boolean isDeleted() {
189         return deleted;
190     }
191
192     /**
193      * @param deleted the deleted to set
194      */
195     public void setDeleted(boolean deleted) {
196         this.deleted = deleted;
197     }
198
199     @Override
200     public int hashCode() {
201     return Objects.hash(actionBodyId, actionBodyName, version, actionBody,
202             createdBy, createdDate, modifiedBy, modifiedDate, deleted);
203     }
204
205     @Override
206     public boolean equals(Object obj) {
207         if(obj == null){
208             return false;
209         }
210         if(obj == this){
211             return true;
212         }
213         if(!(obj instanceof ActionBodyEntity)){
214             return false;
215         }
216
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;
226     }
227 }