460 lines
11 KiB
Java
460 lines
11 KiB
Java
/*
|
|
* 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.CascadeType;
|
|
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.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;
|
|
|
|
/**
|
|
*
|
|
* @author Rafius
|
|
*/
|
|
@Entity
|
|
@SequenceGenerator(name = "RUTA_SEQ", sequenceName = "RUTA_SEQ", allocationSize = 1)
|
|
@org.hibernate.annotations.Entity(dynamicUpdate = true)
|
|
@Table(name = "RUTA")
|
|
public class Ruta implements Serializable, Comparable<Ruta> {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
@Id
|
|
@Basic(optional = false)
|
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "RUTA_SEQ")
|
|
@Column(name = "RUTA_ID")
|
|
private Integer rutaId;
|
|
@Column(name = "DESCRUTA")
|
|
private String descruta;
|
|
@Column(name = "ACTIVO")
|
|
private Boolean activo;
|
|
@Column(name = "FECMODIF")
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
private Date fecmodif;
|
|
@Column(name = "USUARIO_ID")
|
|
private Integer usuarioId;
|
|
@JoinColumn(name = "CLASESERVICIO_ID", referencedColumnName = "CLASESERVICIO_ID")
|
|
@ManyToOne
|
|
private ClaseServicio claseServicio;
|
|
@JoinColumn(name = "GRUPORUTA_ID", referencedColumnName = "GRUPORUTA_ID")
|
|
@ManyToOne
|
|
private GrupoRuta grupoRuta;
|
|
@OneToMany(mappedBy = "ruta", cascade=CascadeType.ALL)
|
|
private List<RutaSecuencia> rutaSecuenciaList;
|
|
@OneToMany(mappedBy = "ruta")
|
|
private List<RutaCombinacion> rutaCombinacionList;
|
|
@Column(name = "indnombreobligatorio")
|
|
private Boolean indNombreObligatorio;
|
|
@OneToMany(mappedBy = "ruta", cascade = CascadeType.ALL)
|
|
private List<RutaEmpresa> lsRutaEmpresa;
|
|
@Column(name = "INDVENTAOFFLINE")
|
|
private Boolean ventaOffLine;
|
|
@Column(name = "PREFIXO")
|
|
private String prefixo;
|
|
@Column(name = "PREFIXOAUXILIAR")
|
|
private String prefixoAuxiliar;
|
|
@OneToOne
|
|
@JoinColumn(name = "ORGAOCONCEDENTE_ID")
|
|
private OrgaoConcedente orgaoConcedente;
|
|
|
|
@Column(name = "INDSENTIDOIDA")
|
|
private Boolean indSentidoIda;
|
|
@Column(name = "NUMRUTA")
|
|
private String numRuta;
|
|
|
|
@Column(name = "INDTRIBTARIFA")
|
|
private Boolean indTribTarifa;
|
|
@Column(name = "INDTRIBPEDAGIO")
|
|
private Boolean indTribPedagio;
|
|
@Column(name = "INDTRIBTAXAEMBARQUE")
|
|
private Boolean indTribTaxaEmbarque;
|
|
@Column(name = "CANTEIXOS")
|
|
private Integer cantEixos;
|
|
@Column(name = "CANTASIENTOS")
|
|
private Integer cantAsientos;
|
|
@Column(name = "INDVENTARIOCARD")
|
|
private Boolean indVentaRioCard;
|
|
@Column(name = "NUMRIOCARD")
|
|
private String numRioCard;
|
|
@Column(name = "INDBLOQVTAABIERTA")
|
|
private Boolean indBloqueoVtaAbierta;
|
|
@Transient
|
|
private Boolean isClone;
|
|
|
|
public Ruta() {
|
|
}
|
|
|
|
public static Ruta clone(Ruta other){
|
|
Ruta ruta = new Ruta();
|
|
ruta.setIsClone(Boolean.TRUE);
|
|
ruta.activo = other.activo;
|
|
ruta.cantAsientos = other.cantAsientos;
|
|
ruta.cantEixos = other.cantEixos;
|
|
ruta.claseServicio = other.claseServicio;
|
|
ruta.descruta = other.descruta;
|
|
ruta.fecmodif = other.fecmodif;
|
|
ruta.grupoRuta = other.grupoRuta;
|
|
ruta.indNombreObligatorio = other.indNombreObligatorio;
|
|
ruta.indSentidoIda = other.indSentidoIda;
|
|
ruta.indTribPedagio = other.indTribPedagio;
|
|
ruta.indTribTarifa = other.indTribTarifa;
|
|
ruta.indTribTaxaEmbarque = other.indTribTaxaEmbarque;
|
|
ruta.indVentaRioCard = other.indVentaRioCard;
|
|
|
|
/******* ruta.lsRutaEmpresa *************/
|
|
if (ruta.lsRutaEmpresa == null){
|
|
ruta.lsRutaEmpresa = new ArrayList<RutaEmpresa>();
|
|
}
|
|
for (RutaEmpresa re : other.lsRutaEmpresa){
|
|
RutaEmpresa r = new RutaEmpresa();
|
|
r.setActivo(re.getActivo());
|
|
r.setEmpresa(re.getEmpresa());
|
|
r.setFecmodif(re.getFecmodif());
|
|
r.setRuta(ruta);
|
|
r.setRutaEmpresaId(null);
|
|
r.setUsuarioId(re.getUsuarioId());
|
|
ruta.lsRutaEmpresa.add(r);
|
|
}
|
|
/*****************************************/
|
|
|
|
ruta.numRioCard = other.numRioCard;
|
|
ruta.numRuta = other.numRuta;
|
|
ruta.orgaoConcedente = other.orgaoConcedente;
|
|
ruta.prefixo = other.prefixo;
|
|
ruta.prefixoAuxiliar = other.prefixoAuxiliar;
|
|
|
|
/************* ruta.rutaCombinacionList **************/
|
|
// if (ruta.rutaCombinacionList == null){
|
|
// ruta.rutaCombinacionList = new ArrayList<RutaCombinacion>();
|
|
// }
|
|
// for (RutaCombinacion rc : other.rutaCombinacionList){
|
|
// RutaCombinacion rcnew = RutaCombinacion.clone(rc);
|
|
// rcnew.setRuta(ruta);
|
|
// rcnew.setRutacombinacionId(null);
|
|
// ruta.rutaCombinacionList.add(rcnew);
|
|
// }
|
|
/*******************************************************/
|
|
|
|
ruta.rutaId = other.rutaId;
|
|
|
|
/************ ruta.rutaSecuenciaList ************/
|
|
if (ruta.rutaSecuenciaList == null){
|
|
ruta.rutaSecuenciaList = new ArrayList<RutaSecuencia>();
|
|
}
|
|
for (RutaSecuencia rs : other.rutaSecuenciaList){
|
|
RutaSecuencia rsnew = RutaSecuencia.clone(rs);
|
|
rsnew.setRuta(ruta);
|
|
rsnew.setRutasecuenciaId(null);
|
|
ruta.rutaSecuenciaList.add(rsnew);
|
|
}
|
|
/************************************************/
|
|
|
|
ruta.usuarioId = other.usuarioId;
|
|
ruta.ventaOffLine = other.ventaOffLine;
|
|
return ruta;
|
|
}
|
|
|
|
|
|
public Integer numSecuenciaOrigen(Integer origenId){
|
|
Integer numSecuencia = -1;
|
|
for (RutaSecuencia rs : rutaSecuenciaList){
|
|
if (rs.tieneOrigen(origenId)){
|
|
numSecuencia = rs.getNumsecuencia().intValue();
|
|
}
|
|
}
|
|
return numSecuencia;
|
|
}
|
|
|
|
public Integer numSecuenciaDestino(Integer destinoId){
|
|
Integer numSecuencia = -1;
|
|
for (RutaSecuencia rs : rutaSecuenciaList){
|
|
if (rs.tieneDestino(destinoId)){
|
|
numSecuencia = rs.getNumsecuencia().intValue();
|
|
}
|
|
}
|
|
return numSecuencia;
|
|
}
|
|
|
|
public Ruta(Integer rutaId) {
|
|
this.rutaId = rutaId;
|
|
}
|
|
|
|
public Integer getRutaId() {
|
|
return rutaId;
|
|
}
|
|
|
|
public void setRutaId(Integer rutaId) {
|
|
this.rutaId = rutaId;
|
|
}
|
|
|
|
public String getDescruta() {
|
|
return descruta;
|
|
}
|
|
|
|
public void setDescruta(String descruta) {
|
|
this.descruta = descruta;
|
|
}
|
|
|
|
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 String getNumRuta() {
|
|
return numRuta;
|
|
}
|
|
|
|
public void setNumRuta(String numRuta) {
|
|
this.numRuta = numRuta;
|
|
}
|
|
|
|
public List<RutaSecuencia> getRutaSecuenciaList() {
|
|
List<RutaSecuencia> rsList = new ArrayList<RutaSecuencia>();
|
|
for (RutaSecuencia rs : this.rutaSecuenciaList) {
|
|
if (rs.getActivo() == Boolean.TRUE) {
|
|
rsList.add(rs);
|
|
}
|
|
}
|
|
|
|
return rsList;
|
|
}
|
|
|
|
public void setRutaSecuenciaList(List<RutaSecuencia> rutaSecuenciaList) {
|
|
this.rutaSecuenciaList = rutaSecuenciaList;
|
|
}
|
|
|
|
public ClaseServicio getClaseServicio() {
|
|
return claseServicio;
|
|
}
|
|
|
|
public void setClaseServicio(ClaseServicio claseServicio) {
|
|
this.claseServicio = claseServicio;
|
|
}
|
|
|
|
public List<RutaCombinacion> getRutaCombinacionList() {
|
|
|
|
List<RutaCombinacion> rcList = new ArrayList<RutaCombinacion>();
|
|
if (this.rutaCombinacionList == null) {
|
|
return rcList;
|
|
}
|
|
for (RutaCombinacion rc : this.rutaCombinacionList) {
|
|
if (rc.getActivo() == Boolean.TRUE) {
|
|
rcList.add(rc);
|
|
}
|
|
}
|
|
|
|
return rcList;
|
|
}
|
|
|
|
public void setRutaCombinacionList(List<RutaCombinacion> rutaCombinacionList) {
|
|
this.rutaCombinacionList = rutaCombinacionList;
|
|
}
|
|
|
|
public List<RutaEmpresa> getLsRutaEmpresa() {
|
|
List<RutaEmpresa> rsList = new ArrayList<RutaEmpresa>();
|
|
for (RutaEmpresa rs : this.lsRutaEmpresa) {
|
|
if (rs.getActivo() == Boolean.TRUE) {
|
|
rsList.add(rs);
|
|
}
|
|
}
|
|
|
|
return rsList;
|
|
}
|
|
|
|
public void setLsRutaEmpresa(List<RutaEmpresa> lsRutaEmpresa) {
|
|
this.lsRutaEmpresa = lsRutaEmpresa;
|
|
}
|
|
|
|
public Boolean getVentaOffLine() {
|
|
return ventaOffLine;
|
|
}
|
|
|
|
public void setVentaOffLine(Boolean ventaOffLine) {
|
|
this.ventaOffLine = ventaOffLine;
|
|
}
|
|
|
|
public String getPrefixo() {
|
|
return prefixo;
|
|
}
|
|
|
|
public void setPrefixo(String prefixo) {
|
|
this.prefixo = prefixo;
|
|
}
|
|
|
|
public String getPrefixoAuxiliar() {
|
|
return prefixoAuxiliar;
|
|
}
|
|
|
|
public void setPrefixoAuxiliar(String prefixoAuxiliar) {
|
|
this.prefixoAuxiliar = prefixoAuxiliar;
|
|
}
|
|
|
|
public OrgaoConcedente getOrgaoConcedente() {
|
|
return orgaoConcedente;
|
|
}
|
|
|
|
public void setOrgaoConcedente(OrgaoConcedente orgaoConcedente) {
|
|
this.orgaoConcedente = orgaoConcedente;
|
|
}
|
|
|
|
public Boolean getIndSentidoIda() {
|
|
return indSentidoIda;
|
|
}
|
|
|
|
public void setIndSentidoIda(Boolean indSentidoIda) {
|
|
this.indSentidoIda = indSentidoIda;
|
|
}
|
|
|
|
public GrupoRuta getGrupoRuta() {
|
|
return grupoRuta;
|
|
}
|
|
|
|
public void setGrupoRuta(GrupoRuta grupoRuta) {
|
|
this.grupoRuta = grupoRuta;
|
|
}
|
|
|
|
public Boolean getIndTribTarifa() {
|
|
return indTribTarifa;
|
|
}
|
|
|
|
public void setIndTribTarifa(Boolean indTribTarifa) {
|
|
this.indTribTarifa = indTribTarifa;
|
|
}
|
|
|
|
public Boolean getIndTribPedagio() {
|
|
return indTribPedagio;
|
|
}
|
|
|
|
public void setIndTribPedagio(Boolean indTribPedagio) {
|
|
this.indTribPedagio = indTribPedagio;
|
|
}
|
|
|
|
public Boolean getIndTribTaxaEmbarque() {
|
|
return indTribTaxaEmbarque;
|
|
}
|
|
|
|
public void setIndTribTaxaEmbarque(Boolean indTribTaxaEmbarque) {
|
|
this.indTribTaxaEmbarque = indTribTaxaEmbarque;
|
|
}
|
|
|
|
public Boolean getIndNombreObligatorio() {
|
|
return indNombreObligatorio;
|
|
}
|
|
|
|
public void setIndNombreObligatorio(Boolean indNombreObligatorio) {
|
|
this.indNombreObligatorio = indNombreObligatorio;
|
|
}
|
|
|
|
public Integer getCantEixos() {
|
|
return cantEixos;
|
|
}
|
|
|
|
public void setCantEixos(Integer cantEixos) {
|
|
this.cantEixos = cantEixos;
|
|
}
|
|
|
|
public Integer getCantAsientos() {
|
|
return cantAsientos;
|
|
}
|
|
|
|
public void setCantAsientos(Integer cantAsientos) {
|
|
this.cantAsientos = cantAsientos;
|
|
}
|
|
|
|
public Boolean getIndVentaRioCard() {
|
|
return indVentaRioCard;
|
|
}
|
|
|
|
public void setIndVentaRioCard(Boolean indVentaRioCard) {
|
|
this.indVentaRioCard = indVentaRioCard;
|
|
}
|
|
|
|
public String getNumRioCard() {
|
|
return numRioCard;
|
|
}
|
|
|
|
public void setNumRioCard(String numRioCard) {
|
|
this.numRioCard = numRioCard;
|
|
}
|
|
|
|
public Boolean getIndBloqueoVtaAbierta() {
|
|
return indBloqueoVtaAbierta;
|
|
}
|
|
|
|
public void setIndBloqueoVtaAbierta(Boolean indBloqueoVtaAbierta) {
|
|
this.indBloqueoVtaAbierta = indBloqueoVtaAbierta;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
int hash = 0;
|
|
hash += (getRutaId() != null ? getRutaId().hashCode() : 0);
|
|
return hash;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object object) {
|
|
if (!(object instanceof Ruta)) {
|
|
return false;
|
|
}
|
|
Ruta other = (Ruta) object;
|
|
if ((this.getRutaId() == null && other.getRutaId() != null) || (this.getRutaId() != null && !this.getRutaId().equals(other.getRutaId()))) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return this.getDescruta() + " - " + this.getRutaId();
|
|
}
|
|
@Override
|
|
public int compareTo(Ruta ruta) {
|
|
return this.getRutaId().intValue() - ruta.getRutaId().intValue();
|
|
}
|
|
|
|
public Boolean getIsClone() {
|
|
return isClone;
|
|
}
|
|
|
|
public void setIsClone(Boolean isClone) {
|
|
this.isClone = isClone;
|
|
}
|
|
} |