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.be.resources.data.auditing.model.ResourceCommonInfo;
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.DISTRIBUTION_DEPLOY_EVENT_TYPE)
44 public class DistributionDeployEvent extends AuditingGenericEvent {
47 protected UUID timebaseduuid;
50 protected Date timestamp1;
52 @Column(name = "request_id")
53 protected String requestId;
55 @Column(name = "service_instance_id")
56 protected String serviceInstanceId;
58 protected String action;
60 protected String status;
62 @Column(name = "description")
63 protected String desc;
65 @Column(name = "resource_name")
66 private String resourceName;
68 @Column(name = "resource_type")
69 private String resourceType;
71 @Column(name = "curr_version")
72 private String currVersion;
75 private String modifier;
80 public DistributionDeployEvent() {
81 timestamp1 = new Date();
82 timebaseduuid = UUIDs.timeBased();
85 public DistributionDeployEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo, String did, String modifier,
89 this.requestId = commonAuditData.getRequestId();
90 this.serviceInstanceId = commonAuditData.getServiceInstanceId();
91 this.status = commonAuditData.getStatus();
92 this.desc = commonAuditData.getDescription();
94 this.modifier = modifier;
95 this.currVersion = currVersion;
96 this.resourceName = resourceCommonInfo.getResourceName();
97 this.resourceType = resourceCommonInfo.getResourceType();
100 public void setTimestamp1(String timestamp) {
101 this.timestamp1 = parseDateFromString(timestamp);
104 public void setTimestamp1(Date timestamp1) {
105 this.timestamp1 = timestamp1;
109 public void fillFields() {
110 fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
111 fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
112 fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
113 fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
114 fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
116 fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid());
117 fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier());
118 fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion());
119 fields.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName());
120 fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType());
121 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
122 simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
123 fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));