/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rjconsultores.ventaboletos.entidad;

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

import javax.persistence.Basic;
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.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.Hibernate;

import br.com.rjconsultores.auditador.annotations.AuditarClasse;
import br.com.rjconsultores.auditador.annotations.NaoAuditar;
import br.com.rjconsultores.auditador.interfaces.Auditavel;

/**
 * 
 * @author RJ
 */
@AuditarClasse(nome = "PtoVtaCheckin", tela = "auditarClasse.PtoVtaCheckin")
@Entity
@SequenceGenerator(name = "PTOVTA_CHECKIN_SEQ", sequenceName = "PTOVTA_CHECKIN_SEQ", allocationSize = 1)
@Table(name = "PTOVTA_CHECKIN")
public class PtoVtaCheckin implements Serializable, Auditavel<PtoVtaCheckin>{
	private static final long serialVersionUID = 1L;
	@Id
	@Basic(optional = false)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "PTOVTA_CHECKIN_SEQ")
	@Column(name = "PTOVTACHECKIN_ID")
	private Integer ptoVtaCheckinId;

	@JoinColumn(name = "PUNTOVENTA_ID", referencedColumnName = "PUNTOVENTA_ID")
	@OneToOne
	private PuntoVenta puntoventaId;

	@JoinColumn(name = "PARADA_ID", referencedColumnName = "PARADA_ID")
	@ManyToOne
	private Parada paradaId;

	@Basic(optional = false)
	@Column(name = "ACTIVO")
	private Boolean activo;

	@Column(name = "FECMODIF")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fecmodif;

	@Column(name = "USUARIO_ID")
	private int usuarioId;
	
	@Transient
	@NaoAuditar
	private PtoVtaCheckin ptoVtaCheckinClone;

	public PtoVtaCheckin() {
	}

	public PtoVtaCheckin(Integer ptoVtaCheckinId) {
		this.ptoVtaCheckinId = ptoVtaCheckinId;
	}

	public Integer getPtoVtaCheckinId() {
		return ptoVtaCheckinId;
	}

	public void setPtoVtaCheckinId(Integer ptoVtaCheckinId) {
		this.ptoVtaCheckinId = ptoVtaCheckinId;
	}

	public PuntoVenta getPuntoventaId() {
		return puntoventaId;
	}

	public void setPuntoventaId(PuntoVenta puntoventaId) {
		this.puntoventaId = puntoventaId;
	}

	public Parada getParadaId() {
		return paradaId;
	}

	public void setParadaId(Parada paradaId) {
		this.paradaId = paradaId;
	}

	public Boolean getActivo() {
		return activo;
	}

	public void setActivo(Boolean activo) {
		this.activo = activo;
	}

	public Date getFecmodif() {
		return fecmodif;
	}

	public void setFecmodif(Date fecmodif) {
		this.fecmodif = fecmodif;
	}

	public int getUsuarioId() {
		return usuarioId;
	}

	public void setUsuarioId(int usuarioId) {
		this.usuarioId = usuarioId;
	}

	@Override
	public void clonar() throws CloneNotSupportedException {
		ptoVtaCheckinClone = new PtoVtaCheckin();
		ptoVtaCheckinClone = (PtoVtaCheckin) this.clone();
		Hibernate.initialize(ptoVtaCheckinClone.getPuntoventaId());
		
	}

	@Override
	public PtoVtaCheckin getCloneObject() throws CloneNotSupportedException {
		return ptoVtaCheckinClone;
	}

	@Override
	public String getTextoInclusaoExclusao() {
		return String.format("ID [%s]", getPtoVtaCheckinId());
	}
	
	@Override
	public int hashCode() {
		int hash = 0;
		hash += (ptoVtaCheckinId != null ? ptoVtaCheckinId.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		if (!(object instanceof PtoVtaCheckin)) {
			return false;
		}
		PtoVtaCheckin other = (PtoVtaCheckin) object;
		if ((this.ptoVtaCheckinId == null && other.ptoVtaCheckinId != null) || (this.ptoVtaCheckinId != null && !this.ptoVtaCheckinId.equals(other.ptoVtaCheckinId))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "com.rjconsultores.ventaboletos.entidad.PtoVtaCheckin[ ptoVtaCheckinId=" + ptoVtaCheckinId + " ]";
	}

}
