2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.loop.common;
26 import com.google.gson.annotations.Expose;
27 import java.time.Instant;
28 import java.time.temporal.ChronoUnit;
29 import javax.persistence.Column;
30 import javax.persistence.EntityListeners;
31 import javax.persistence.MappedSuperclass;
32 import org.springframework.data.annotation.CreatedBy;
33 import org.springframework.data.annotation.CreatedDate;
34 import org.springframework.data.annotation.LastModifiedBy;
35 import org.springframework.data.annotation.LastModifiedDate;
36 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
39 * This class is the parent of the hibernate entities requiring to be audited.
42 @EntityListeners(AuditingEntityListener.class)
43 public class AuditEntity {
47 @Column(name = "created_timestamp", nullable = false, updatable = false)
48 private Instant createdDate;
52 @Column(name = "updated_timestamp", nullable = false)
53 private Instant updatedDate;
57 @Column(name = "updated_by")
58 private String updatedBy;
62 @Column(name = "created_by")
63 private String createdBy;
65 public Instant getCreatedDate() {
72 * @param createdDate The created Date object
74 public void setCreatedDate(Instant createdDate) {
75 if (createdDate != null) {
76 this.createdDate = createdDate.truncatedTo(ChronoUnit.SECONDS);
79 this.createdDate = null;
86 * @return the updatedDate
88 public Instant getUpdatedDate() {
95 * @param updatedDate updatedDate to set
97 public void setUpdatedDate(Instant updatedDate) {
98 if (updatedDate != null) {
99 this.updatedDate = updatedDate.truncatedTo(ChronoUnit.SECONDS);
102 this.updatedDate = null;
109 * @return the updatedBy
111 public String getUpdatedBy() {
118 * @param updatedBy the updatedBy
120 public void setUpdatedBy(String updatedBy) {
121 this.updatedBy = updatedBy;
127 * @return the createdBy
129 public String getCreatedBy() {
136 * @param createdBy the createdBy to set
138 public void setCreatedBy(String createdBy) {
139 this.createdBy = createdBy;
145 public AuditEntity() {