Initial OpenECOMP policy/engine commit
[policy/engine.git] / ECOMP-REST / src / main / java / org / openecomp / policy / rest / jpa / ActionBodyEntity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP-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.openecomp.policy.rest.jpa;
21 /*
22  */
23 import java.io.Serializable;
24 import java.util.Date;
25
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.GeneratedValue;
29 import javax.persistence.GenerationType;
30 import javax.persistence.Id;
31 import javax.persistence.Lob;
32 import javax.persistence.NamedQueries;
33 import javax.persistence.NamedQuery;
34 import javax.persistence.PrePersist;
35 import javax.persistence.PreUpdate;
36 import javax.persistence.SequenceGenerator;
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 import com.fasterxml.jackson.annotation.JsonBackReference;
46
47 @Entity
48 @Table(name="ActionBodyEntity")
49 @NamedQueries({
50         @NamedQuery(name=" ActionBodyEntity.findAll", query="SELECT e FROM ActionBodyEntity e "),
51         @NamedQuery(name="ActionBodyEntity.deleteAll", query="DELETE FROM ActionBodyEntity WHERE 1=1")
52 })
53 //@SequenceGenerator(name="seqActBody", initialValue=1, allocationSize=1)
54
55 public class ActionBodyEntity implements Serializable {
56         private static final long serialVersionUID = 1L;
57
58         @Id
59         //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqActBody")
60         @GeneratedValue(strategy = GenerationType.AUTO)
61         @Column(name="actionBodyId")
62         @JsonBackReference
63         private long actionBodyId;
64         
65         @Column(name="actionBodyName", nullable=false, length=255)
66         private String actionBodyName = "";
67         
68         @Version 
69         @Column(name="version")
70         private int version;
71         
72         @Lob
73         @Column(name="actionBody", nullable=false, columnDefinition="TEXT")
74         private String actionBody = "NoBody";
75         
76         @Column(name="created_by", nullable=false, length=255)
77         private String createdBy = "guest";
78
79         @Temporal(TemporalType.TIMESTAMP)
80         @Column(name="created_date", updatable=false)
81         private Date createdDate;
82
83         @Column(name="modified_by", nullable=false, length=255)
84         private String modifiedBy = "guest";
85
86         @Temporal(TemporalType.TIMESTAMP)
87         @Column(name="modified_date", nullable=false)
88         private Date modifiedDate;
89         
90         @Column(name="deleted", nullable=false)
91         private boolean deleted = false;
92
93         public ActionBodyEntity() {
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 configurationDataId the configurationDataId 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 configBody 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 }