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;
28 import lombok.AccessLevel;
31 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
32 import org.openecomp.sdc.be.resources.data.auditing.model.OperationalEnvAuditData;
33 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
34 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
35 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
37 import java.text.SimpleDateFormat;
38 import java.util.Date;
39 import java.util.TimeZone;
40 import java.util.UUID;
44 @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE)
45 public class DistributionNotificationEvent extends AuditingGenericEvent {
48 protected UUID timebaseduuid;
51 @Setter(AccessLevel.NONE)protected Date timestamp1;
53 @Column(name = "request_id")
54 protected String requestId;
56 @Column(name = "service_instance_id")
57 protected String serviceInstanceId;
59 protected String action;
61 protected String status;
63 @Column(name = "description")
64 protected String desc;
66 @Column(name = "resource_name")
67 private String resourceName;
69 @Column(name = "resource_type")
70 private String resourceType;
72 @Column(name = "curr_version")
73 private String currVersion;
76 private String modifier;
78 @Column(name = "curr_state")
79 private String currState;
81 @Column(name = "topic_name")
82 private String topicName;
87 @Column(name = "env_id")
90 @Column(name = "vnf_workload_context")
91 private String vnfWorkloadContext;
93 @Column(name = "tenant")
94 private String tenant;
96 public DistributionNotificationEvent() {
97 timestamp1 = new Date();
98 timebaseduuid = UUIDs.timeBased();
101 public DistributionNotificationEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo,
102 ResourceVersionInfo resourceVersionInfo,
103 String did, String modifier, String topicName,
104 OperationalEnvAuditData opEnvFields) {
106 this.action = action;
107 this.requestId = commonAuditData.getRequestId();
108 this.serviceInstanceId = commonAuditData.getServiceInstanceId();
109 this.status = commonAuditData.getStatus();
110 this.desc = commonAuditData.getDescription();
112 this.modifier = modifier;
113 this.currState = resourceVersionInfo.getState();
114 this.currVersion = resourceVersionInfo.getVersion();
115 this.resourceName = resourceCommonInfo.getResourceName();
116 this.resourceType = resourceCommonInfo.getResourceType();
117 this.topicName = topicName;
118 this.envId = opEnvFields.getEnvId();
119 this.vnfWorkloadContext = opEnvFields.getVnfWorkloadContext();
120 this.tenant = opEnvFields.getTenant();
124 public void setTimestamp1(String timestamp) {
125 this.timestamp1 = parseDateFromString(timestamp);
128 public void setTimestamp1(Date timestamp) {
129 this.timestamp1 = timestamp;
133 public void fillFields() {
134 fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
136 fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
137 fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
138 fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
139 fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
140 fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ENVIRONMENT_ID.getDisplayName(), getEnvId());
141 fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_VNF_WORKLOAD_CONTEXT.getDisplayName(), getVnfWorkloadContext());
142 fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_TENANT.getDisplayName(), getTenant());
144 fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid());
145 fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier());
146 fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE.getDisplayName(), getCurrState());
147 fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion());
148 fields.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName());
149 fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType());
150 fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_TOPIC_NAME.getDisplayName(), getTopicName());
151 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
152 simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
153 fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
157 public String toString() {
158 return "DistributionNotificationEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1
159 + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action
160 + ", status=" + status + ", desc=" + desc + ", resourceName=" + resourceName + ", resourceType="
161 + resourceType + ", currVersion=" + currVersion + ", modifier=" + modifier + ", currState=" + currState
162 + ", topicName=" + topicName + ", did=" + did
163 + ", envId=" + envId + ", vnfWorkloadContext=" + vnfWorkloadContext + ", tenant=" + tenant + "]";