JUnit/SONAR/Checkstyle in ONAP-REST
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / DecisionSettings.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
4  * ================================================================================
5  * Copyright (C) 2017-2018 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.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.NamedQuery;
35 import javax.persistence.OrderBy;
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 import javax.persistence.Transient;
42
43 /**
44  * The Class DecisionSettings.
45  */
46 // @formatter:off
47 @Entity
48 @Table(name = "DecisionSettings")
49 @NamedQuery(
50     name = "DecisionSettings.findAll",
51     query = "SELECT a FROM DecisionSettings a order by  a.priority asc, a.xacmlId asc"
52 )
53 //@formatter:on
54 public class DecisionSettings implements Serializable {
55     private static final long serialVersionUID = 1L;
56
57     @Id
58     @GeneratedValue(strategy = GenerationType.AUTO)
59     @Column(name = "id")
60     private int id;
61
62     @Temporal(TemporalType.TIMESTAMP)
63     @Column(name = "created_date", updatable = false)
64     private Date createdDate;
65
66     @Column(name = "description", nullable = true, length = 2048)
67     private String description;
68
69     @Temporal(TemporalType.TIMESTAMP)
70     @Column(name = "modified_date", nullable = false)
71     private Date modifiedDate;
72
73     @Column(name = "PRIORITY", nullable = true)
74     @OrderBy("asc")
75     private String priority;
76
77     @Column(name = "xacml_id", unique = true, nullable = false)
78     @OrderBy("asc")
79     private String xacmlId = "urn";
80
81     // bi-directional many-to-one association to Datatype
82     @ManyToOne
83     @JoinColumn(name = "datatype")
84     private Datatype datatypeBean;
85
86     @Transient
87     private String issuer = null;
88
89     @Transient
90     private boolean mustBePresent = false;
91
92     @ManyToOne(optional = false)
93     @JoinColumn(name = "created_by")
94     private UserInfo userCreatedBy;
95
96     @ManyToOne(optional = false)
97     @JoinColumn(name = "modified_by")
98     private UserInfo userModifiedBy;
99
100     /**
101      * Gets the user created by.
102      *
103      * @return the user created by
104      */
105     public UserInfo getUserCreatedBy() {
106         return userCreatedBy;
107     }
108
109     /**
110      * Sets the user created by.
111      *
112      * @param userCreatedBy the new user created by
113      */
114     public void setUserCreatedBy(UserInfo userCreatedBy) {
115         this.userCreatedBy = userCreatedBy;
116     }
117
118     /**
119      * Gets the user modified by.
120      *
121      * @return the user modified by
122      */
123     public UserInfo getUserModifiedBy() {
124         return userModifiedBy;
125     }
126
127     /**
128      * Sets the user modified by.
129      *
130      * @param userModifiedBy the new user modified by
131      */
132     public void setUserModifiedBy(UserInfo userModifiedBy) {
133         this.userModifiedBy = userModifiedBy;
134     }
135
136     /**
137      * Pre persist.
138      */
139     @PrePersist
140     public void prePersist() {
141         Date date = new Date();
142         this.createdDate = date;
143         this.modifiedDate = date;
144     }
145
146     /**
147      * Pre update.
148      */
149     @PreUpdate
150     public void preUpdate() {
151         this.modifiedDate = new Date();
152     }
153
154     /**
155      * Gets the id.
156      *
157      * @return the id
158      */
159     public int getId() {
160         return this.id;
161     }
162
163     /**
164      * Sets the id.
165      *
166      * @param id the new id
167      */
168     public void setId(int id) {
169         this.id = id;
170     }
171
172     /**
173      * Gets the created date.
174      *
175      * @return the created date
176      */
177     public Date getCreatedDate() {
178         return this.createdDate;
179     }
180
181     /**
182      * Sets the created date.
183      *
184      * @param createdDate the new created date
185      */
186     public void setCreatedDate(Date createdDate) {
187         this.createdDate = createdDate;
188     }
189
190     /**
191      * Gets the description.
192      *
193      * @return the description
194      */
195     public String getDescription() {
196         return this.description;
197     }
198
199     /**
200      * Sets the description.
201      *
202      * @param description the new description
203      */
204     public void setDescription(String description) {
205         this.description = description;
206     }
207
208     /**
209      * Gets the modified date.
210      *
211      * @return the modified date
212      */
213     public Date getModifiedDate() {
214         return this.modifiedDate;
215     }
216
217     /**
218      * Sets the modified date.
219      *
220      * @param modifiedDate the new modified date
221      */
222     public void setModifiedDate(Date modifiedDate) {
223         this.modifiedDate = modifiedDate;
224     }
225
226     /**
227      * Gets the xacml id.
228      *
229      * @return the xacml id
230      */
231     public String getXacmlId() {
232         return this.xacmlId;
233     }
234
235     /**
236      * Sets the xacml id.
237      *
238      * @param xacmlId the new xacml id
239      */
240     public void setXacmlId(String xacmlId) {
241         this.xacmlId = xacmlId;
242     }
243
244     /**
245      * Gets the datatype bean.
246      *
247      * @return the datatype bean
248      */
249     public Datatype getDatatypeBean() {
250         return this.datatypeBean;
251     }
252
253     /**
254      * Sets the datatype bean.
255      *
256      * @param datatypeBean the new datatype bean
257      */
258     public void setDatatypeBean(Datatype datatypeBean) {
259         this.datatypeBean = datatypeBean;
260     }
261
262     /**
263      * Gets the issuer.
264      *
265      * @return the issuer
266      */
267     @Transient
268     public String getIssuer() {
269         return issuer;
270     }
271
272     /**
273      * Sets the issuer.
274      *
275      * @param issuer the new issuer
276      */
277     @Transient
278     public void setIssuer(String issuer) {
279         this.issuer = issuer;
280     }
281
282     /**
283      * Checks if is must be present.
284      *
285      * @return true, if is must be present
286      */
287     @Transient
288     public boolean isMustBePresent() {
289         return mustBePresent;
290     }
291
292     /**
293      * Sets the must be present.
294      *
295      * @param mustBePresent the new must be present
296      */
297     @Transient
298     public void setMustBePresent(boolean mustBePresent) {
299         this.mustBePresent = mustBePresent;
300     }
301
302     /**
303      * Gets the priority.
304      *
305      * @return the priority
306      */
307     public String getPriority() {
308         return priority;
309     }
310
311     /**
312      * Sets the priority.
313      *
314      * @param priority the new priority
315      */
316     public void setPriority(String priority) {
317         this.priority = priority;
318     }
319 }