8239d4ef820077b17a2062429020999f10949044
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / RiskType.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  */
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
42
43 @Entity
44 @Table(name="RiskType")
45 @NamedQuery(name="RiskType.findAll", query="SELECT e FROM RiskType e ")
46 public class RiskType 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     @Column(name="name", nullable=false, unique=true)
55     @OrderBy("asc")
56     private String name;
57
58     @Temporal(TemporalType.TIMESTAMP)
59     @Column(name="created_date", updatable=false)
60     private Date createdDate;
61
62     @Column(name="description", nullable=true, length=2048)
63     private String description;
64
65     @Temporal(TemporalType.TIMESTAMP)
66     @Column(name="modified_date", nullable=false)
67     private Date modifiedDate;
68
69     @ManyToOne(optional = false)
70     @JoinColumn(name="created_by")
71     private UserInfo userCreatedBy;
72
73     @ManyToOne(optional = false)
74     @JoinColumn(name="modified_by")
75     private UserInfo userModifiedBy;
76
77     public UserInfo getUserCreatedBy() {
78         return userCreatedBy;
79     }
80
81     public void setUserCreatedBy(UserInfo userCreatedBy) {
82         this.userCreatedBy = userCreatedBy;
83     }
84
85     public UserInfo getUserModifiedBy() {
86         return userModifiedBy;
87     }
88
89     public void setUserModifiedBy(UserInfo userModifiedBy) {
90         this.userModifiedBy = userModifiedBy;
91     }
92
93     @PrePersist
94     public void prePersist() {
95         Date date = new Date();
96         this.createdDate = date;
97         this.modifiedDate = date;
98     }
99
100     @PreUpdate
101     public void preUpdate() {
102         this.modifiedDate = new Date();
103     }
104     public String getRiskName() {
105         return this.name;
106     }
107
108     public void setRiskName(String riskName) {
109         this.name = riskName;
110
111     }
112     public int getId() {
113         return this.id;
114     }
115
116     public void setId(int id) {
117         this.id = id;
118     }
119
120     public Date getCreatedDate() {
121         return this.createdDate;
122     }
123
124     public void setCreatedDate(Date createdDate) {
125         this.createdDate = createdDate;
126     }
127
128     public String getDescription() {
129         return this.description;
130     }
131
132     public void setDescription(String description) {
133         this.description = description;
134     }
135
136     public Date getModifiedDate() {
137         return this.modifiedDate;
138     }
139
140     public void setModifiedDate(Date modifiedDate) {
141         this.modifiedDate = modifiedDate;
142     }
143
144 }