Added oparent to sdc main
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / auditing / EcompOperationalEnvironmentEvent.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.resources.data.auditing;
22
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;
28
29 import java.text.SimpleDateFormat;
30 import java.util.Date;
31 import java.util.TimeZone;
32
33 //import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
34
35 @Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE)
36 public class EcompOperationalEnvironmentEvent  extends AuditingGenericEvent {
37
38     @PartitionKey
39     protected String operationalEnvironmentId;
40
41     @ClusteringColumn
42     protected Date timestamp1;
43
44     @Column
45     protected String action;
46
47     @Column(name = "operational_environment_action")
48     protected String operationalEnvironmentAction;
49
50     @Column(name = "operational_environment_name")
51     protected String operationalEnvironmentName;
52
53     @Column(name = "operational_environment_type")
54     protected String operationalEnvironmentType;
55
56     @Column(name = "tenant_context")
57     protected String tenantContext;
58
59
60     //Required to be public as it is used by Cassandra driver on get operation
61     public EcompOperationalEnvironmentEvent() {
62         timestamp1 = new Date();
63     }
64
65     public EcompOperationalEnvironmentEvent(String action, String operationalEnvironmentId, String operationalEnvironmentName,
66                                             String operationalEnvironmentType, String operationalEnvironmentAction, String tenantContext) {
67         this();
68         this.action = action;
69         this.operationalEnvironmentId = operationalEnvironmentId;
70         this.operationalEnvironmentType = operationalEnvironmentType;
71         this.operationalEnvironmentName = operationalEnvironmentName;
72         this.operationalEnvironmentAction = operationalEnvironmentAction;
73         this.tenantContext = tenantContext;
74     }
75
76     public String getOperationalEnvironmentId() {
77         return operationalEnvironmentId;
78     }
79
80     public void setOperationalEnvironmentId(String operationalEnvironmentId) {
81         this.operationalEnvironmentId = operationalEnvironmentId;
82     }
83
84     public String getOperationalEnvironmentAction() {
85         return operationalEnvironmentAction;
86     }
87
88     public void setOperationalEnvironmentAction(String operationalEnvironmentAction) {
89         this.operationalEnvironmentAction = operationalEnvironmentAction;
90     }
91
92     public String getOperationalEnvironmentName() {
93         return operationalEnvironmentName;
94     }
95
96     public void setOperationalEnvironmentName(String operationalEnvironmentName) {
97         this.operationalEnvironmentName = operationalEnvironmentName;
98     }
99
100     public String getOperationalEnvironmentType() {
101         return operationalEnvironmentType;
102     }
103
104     public void setOperational_environment_type(String operationalEnvironmentType) {
105         this.operationalEnvironmentType = operationalEnvironmentType;
106     }
107
108     public String getTenantContext() {
109         return tenantContext;
110     }
111
112     public void setTenantContext(String tenantContext) {
113         this.tenantContext = tenantContext;
114     }
115
116     public Date getTimestamp1() {
117         return timestamp1;
118     }
119
120     public void setTimestamp1(Date timestamp) {
121         this.timestamp1 = timestamp;
122     }
123
124     @Override
125     public String getAction() {
126         return action;
127     }
128
129     @Override
130     public void setAction(String action) {
131         this.action = action;
132     }
133
134     @Override
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));
145     }
146
147     @Override
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 + "]";
153     }
154
155 }