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 @Column(name = "operational_environment_id")
40 protected String operationalEnvironmentId;
43 protected Date timestamp1;
46 protected String action;
48 @Column(name = "operational_environment_action")
49 protected String operationalEnvironmentAction;
51 @Column(name = "operational_environment_name")
52 protected String operationalEnvironmentName;
54 @Column(name = "operational_environment_type")
55 protected String operationalEnvironmentType;
57 @Column(name = "tenant_context")
58 protected String tenantContext;
61 //Required to be public as it is used by Cassandra driver on get operation
62 public EcompOperationalEnvironmentEvent() {
63 timestamp1 = new Date();
66 public EcompOperationalEnvironmentEvent(String action, String operationalEnvironmentId, String operationalEnvironmentName,
67 String operationalEnvironmentType, String operationalEnvironmentAction, String tenantContext) {
70 this.operationalEnvironmentId = operationalEnvironmentId;
71 this.operationalEnvironmentType = operationalEnvironmentType;
72 this.operationalEnvironmentName = operationalEnvironmentName;
73 this.operationalEnvironmentAction = operationalEnvironmentAction;
74 this.tenantContext = tenantContext;
77 public String getOperationalEnvironmentId() {
78 return operationalEnvironmentId;
81 public void setOperationalEnvironmentId(String operationalEnvironmentId) {
82 this.operationalEnvironmentId = operationalEnvironmentId;
85 public String getOperationalEnvironmentAction() {
86 return operationalEnvironmentAction;
89 public void setOperationalEnvironmentAction(String operationalEnvironmentAction) {
90 this.operationalEnvironmentAction = operationalEnvironmentAction;
93 public String getOperationalEnvironmentName() {
94 return operationalEnvironmentName;
97 public void setOperationalEnvironmentName(String operationalEnvironmentName) {
98 this.operationalEnvironmentName = operationalEnvironmentName;
101 public String getOperationalEnvironmentType() {
102 return operationalEnvironmentType;
105 public void setOperationalEnvironmentType(String operationalEnvironmentType) {
106 this.operationalEnvironmentType = operationalEnvironmentType;
109 public String getTenantContext() {
110 return tenantContext;
113 public void setTenantContext(String tenantContext) {
114 this.tenantContext = tenantContext;
117 public Date getTimestamp1() {
121 public void setTimestamp1(Date timestamp) {
122 this.timestamp1 = timestamp;
126 public String getAction() {
131 public void setAction(String action) {
132 this.action = action;
136 public void fillFields() {
137 fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
138 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_ID.getDisplayName(), getOperationalEnvironmentId());
139 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_NAME.getDisplayName(), getOperationalEnvironmentName());
140 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_TYPE.getDisplayName(), getOperationalEnvironmentType());
141 fields.put(AuditingFieldsKey.AUDIT_OPERATIONAL_ENVIRONMENT_ACTION.getDisplayName(), getOperationalEnvironmentAction());
142 fields.put(AuditingFieldsKey.AUDIT_TENANT_CONTEXT.getDisplayName(), getTenantContext());
143 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
144 simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
145 fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
149 public String toString() {
150 return "EcompOperationalEnvironmentEvent [timestamp1=" + timestamp1 + ", action = " + action
151 + ", operational_environment_id=" + operationalEnvironmentId + ", operational_environment_name=" + operationalEnvironmentName
152 + ", operational_environment_type=" + operationalEnvironmentType + ", operational_environment_action=" + operationalEnvironmentAction
153 + ", tenant_context=" + tenantContext + "]";