Unit/SONAR/Checkstyle in ONAP-REST
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / PolicyDbDaoEntity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.rest.jpa;
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.Id;
30 import javax.persistence.NamedQueries;
31 import javax.persistence.NamedQuery;
32 import javax.persistence.PrePersist;
33 import javax.persistence.PreUpdate;
34 import javax.persistence.Table;
35 import javax.persistence.Temporal;
36 import javax.persistence.TemporalType;
37
38 import lombok.Getter;
39 import lombok.Setter;
40
41 /**
42  * The Entity class to persist a PolicyDbDaoEntity object for registration of PolicyDBDao.
43  */
44 // @formatter:off
45 @Entity
46 @Table(name = "PolicyDbDaoEntity")
47 @NamedQueries(
48     {
49         @NamedQuery(name = "PolicyDbDaoEntity.findAll", query = "SELECT e FROM PolicyDbDaoEntity e "),
50         @NamedQuery(name = "PolicyDbDaoEntity.deleteAll", query = "DELETE FROM PolicyDbDaoEntity WHERE 1=1")
51     }
52 )
53 @Getter
54 @Setter
55 //@formatter:on
56 public class PolicyDbDaoEntity implements Serializable {
57     private static final long serialVersionUID = 1L;
58
59     @Id
60     @Column(name = "policyDbDaoUrl", nullable = false, unique = true)
61     private String policyDbDaoUrl;
62
63     @Temporal(TemporalType.TIMESTAMP)
64     @Column(name = "created_date", updatable = false)
65     private Date createdDate;
66
67     // username for the pap server that registered this PolicyDbDaoEntity
68     @Column(name = "username")
69     private String username;
70
71     // AES encrypted password for the pap server that registered this PolicyDbDaoEntity
72     @Column(name = "password")
73     private String password;
74
75     // A column to allow some descriptive text. For example: Atlanta data center
76     @Column(name = "description", nullable = false, length = 2048)
77     private String description = "NoDescription";
78
79     @Temporal(TemporalType.TIMESTAMP)
80     @Column(name = "modified_date", nullable = false)
81     private Date modifiedDate;
82
83     /**
84      * Instantiates a new policy DB dao entity.
85      */
86     public PolicyDbDaoEntity() {
87         super();
88     }
89
90     /**
91      * Pre persist.
92      */
93     @PrePersist
94     public void prePersist() {
95         Date date = new Date();
96         this.createdDate = date;
97         this.modifiedDate = date;
98     }
99
100     /**
101      * Pre update.
102      */
103     @PreUpdate
104     public void preUpdate() {
105         this.modifiedDate = new Date();
106     }
107 }