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;
27 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
29 import java.text.SimpleDateFormat;
30 import java.util.Date;
31 import java.util.TimeZone;
33 //import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
35 @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE)
36 public class EcompOperationalEnvironmentEvent extends AuditingGenericEvent {
39 protected String operationalEnvironmentId;
42 protected Date timestamp1;
45 protected String action;
47 @Column(name = "operational_environment_action")
48 protected String operationalEnvironmentAction;
50 @Column(name = "operational_environment_name")
51 protected String operationalEnvironmentName;
53 @Column(name = "operational_environment_type")
54 protected String operationalEnvironmentType;
56 @Column(name = "tenant_context")
57 protected String tenantContext;
60 //Required to be public as it is used by Cassandra driver on get operation
61 public EcompOperationalEnvironmentEvent() {
62 timestamp1 = new Date();
65 public EcompOperationalEnvironmentEvent(String action, String operationalEnvironmentId, String operationalEnvironmentName,
66 String operationalEnvironmentType, String operationalEnvironmentAction, String tenantContext) {
69 this.operationalEnvironmentId = operationalEnvironmentId;
70 this.operationalEnvironmentType = operationalEnvironmentType;
71 this.operationalEnvironmentName = operationalEnvironmentName;
72 this.operationalEnvironmentAction = operationalEnvironmentAction;
73 this.tenantContext = tenantContext;
76 public String getOperationalEnvironmentId() {
77 return operationalEnvironmentId;
80 public void setOperationalEnvironmentId(String operationalEnvironmentId) {
81 this.operationalEnvironmentId = operationalEnvironmentId;
84 public String getOperationalEnvironmentAction() {
85 return operationalEnvironmentAction;
88 public void setOperationalEnvironmentAction(String operationalEnvironmentAction) {
89 this.operationalEnvironmentAction = operationalEnvironmentAction;
92 public String getOperationalEnvironmentName() {
93 return operationalEnvironmentName;
96 public void setOperationalEnvironmentName(String operationalEnvironmentName) {
97 this.operationalEnvironmentName = operationalEnvironmentName;
100 public String getOperationalEnvironmentType() {
101 return operationalEnvironmentType;
104 public void setOperational_environment_type(String operationalEnvironmentType) {
105 this.operationalEnvironmentType = operationalEnvironmentType;
108 public String getTenantContext() {
109 return tenantContext;
112 public void setTenantContext(String tenantContext) {
113 this.tenantContext = tenantContext;
116 public Date getTimestamp1() {
120 public void setTimestamp1(Date timestamp) {
121 this.timestamp1 = timestamp;
125 public String getAction() {
130 public void setAction(String action) {
131 this.action = action;
135 public void fillFields() {
136 fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
137 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_ID.getDisplayName(), getOperationalEnvironmentId());
138 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_NAME.getDisplayName(), getOperationalEnvironmentName());
139 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_TYPE.getDisplayName(), getOperationalEnvironmentType());
140 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_ACTION.getDisplayName(), getOperationalEnvironmentAction());
141 fields.put(AuditingFieldsKey.AUDIT_TENANT_CONTEXT.getDisplayName(), getTenantContext());
142 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
143 simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
144 fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
148 public String toString() {
149 return "EcompOperationalEnvironmentEvent [timestamp1=" + timestamp1 + ", action = " + action
150 + ", operational_environment_id=" + operationalEnvironmentId + ", operational_environment_name=" + operationalEnvironmentName
151 + ", operational_environment_type=" + operationalEnvironmentType + ", operational_environment_action=" + operationalEnvironmentAction
152 + ", tenant_context=" + tenantContext + "]";