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.openecomp.policy.rest.jpa;
25 import java.io.Serializable;
26 import java.util.Date;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.GeneratedValue;
31 import javax.persistence.GenerationType;
32 import javax.persistence.Id;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.ManyToOne;
35 import javax.persistence.NamedQuery;
36 import javax.persistence.OrderBy;
37 import javax.persistence.PrePersist;
38 import javax.persistence.PreUpdate;
39 import javax.persistence.Table;
40 import javax.persistence.Temporal;
41 import javax.persistence.TemporalType;
43 import org.apache.commons.logging.Log;
44 import org.apache.commons.logging.LogFactory;
45 import org.openecomp.policy.rest.XacmlAdminAuthorization;
47 import org.openecomp.policy.common.logging.eelf.MessageCodes;
48 import org.openecomp.policy.common.logging.eelf.PolicyLogger;
52 @Table(name = "ClosedLoopD2Services")
53 @NamedQuery(name="ClosedLoopD2Services.findAll", query="SELECT c FROM ClosedLoopD2Services c ")
54 public class ClosedLoopD2Services implements Serializable{
55 private static final long serialVersionUID = 1L;
57 private static String domain;
62 @GeneratedValue(strategy = GenerationType.AUTO)
65 @Column(name="service_Name", nullable=false, unique=true)
67 private String serviceName;
69 @Column(name="description", nullable=true, length=2048)
70 private String description;
72 @Temporal(TemporalType.TIMESTAMP)
73 @Column(name="created_date", updatable=false)
74 private Date createdDate;
76 @Temporal(TemporalType.TIMESTAMP)
77 @Column(name="modified_date", nullable=false)
78 private Date modifiedDate;
80 @ManyToOne(optional = false)
81 @JoinColumn(name="created_by")
82 private UserInfo userCreatedBy;
84 @ManyToOne(optional = false)
85 @JoinColumn(name="modified_by")
86 private UserInfo userModifiedBy;
88 public UserInfo getUserCreatedBy() {
92 public void setUserCreatedBy(UserInfo userCreatedBy) {
93 this.userCreatedBy = userCreatedBy;
96 public UserInfo getUserModifiedBy() {
97 return userModifiedBy;
100 public void setUserModifiedBy(UserInfo userModifiedBy) {
101 this.userModifiedBy = userModifiedBy;
104 private static Log logger = LogFactory.getLog(ClosedLoopD2Services.class);
106 public ClosedLoopD2Services(){
110 public ClosedLoopD2Services(String string, String userid) {
114 public ClosedLoopD2Services(String domain) {
115 this.serviceName = domain;
119 public void prePersist() {
120 Date date = new Date();
121 this.createdDate = date;
122 this.modifiedDate = date;
126 public void preUpdate() {
127 this.modifiedDate = new Date();
129 this.userModifiedBy = XacmlAdminAuthorization.getUserId();;
130 } catch (Exception e) {
131 logger.error("Exception caused While adding Modified by Role"+e);
132 // TODO:EELF Cleanup - Remove logger
133 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ClosedLoopD2Services", "Exception caused While adding Modified by Role");
141 public void setId(int id) {
145 public String getServiceName() {
149 public void setServiceName(String serviceName) {
150 this.serviceName = serviceName;
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;