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

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

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

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

/**
 * 
 * @author Administrador
 */
@Entity
@SequenceGenerator(name = "PARADA_SEQ", sequenceName = "PARADA_SEQ", allocationSize = 1)
@Table(name = "PARADA")
public class Parada implements Serializable, Auditavel<Parada> {
	public static Integer ID_PARADA_TODOS = -1;

	private static final long serialVersionUID = 1L;
	@Id
	@Basic(optional = false)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "PARADA_SEQ")
	@Column(name = "PARADA_ID")
	private Integer paradaId;
	@Basic(optional = false)
	@Column(name = "DESCPARADA")
	private String descparada;
	@Column(name = "CVEPARADA")
	private String cveparada;
	@Column(name = "ACTIVO")
	private Boolean activo;
	@Column(name = "FECMODIF")
	@Temporal(TemporalType.TIMESTAMP)
	private Date fecmodif;
	@Column(name = "USUARIO_ID")
	private Integer usuarioId;
	@OneToOne
	@JoinColumn(name = "CIUDAD_ID")
	private Ciudad ciudad;
	@OneToOne
	@JoinColumn(name = "TIPOPARADA_ID")
	private TipoParada tipoParada;
	@OneToMany(mappedBy = "origem")
	private List<Corrida> corridaList;
	@OneToMany(mappedBy = "destino")
	private List<Corrida> corridaList1;
	@OneToMany(mappedBy = "paradaOrigem")
	private List<ReservacionMercado> reservacionMercadoList;
	@OneToMany(mappedBy = "paradaDestino")
	private List<ReservacionMercado> reservacionMercadoList1;
	@OneToMany(mappedBy = "destino")
	private List<CategoriaMercado> categoriaMercadoDestinoList;
	@OneToMany(mappedBy = "origem")
	private List<CategoriaMercado> categoriaMercadoOrigemList;
	@OneToOne
	@JoinColumn(name = "NODO_ID")
	private Nodo nodo;
	@OneToMany(mappedBy = "origem")
	private List<Tramo> tramoOrigemList;
	@OneToMany(mappedBy = "destino")
	private List<Tramo> tramoDestinoList;
	@Column(name = "CODANTT")
	private Integer codantt;
	@Column(name = "CODANTTAUX")
	private Integer codanttaux;
	@Column(name = "DESCPROCON")
	private String descProcon;
	@Column(name="INDVENDETOTEM")
	private Boolean indVendeTotem;
	@Column(name="INDVISIBLEINTERNET")
	private Boolean indVisibleInternet;
	@OneToOne
	@JoinColumn(name = "AGRUPAMENTOPARADA_ID")
	private AgrupamentoParada agrupamentoParada;

	@ManyToOne
	@JoinColumn(name = "REGIONMETROPOLITANA_ID", referencedColumnName = "REGIONMETROPOLITANA_ID")
	private RegionMetropolitana regionMetropolitana;

	@OneToMany(mappedBy = "parada", fetch = FetchType.EAGER, cascade = javax.persistence.CascadeType.ALL)
	@Fetch(value = FetchMode.SUBSELECT)
	private List<ParadaCodOrgaoConcedente> codigosOrgaosConcedentes = new ArrayList<ParadaCodOrgaoConcedente>();

	@Column(name="INDINTEGRACAOW2I")
	private Boolean indIntegracaoW2i;
	
	@Column(name="INDDISPONIBLETOTALBUS")
	private Boolean indDisponibleTotalBus;
	
	@Column(name="CODSIGMA")
	private String codSigma;
	
	@Transient
	@NaoAuditar
	private Parada paradaClone;
	
	@Transient
	@NaoAuditar
	Boolean isParadaConexaoRutaExcluida;
	

	public Boolean getIsParadaConexaoRutaExcluida() {
		return isParadaConexaoRutaExcluida ==null?false:isParadaConexaoRutaExcluida;
	}

	public void setIsParadaConexaoRutaExcluida(Boolean isParadaConexaoRutaExcluida) {
		this.isParadaConexaoRutaExcluida = isParadaConexaoRutaExcluida;
	}

	public Parada() {
		super();
	}

	public Parada(Integer paradaId) {
		this();
		
		this.paradaId = paradaId;
	}
	
	public Parada(Integer paradaId, String cveparada, String descparada) {
		this(paradaId);
		this.cveparada = cveparada;
		this.descparada = descparada;
	}

	public List<CategoriaMercado> getCategoriaMercadoDestinoList() {
		return categoriaMercadoDestinoList;
	}

	public void setCategoriaMercadoDestinoList(List<CategoriaMercado> categoriaMercadoDestinoList) {
		this.categoriaMercadoDestinoList = categoriaMercadoDestinoList;
	}

	public List<CategoriaMercado> getCategoriaMercadoOrigemList() {
		return categoriaMercadoOrigemList;
	}

	public void setCategoriaMercadoOrigemList(List<CategoriaMercado> categoriaMercadoOrigemList) {
		this.categoriaMercadoOrigemList = categoriaMercadoOrigemList;
	}

	public String getDescparada() {
		return descparada;
	}

	public void setDescparada(String descparada) {
		this.descparada = descparada;
	}

	public Integer getParadaId() {
		return paradaId;
	}

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

	public List<ReservacionMercado> getReservacionMercadoList() {
		return reservacionMercadoList;
	}

	public void setReservacionMercadoList(List<ReservacionMercado> reservacionMercadoList) {
		this.reservacionMercadoList = reservacionMercadoList;
	}

	public List<ReservacionMercado> getReservacionMercadoList1() {
		return reservacionMercadoList1;
	}

	public void setReservacionMercadoList1(List<ReservacionMercado> reservacionMercadoList1) {
		this.reservacionMercadoList1 = reservacionMercadoList1;
	}

	public String getCveparada() {
		return cveparada;
	}

	public void setCveparada(String cveparada) {
		this.cveparada = cveparada;
	}

	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 List<Corrida> getCorridaList() {
		return corridaList;
	}

	public void setCorridaList(List<Corrida> corridaList) {
		this.corridaList = corridaList;
	}

	public List<Corrida> getCorridaList1() {
		return corridaList1;
	}

	public void setCorridaList1(List<Corrida> corridaList1) {
		this.corridaList1 = corridaList1;
	}

	public List<Tramo> getTramoDestinoList() {
		return tramoDestinoList;
	}

	public void setTramoDestinoList(List<Tramo> tramoDestinoList) {
		this.tramoDestinoList = tramoDestinoList;
	}

	public List<Tramo> getTramoOrigemList() {
		return tramoOrigemList;
	}

	public void setTramoOrigemList(List<Tramo> tramoOrigemList) {
		this.tramoOrigemList = tramoOrigemList;
	}

	public Ciudad getCiudad() {
		return ciudad;
	}

	public void setCiudad(Ciudad ciudad) {
		this.ciudad = ciudad;
	}

	public TipoParada getTipoParada() {
		return tipoParada;
	}

	public void setTipoParada(TipoParada tipoParada) {
		this.tipoParada = tipoParada;
	}

	public Nodo getNodo() {
		return nodo;
	}

	public void setNodo(Nodo nodo) {
		this.nodo = nodo;
	}

	public Integer getCodantt() {
		return codantt;
	}

	public void setCodantt(Integer codantt) {
		this.codantt = codantt;
	}

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

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

	@Override
	public String toString() {
		return getDescparada();	
	}

	public String toStringCve() {
		return getCveparada();
	}

	public RegionMetropolitana getRegionMetropolitana() {
		return regionMetropolitana;
	}

	public void setRegionMetropolitana(RegionMetropolitana regionMetropolitana) {
		this.regionMetropolitana = regionMetropolitana;
	}

	public List<ParadaCodOrgaoConcedente> getCodigosOrgaosConcedentes() {
		return codigosOrgaosConcedentes;
	}

	public void setCodigosOrgaosConcedentes(List<ParadaCodOrgaoConcedente> codigosOrgaosConcedentes) {
		this.codigosOrgaosConcedentes = codigosOrgaosConcedentes;
	}

	public void addCodOrgaoConcedente(ParadaCodOrgaoConcedente codigo) {
		this.codigosOrgaosConcedentes.add(codigo);
	}

	public void removeCodOrgaoConcedente(ParadaCodOrgaoConcedente codigo) {
		this.codigosOrgaosConcedentes.remove(codigo);
	}

	public String getDescProcon() {
		return descProcon;
	}

	public void setDescProcon(String descProcon) {
		this.descProcon = descProcon;
	}

	public Boolean getIndVendeTotem() {
		return indVendeTotem;
	}

	public void setIndVendeTotem(Boolean indVendeTotem) {
		this.indVendeTotem = indVendeTotem;
	}

	public Integer getCodanttaux() {
		return codanttaux;
	}

	public void setCodanttaux(Integer codanttaux) {
		this.codanttaux = codanttaux;
	}

	public Boolean getIndVisibleInternet() {
		return indVisibleInternet;
	}

	public void setIndVisibleInternet(Boolean indVisibleInternet) {
		this.indVisibleInternet = indVisibleInternet;
	}
	
	public Boolean getIndIntegracaoW2i() {
		return indIntegracaoW2i == null ? false : indIntegracaoW2i;
	}

	public void setIndIntegracaoW2i(Boolean indIntegracaoW2i) {
		this.indIntegracaoW2i = indIntegracaoW2i;
	}

	public Boolean getIndDisponibleTotalBus() {
		return indDisponibleTotalBus;
	}

	public void setIndDisponibleTotalBus(Boolean indDisponibleTotalBus) {
		this.indDisponibleTotalBus = indDisponibleTotalBus;
	}

	public AgrupamentoParada getAgrupamentoParada() {
		return agrupamentoParada;
	}

	public void setAgrupamentoParada(AgrupamentoParada agrupamentoParada) {
		this.agrupamentoParada = agrupamentoParada;
	}

	public String getCodSigma() {
		return codSigma;
	}

	public void setCodSigma(String codSigma) {
		this.codSigma = codSigma;
	}

	@Override
	public void clonar() throws CloneNotSupportedException {
		paradaClone = new Parada();
		paradaClone = (Parada) this.clone();
	}

	@Override
	public Parada getCloneObject() throws CloneNotSupportedException {
		return paradaClone;
	}

	@Override
	public String getTextoInclusaoExclusao() {
		return String.format("EsquemaAsientoID [%s]", getParadaId());
	}
	
	@Override
	public Object clone() throws CloneNotSupportedException {
		return super.clone();
	}
	
}
