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.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
32 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
34 import java.text.SimpleDateFormat;
35 import java.util.Date;
36 import java.util.TimeZone;
37 import java.util.UUID;
42 @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE)
43 public class GetCategoryHierarchyEvent extends AuditingGenericEvent {
45 protected UUID timebaseduuid;
48 // @Column(name="timestamp")
49 protected Date timestamp1;
51 @Column(name = "request_id")
52 protected String requestId;
54 protected String action;
56 protected String status;
58 @Column(name = "description")
59 protected String desc;
62 private String modifier;
65 private String details;
67 //Required to be public as it is used by Cassandra driver on get operation
68 public GetCategoryHierarchyEvent() {
69 timestamp1 = new Date();
70 timebaseduuid = UUIDs.timeBased();
73 public GetCategoryHierarchyEvent(String action, CommonAuditData commonAuditData, String modifier, String details) {
76 this.requestId = commonAuditData.getRequestId();
77 this.desc = commonAuditData.getDescription();
78 this.status = commonAuditData.getStatus();
79 this.modifier = modifier;
80 this.details = details;
83 public void setTimestamp1(String timestamp) {
84 this.timestamp1 = parseDateFromString(timestamp);
87 public void setTimestamp1(Date timestamp1) {
88 this.timestamp1 = timestamp1;
92 public void fillFields() {
93 fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
95 fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
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_DETAILS.getDisplayName(), getDetails());
100 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
101 simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
102 fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));