2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.policy.rest.jpa;
22 import java.io.Serializable;
23 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;
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;
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;
52 @GeneratedValue(strategy = GenerationType.AUTO)
56 @Column(name="tagPickerName", nullable=false)
58 private String tagPickerName;
60 @Column(name="description", nullable=true, length=2048)
61 private String description;
63 @Column(name="networkRole", nullable=true)
64 private String networkRole;
66 @Column(name="tags", nullable=true)
68 private String tagValues;
70 @Temporal(TemporalType.TIMESTAMP)
71 @Column(name="created_date", updatable=false)
72 private Date createdDate;
74 @Temporal(TemporalType.TIMESTAMP)
75 @Column(name="modified_date", nullable=false)
76 private Date modifiedDate;
78 @ManyToOne(optional = false)
79 @JoinColumn(name="created_by")
80 private UserInfo userCreatedBy;
82 @ManyToOne(optional = false)
83 @JoinColumn(name="modified_by")
84 private UserInfo userModifiedBy;
86 private static Log logger = LogFactory.getLog(FWTagPicker.class);
89 //An empty constructor
92 public FWTagPicker(String string, String userid) {
96 public FWTagPicker(String domain) {
97 this.tagPickerName = domain;
101 public void prePersist() {
102 Date date = new Date();
103 this.createdDate = date;
104 this.modifiedDate = date;
108 public void preUpdate() {
109 this.modifiedDate = new Date();
111 this.userModifiedBy =XacmlAdminAuthorization.getUserId();
112 } catch (Exception e) {
113 logger.error("Exception caused While adding Modified by Role"+e);
114 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DescriptiveScope", "Exception caused While adding Modified by Role");
121 public void setId(int id) {
125 public String getTagPickerName() {
126 return tagPickerName;
129 public void setTagPickerName(String tagPickerName) {
130 this.tagPickerName = tagPickerName;
133 public String getDescription() {
134 return this.description;
137 public void setDescription(String description) {
138 this.description = description;
141 public String getNetworkRole() {
145 public void setNetworkRole(String networkRole) {
146 this.networkRole = networkRole;
149 public String getTagValues() {
153 public void setTagValues(String tagValues) {
154 this.tagValues = tagValues;
157 public Date getCreatedDate() {
158 return this.createdDate;
161 public void setCreatedDate(Date createdDate) {
162 this.createdDate = createdDate;
165 public Date getModifiedDate() {
166 return this.modifiedDate;
169 public void setModifiedDate(Date modifiedDate) {
170 this.modifiedDate = modifiedDate;
173 public UserInfo getUserCreatedBy() {
174 return userCreatedBy;
177 public void setUserCreatedBy(UserInfo userCreatedBy) {
178 this.userCreatedBy = userCreatedBy;
181 public UserInfo getUserModifiedBy() {
182 return userModifiedBy;
185 public void setUserModifiedBy(UserInfo userModifiedBy) {
186 this.userModifiedBy = userModifiedBy;