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=========================================================
23 package org.onap.policy.rest.jpa;
24 import java.io.Serializable;
25 import java.util.Date;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.GeneratedValue;
30 import javax.persistence.GenerationType;
31 import javax.persistence.Id;
32 import javax.persistence.JoinColumn;
33 import javax.persistence.ManyToOne;
34 import javax.persistence.NamedQueries;
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.onap.policy.rest.XacmlAdminAuthorization;
49 @Table(name="ActionPolicyDict")
51 @NamedQuery(name="ActionPolicyDict.findAll", query="SELECT e FROM ActionPolicyDict e")
53 public class ActionPolicyDict implements Serializable {
54 private static final long serialVersionUID = 1L;
56 @GeneratedValue(strategy = GenerationType.AUTO)
60 @Column(name="ATTRIBUTE_NAME", nullable=false)
62 private String attributeName;
64 @Column(name="Type", nullable=false)
68 @Column(name="URL", nullable=false)
72 @Column(name="Method", nullable=false)
74 private String method;
76 @Column(name="Headers", nullable=true)
78 private String header;
80 @Column(name="Body", nullable=true)
84 @Temporal(TemporalType.TIMESTAMP)
85 @Column(name="created_date", updatable=false)
86 private Date createdDate;
88 @Column(name="description", nullable=true, length=2048)
89 private String description;
91 @Temporal(TemporalType.TIMESTAMP)
92 @Column(name="modified_date", nullable=false)
93 private Date modifiedDate;
95 @ManyToOne(optional = false)
96 @JoinColumn(name="created_by")
97 private UserInfo userCreatedBy;
99 @ManyToOne(optional = false)
100 @JoinColumn(name="modified_by")
101 private UserInfo userModifiedBy;
103 public UserInfo getUserCreatedBy() {
104 return userCreatedBy;
107 public void setUserCreatedBy(UserInfo userCreatedBy) {
108 this.userCreatedBy = userCreatedBy;
111 public UserInfo getUserModifiedBy() {
112 return userModifiedBy;
115 public void setUserModifiedBy(UserInfo userModifiedBy) {
116 this.userModifiedBy = userModifiedBy;
119 private static Log logger = LogFactory.getLog(ActionPolicyDict.class);
120 public ActionPolicyDict() {
121 //An empty constructor
124 public ActionPolicyDict(String string, String userid) {
128 public ActionPolicyDict(String domain) {
132 public void prePersist() {
133 Date date = new Date();
134 this.createdDate = date;
135 this.modifiedDate = date;
138 public void preUpdate() {
139 this.modifiedDate = new Date();
141 this.userModifiedBy =XacmlAdminAuthorization.getUserId();
142 } catch (Exception e) {
143 logger.error("Exception caused While adding Modified by Role"+e);
149 public void setId(int id) {
153 public Date getCreatedDate() {
154 return this.createdDate;
156 public void setCreatedDate(Date createdDate) {
157 this.createdDate = createdDate;
159 public String getDescription() {
160 return this.description;
162 public void setDescription(String description) {
163 this.description = description;
166 public Date getModifiedDate() {
167 return this.modifiedDate;
169 public void setModifiedDate(Date modifiedDate) {
170 this.modifiedDate = modifiedDate;
172 public String getType() {
175 public void setType(String type) {
179 public String getUrl() {
182 public void setUrl(String url) {
185 public String getMethod() {
188 public void setMethod(String method) {
189 this.method = method;
191 public String getHeader() {
194 public void setHeader(String header) {
195 this.header = header;
198 public String getBody() {
201 public void setBody(String body) {
204 public String getAttributeName() {
205 return attributeName;
207 public void setAttributeName(String attributeName) {
208 this.attributeName = attributeName;