package com.rjconsultores.ventaboletos.entidad;

import java.util.Calendar;
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.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@SequenceGenerator(name = "RESERVA_ESPECIAL_CLIENTE_SEQ", sequenceName = "RESERVA_ESPECIAL_CLIENTE_SEQ", allocationSize = 1)
@Table(name = "RESERVA_ESPECIAL_CLIENTE")
public class ReservaEspecialCliente {

	@Id
	@Basic(optional = false)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "RESERVA_ESPECIAL_CLIENTE_SEQ")
	@Column(name = "RESERVAESPECIALCLIENTE_ID")
	private Long reservaEspecialClienteId;
	
	//Cliente
	@Basic(optional = false)
	@Column(name = "CLIENTE_ID")
	private Long clienteId;
	
	//Corrida
	@Basic(optional = false)
	@Column(name = "CORRIDA_ID")
	private Long corridaId;
	
	//Origem trecho
	@Basic(optional = false)
	@JoinColumn(name = "ORIGEM_ID", referencedColumnName = "PARADA_ID")
	@ManyToOne
	private Parada origem;
	
	//Destino trecho
	@Basic(optional = false)
	@JoinColumn(name = "DESTINO_ID", referencedColumnName = "PARADA_ID")
	@ManyToOne
	private Parada destino;
	
	//Data Final Vigência
	@Basic(optional = false)
	@Column(name = "FECINICIO")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fecinicio;
	
	//Data Final Vigência
	@Basic(optional = false)
	@Column(name = "FECFINAL")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fecfinal;
	
	//Dias da Semana
	@Column(name = "NUMASENTOCORRIDA")
	private Short numAsentoCorrida;
	@Column(name = "INDSEGUNDA")
	private Boolean indSegunda;
	@Column(name = "INDTERCA")
	private Boolean indTerca;
	@Column(name = "INDQUARTA")
	private Boolean indQuarta;
	@Column(name = "INDQUINTA")
	private Boolean indQuinta;
	@Column(name = "INDSEXTA")
	private Boolean indSexta;
	@Column(name = "INDSABADO")
	private Boolean indSabado;
	@Column(name = "INDDOMINGO")
	private Boolean indDomingo;
	
	//FecModif
	@Basic(optional = false)
	@Column(name = "FECMODIF")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fecmodif;
	
	//Activo
	@Column(name = "ACTIVO")
	private Boolean activo;
	
	//Usuario
	@Column(name = "USUARIO_ID")
	private Integer usuarioId;
	
	@Column(name = "TEMPOCONFIRMACAO")
	@Temporal(TemporalType.TIMESTAMP)
	private Date tempoConfirmacao;

	public Date getTempoConfirmacao() {
		return tempoConfirmacao;
	}

	public void setTempoConfirmacao(Date tempoConfirmacao) {
		this.tempoConfirmacao = tempoConfirmacao;
	}

	public Long getReservaEspecialClienteId() {
		return reservaEspecialClienteId;
	}

	public void setReservaEspecialClienteId(Long reservaEspecialClienteId) {
		this.reservaEspecialClienteId = reservaEspecialClienteId;
	}

	public Long getClienteId() {
		return clienteId;
	}

	public void setClienteId(Long clienteId) {
		this.clienteId = clienteId;
	}

	public Long getCorridaId() {
		return corridaId;
	}

	public void setCorridaId(Long corridaId) {
		this.corridaId = corridaId;
	}

	public Parada getOrigem() {
		return origem;
	}

	public void setOrigem(Parada origem) {
		this.origem = origem;
	}

	public Parada getDestino() {
		return destino;
	}

	public void setDestino(Parada destino) {
		this.destino = destino;
	}

	public Date getFecinicio() {
		return fecinicio;
	}

	public void setFecinicio(Date fecinicio) {
		this.fecinicio = fecinicio;
	}

	public Date getFecfinal() {
		return fecfinal;
	}

	public void setFecfinal(Date fecfinal) {
		this.fecfinal = fecfinal;
	}

	public Short getNumAsentoCorrida() {
		return numAsentoCorrida;
	}

	public void setNumAsentoCorrida(Short numAsentoCorrida) {
		this.numAsentoCorrida = numAsentoCorrida;
	}

	public Boolean getIndSegunda() {
		return indSegunda;
	}

	public void setIndSegunda(Boolean indSegunda) {
		this.indSegunda = indSegunda;
	}

	public Boolean getIndTerca() {
		return indTerca;
	}

	public void setIndTerca(Boolean indTerca) {
		this.indTerca = indTerca;
	}

	public Boolean getIndQuarta() {
		return indQuarta;
	}

	public void setIndQuarta(Boolean indQuarta) {
		this.indQuarta = indQuarta;
	}

	public Boolean getIndQuinta() {
		return indQuinta;
	}

	public void setIndQuinta(Boolean indQuinta) {
		this.indQuinta = indQuinta;
	}


	public Boolean getIndSexta() {
		return indSexta !=null ? indSexta : Boolean.FALSE ;
	}

	public void setIndSexta(Boolean indSexta) {
		this.indSexta = indSexta;
	}

	public Boolean getIndDomingo() {
		return indDomingo;
	}

	public void setIndDomingo(Boolean indDomingo) {
		this.indDomingo = indDomingo;
	}

	public Date getFecmodif() {
		return fecmodif;
	}

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

	public Boolean getActivo() {
		return activo;
	}

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

	public Integer getUsuarioId() {
		return usuarioId;
	}

	public void setUsuarioId(Integer usuarioId) {
		this.usuarioId = usuarioId;
	}
	
	public Boolean getIndSabado() {
		return indSabado;
	}

	public void setIndSabado(Boolean indSabado) {
		this.indSabado = indSabado;
	}
	
	public void setTempoConfirmacao(Integer hora, Integer minuto) {
		Calendar c = Calendar.getInstance();
		c.set(Calendar.YEAR, 1970);
		c.set(Calendar.DAY_OF_MONTH, 1);
		c.set(Calendar.MONTH, 0);
		c.set(Calendar.HOUR_OF_DAY, 0);
		c.set(Calendar.MINUTE, 0);
		c.set(Calendar.MILLISECOND, 0);
		c.set(Calendar.SECOND, 0);
		c.set(Calendar.HOUR_OF_DAY, 0);
		c.set(Calendar.MINUTE, 0);
		c.add(Calendar.HOUR_OF_DAY, hora);
		c.add(Calendar.MINUTE, minuto);

		setTempoConfirmacao(c.getTime());
	}
	
}
