All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hu.icellmobilsoft.coffee.model.base.AbstractAuditEntity Maven / Gradle / Ivy

There is a newer version: 2.9.0
Show newest version
/*-
 * #%L
 * Coffee
 * %%
 * Copyright (C) 2020 i-Cell Mobilsoft Zrt.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package hu.icellmobilsoft.coffee.model.base;

import java.util.Date;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.validation.constraints.NotNull;

import hu.icellmobilsoft.coffee.model.base.annotation.CreatedBy;
import hu.icellmobilsoft.coffee.model.base.annotation.ModifiedBy;
import hu.icellmobilsoft.coffee.model.base.audit.AuditProvider;
import hu.icellmobilsoft.coffee.model.base.javatime.annotation.CreatedOn;
import hu.icellmobilsoft.coffee.model.base.javatime.annotation.ModifiedOn;
import hu.icellmobilsoft.coffee.model.base.javatime.listener.TimestampsProvider;

/**
 * Base class for audited entities.
 * 
 * @param 
 *            The type of the creator and modifier user
 *
 * @author imre.scheffer
 * @since 1.0.0
 */
@MappedSuperclass
@EntityListeners({ TimestampsProvider.class, AuditProvider.class })
public abstract class AbstractAuditEntity extends AbstractEntity implements IAuditEntity {

    private static final long serialVersionUID = 1L;

    /**
     * Default constructor, constructs a new object.
     */
    public AbstractAuditEntity() {
        super();
    }

    /**
     * Creation date of the entity
     */
    @CreatedOn
    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "X__INSDATE", updatable = false)
    private Date creationDate;

    /**
     * Last modification date of the entity
     */
    @ModifiedOn
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "X__MODDATE")
    private Date modificationDate;

    /**
     * Creator user of the entity
     */
    @CreatedBy
    @NotNull
    @Column(name = "X__INSUSER", length = 30, updatable = false)
    private T creatorUser;

    /**
     * The last modifier user of the entity
     */
    @ModifiedBy
    @Column(name = "X__MODUSER", length = 30)
    private T modifierUser;

    /**
     * Getter for the field {@code creationDate}.
     *
     * @return creationDate
     */
    public Date getCreationDate() {
        return this.creationDate;
    }

    /**
     * Setter for the field {@code creationDate}.
     *
     * @param creationDate
     *            creationDate
     */
    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    /**
     * Getter for the field {@code modificationDate}.
     *
     * @return modificationDate
     */
    public Date getModificationDate() {
        return this.modificationDate;
    }

    /**
     * Setter for the field {@code modificationDate}.
     *
     * @param modificationDate
     *            modificationDate
     */
    public void setModificationDate(Date modificationDate) {
        this.modificationDate = modificationDate;
    }

    /**
     * Getter for the field {@code creatorUser}.
     *
     * @return creatorUser
     */
    public T getCreatorUser() {
        return this.creatorUser;
    }

    /**
     * Setter for the field {@code creatorUser}.
     *
     * @param creatorUser
     *            creatorUser
     */
    public void setCreatorUser(T creatorUser) {
        this.creatorUser = creatorUser;
    }

    /**
     * Getter for the field {@code modifierUser}.
     *
     * @return modifierUser
     */
    public T getModifierUser() {
        return this.modifierUser;
    }

    /**
     * Setter for the field {@code modifierUser}.
     *
     * @param modifierUser
     *            modifierUser
     */
    public void setModifierUser(T modifierUser) {
        this.modifierUser = modifierUser;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy