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