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