441cbc42f0bc5b6e29f9d4c15301eee85b3fc882
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / auditing / GetUsersListEvent.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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.sdc.be.resources.data.auditing;
22
23 import com.datastax.driver.core.utils.UUIDs;
24 import com.datastax.driver.mapping.annotations.ClusteringColumn;
25 import com.datastax.driver.mapping.annotations.Column;
26 import com.datastax.driver.mapping.annotations.PartitionKey;
27 import com.datastax.driver.mapping.annotations.Table;
28 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
29 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
30
31 import java.text.SimpleDateFormat;
32 import java.util.Date;
33 import java.util.TimeZone;
34 import java.util.UUID;
35
36 @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE)
37 public class GetUsersListEvent extends AuditingGenericEvent {
38     @PartitionKey
39     protected UUID timebaseduuid;
40
41     @ClusteringColumn
42     protected Date timestamp1;
43
44     @Column(name = "request_id")
45     protected String requestId;
46     @Column
47     protected String action;
48     @Column
49     protected String status;
50
51     @Column(name = "description")
52     protected String desc;
53
54     @Column
55     private String modifier;
56
57     @Column
58     private String details;
59
60     //Required to be public as it is used by Cassandra driver on get operation
61     public GetUsersListEvent() {
62         timestamp1 = new Date();
63         timebaseduuid = UUIDs.timeBased();
64     }
65
66     public GetUsersListEvent(String action, CommonAuditData commonAuditData, String modifier, String userDetails) {
67         this();
68         this.action = action;
69         this.requestId = commonAuditData.getRequestId();
70         this.status = commonAuditData.getStatus();
71         this.desc = commonAuditData.getDescription();
72         this.modifier = modifier;
73         this.details = userDetails;
74     }
75
76     public void setTimestamp1(String timestamp) {
77         this.timestamp1 = parseDateFromString(timestamp);
78     }
79
80     @Override
81     public void fillFields() {
82         fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
83
84         fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
85         fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
86         fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
87         fields.put(AuditingFieldsKey.AUDIT_USER_DETAILS.getDisplayName(), getDetails());
88         fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier());
89         SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
90         simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
91         fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
92     }
93
94     public UUID getTimebaseduuid() {
95         return timebaseduuid;
96     }
97
98     public void setTimebaseduuid(UUID timebaseduuid) {
99         this.timebaseduuid = timebaseduuid;
100     }
101
102     public Date getTimestamp1() {
103         return timestamp1;
104     }
105
106     public void setTimestamp1(Date timestamp1) {
107         this.timestamp1 = timestamp1;
108     }
109
110     public String getRequestId() {
111         return requestId;
112     }
113
114     public void setRequestId(String requestId) {
115         this.requestId = requestId;
116     }
117
118     public String getAction() {
119         return action;
120     }
121
122     public void setAction(String action) {
123         this.action = action;
124     }
125
126     public String getStatus() {
127         return status;
128     }
129
130     public void setStatus(String status) {
131         this.status = status;
132     }
133
134     public String getDesc() {
135         return desc;
136     }
137
138     public void setDesc(String desc) {
139         this.desc = desc;
140     }
141
142     public String getModifier() {
143         return modifier;
144     }
145
146     public void setModifier(String modifier) {
147         this.modifier = modifier;
148     }
149
150     public String getDetails() {
151         return details;
152     }
153
154     public void setDetails(String details) {
155         this.details = details;
156     }
157
158     @Override
159     public String toString() {
160         return "GetUsersListEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId="
161                 + requestId + ", action=" + action + ", status=" + status + ", desc=" + desc + ", modifier=" + modifier
162                 + ", details=" + details + "]";
163     }
164
165 }