2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.mapping.annotations.ClusteringColumn;
24 import com.datastax.driver.mapping.annotations.Column;
25 import com.datastax.driver.mapping.annotations.PartitionKey;
26 import com.datastax.driver.mapping.annotations.Table;
29 import lombok.ToString;
30 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
32 import java.text.SimpleDateFormat;
33 import java.util.Date;
34 import java.util.TimeZone;
40 @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE)
41 public class EcompOperationalEnvironmentEvent extends AuditingGenericEvent {
44 @Column(name = "operational_environment_id")
45 protected String operationalEnvironmentId;
48 protected Date timestamp1;
51 protected String action;
53 @Column(name = "operational_environment_action")
54 protected String operationalEnvironmentAction;
56 @Column(name = "operational_environment_name")
57 protected String operationalEnvironmentName;
59 @Column(name = "operational_environment_type")
60 protected String operationalEnvironmentType;
62 @Column(name = "tenant_context")
63 protected String tenantContext;
66 //Required to be public as it is used by Cassandra driver on get operation
67 public EcompOperationalEnvironmentEvent() {
68 timestamp1 = new Date();
71 public EcompOperationalEnvironmentEvent(String action, String operationalEnvironmentId, String operationalEnvironmentName,
72 String operationalEnvironmentType, String operationalEnvironmentAction, String tenantContext) {
75 this.operationalEnvironmentId = operationalEnvironmentId;
76 this.operationalEnvironmentType = operationalEnvironmentType;
77 this.operationalEnvironmentName = operationalEnvironmentName;
78 this.operationalEnvironmentAction = operationalEnvironmentAction;
79 this.tenantContext = tenantContext;
83 public void fillFields() {
84 fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
85 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_ID.getDisplayName(), getOperationalEnvironmentId());
86 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_NAME.getDisplayName(), getOperationalEnvironmentName());
87 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_TYPE.getDisplayName(), getOperationalEnvironmentType());
88 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_ACTION.getDisplayName(), getOperationalEnvironmentAction());
89 fields.put(AuditingFieldsKey.AUDIT_TENANT_CONTEXT.getDisplayName(), getTenantContext());
90 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
91 simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
92 fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));