Initial OpenECOMP policy/engine commit
[policy/engine.git] / ECOMP-REST / src / main / java / org / openecomp / policy / rest / jpa / PdpEntity.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.Index;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.Lob;
35 import javax.persistence.ManyToOne;
36 import javax.persistence.NamedQueries;
37 import javax.persistence.NamedQuery;
38 import javax.persistence.OneToOne;
39 import javax.persistence.PrePersist;
40 import javax.persistence.PreUpdate;
41 import javax.persistence.SequenceGenerator;
42 import javax.persistence.Table;
43 import javax.persistence.Temporal;
44 import javax.persistence.TemporalType;
45 import javax.persistence.UniqueConstraint;
46 import javax.persistence.Version;
47
48 /*
49  * The Entity class to persist a policy object and its configuration data
50  */
51
52 /**
53  *
54  */
55 @Entity
56 //Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique
57 @Table(name="PdpEntity")
58 @NamedQueries({
59         @NamedQuery(name="PdpEntity.findAll", query="SELECT e FROM PdpEntity e "),
60         @NamedQuery(name="PdpEntity.deleteAll", query="DELETE FROM PdpEntity WHERE 1=1")
61 })
62
63 public class PdpEntity implements Serializable {
64         private static final long serialVersionUID = 1L;
65
66         @Id
67         //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPdp")
68         @GeneratedValue(strategy = GenerationType.AUTO)
69         @Column (name="pdpKey")
70         private long pdpKey;
71         
72         @Column (name="pdpId", nullable=false, unique=false, length=255)
73         private String pdpId;
74
75         @Column(name="pdpName", nullable=false, unique=false, length=255)
76         private String pdpName;
77         
78         @Column(name="jmxPort", nullable=false, unique=false)
79         private int jmxPort;
80         
81         
82         @ManyToOne(optional=false)
83         @JoinColumn(name="groupKey", referencedColumnName="groupKey")
84         private GroupEntity groupEntity;
85         
86         @Column(name="created_by", nullable=false, length=255)
87         private String createdBy = "guest";
88
89         @Temporal(TemporalType.TIMESTAMP)
90         @Column(name="created_date", updatable=false)
91         private Date createdDate;
92
93         @Column(name="description", nullable=false, length=2048)
94         private String description = "NoDescription";
95
96         @Column(name="modified_by", nullable=false, length=255)
97         private String modifiedBy = "guest";
98
99         @Temporal(TemporalType.TIMESTAMP)
100         @Column(name="modified_date", nullable=false)
101         private Date modifiedDate;
102         
103         @Column(name="deleted", nullable=false)
104         private boolean deleted = false;
105
106         public PdpEntity() {
107                 super();
108         }
109
110         @PrePersist
111         public void     prePersist() {
112                 Date date = new Date();
113                 this.createdDate = date;
114                 this.modifiedDate = date;
115         }
116
117         @PreUpdate
118         public void preUpdate() {
119                 this.modifiedDate = new Date();
120         }
121
122         public long getPdpKey(){
123                 return pdpKey;
124         }
125         /**
126          * @return the policyId
127          */
128         public String getPdpId() {
129                 return pdpId;
130         }
131
132         public void setPdpId(String id){
133                 pdpId = id;
134         }
135         /**
136          * @param policyId cannot be set
137          */
138
139         public String getPdpName() {
140                 return pdpName;
141         }
142
143         public void setPdpName(String groupName) {
144                 this.pdpName = groupName;
145         }
146
147
148
149         /**
150          * @return the configurationDataEntity
151          */
152         public GroupEntity getGroup() {
153                 return groupEntity;
154         }
155
156         /**
157          * @param configurationDataEntity the configurationDataEntity to set
158          */
159         public void setGroup(GroupEntity group) {
160                 this.groupEntity = group;
161         }
162
163
164
165         /**
166          * @return the createdBy
167          */
168         public String getCreatedBy() {
169                 return createdBy;
170         }
171
172         /**
173          * @param createdBy the createdBy to set
174          */
175         public void setCreatedBy(String createdBy) {
176                 this.createdBy = createdBy;
177         }
178
179         /**
180          * @return the description
181          */
182         public String getDescription() {
183                 return description;
184         }
185
186         /**
187          * @param description the description to set
188          */
189         public void setDescription(String description) {
190                 this.description = description;
191         }
192
193         /**
194          * @return the modifiedBy
195          */
196         public String getModifiedBy() {
197                 return modifiedBy;
198         }
199
200         /**
201          * @param modifiedBy the modifiedBy to set
202          */
203         public void setModifiedBy(String modifiedBy) {
204                 this.modifiedBy = modifiedBy;
205         }
206
207         /**
208          * @return the version
209          */
210         public int getJmxPort() {
211                 return jmxPort;
212         }
213         
214         public void setJmxPort(int jmxPort){
215                 this.jmxPort = jmxPort;
216         }
217
218         /**
219          * @return the createdDate
220          */
221         public Date getCreatedDate() {
222                 return createdDate;
223         }
224
225         /**
226          * @return the modifiedDate
227          */
228         public Date getModifiedDate() {
229                 return modifiedDate;
230         }
231
232         /**
233          * @return the deleted
234          */
235         public boolean isDeleted() {
236                 return deleted;
237         }
238
239         /**
240          * @param deleted the deleted to set
241          */
242         public void setDeleted(boolean deleted) {
243                 this.deleted = deleted;
244         }
245
246
247 }