52b5a2a4a985f95a6db126de3a9c94106958e6eb
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / ClosedLoopSite.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
4  * ================================================================================
5  * Copyright (C) 2017-2019 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  *
25  */
26 import java.io.Serializable;
27 import java.util.Date;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.GeneratedValue;
31 import javax.persistence.GenerationType;
32 import javax.persistence.Id;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.ManyToOne;
35 import javax.persistence.NamedQuery;
36 import javax.persistence.OrderBy;
37 import javax.persistence.PrePersist;
38 import javax.persistence.PreUpdate;
39 import javax.persistence.Table;
40 import javax.persistence.Temporal;
41 import javax.persistence.TemporalType;
42
43
44 @Entity
45 @Table(name = "ClosedLoopSite")
46 @NamedQuery(name="ClosedLoopSite.findAll", query="SELECT c FROM ClosedLoopSite c ")
47 public class ClosedLoopSite implements Serializable{
48     private static final long serialVersionUID = 1L;
49
50
51     @Id
52     @Column(name ="id")
53     @GeneratedValue(strategy = GenerationType.AUTO)
54     private int id;
55
56     @Column(name="site_Name", nullable=false, unique=true)
57     @OrderBy("asc")
58     private String siteName;
59
60     @Column(name="description", nullable=true, length=2048)
61     private String description;
62
63     @Temporal(TemporalType.TIMESTAMP)
64     @Column(name="created_date", updatable=false)
65     private Date createdDate;
66
67     @Temporal(TemporalType.TIMESTAMP)
68     @Column(name="modified_date", nullable=false)
69     private Date modifiedDate;
70
71     @ManyToOne(optional = false)
72     @JoinColumn(name="created_by")
73     private UserInfo userCreatedBy;
74
75     @ManyToOne(optional = false)
76     @JoinColumn(name="modified_by")
77     private UserInfo userModifiedBy;
78
79     public ClosedLoopSite() {
80         this.setModifiedDate(new Date());
81     }
82
83
84     public UserInfo getUserCreatedBy() {
85         return userCreatedBy;
86     }
87
88     public void setUserCreatedBy(UserInfo userCreatedBy) {
89         this.userCreatedBy = userCreatedBy;
90     }
91
92     public UserInfo getUserModifiedBy() {
93         return userModifiedBy;
94     }
95
96     public void setUserModifiedBy(UserInfo userModifiedBy) {
97         this.userModifiedBy = userModifiedBy;
98     }
99
100     @PrePersist
101     public void prePersist() {
102         Date date = new Date();
103         this.createdDate = date;
104         this.modifiedDate = date;
105     }
106
107     @PreUpdate
108     public void preUpdate() {
109         this.modifiedDate = new Date();
110     }
111
112     public int getId() {
113         return id;
114     }
115
116     public void setId(int id) {
117         this.id = id;
118     }
119
120     public String getSiteName() {
121         return siteName;
122     }
123
124     public void setSiteName(String siteName) {
125         this.siteName = siteName;
126     }
127
128     public String getDescription() {
129         return description;
130     }
131
132     public void setDescription(String description) {
133         this.description = description;
134     }
135
136     public Date getCreatedDate() {
137         return createdDate;
138     }
139
140     public void setCreatedDate(Date createdDate) {
141         this.createdDate = createdDate;
142     }
143
144     public Date getModifiedDate() {
145         return modifiedDate;
146     }
147
148     public void setModifiedDate(Date modifiedDate) {
149         this.modifiedDate = modifiedDate;
150     }
151
152 }