fixes bug #9339
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@71960 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
526891a3bb
commit
4d9a17a151
|
@ -4,11 +4,14 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoTramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.TramoServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -24,6 +27,8 @@ public interface TramoDAO extends GenericDAO<Tramo, Integer> {
|
|||
|
||||
public Tramo busca(Parada origem, Parada destino, Via via);
|
||||
|
||||
public List<OrgaoTramo> getLsOrgaoTramo(Tramo tramo);
|
||||
|
||||
|
||||
/**
|
||||
* Hace la búsqueda del tramo que tiene origen - destino - via - clase servicio.
|
||||
|
@ -41,4 +46,5 @@ public interface TramoDAO extends GenericDAO<Tramo, Integer> {
|
|||
public Long count(Via via);
|
||||
public List<Via> obtenerViasOrigemDestino(Parada origem, Parada destino);
|
||||
public List<Tramo> obtenerPorOrigemDestinoFetchLazy(Parada origem, Parada destino) ;
|
||||
public List<TramoServicio> obtenerTramosServiciosPorTramo(Tramo t);
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ import org.springframework.stereotype.Repository;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.TramoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoTramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.TramoServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||
|
||||
/**
|
||||
|
@ -44,6 +46,10 @@ public class TramoHibernateDAO extends GenericHibernateDAO<Tramo, Integer>
|
|||
return c.list();
|
||||
}
|
||||
|
||||
public List<TramoServicio> obtenerTramosServiciosPorTramo(Tramo t){
|
||||
return obtenerID(t.getTramoId()).getTramoServicioList();
|
||||
}
|
||||
|
||||
public Tramo obtenerPorOrigemDestino(Parada origem, Parada destino) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("origem", origem));
|
||||
|
@ -171,4 +177,8 @@ public class TramoHibernateDAO extends GenericHibernateDAO<Tramo, Integer>
|
|||
|
||||
return HibernateFix.count(c.list());
|
||||
}
|
||||
|
||||
public List<OrgaoTramo> getLsOrgaoTramo(Tramo tramo){
|
||||
return obtenerID(tramo.getTramoId()).getLsOrgaoTramo();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,9 +187,9 @@ public class Tramo implements Serializable {
|
|||
this.rutaCombinacionList = rutaCombinacionList;
|
||||
}
|
||||
|
||||
public List<TramoServicio> getTramoServicioList() {
|
||||
public List<TramoServicio> getTramoServicioList() throws LazyInitializationException{
|
||||
List<TramoServicio> lsTramoServicio = new ArrayList<TramoServicio>();
|
||||
try{
|
||||
|
||||
for (TramoServicio tramoServicio : this.tramoServicioList) {
|
||||
if (tramoServicio.getActivo()) {
|
||||
lsTramoServicio.add(tramoServicio);
|
||||
|
@ -197,9 +197,7 @@ public class Tramo implements Serializable {
|
|||
}
|
||||
|
||||
this.tramoServicioList = lsTramoServicio;
|
||||
} catch (LazyInitializationException le){
|
||||
Log.error("", le);
|
||||
}
|
||||
|
||||
return lsTramoServicio;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.service;
|
|||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoTramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||
|
@ -63,6 +64,8 @@ public interface TramoService {
|
|||
|
||||
public Tramo suscribirActualizar(Tramo tramo) throws BusinessException ;
|
||||
|
||||
public List<OrgaoTramo> getLsOrgaoTramoByTramo(Tramo tramo);
|
||||
|
||||
/**
|
||||
* Gerar a descrição automática do tramo
|
||||
*
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.Predicate;
|
||||
import org.hibernate.LazyInitializationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -17,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import com.rjconsultores.ventaboletos.dao.RutaCombinacionDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.TramoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoTramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
||||
import com.rjconsultores.ventaboletos.entidad.TramoServicio;
|
||||
|
@ -175,6 +177,14 @@ public class TramoServiceImpl implements TramoService {
|
|||
return tramoDAO.obtenerPorOrigemDestinoFetchLazy(origem, destino);
|
||||
}
|
||||
|
||||
private List<TramoServicio> getListTramoService(Tramo t){
|
||||
return tramoDAO.obtenerTramosServiciosPorTramo(t);
|
||||
}
|
||||
|
||||
public List<OrgaoTramo> getLsOrgaoTramoByTramo(Tramo tramo){
|
||||
return tramoDAO.getLsOrgaoTramo(tramo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = BusinessException.class)
|
||||
public Tramo suscribirActualizar(Tramo tramo) throws BusinessException {
|
||||
|
@ -217,19 +227,24 @@ public class TramoServiceImpl implements TramoService {
|
|||
// Esa validación tambien permite que el usuario quite una clase y la agregue de nuevo con otro tiempo de recorrido
|
||||
List<TramoServicio> lsTramoServicioOriginal = tramoOriginal.getTramoServicioList();
|
||||
for (final TramoServicio ts : lsTramoServicioOriginal) {
|
||||
boolean existe = CollectionUtils.exists(tramo.getTramoServicioList(), new Predicate() {
|
||||
|
||||
@Override
|
||||
public boolean evaluate(Object o) {
|
||||
TramoServicio t = (TramoServicio) o;
|
||||
if (t.getActivo()) {
|
||||
return t.getClaseServicio().equals(ts.getClaseServicio());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!existe) {
|
||||
boolean alterouClaseTramoServico = true;
|
||||
|
||||
try{
|
||||
tramo.getTramoServicioList();
|
||||
} catch(LazyInitializationException le){
|
||||
tramo.setTramoServicioList(getListTramoService(tramo));
|
||||
}
|
||||
|
||||
for( TramoServicio tsNovo : tramo.getTramoServicioList()){
|
||||
if (tsNovo.getClaseServicio().equals(ts.getClaseServicio())){
|
||||
alterouClaseTramoServico = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (alterouClaseTramoServico) {
|
||||
if (rutaCombinacionDAO.existeTramo(tramo, ts.getClaseServicio())) {
|
||||
throw new BusinessException("TramoServiceImpl.msg.validacionTramoServicio");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue