re base code
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / auditing / AuditingGetUebClusterEvent.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.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE)
37 public class AuditingGetUebClusterEvent extends AuditingGenericEvent {
38
39     @PartitionKey
40     protected UUID timebaseduuid;
41
42     @ClusteringColumn
43     protected Date timestamp1;
44
45     @Column(name = "request_id")
46     protected String requestId;
47
48     @Column(name = "service_instance_id")
49     protected String serviceInstanceId;
50     @Column
51     protected String action;
52     @Column
53     protected String status;
54
55     @Column(name = "description")
56     protected String desc;
57
58     @Column(name = "consumer_id")
59     private String consumerId;
60
61     //Required to be public as it is used by Cassandra driver on get operation
62     public AuditingGetUebClusterEvent() {
63         timestamp1 = new Date();
64         timebaseduuid = UUIDs.timeBased();
65     }
66
67     public AuditingGetUebClusterEvent(String action, CommonAuditData commonAuditData, String consumerId) {
68         this();
69         this.action = action;
70         this.requestId = commonAuditData.getRequestId();
71         this.serviceInstanceId = commonAuditData.getServiceInstanceId();
72         this.status = commonAuditData.getStatus();
73         this.desc = commonAuditData.getDescription();
74         this.consumerId = consumerId;
75     }
76
77     public void setTimestamp1(String timestamp) {
78         this.timestamp1 = parseDateFromString(timestamp);
79     }
80
81     @Override
82     public void fillFields() {
83         fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
84
85         fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
86         fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
87         fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
88         fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
89         fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId());
90         SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
91         simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
92         fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
93
94     }
95
96     public String getConsumerId() {
97         return consumerId;
98     }
99
100     public void setConsumerId(String consumerId) {
101         this.consumerId = consumerId;
102     }
103
104     public UUID getTimebaseduuid() {
105         return timebaseduuid;
106     }
107
108     public void setTimebaseduuid(UUID timebaseduuid) {
109         this.timebaseduuid = timebaseduuid;
110     }
111
112     public Date getTimestamp1() {
113         return timestamp1;
114     }
115
116     public void setTimestamp1(Date timestamp1) {
117         this.timestamp1 = timestamp1;
118     }
119
120     public String getRequestId() {
121         return requestId;
122     }
123
124     public void setRequestId(String requestId) {
125         this.requestId = requestId;
126     }
127
128     public String getServiceInstanceId() {
129         return serviceInstanceId;
130     }
131
132     public void setServiceInstanceId(String serviceInstanceId) {
133         this.serviceInstanceId = serviceInstanceId;
134     }
135
136     public String getAction() {
137         return action;
138     }
139
140     public void setAction(String action) {
141         this.action = action;
142     }
143
144     public String getStatus() {
145         return status;
146     }
147
148     public void setStatus(String status) {
149         this.status = status;
150     }
151
152     public String getDesc() {
153         return desc;
154     }
155
156     public void setDesc(String desc) {
157         this.desc = desc;
158     }
159
160     @Override
161     public String toString() {
162         return "AuditingGetUebClusterEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1
163                 + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action
164                 + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + "]";
165     }
166
167 }