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.sdc.be.resources.data.auditing;
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;
30 import lombok.ToString;
31 import org.apache.tinkerpop.shaded.jackson.annotation.JsonSetter;
32 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
33 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
35 import java.text.SimpleDateFormat;
36 import java.util.Date;
37 import java.util.TimeZone;
38 import java.util.UUID;
43 @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.CONSUMER_EVENT_TYPE)
44 public class ConsumerEvent extends AuditingGenericEvent {
47 protected UUID timebaseduuid;
50 protected Date timestamp1;
52 @Column(name = "request_id")
53 protected String requestId;
55 protected String action;
57 protected String status;
59 @Column(name = "description")
60 protected String desc;
63 private String modifier;
65 @Column(name = "ecomp_user")
66 private String ecompUser;
68 public ConsumerEvent(String action, CommonAuditData commonAuditData, String ecompUser, String modifier) {
71 this.requestId = commonAuditData.getRequestId();
72 this.status = commonAuditData.getStatus();
73 this.desc = commonAuditData.getDescription();
74 this.modifier = modifier;
75 this.ecompUser = ecompUser;
78 //Required to be public as it is used by Cassandra driver on get operation
79 public ConsumerEvent() {
80 timestamp1 = new Date();
81 timebaseduuid = UUIDs.timeBased();
84 public void setTimestamp1(String timestamp) {
85 this.timestamp1 = parseDateFromString(timestamp);
88 public void setTimestamp1(Date timestamp1) {
89 this.timestamp1 = timestamp1;
93 public void fillFields() {
94 fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
96 fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
97 fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
98 fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
99 fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier());
100 fields.put(AuditingFieldsKey.AUDIT_ECOMP_USER.getDisplayName(), getEcompUser());
101 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
102 simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
103 fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));