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.onap.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.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;
43 * The Entity class to persist a policy object and its configuration data
50 //Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique
51 @Table(name="PdpEntity")
53 @NamedQuery(name="PdpEntity.findAll", query="SELECT e FROM PdpEntity e "),
54 @NamedQuery(name="PdpEntity.deleteAll", query="DELETE FROM PdpEntity WHERE 1=1")
57 public class PdpEntity implements Serializable {
58 private static final long serialVersionUID = 1L;
61 //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPdp")
62 @GeneratedValue(strategy = GenerationType.AUTO)
63 @Column (name="pdpKey")
66 @Column (name="pdpId", nullable=false, unique=false, length=255)
69 @Column(name="pdpName", nullable=false, unique=false, length=255)
70 private String pdpName;
72 @Column(name="jmxPort", nullable=false, unique=false)
76 @ManyToOne(optional=false)
77 @JoinColumn(name="groupKey", referencedColumnName="groupKey")
78 private GroupEntity groupEntity;
80 @Column(name="created_by", nullable=false, length=255)
81 private String createdBy = "guest";
83 @Temporal(TemporalType.TIMESTAMP)
84 @Column(name="created_date", updatable=false)
85 private Date createdDate;
87 @Column(name="description", nullable=false, length=2048)
88 private String description = "NoDescription";
90 @Column(name="modified_by", nullable=false, length=255)
91 private String modifiedBy = "guest";
93 @Temporal(TemporalType.TIMESTAMP)
94 @Column(name="modified_date", nullable=false)
95 private Date modifiedDate;
97 @Column(name="deleted", nullable=false)
98 private boolean deleted = false;
105 public void prePersist() {
106 Date date = new Date();
107 this.createdDate = date;
108 this.modifiedDate = date;
112 public void preUpdate() {
113 this.modifiedDate = new Date();
116 public long getPdpKey(){
120 * @return the policyId
122 public String getPdpId() {
126 public void setPdpId(String id){
130 * @param policyId cannot be set
133 public String getPdpName() {
137 public void setPdpName(String groupName) {
138 this.pdpName = groupName;
144 * @return the configurationDataEntity
146 public GroupEntity getGroup() {
151 * @param configurationDataEntity the configurationDataEntity to set
153 public void setGroup(GroupEntity group) {
154 this.groupEntity = group;
160 * @return the createdBy
162 public String getCreatedBy() {
167 * @param createdBy the createdBy to set
169 public void setCreatedBy(String createdBy) {
170 this.createdBy = createdBy;
174 * @return the description
176 public String getDescription() {
181 * @param description the description to set
183 public void setDescription(String description) {
184 this.description = description;
188 * @return the modifiedBy
190 public String getModifiedBy() {
195 * @param modifiedBy the modifiedBy to set
197 public void setModifiedBy(String modifiedBy) {
198 this.modifiedBy = modifiedBy;
202 * @return the version
204 public int getJmxPort() {
208 public void setJmxPort(int jmxPort){
209 this.jmxPort = jmxPort;
213 * @return the createdDate
215 public Date getCreatedDate() {
220 * @return the modifiedDate
222 public Date getModifiedDate() {
227 * @return the deleted
229 public boolean isDeleted() {
234 * @param deleted the deleted to set
236 public void setDeleted(boolean deleted) {
237 this.deleted = deleted;