package com.rjconsultores.ventaboletos.entidad;

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

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@SequenceGenerator(name = "AUDITLOG_SEQ", sequenceName = "AUDIT_LOG_SEQ", allocationSize = 1)
@Table(name = "AUDIT_LOG")
public class AuditLog implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "AUDITLOG_ID")
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "AUDITLOG_SEQ")
	private Long auditLogId;

	@Column(name = "AUDITACTION_ID")
	private Integer action;

	@Column(name = "ENTITY_DETAIL")
	private String entityDetail;

	@Column(name = "ENTITY_NAME")
	private String entityName;

	@Column(name = "CREATED_DATE")
	private Date createdDate;
	
	@JoinColumn(name = "SISTEMA_ID", referencedColumnName = "SISTEMA_ID")
	@ManyToOne
	private Sistema sistema;
	
	@JoinColumn(name = "USUARIO_ID", referencedColumnName = "USUARIO_ID")
	@ManyToOne
	private Usuario usuario;
	
	@JoinColumn(name = "AUDITSERVICE_ID", referencedColumnName = "AUDITSERVICE_ID")
	@ManyToOne
	private AuditService service;
	
	@Transient
	private Date dataInicio;
	
	@Transient
	private Date dataFim;

	public Long getAuditLogId() {
		return auditLogId;
	}

	public void setAuditLogId(Long auditLogId) {
		this.auditLogId = auditLogId;
	}

	public Integer getAction() {
		return action;
	}
	
	public void setAction(Integer action) {
		this.action = action;
	}

	public Sistema getSistema() {
		return sistema;
	}
	
	public void setSistema(Sistema sistema) {
		this.sistema = sistema;
	}

	public String getEntityDetail() {
		return entityDetail;
	}

	public void setEntityDetail(String entityDetail) {
		this.entityDetail = entityDetail;
	}

	public String getEntityName() {
		return entityName;
	}

	public void setEntityName(String entityName) {
		this.entityName = entityName;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Usuario getUsuario() {
		return usuario;
	}
	
	public void setUsuario(Usuario usuario) {
		this.usuario = usuario;
	}

	public AuditService getService() {
		return service;
	}
	
	public void setService(AuditService service) {
		this.service = service;
	}
	
	@Override
    public String toString() {
        return createdDate.toString() + sistema.toString();
    }
	
	public Date getDataFim() {
		return dataFim;
	}
	
	public void setDataFim(Date dataFim) {
		this.dataFim = dataFim;
	}
	
	public Date getDataInicio() {
		return dataInicio;
	}
	
	public void setDataInicio(Date dataInicio) {
		this.dataInicio = dataInicio;
	}
}
