JUnit/SONAR/Checkstyle in ONAP-REST
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / ConfigurationDataEntity.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 com.fasterxml.jackson.annotation.JsonBackReference;
25
26 /*
27  */
28 import java.io.Serializable;
29 import java.util.Date;
30
31 import javax.persistence.Column;
32 import javax.persistence.Entity;
33 import javax.persistence.GeneratedValue;
34 import javax.persistence.GenerationType;
35 import javax.persistence.Id;
36 import javax.persistence.Lob;
37 import javax.persistence.NamedQueries;
38 import javax.persistence.NamedQuery;
39 import javax.persistence.PrePersist;
40 import javax.persistence.PreUpdate;
41 import javax.persistence.Table;
42 import javax.persistence.Temporal;
43 import javax.persistence.TemporalType;
44 import javax.persistence.Version;
45 /*
46  * The Entity class to persist a policy object configuration data
47  */
48
49 import lombok.Getter;
50 import lombok.NoArgsConstructor;
51 import lombok.Setter;
52 import lombok.ToString;
53
54 /**
55  * The Class ConfigurationDataEntity.
56  */
57 // @formatter:off
58 @Entity
59 @Table(name = "ConfigurationDataEntity")
60 @NamedQueries(
61     {
62         @NamedQuery(name = "ConfigurationDataEntity.findAll", query = "SELECT e FROM ConfigurationDataEntity e "),
63         @NamedQuery(name = "ConfigurationDataEntity.deleteAll", query = "DELETE FROM ConfigurationDataEntity WHERE 1=1")
64     }
65 )
66 @Getter
67 @Setter
68 @ToString
69 @NoArgsConstructor
70 //@formatter:on
71
72 public class ConfigurationDataEntity implements Serializable {
73     private static final long serialVersionUID = 1L;
74
75     @Id
76     @GeneratedValue(strategy = GenerationType.AUTO)
77     @Column(name = "configurationDataId")
78     @JsonBackReference
79     private long configurationDataId;
80
81     @Column(name = "configurationName", nullable = false, length = 255)
82     private String configurationName = "";
83
84     @Version
85     @Column(name = "version")
86     private int version;
87
88     @Column(name = "configType", nullable = false, length = 255)
89     private String configType = "NoType";
90
91     @Lob
92     @Column(name = "configBody", nullable = false, columnDefinition = "TEXT")
93     private String configBody = "NoBody";
94
95     @Column(name = "created_by", nullable = false, length = 255)
96     private String createdBy = "guest";
97
98     @Temporal(TemporalType.TIMESTAMP)
99     @Column(name = "created_date", updatable = false)
100     private Date createdDate;
101
102     @Column(name = "description", nullable = false, length = 2048)
103     private String description = "NoDescription";
104
105     @Column(name = "modified_by", nullable = false, length = 255)
106     private String modifiedBy = "guest";
107
108     @Temporal(TemporalType.TIMESTAMP)
109     @Column(name = "modified_date", nullable = false)
110     private Date modifiedDate;
111
112     @Column(name = "deleted", nullable = false)
113     private boolean deleted = false;
114
115     /**
116      * Pre persist.
117      */
118     @PrePersist
119     public void prePersist() {
120         Date date = new Date();
121         this.createdDate = date;
122         this.modifiedDate = date;
123     }
124
125     /**
126      * Pre update.
127      */
128     @PreUpdate
129     public void preUpdate() {
130         this.modifiedDate = new Date();
131     }
132 }