2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.policy.rest.jpa;
24 import java.io.Serializable;
25 import java.util.Date;
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;
49 * The Entity class to persist a policy object and its configuration data
56 //Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique
57 @Table(name="PdpEntity")
59 @NamedQuery(name="PdpEntity.findAll", query="SELECT e FROM PdpEntity e "),
60 @NamedQuery(name="PdpEntity.deleteAll", query="DELETE FROM PdpEntity WHERE 1=1")
63 public class PdpEntity implements Serializable {
64 private static final long serialVersionUID = 1L;
67 //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPdp")
68 @GeneratedValue(strategy = GenerationType.AUTO)
69 @Column (name="pdpKey")
72 @Column (name="pdpId", nullable=false, unique=false, length=255)
75 @Column(name="pdpName", nullable=false, unique=false, length=255)
76 private String pdpName;
78 @Column(name="jmxPort", nullable=false, unique=false)
82 @ManyToOne(optional=false)
83 @JoinColumn(name="groupKey", referencedColumnName="groupKey")
84 private GroupEntity groupEntity;
86 @Column(name="created_by", nullable=false, length=255)
87 private String createdBy = "guest";
89 @Temporal(TemporalType.TIMESTAMP)
90 @Column(name="created_date", updatable=false)
91 private Date createdDate;
93 @Column(name="description", nullable=false, length=2048)
94 private String description = "NoDescription";
96 @Column(name="modified_by", nullable=false, length=255)
97 private String modifiedBy = "guest";
99 @Temporal(TemporalType.TIMESTAMP)
100 @Column(name="modified_date", nullable=false)
101 private Date modifiedDate;
103 @Column(name="deleted", nullable=false)
104 private boolean deleted = false;
111 public void prePersist() {
112 Date date = new Date();
113 this.createdDate = date;
114 this.modifiedDate = date;
118 public void preUpdate() {
119 this.modifiedDate = new Date();
122 public long getPdpKey(){
126 * @return the policyId
128 public String getPdpId() {
132 public void setPdpId(String id){
136 * @param policyId cannot be set
139 public String getPdpName() {
143 public void setPdpName(String groupName) {
144 this.pdpName = groupName;
150 * @return the configurationDataEntity
152 public GroupEntity getGroup() {
157 * @param configurationDataEntity the configurationDataEntity to set
159 public void setGroup(GroupEntity group) {
160 this.groupEntity = group;
166 * @return the createdBy
168 public String getCreatedBy() {
173 * @param createdBy the createdBy to set
175 public void setCreatedBy(String createdBy) {
176 this.createdBy = createdBy;
180 * @return the description
182 public String getDescription() {
187 * @param description the description to set
189 public void setDescription(String description) {
190 this.description = description;
194 * @return the modifiedBy
196 public String getModifiedBy() {
201 * @param modifiedBy the modifiedBy to set
203 public void setModifiedBy(String modifiedBy) {
204 this.modifiedBy = modifiedBy;
208 * @return the version
210 public int getJmxPort() {
214 public void setJmxPort(int jmxPort){
215 this.jmxPort = jmxPort;
219 * @return the createdDate
221 public Date getCreatedDate() {
226 * @return the modifiedDate
228 public Date getModifiedDate() {
233 * @return the deleted
235 public boolean isDeleted() {
240 * @param deleted the deleted to set
242 public void setDeleted(boolean deleted) {
243 this.deleted = deleted;