fixes bug #7496
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@56270 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
c7a5848b39
commit
a258737a1a
|
@ -33,6 +33,7 @@ public class CasetaPeajeHibernateDAO extends GenericHibernateDAO<CasetaPeaje, In
|
|||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.addOrder(Order.asc("desccaseta"));
|
||||
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
||||
return (List<CasetaPeaje>) c.list();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,14 @@ 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.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
@ -22,7 +24,7 @@ import javax.persistence.TemporalType;
|
|||
@Entity
|
||||
@SequenceGenerator(name = "CASETA_PEAJE_SEQ", sequenceName = "CASETA_PEAJE_SEQ", allocationSize = 1)
|
||||
@Table(name = "CASETA_PEAJE")
|
||||
public class CasetaPeaje implements Serializable, Comparable<CasetaPeaje> {
|
||||
public class CasetaPeaje implements Serializable, Comparable<CasetaPeaje>, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
|
@ -44,7 +46,7 @@ public class CasetaPeaje implements Serializable, Comparable<CasetaPeaje> {
|
|||
@Column(name = "USUARIO_ID")
|
||||
private Integer usuarioId;
|
||||
|
||||
@ManyToMany
|
||||
@ManyToMany(fetch=FetchType.EAGER)
|
||||
@JoinTable(name = "RUTA_CASETA", joinColumns = { @JoinColumn(name = "CASETAPEAJE_ID") },
|
||||
inverseJoinColumns = { @JoinColumn(name = "RUTASECUENCIA_ID") })
|
||||
private List<RutaSecuencia> lsRutaSecuencia;
|
||||
|
@ -68,7 +70,11 @@ public class CasetaPeaje implements Serializable, Comparable<CasetaPeaje> {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public CasetaPeaje(){
|
||||
lsRutaSecuencia = new ArrayList<RutaSecuencia>();
|
||||
}
|
||||
|
||||
public Integer getCasetaPeajeId() {
|
||||
return casetaPeajeId;
|
||||
}
|
||||
|
@ -121,4 +127,12 @@ public class CasetaPeaje implements Serializable, Comparable<CasetaPeaje> {
|
|||
public int compareTo(CasetaPeaje caseta) {
|
||||
return this.getDesccaseta().compareTo(caseta.getDesccaseta());
|
||||
}
|
||||
|
||||
public List<RutaSecuencia> getLsRutaSecuencia() {
|
||||
return lsRutaSecuencia;
|
||||
}
|
||||
|
||||
public void setLsRutaSecuencia(List<RutaSecuencia> lsRutaSecuencia) {
|
||||
this.lsRutaSecuencia = lsRutaSecuencia;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ public class ParadaSecuencia {
|
|||
private Short secuencia;
|
||||
private Parada parada;
|
||||
private Via via;
|
||||
private List<CasetaPeaje> casetas;
|
||||
private List<RutaCaseta> casetas;
|
||||
private String casetasTxt ="";
|
||||
private String kmReal = "";
|
||||
private String tempoReal = "";
|
||||
|
@ -47,22 +47,22 @@ public class ParadaSecuencia {
|
|||
this.via = via;
|
||||
}
|
||||
|
||||
public List<CasetaPeaje> getCasetas() {
|
||||
public List<RutaCaseta> getCasetas() {
|
||||
return casetas;
|
||||
}
|
||||
|
||||
public void setCasetas(List<CasetaPeaje> casetas) {
|
||||
public void setCasetas(List<RutaCaseta> casetas) {
|
||||
this.casetas = casetas;
|
||||
}
|
||||
|
||||
public String getCasetasTxt() {
|
||||
if(casetas != null){
|
||||
for( int i = 0 ; i < casetas.size() ; i ++){
|
||||
CasetaPeaje cs = casetas.get(i);
|
||||
RutaCaseta cs = casetas.get(i);
|
||||
if(i == casetas.size()-1){
|
||||
casetasTxt = casetasTxt + cs.getDesccaseta();
|
||||
casetasTxt = casetasTxt + cs.getCasetaPeaje().getDesccaseta();
|
||||
}else{
|
||||
casetasTxt = casetasTxt + cs.getDesccaseta()+", ";
|
||||
casetasTxt = casetasTxt + cs.getCasetaPeaje().getDesccaseta()+", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import javax.persistence.SequenceGenerator;
|
|||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -56,7 +57,7 @@ public class Ruta implements Serializable, Comparable<Ruta> {
|
|||
@JoinColumn(name = "GRUPORUTA_ID", referencedColumnName = "GRUPORUTA_ID")
|
||||
@ManyToOne
|
||||
private GrupoRuta grupoRuta;
|
||||
@OneToMany(mappedBy = "ruta")
|
||||
@OneToMany(mappedBy = "ruta", cascade=CascadeType.ALL)
|
||||
private List<RutaSecuencia> rutaSecuenciaList;
|
||||
@OneToMany(mappedBy = "ruta")
|
||||
private List<RutaCombinacion> rutaCombinacionList;
|
||||
|
@ -95,10 +96,83 @@ public class Ruta implements Serializable, Comparable<Ruta> {
|
|||
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){
|
||||
|
@ -375,4 +449,12 @@ public class Ruta implements Serializable, Comparable<Ruta> {
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ 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;
|
||||
|
@ -14,10 +15,10 @@ 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;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -26,7 +27,7 @@ import javax.persistence.SequenceGenerator;
|
|||
@Entity
|
||||
@SequenceGenerator(name = "RUTA_COMBINACION_SEQ", sequenceName = "RUTA_COMBINACION_SEQ", allocationSize=1)
|
||||
@Table(name = "RUTA_COMBINACION")
|
||||
public class RutaCombinacion implements Serializable {
|
||||
public class RutaCombinacion implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
|
@ -53,6 +54,12 @@ public class RutaCombinacion implements Serializable {
|
|||
public RutaCombinacion() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
|
||||
public RutaCombinacion(Integer rutacombinacionId) {
|
||||
this.rutacombinacionId = rutacombinacionId;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
@ -24,7 +25,7 @@ import javax.persistence.Temporal;
|
|||
@Entity
|
||||
@SequenceGenerator(name = "RUTA_EMPRESA_SEQ", sequenceName = "RUTA_EMPRESA_SEQ", allocationSize = 1)
|
||||
@Table(name = "RUTA_EMPRESA")
|
||||
public class RutaEmpresa {
|
||||
public class RutaEmpresa implements Cloneable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "RUTA_EMPRESA_SEQ")
|
||||
|
@ -96,4 +97,9 @@ public class RutaEmpresa {
|
|||
public void setRuta(Ruta ruta) {
|
||||
this.ruta = ruta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
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.FetchType;
|
||||
|
@ -16,9 +18,8 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
|
@ -31,7 +32,7 @@ import javax.persistence.TemporalType;
|
|||
@Entity
|
||||
@SequenceGenerator(name = "RUTA_SECUENCIA_SEQ", sequenceName = "RUTA_SECUENCIA_SEQ", allocationSize=1)
|
||||
@Table(name = "RUTA_SECUENCIA")
|
||||
public class RutaSecuencia implements Serializable {
|
||||
public class RutaSecuencia implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
|
@ -54,16 +55,36 @@ public class RutaSecuencia implements Serializable {
|
|||
@JoinColumn(name = "RUTA_ID", referencedColumnName = "RUTA_ID")
|
||||
@ManyToOne
|
||||
private Ruta ruta;
|
||||
// @JoinColumn( referencedColumnName = "RUTACASETA_ID")
|
||||
// @OneToMany
|
||||
// private List<RutaCaseta> rutaCaseta;
|
||||
|
||||
@ManyToMany(fetch=FetchType.EAGER)
|
||||
@JoinTable(name = "RUTA_CASETA", joinColumns = { @JoinColumn(name = "RUTASECUENCIA_ID")},
|
||||
inverseJoinColumns = { @JoinColumn(name = "CASETAPEAJE_ID") })
|
||||
private List<CasetaPeaje> lsCasetaPeaje;
|
||||
@OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL)
|
||||
@JoinColumn(name = "RUTASECUENCIA_ID")
|
||||
private List<RutaCaseta> lsRutaCase;
|
||||
|
||||
public RutaSecuencia() {
|
||||
public RutaSecuencia() {}
|
||||
|
||||
public static RutaSecuencia clone(RutaSecuencia other){
|
||||
List<RutaCaseta> rutasCaseta = new ArrayList<RutaCaseta>();
|
||||
RutaSecuencia rsnew = new RutaSecuencia();
|
||||
rsnew.setActivo(other.activo);
|
||||
rsnew.setFecmodif(other.fecmodif);
|
||||
rsnew.setNumsecuencia(other.numsecuencia);
|
||||
rsnew.setRuta(other.ruta);
|
||||
rsnew.setRutasecuenciaId(other.rutasecuenciaId);
|
||||
rsnew.setTramo(other.tramo);
|
||||
rsnew.setUsuarioId(other.usuarioId);
|
||||
|
||||
|
||||
for (RutaCaseta rc : other.getLsRutaCase()){
|
||||
RutaCaseta rutaCaseta = new RutaCaseta();
|
||||
rutaCaseta.setRutaSecuencia(rsnew);
|
||||
rutaCaseta.setCasetaPeaje(rc.getCasetaPeaje());
|
||||
rutaCaseta.setActivo(Boolean.TRUE);
|
||||
rutaCaseta.setFecmodif(new Date());
|
||||
rutaCaseta.setUsuarioId(other.usuarioId);
|
||||
rutasCaseta.add(rutaCaseta);
|
||||
}
|
||||
rsnew.setLsRutaCase(rutasCaseta);
|
||||
return rsnew;
|
||||
}
|
||||
|
||||
public boolean tieneOrigen(Integer origenId){
|
||||
|
@ -134,12 +155,12 @@ public class RutaSecuencia implements Serializable {
|
|||
this.ruta = ruta;
|
||||
}
|
||||
|
||||
public List<CasetaPeaje> getLsCasetaPeaje() {
|
||||
return lsCasetaPeaje;
|
||||
public List<RutaCaseta> getLsRutaCase() {
|
||||
return lsRutaCase;
|
||||
}
|
||||
|
||||
public void setLsCasetaPeaje(List<CasetaPeaje> lsCasetaPeaje) {
|
||||
this.lsCasetaPeaje = lsCasetaPeaje;
|
||||
public void setLsRutaCase(List<RutaCaseta> lsRutaCase) {
|
||||
this.lsRutaCase = lsRutaCase;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,14 +78,17 @@ public class RutaServiceImpl implements RutaService {
|
|||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
|
||||
if (entidad.getVentaOffLine() == null) {
|
||||
entidad.setVentaOffLine(false);
|
||||
}
|
||||
|
||||
|
||||
Boolean isClone = entidad.getIsClone() != null ? entidad.getIsClone() : Boolean.FALSE;
|
||||
entidad = rutaDAO.suscribir(entidad);
|
||||
if (lsParadasSequencia != null) {
|
||||
generarSecuencias(entidad, lsParadasSequencia);
|
||||
if(!isClone) {
|
||||
generarSecuencias(entidad, lsParadasSequencia);
|
||||
}
|
||||
generarCombinacion(entidad);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue