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 @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() {
69 public void setCreatedDate(Instant createdDate) {
70 if (createdDate != null) {
71 this.createdDate = createdDate.truncatedTo(ChronoUnit.SECONDS);
73 this.createdDate = null;
77 public Instant getUpdatedDate() {
81 public void setUpdatedDate(Instant updatedDate) {
82 if (updatedDate != null) {
83 this.updatedDate = updatedDate.truncatedTo(ChronoUnit.SECONDS);
85 this.updatedDate = null;
89 public String getUpdatedBy() {
93 public void setUpdatedBy(String updatedBy) {
94 this.updatedBy = updatedBy;
97 public String getCreatedBy() {
101 public void setCreatedBy(String createdBy) {
102 this.createdBy = createdBy;
105 public AuditEntity() {