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.openecomp.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.openecomp.policy.common.logging.eelf.MessageCodes;
43 import org.openecomp.policy.common.logging.eelf.PolicyLogger;
44 import org.openecomp.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="tags", nullable=true)
65 private String tagValues;
67 @Temporal(TemporalType.TIMESTAMP)
68 @Column(name="created_date", updatable=false)
69 private Date createdDate;
71 @Temporal(TemporalType.TIMESTAMP)
72 @Column(name="modified_date", nullable=false)
73 private Date modifiedDate;
75 @ManyToOne(optional = false)
76 @JoinColumn(name="created_by")
77 private UserInfo userCreatedBy;
79 @ManyToOne(optional = false)
80 @JoinColumn(name="modified_by")
81 private UserInfo userModifiedBy;
83 private static Log logger = LogFactory.getLog(FWTagPicker.class);
89 public FWTagPicker(String string, String userid) {
93 public FWTagPicker(String domain) {
94 this.tagPickerName = domain;
98 public void prePersist() {
99 Date date = new Date();
100 this.createdDate = date;
101 this.modifiedDate = date;
105 public void preUpdate() {
106 this.modifiedDate = new Date();
108 this.userModifiedBy =XacmlAdminAuthorization.getUserId();
109 } catch (Exception e) {
110 logger.error("Exception caused While adding Modified by Role"+e);
111 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DescriptiveScope", "Exception caused While adding Modified by Role");
118 public void setId(int id) {
122 public String getTagPickerName() {
123 return tagPickerName;
126 public void setTagPickerName(String tagPickerName) {
127 this.tagPickerName = tagPickerName;
130 public String getDescription() {
131 return this.description;
134 public void setDescription(String description) {
135 this.description = description;
138 public String getTagValues() {
142 public void setTagValues(String tagValues) {
143 this.tagValues = tagValues;
146 public Date getCreatedDate() {
147 return this.createdDate;
150 public void setCreatedDate(Date createdDate) {
151 this.createdDate = createdDate;
154 public Date getModifiedDate() {
155 return this.modifiedDate;
158 public void setModifiedDate(Date modifiedDate) {
159 this.modifiedDate = modifiedDate;
162 public UserInfo getUserCreatedBy() {
163 return userCreatedBy;
166 public void setUserCreatedBy(UserInfo userCreatedBy) {
167 this.userCreatedBy = userCreatedBy;
170 public UserInfo getUserModifiedBy() {
171 return userModifiedBy;
174 public void setUserModifiedBy(UserInfo userModifiedBy) {
175 this.userModifiedBy = userModifiedBy;