Initial OpenECOMP policy/engine commit
[policy/engine.git] / ECOMP-REST / src / main / java / org / openecomp / policy / rest / jpa / FirewallDictionaryList.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP-REST
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.policy.rest.jpa;
22
23 import java.io.Serializable;
24 import java.util.Date;
25
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;
40
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43 import org.openecomp.policy.rest.XacmlAdminAuthorization;
44
45 import org.openecomp.policy.common.logging.eelf.MessageCodes;
46 import org.openecomp.policy.common.logging.eelf.PolicyLogger;
47
48
49 @Entity
50 @Table(name="parentdictionaryitems")
51 @NamedQuery(name="FirewallDictionaryList.findAll", query="SELECT e FROM FirewallDictionaryList e")
52 public class FirewallDictionaryList implements Serializable {
53         private static final long serialVersionUID = 1L;
54
55         private static String domain;
56
57         @Id
58         @GeneratedValue(strategy = GenerationType.AUTO)
59         @Column(name="id")
60         private int id;
61         
62         @Column(name="parentItemName", nullable=false)
63         @OrderBy("asc")
64         private String parentItemName;
65         
66         @Column(name="description")
67         private String description;
68         
69         @Column(name="addressList")
70         private String addressList;
71         
72         @Column(name="serviceList")
73         private String serviceList;
74         
75 /*      @Temporal(TemporalType.TIMESTAMP)
76         @Column(name="created_date", updatable=false)
77         private Date createdDate;
78
79         @Temporal(TemporalType.TIMESTAMP)
80         @Column(name="modified_date", nullable=false)
81         private Date modifiedDate;
82         
83         @ManyToOne(optional = false)
84         @JoinColumn(name="created_by")
85         private UserInfo userCreatedBy;
86
87         @ManyToOne(optional = false)
88         @JoinColumn(name="modified_by")
89         private UserInfo userModifiedBy;*/
90
91         public int getId() {
92                 return this.id;
93         }
94
95         public void setId(int id) {
96                 this.id = id;
97         }
98         
99         public String getParentItemName() {
100                 return parentItemName;
101         }
102
103         public String getDescription() {
104                 return description;
105         }
106
107         public String getAddressList() {
108                 return addressList;
109         }
110
111         public String getServiceList() {
112                 return serviceList;
113         }
114
115         public void setParentItemName(String parentItemName) {
116                 this.parentItemName = parentItemName;
117         }
118
119         public void setDescription(String description) {
120                 this.description = description;
121         }
122
123         public void setAddressList(String addressList) {
124                 this.addressList = addressList;
125         }
126
127         public void setServiceList(String serviceList) {
128                 this.serviceList = serviceList;
129         }
130         
131         
132         /*public UserInfo getUserCreatedBy() {
133                 return userCreatedBy;
134         }
135
136         public void setUserCreatedBy(UserInfo userCreatedBy) {
137                 this.userCreatedBy = userCreatedBy;
138         }
139
140         public UserInfo getUserModifiedBy() {
141                 return userModifiedBy;
142         }
143
144         public void setUserModifiedBy(UserInfo userModifiedBy) {
145                 this.userModifiedBy = userModifiedBy;
146         }*/
147
148         private static Log logger = LogFactory.getLog(FirewallDictionaryList.class);
149         
150         public FirewallDictionaryList() {
151                 
152         }
153         
154         private static final Log auditLogger = LogFactory
155                         .getLog("auditLogger");
156         
157         public FirewallDictionaryList(String string, String userid) {
158                 this(domain);
159         }
160         public FirewallDictionaryList(String domain) {
161                 this.parentItemName = domain;
162         }       
163
164         /*@PrePersist
165         public void     prePersist() {
166                 Date date = new Date();
167                 this.createdDate = date;
168                 this.modifiedDate = date;
169                 auditLogger.debug("Added New Term Name: "+this.parentItemName+" by "+this.userCreatedBy);
170                 
171         }
172         @PreUpdate
173         public void preUpdate() {
174                 this.modifiedDate = new Date();
175                 try {
176                         this.userModifiedBy =XacmlAdminAuthorization.getUserId();;
177                 } catch (Exception e) {
178                         logger.error("Exception caused While adding Modified by Role"+e);
179                         // TODO:EELF Cleanup - Remove logger
180                         PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role");
181                 }
182                 auditLogger.debug("Updated Term Name: "+this.parentItemName+" by "+this.userModifiedBy);
183         }
184 */
185 }