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