e469c0b4fb62486cfe4119f788bbee9741a6b19a
[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  * ================================================================================
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.policy.rest.jpa;
22
23 import java.io.Serializable;
24 import java.util.Date;
25
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.GeneratedValue;
29 import javax.persistence.GenerationType;
30 import javax.persistence.Id;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.ManyToOne;
33 import javax.persistence.NamedQuery;
34 import javax.persistence.OrderBy;
35 import javax.persistence.PrePersist;
36 import javax.persistence.PreUpdate;
37 import javax.persistence.Table;
38 import javax.persistence.Temporal;
39 import javax.persistence.TemporalType;
40 import javax.persistence.Transient;
41
42
43 @Entity
44 @Table(name="DecisionSettings")
45 @NamedQuery(name="DecisionSettings.findAll", query="SELECT a FROM DecisionSettings a order by  a.priority asc, a.xacmlId asc")
46 public class DecisionSettings implements Serializable {
47     private static final long serialVersionUID = 1L;
48
49     @Id
50     @GeneratedValue(strategy = GenerationType.AUTO)
51     @Column(name="id")
52     private int id;
53
54     @Temporal(TemporalType.TIMESTAMP)
55     @Column(name="created_date", updatable=false)
56     private Date createdDate;
57
58     @Column(name="description", nullable=true, length=2048)
59     private String description;
60
61     @Temporal(TemporalType.TIMESTAMP)
62     @Column(name="modified_date", nullable=false)
63     private Date modifiedDate;
64
65     @Column(name="PRIORITY", nullable=true)
66     @OrderBy("asc")
67     private String priority;
68
69     @Column(name="xacml_id", unique = true, nullable=false)
70     @OrderBy("asc")
71     private String xacmlId = "urn";
72
73     //bi-directional many-to-one association to Datatype
74     @ManyToOne
75     @JoinColumn(name="datatype")
76     private Datatype datatypeBean;
77
78     @Transient
79     private String issuer = null;
80
81     @Transient
82     private boolean mustBePresent = false;
83
84     @ManyToOne(optional = false)
85     @JoinColumn(name="created_by")
86     private UserInfo userCreatedBy;
87
88     @ManyToOne(optional = false)
89     @JoinColumn(name="modified_by")
90     private UserInfo userModifiedBy;
91
92     public UserInfo getUserCreatedBy() {
93         return userCreatedBy;
94     }
95
96     public void setUserCreatedBy(UserInfo userCreatedBy) {
97         this.userCreatedBy = userCreatedBy;
98     }
99
100     public UserInfo getUserModifiedBy() {
101         return userModifiedBy;
102     }
103
104     public void setUserModifiedBy(UserInfo userModifiedBy) {
105         this.userModifiedBy = userModifiedBy;
106     }
107
108     @PrePersist
109     public void prePersist() {
110         Date date = new Date();
111         this.createdDate = date;
112         this.modifiedDate = date;
113     }
114
115     @PreUpdate
116     public void preUpdate() {
117         this.modifiedDate = new Date();
118     }
119
120     public int getId() {
121         return this.id;
122     }
123
124     public void setId(int id) {
125         this.id = id;
126     }
127
128
129     public Date getCreatedDate() {
130         return this.createdDate;
131     }
132
133     public void setCreatedDate(Date createdDate) {
134         this.createdDate = createdDate;
135     }
136
137     public String getDescription() {
138         return this.description;
139     }
140
141     public void setDescription(String description) {
142         this.description = description;
143     }
144
145     public Date getModifiedDate() {
146         return this.modifiedDate;
147     }
148
149     public void setModifiedDate(Date modifiedDate) {
150         this.modifiedDate = modifiedDate;
151     }
152
153     public String getXacmlId() {
154         return this.xacmlId;
155     }
156
157     public void setXacmlId(String xacmlId) {
158         this.xacmlId = xacmlId;
159     }
160
161     public Datatype getDatatypeBean() {
162         return this.datatypeBean;
163     }
164
165     public void setDatatypeBean(Datatype datatypeBean) {
166         this.datatypeBean = datatypeBean;
167     }
168
169     @Transient
170     public String getIssuer() {
171         return issuer;
172     }
173
174     @Transient
175     public void setIssuer(String issuer) {
176         this.issuer = issuer;
177     }
178
179     @Transient
180     public boolean isMustBePresent() {
181         return mustBePresent;
182     }
183
184     @Transient
185     public void setMustBePresent(boolean mustBePresent) {
186         this.mustBePresent = mustBePresent;
187     }
188
189     public String getPriority() {
190         return priority;
191     }
192
193     public void setPriority(String priority) {
194         this.priority = priority;
195     }
196 }
197