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