/*
 * 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.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.Where;

/**
 * 
 * @author Rafius
 */
@Entity
@SequenceGenerator(name = "PRICING_ESPECIFICO_SEQ", sequenceName = "PRICING_ESPECIFICO_SEQ", allocationSize = 1)
@Table(name = "PRICING_ESPECIFICO")
public class PricingEspecifico implements Serializable, Cloneable {

	private static final long serialVersionUID = 1L;
	@Id
	@Basic(optional = false)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "PRICING_ESPECIFICO_SEQ")
	@Column(name = "PRICINGESPECIFICO_ID")
	private Long pricingespecificoId;
	@Column(name = "NOMBPRICING")
	private String nombPricing;
	@Column(name = "FECHORINICIO")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fechorinicio;
	@Column(name = "FECHORFIN")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fechorfin;
	@Column(name = "TARIFA")
	private BigDecimal tarifa;
	@Column(name = "TARIFAREDABIERTO")
	private BigDecimal tarifaredabierto;
	@Column(name = "ACTIVO")
	private Boolean activo;
	@Column(name = "FECMODIF")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fecmodif;
	@Column(name = "USUARIO_ID")
	private Integer usuarioId;
//	@JoinColumn(name = "TIPOPTOVTA_ID", referencedColumnName = "TIPOPTOVTA_ID")
//	@ManyToOne
//	private TipoPuntoVenta tipoPtovta;
	@JoinColumn(name = "ORIGEN_ID", referencedColumnName = "PARADA_ID")
	@ManyToOne
	private Parada parada;
	@JoinColumn(name = "DESTINO_ID", referencedColumnName = "PARADA_ID")
	@ManyToOne
	private Parada parada1;
	@JoinColumn(name = "MONEDA_ID", referencedColumnName = "MONEDA_ID")
	@ManyToOne
	private Moneda moneda;
	@JoinColumn(name = "MARCA_ID", referencedColumnName = "MARCA_ID")
	@ManyToOne
	private Marca marca;
	@JoinColumn(name = "CLASESERVICIO_ID", referencedColumnName = "CLASESERVICIO_ID")
	@ManyToOne
	private ClaseServicio claseServicio;
	@Column(name = "CORRIDA_ID")
	private Integer corridaId;
	@Column(name = "EXIBEVENDA")
	private Boolean exibeVenda;
	@OneToMany(mappedBy = "pricingEspecifico", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<PricingEspecificoOcupacion> pricingEspecificoOcupacionsList;
	
	@OneToMany(mappedBy = "pricingEspecifico", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@Where(clause="ACTIVO=1")
	private List<PricingEspecificoAgencia> pricingEspecificoAgenciasList;
	
	@OneToMany(mappedBy = "pricingEspecifico", cascade = CascadeType.ALL)
	@LazyCollection(LazyCollectionOption.FALSE)
	@Where(clause="ACTIVO=1")
	private List<PricingEspecificoCanalVendas> pricingEspecificoCanalVendasList;

	@OneToMany(mappedBy = "pricingEspecifico", cascade = CascadeType.ALL)
	@LazyCollection(LazyCollectionOption.FALSE)
	@Where(clause="ACTIVO=1")
	private List<PricingEspecificoCategoria> pricingEspecificoCategoriaList;

	@Column(name = "DATAINICIOVIAGEM")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataInicioViagem;
	
	@Column(name = "DATAFIMVIAGEM")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataFimViagem;
	
	@Column(name = "DATAINICIOVENDA")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataInicioVenda;
	
	@Column(name = "DATAFIMVENDA")
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataFimVenda;
	
	@Column(name = "DOMINGO")
	private Boolean domingo;

	@Column(name = "SEGUNDA")
	private Boolean segunda;

	@Column(name = "TERCA")
	private Boolean terca;

	@Column(name = "QUARTA")
	private Boolean quarta;

	@Column(name = "QUINTA")
	private Boolean quinta;

	@Column(name = "SEXTA")
	private Boolean sexta;

	@Column(name = "SABADO")
	private Boolean sabado;
	
	public PricingEspecifico() {
	}

	public PricingEspecifico(Long pricingespecificoId) {
		this.pricingespecificoId = pricingespecificoId;
	}

	public Long getPricingespecificoId() {
		return pricingespecificoId;
	}

	public void setPricingespecificoId(Long pricingespecificoId) {
		this.pricingespecificoId = pricingespecificoId;
	}

	public Date getFechorinicio() {
		return fechorinicio;
	}

	public void setFechorinicio(Date fechorinicio) {
		this.fechorinicio = fechorinicio;
	}

	public Date getFechorfin() {
		return fechorfin;
	}

	public void setFechorfin(Date fechorfin) {
		this.fechorfin = fechorfin;
	}

	public BigDecimal getTarifa() {
		return tarifa;
	}

	public void setTarifa(BigDecimal tarifa) {
		this.tarifa = tarifa;
	}

	public BigDecimal getTarifaredabierto() {
		return tarifaredabierto;
	}

	public void setTarifaredabierto(BigDecimal tarifaredabierto) {
		this.tarifaredabierto = tarifaredabierto;
	}

	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 Integer getUsuarioId() {
		return usuarioId;
	}

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

	public Parada getParada() {
		return parada;
	}

	public void setParada(Parada parada) {
		this.parada = parada;
	}

	public Parada getParada1() {
		return parada1;
	}

	public void setParada1(Parada parada1) {
		this.parada1 = parada1;
	}

	public Moneda getMoneda() {
		return moneda;
	}

	public void setMoneda(Moneda moneda) {
		this.moneda = moneda;
	}

	public Marca getMarca() {
		return marca;
	}

	public void setMarca(Marca marca) {
		this.marca = marca;
	}

	public ClaseServicio getClaseServicio() {
		return claseServicio;
	}

	public void setClaseServicio(ClaseServicio claseServicio) {
		this.claseServicio = claseServicio;
	}

	public String getNombPricing() {
		return nombPricing;
	}

	public void setNombPricing(String nombPricing) {
		this.nombPricing = nombPricing;
	}

	public Integer getCorridaId() {
		return corridaId;
	}

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

	public List<PricingEspecificoOcupacion> getPricingEspecificoOcupacionsList() {
		if(this.pricingEspecificoOcupacionsList == null){
			this.pricingEspecificoOcupacionsList = new ArrayList<PricingEspecificoOcupacion>();
		}
		return this.pricingEspecificoOcupacionsList;
	}

	public void setPricingEspecificoOcupacionsList(List<PricingEspecificoOcupacion> pricingEspecificoOcupacionsList) {
		this.pricingEspecificoOcupacionsList = pricingEspecificoOcupacionsList;
	}
	
	public Boolean getExibeVenda() {
		return exibeVenda;
	}

	public void setExibeVenda(Boolean exibeVenda) {
		this.exibeVenda = exibeVenda;
	}
	
	public List<PricingEspecificoAgencia> getPricingEspecificoAgenciasList() {
		if(this.pricingEspecificoAgenciasList == null){
			this.pricingEspecificoAgenciasList = new ArrayList<PricingEspecificoAgencia>();
		}
		return pricingEspecificoAgenciasList;
	}

	public void setPricingEspecificoAgenciasList(List<PricingEspecificoAgencia> pricingEspecificoAgenciasList) {
		this.pricingEspecificoAgenciasList = pricingEspecificoAgenciasList;
	}
	

	public List<PricingEspecificoCanalVendas> getPricingEspecificoCanalVendasList() {
		if(this.pricingEspecificoCanalVendasList == null){
			this.pricingEspecificoCanalVendasList = new ArrayList<PricingEspecificoCanalVendas>();
		}
		return pricingEspecificoCanalVendasList;
	}

	public void setPricingEspecificoCanalVendasList(List<PricingEspecificoCanalVendas> pricingEspecificoCanalVendasList) {
		this.pricingEspecificoCanalVendasList = pricingEspecificoCanalVendasList;
	}

	public List<PricingEspecificoCategoria> getPricingEspecificoCategoriaList() {
		if (this.pricingEspecificoCategoriaList == null) {
			this.pricingEspecificoCategoriaList = new ArrayList<PricingEspecificoCategoria>();
		}
		return pricingEspecificoCategoriaList;
	}

	public void setPricingEspecificoCategoriaList(List<PricingEspecificoCategoria> pricingEspecificoCategoriaList) {
		this.pricingEspecificoCategoriaList = pricingEspecificoCategoriaList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (pricingespecificoId != null ? pricingespecificoId.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof PricingEspecifico)) {
			return false;
		}
		PricingEspecifico other = (PricingEspecifico) object;
		if ((this.pricingespecificoId == null && other.pricingespecificoId != null) || (this.pricingespecificoId != null && !this.pricingespecificoId.equals(other.pricingespecificoId))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "entidad.test.PricingEspecifico[pricingespecificoId=" + pricingespecificoId + "]";
	}
	
	@Transient
	public List<PricingEspecificoOcupacion> getPricingEspecificoOcupacionsListActivos() {
		List<PricingEspecificoOcupacion> peoList = new ArrayList<PricingEspecificoOcupacion>();
		if(getPricingEspecificoOcupacionsList() != null) {
			for (PricingEspecificoOcupacion peo : getPricingEspecificoOcupacionsList()) {
				if (peo.getActivo()) {
					peoList.add(peo);
				}
			}
		}
		return peoList;
	}
	@Transient
	public List<PricingEspecificoAgencia> getPricingEspecificoAgenciaListActivos() {
		List<PricingEspecificoAgencia> peoList = new ArrayList<PricingEspecificoAgencia>();
		if(getPricingEspecificoAgenciasList() != null) {
			for (PricingEspecificoAgencia peo : getPricingEspecificoAgenciasList()) {
				if (peo.getActivo()) {
					peoList.add(peo);
				}
			}
		}
		return peoList;
	}
	@Transient
	public List<PricingEspecificoCanalVendas> getPricingEspecificoCanalListActivos() {
		List<PricingEspecificoCanalVendas> pecList = new ArrayList<PricingEspecificoCanalVendas>();
		if(getPricingEspecificoCanalVendasList() != null) {
			for (PricingEspecificoCanalVendas pec : getPricingEspecificoCanalVendasList()) {
				if (pec.getActivo()) {
					pecList.add(pec);
				}
			}
		}
		return pecList;
	}

	public Date getDataInicioViagem() {
		return dataInicioViagem;
	}

	public void setDataInicioViagem(Date dataInicioViagem) {
		this.dataInicioViagem = dataInicioViagem;
	}

	public Date getDataFimViagem() {
		return dataFimViagem;
	}

	public void setDataFimViagem(Date dataFimViagem) {
		this.dataFimViagem = dataFimViagem;
	}

	public Date getDataInicioVenda() {
		return dataInicioVenda;
	}

	public void setDataInicioVenda(Date dataInicioVenda) {
		this.dataInicioVenda = dataInicioVenda;
	}

	public Date getDataFimVenda() {
		return dataFimVenda;
	}

	public void setDataFimVenda(Date dataFimVenda) {
		this.dataFimVenda = dataFimVenda;
	}

	public Boolean getDomingo() {
		return domingo == null ? true : domingo;
	}

	public void setDomingo(Boolean domingo) {
		this.domingo = domingo;
	}

	public Boolean getSegunda() {
		return segunda == null ? true : segunda;
	}

	public void setSegunda(Boolean segunda) {
		this.segunda = segunda;
	}

	public Boolean getTerca() {
		return terca == null ? true : terca;
	}

	public void setTerca(Boolean terca) {
		this.terca = terca;
	}

	public Boolean getQuarta() {
		return quarta == null ? true : quarta;
	}

	public void setQuarta(Boolean quarta) {
		this.quarta = quarta;
	}

	public Boolean getQuinta() {
		return quinta == null ? true : quinta;
	}

	public void setQuinta(Boolean quinta) {
		this.quinta = quinta;
	}

	public Boolean getSexta() {
		return sexta == null ? true : sexta;
	}

	public void setSexta(Boolean sexta) {
		this.sexta = sexta;
	}

	public Boolean getSabado() {
		return sabado == null ? true : sabado;
	}

	public void setSabado(Boolean sabado) {
		this.sabado = sabado;
	}
}
