708ebf591a09373fd08016b9399cbb41321f5a04
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / FWTagPicker.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 package org.onap.policy.rest.jpa;
21
22 import java.io.Serializable;
23 import java.util.Date;
24
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 import org.apache.commons.logging.Log;
41 import org.apache.commons.logging.LogFactory;
42 import org.onap.policy.common.logging.eelf.MessageCodes;
43 import org.onap.policy.common.logging.eelf.PolicyLogger;
44 import org.onap.policy.rest.XacmlAdminAuthorization;
45
46 @Entity
47 @Table(name = "FWTagPicker")
48 @NamedQuery(name = "FWTagPicker.findAll", query= "Select p from FWTagPicker p")
49 public class FWTagPicker implements Serializable {
50         private static final long serialVersionUID = 1L;
51         @Id
52         @GeneratedValue(strategy = GenerationType.AUTO)
53         @Column(name = "Id")
54         private int id;
55
56         @Column(name="tagPickerName", nullable=false)
57         @OrderBy("asc")
58         private String tagPickerName;
59
60         @Column(name="description", nullable=true, length=2048)
61         private String description;
62         
63         @Column(name="networkRole", nullable=true)
64         private String networkRole;
65
66         @Column(name="tags", nullable=true)
67         @OrderBy("asc")
68         private String tagValues;
69
70         @Temporal(TemporalType.TIMESTAMP)
71         @Column(name="created_date", updatable=false)
72         private Date createdDate;
73
74         @Temporal(TemporalType.TIMESTAMP)
75         @Column(name="modified_date", nullable=false)
76         private Date modifiedDate;
77
78         @ManyToOne(optional = false)
79         @JoinColumn(name="created_by")
80         private UserInfo userCreatedBy;
81
82         @ManyToOne(optional = false)
83         @JoinColumn(name="modified_by")
84         private UserInfo userModifiedBy;
85
86         private static Log logger = LogFactory.getLog(FWTagPicker.class);       
87         
88         @PrePersist
89         public void     prePersist() {
90                 Date date = new Date();
91                 this.createdDate = date;
92                 this.modifiedDate = date;
93         }
94         
95         @PreUpdate
96         public void preUpdate() {
97                 this.modifiedDate = new Date();
98                 try {
99                         this.userModifiedBy =XacmlAdminAuthorization.getUserId();
100                 } catch (Exception e) {
101                         logger.error("Exception caused While adding Modified by Role"+e);
102                         PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DescriptiveScope", "Exception caused While adding Modified by Role");
103                 }
104         }
105         
106         public int getId() {
107                 return this.id;
108         }
109         public void setId(int id) {
110                 this.id = id;
111         }
112         
113         public String getTagPickerName() {
114                 return tagPickerName;
115         }
116
117         public void setTagPickerName(String tagPickerName) {
118                 this.tagPickerName = tagPickerName;
119         }
120         
121         public String getDescription() {
122                 return this.description;
123         }
124         
125         public void setDescription(String description) {
126                 this.description = description;
127         }
128
129         public String getNetworkRole() {
130                 return networkRole;
131         }
132
133         public void setNetworkRole(String networkRole) {
134                 this.networkRole = networkRole;
135         }
136         
137         public String getTagValues() {
138                 return tagValues;
139         }
140
141         public void setTagValues(String tagValues) {
142                 this.tagValues = tagValues;
143         }
144         
145         public Date getCreatedDate() {
146                 return this.createdDate;
147         }
148         
149         public void setCreatedDate(Date createdDate) {
150                 this.createdDate = createdDate;
151         }
152         
153         public Date getModifiedDate() {
154                 return this.modifiedDate;
155         }
156         
157         public void setModifiedDate(Date modifiedDate) {
158                 this.modifiedDate = modifiedDate;
159         }
160         
161         public UserInfo getUserCreatedBy() {
162                 return userCreatedBy;
163         }
164
165         public void setUserCreatedBy(UserInfo userCreatedBy) {
166                 this.userCreatedBy = userCreatedBy;
167         }
168
169         public UserInfo getUserModifiedBy() {
170                 return userModifiedBy;
171         }
172
173         public void setUserModifiedBy(UserInfo userModifiedBy) {
174                 this.userModifiedBy = userModifiedBy;
175         }
176
177 }