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;
28 import java.time.Instant;
29 import java.time.temporal.ChronoUnit;
31 import javax.persistence.Column;
32 import javax.persistence.EntityListeners;
33 import javax.persistence.MappedSuperclass;
35 import org.springframework.data.annotation.CreatedBy;
36 import org.springframework.data.annotation.CreatedDate;
37 import org.springframework.data.annotation.LastModifiedBy;
38 import org.springframework.data.annotation.LastModifiedDate;
39 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
42 * This class is the parent of the hibernate entities requiring to be audited.
46 @EntityListeners(AuditingEntityListener.class)
47 public class AuditEntity {
51 @Column(name = "created_timestamp", nullable = false, updatable = false)
52 private Instant createdDate;
56 @Column(name = "updated_timestamp", nullable = false)
57 private Instant updatedDate;
61 @Column(name = "updated_by")
62 private String updatedBy;
66 @Column(name = "created_by")
67 private String createdBy;
69 public Instant getCreatedDate() {
76 * @param createdDate The created Date object
78 public void setCreatedDate(Instant createdDate) {
79 if (createdDate != null) {
80 this.createdDate = createdDate.truncatedTo(ChronoUnit.SECONDS);
82 this.createdDate = null;
89 * @return the updatedDate
91 public Instant getUpdatedDate() {
98 * @param updatedDate updatedDate to set
100 public void setUpdatedDate(Instant updatedDate) {
101 if (updatedDate != null) {
102 this.updatedDate = updatedDate.truncatedTo(ChronoUnit.SECONDS);
104 this.updatedDate = null;
111 * @return the updatedBy
113 public String getUpdatedBy() {
120 * @param updatedBy the updatedBy
122 public void setUpdatedBy(String updatedBy) {
123 this.updatedBy = updatedBy;
129 * @return the createdBy
131 public String getCreatedBy() {
138 * @param createdBy the createdBy to set
140 public void setCreatedBy(String createdBy) {
141 this.createdBy = createdBy;
147 public AuditEntity() {