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;
26 import java.io.Serializable;
27 import java.util.Date;
29 import javax.persistence.Column;
30 import javax.persistence.Entity;
31 import javax.persistence.GeneratedValue;
32 import javax.persistence.GenerationType;
33 import javax.persistence.Id;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.ManyToOne;
36 import javax.persistence.NamedQuery;
37 import javax.persistence.OrderBy;
38 import javax.persistence.PrePersist;
39 import javax.persistence.PreUpdate;
40 import javax.persistence.Table;
41 import javax.persistence.Temporal;
42 import javax.persistence.TemporalType;
44 import org.apache.commons.logging.Log;
45 import org.apache.commons.logging.LogFactory;
46 import org.onap.policy.rest.XacmlAdminAuthorization;
48 import org.onap.policy.common.logging.eelf.MessageCodes;
49 import org.onap.policy.common.logging.eelf.PolicyLogger;
53 @Table(name = "ClosedLoopSite")
54 @NamedQuery(name="ClosedLoopSite.findAll", query="SELECT c FROM ClosedLoopSite c ")
55 public class ClosedLoopSite implements Serializable{
56 private static final long serialVersionUID = 1L;
58 private static String domain;
63 @GeneratedValue(strategy = GenerationType.AUTO)
66 @Column(name="site_Name", nullable=false, unique=true)
68 private String siteName;
70 @Column(name="description", nullable=true, length=2048)
71 private String description;
73 @Temporal(TemporalType.TIMESTAMP)
74 @Column(name="created_date", updatable=false)
75 private Date createdDate;
77 @Temporal(TemporalType.TIMESTAMP)
78 @Column(name="modified_date", nullable=false)
79 private Date modifiedDate;
81 @ManyToOne(optional = false)
82 @JoinColumn(name="created_by")
83 private UserInfo userCreatedBy;
85 @ManyToOne(optional = false)
86 @JoinColumn(name="modified_by")
87 private UserInfo userModifiedBy;
89 public UserInfo getUserCreatedBy() {
93 public void setUserCreatedBy(UserInfo userCreatedBy) {
94 this.userCreatedBy = userCreatedBy;
97 public UserInfo getUserModifiedBy() {
98 return userModifiedBy;
101 public void setUserModifiedBy(UserInfo userModifiedBy) {
102 this.userModifiedBy = userModifiedBy;
105 private static Log LOGGER = LogFactory.getLog(ClosedLoopSite.class);
107 public ClosedLoopSite(){
111 public ClosedLoopSite(String string, String userid) {
115 public ClosedLoopSite(String domain) {
116 this.siteName = domain;
120 public void prePersist() {
121 Date date = new Date();
122 this.createdDate = date;
123 this.modifiedDate = date;
127 public void preUpdate() {
128 this.modifiedDate = new Date();
130 this.userModifiedBy = XacmlAdminAuthorization.getUserId();;
131 } catch (Exception e) {
132 LOGGER.error("Exception caused While adding Modified by Role"+e);
133 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ClosedLoopSite", "Exception caused While adding Modified by Role");
141 public void setId(int id) {
145 public String getSiteName() {
149 public void setSiteName(String siteName) {
150 this.siteName = siteName;
153 public String getDescription() {
157 public void setDescription(String description) {
158 this.description = description;
161 public Date getCreatedDate() {
165 public void setCreatedDate(Date createdDate) {
166 this.createdDate = createdDate;
169 public Date getModifiedDate() {
173 public void setModifiedDate(Date modifiedDate) {
174 this.modifiedDate = modifiedDate;