Upgrade to Cassandra 3
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / auditing / AuditingGenericEvent.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
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
24 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
25 import com.datastax.driver.mapping.annotations.Transient;
26 import java.text.SimpleDateFormat;
27 import java.util.Date;
28 import java.util.HashMap;
29 import java.util.Map;
30 import java.util.TimeZone;
31
32 public class AuditingGenericEvent {
33     @Transient
34     protected SimpleDateFormat simpleDateFormat;
35     protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z";
36
37     @Transient
38     protected String requestId;
39     @Transient
40     protected String serviceInstanceId;
41     @Transient
42     protected String action;
43     @Transient
44     protected String status;
45     @Transient
46     protected String timestamp;
47     @Transient
48     protected String desc;
49     @Transient
50     protected Map<String, Object> fields = new HashMap<>();
51
52
53     public AuditingGenericEvent() {
54         super();
55         simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
56         simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
57         this.timestamp = simpleDateFormat.format(new Date());
58         fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp);
59
60     }
61
62     public String getRequestId() {
63         return requestId;
64     }
65
66     public void setRequestId(String requestId) {
67         this.requestId = requestId;
68
69     }
70
71     public String getServiceInstanceId() {
72         return serviceInstanceId;
73     }
74
75     public void setServiceInstanceId(String serviceInstanceId) {
76         this.serviceInstanceId = serviceInstanceId;
77     }
78
79     public String getAction() {
80         return action;
81     }
82
83     public void setAction(String action) {
84         this.action = action;
85     }
86
87     public String getStatus() {
88         return status;
89     }
90
91     public void setStatus(String status) {
92         this.status = status;
93     }
94
95     public String getDesc() {
96         return desc;
97     }
98
99     public void setDesc(String desc) {
100         this.desc = desc;
101     }
102
103     public void fillFields() {
104
105     }
106
107     protected Date parseDateFromString(final String timestamp) {
108         try {
109             return simpleDateFormat.parse(timestamp);
110         }
111         catch (Exception e) {
112             return new Date();
113         }
114     }
115
116     public String getTimestamp() {
117         return timestamp;
118     }
119
120     public void setTimestamp(String timestamp) {
121         this.timestamp = timestamp;
122     }
123
124     public Map<String, Object> getFields() {
125         return fields;
126     }
127
128     public void setFields(Map<String, Object> fields) {
129         this.fields = fields;
130     }
131
132
133 }