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

org.genesys.blocks.auditlog.model.AuditLog Maven / Gradle / Ivy

/*
 * Copyright 2017 Global Crop Diversity Trust
 *
 * 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.
 */
package org.genesys.blocks.auditlog.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.genesys.blocks.auditlog.annotations.NotAudited;
import org.genesys.blocks.model.ClassPK;
import org.springframework.data.annotation.CreatedBy;

/**
 * The Class AuditLog.
 */
@Entity
@Table(name = "auditlog", indexes = { @Index(unique = false, columnList = "entityId, classPk, prop") })
@NotAudited
public class AuditLog implements Serializable {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -2254427722756061411L;

	/** The id. */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(nullable = false, length = 20)
	protected Long id;

	/** The created by. */
	@CreatedBy
	private Long createdBy;

	/** The log date. */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "logdate", nullable = false)
	private Date logDate;

	/** Class name of the referenced entity. */
	@ManyToOne(optional = false)
	@JoinColumn(name = "classPk")
	private ClassPK classPk;

	/** ID of the referenced entity. */
	@Column(name = "entityId")
	private long entityId;

	/** The name of the property modified. */
	@Column(nullable = false, name = "prop", length = 50)
	private String propertyName;

	/** The type of entity referenced in the changed property. */
	@ManyToOne(optional = true)
	@JoinColumn(name = "entityClassPk")
	private ClassPK referencedEntity;

	/** String representation of the previous state. */
	@Lob
	@Column(nullable = true)
	private String previousState;

	/** String representation of the updated state. */
	@Lob
	@Column(nullable = true)
	private String newState;

	/** The action. */
	@Enumerated(EnumType.STRING)
	@Column(length = 10, nullable = false, updatable = false)
	private AuditAction action;

	/** The previous entity. */
	@Transient
	private Object previousEntity;

	/** The next entity. */
	@Transient
	private Object newEntity;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	protected void setId(final Long id) {
		this.id = id;
	}

	/**
	 * Gets the created by.
	 *
	 * @return the created by
	 */
	public Long getCreatedBy() {
		return createdBy;
	}

	/**
	 * Sets the created by.
	 *
	 * @param createdBy the new created by
	 */
	protected void setCreatedBy(final Long createdBy) {
		this.createdBy = createdBy;
	}

	/**
	 * Gets the log created date.
	 *
	 * @return the log date
	 */
	public Date getLogDate() {
		return logDate;
	}

	/**
	 * Sets the log create date.
	 *
	 * @param logDate the log date
	 */
	public void setLogDate(final Date logDate) {
		this.logDate = logDate;
	}

	/**
	 * Gets the class pk.
	 *
	 * @return the class pk
	 */
	public ClassPK getClassPk() {
		return classPk;
	}

	/**
	 * Sets the class pk.
	 *
	 * @param classPk the new class pk
	 */
	public void setClassPk(final ClassPK classPk) {
		this.classPk = classPk;
	}

	/**
	 * Gets the entity id.
	 *
	 * @return the entity id
	 */
	public long getEntityId() {
		return entityId;
	}

	/**
	 * Sets the entity id.
	 *
	 * @param entityId the new entity id
	 */
	public void setEntityId(final long entityId) {
		this.entityId = entityId;
	}

	/**
	 * Sets the property name.
	 *
	 * @param propertyName the new property name
	 */
	public void setPropertyName(final String propertyName) {
		this.propertyName = propertyName;
	}

	/**
	 * Gets the property name.
	 *
	 * @return the property name
	 */
	public String getPropertyName() {
		return propertyName;
	}

	/**
	 * Sets the referenced entity.
	 *
	 * @param referencedEntity the new referenced entity
	 */
	public void setReferencedEntity(final ClassPK referencedEntity) {
		this.referencedEntity = referencedEntity;
	}

	/**
	 * Gets the referenced entity.
	 *
	 * @return the referenced entity
	 */
	public ClassPK getReferencedEntity() {
		return referencedEntity;
	}

	/**
	 * Sets the previous state.
	 *
	 * @param previousState the new previous state
	 */
	public void setPreviousState(final String previousState) {
		this.previousState = previousState;
	}

	/**
	 * Gets the previous state.
	 *
	 * @return the previous state
	 */
	public String getPreviousState() {
		return previousState;
	}

	/**
	 * Sets the new state.
	 *
	 * @param newState the new new state
	 */
	public void setNewState(final String newState) {
		this.newState = newState;
	}

	/**
	 * Gets the new state.
	 *
	 * @return the new state
	 */
	public String getNewState() {
		return newState;
	}

	/**
	 * Sets the action.
	 *
	 * @param action the new action
	 */
	public void setAction(final AuditAction action) {
		this.action = action;
	}

	/**
	 * Gets the action.
	 *
	 * @return the action
	 */
	public AuditAction getAction() {
		return action;
	}

	/**
	 * Sets the previous entity.
	 *
	 * @param entity the new previous entity
	 */
	public void setPreviousEntity(Object entity) {
		this.previousEntity=entity;
	}
	
	/**
	 * Gets the previous entity.
	 *
	 * @return the previous entity
	 */
	public Object getPreviousEntity() {
		return previousEntity;
	}
	
	/**
	 * Sets the new entity.
	 *
	 * @param newEntity the new new entity
	 */
	public void setNewEntity(Object newEntity) {
		this.newEntity = newEntity;
	}
	
	/**
	 * Gets the new entity.
	 *
	 * @return the new entity
	 */
	public Object getNewEntity() {
		return newEntity;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy