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=========================================================
21 package org.onap.policy.rest.jpa;
23 import java.io.Serializable;
24 import java.util.Date;
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;
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43 import org.onap.policy.rest.XacmlAdminAuthorization;
45 import org.onap.policy.common.logging.eelf.MessageCodes;
46 import org.onap.policy.common.logging.eelf.PolicyLogger;
49 @Table(name="PolicyEditorScopes")
50 @NamedQuery(name="PolicyEditorScopes.findAll", query="SELECT p FROM PolicyEditorScopes p ")
51 public class PolicyEditorScopes implements Serializable{
52 private static final long serialVersionUID = 1L;
53 private static Log logger = LogFactory.getLog(PolicyEditorScopes.class);
55 private static String domain;
58 @GeneratedValue(strategy = GenerationType.AUTO)
62 @Column(name="scopeName", nullable=false, unique=true)
64 private String scopeName;
66 @Temporal(TemporalType.TIMESTAMP)
67 @Column(name="created_date", updatable=false)
68 private Date createdDate;
70 @Temporal(TemporalType.TIMESTAMP)
71 @Column(name="modified_date", nullable=false)
72 private Date modifiedDate;
74 @ManyToOne(optional = false)
75 @JoinColumn(name="created_by")
76 private UserInfo userCreatedBy;
78 @ManyToOne(optional = false)
79 @JoinColumn(name="modified_by")
80 private UserInfo userModifiedBy;
82 public PolicyEditorScopes() {
85 public PolicyEditorScopes(String string, String userid) {
89 public PolicyEditorScopes(String domain) {
90 this.scopeName = domain;
94 public void prePersist() {
95 Date date = new Date();
96 this.createdDate = date;
97 this.modifiedDate = date;
101 public void preUpdate() {
102 this.modifiedDate = new Date();
104 this.userModifiedBy =XacmlAdminAuthorization.getUserId();
105 } catch (Exception e) {
106 logger.error("Exception caused While adding Modified by Role"+e);
107 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEditorScopes", "Exception caused While adding Modified by Role");
115 public void setId(int id) {
119 public String getScopeName() {
123 public void setScopeName(String scopeName) {
124 this.scopeName = scopeName;
127 public Date getCreatedDate() {
128 return this.createdDate;
131 public void setCreatedDate(Date createdDate) {
132 this.createdDate = createdDate;
135 public Date getModifiedDate() {
136 return this.modifiedDate;
139 public void setModifiedDate(Date modifiedDate) {
140 this.modifiedDate = modifiedDate;
143 public UserInfo getUserCreatedBy() {
144 return userCreatedBy;
147 public void setUserCreatedBy(UserInfo userCreatedBy) {
148 this.userCreatedBy = userCreatedBy;
151 public UserInfo getUserModifiedBy() {
152 return userModifiedBy;
155 public void setUserModifiedBy(UserInfo userModifiedBy) {
156 this.userModifiedBy = userModifiedBy;