fixes bug #8659
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@67559 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
2f6728196b
commit
f13487c69b
|
@ -0,0 +1,9 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ConexionDescuento;
|
||||
|
||||
public interface ConexionDescuentoDAO extends GenericDAO<ConexionDescuento, Long> {
|
||||
public List<ConexionDescuento> bucarPorConexion(Long conexionId);
|
||||
}
|
|
@ -95,4 +95,6 @@ public interface CorridaDAO extends GenericDAO<Corrida, Corrida.Id> {
|
|||
|
||||
List<Corrida> buscarCorridaRelAproveitamento(Parada origem, Parada destino, Date feccorrida, Integer corridaId);
|
||||
|
||||
public Boolean existeCorrida(Long id);
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -24,4 +25,6 @@ public interface GenericDAO<T, ID> {
|
|||
|
||||
public Long count(String campo, Object o);
|
||||
|
||||
public void suscribirTodos(Collection<T> entidades);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.ConexionDescuentoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ConexionDescuento;
|
||||
|
||||
@Repository("conexionDescuentoDAO")
|
||||
public class ConexionDescuentoHibernateDAO extends GenericHibernateDAO<ConexionDescuento, Long>
|
||||
implements ConexionDescuentoDAO {
|
||||
|
||||
@Autowired
|
||||
public ConexionDescuentoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ConexionDescuento> bucarPorConexion(Long conexionId) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("conexion.conexionId", conexionId));
|
||||
c.add(Restrictions.eq("activo", true));
|
||||
return c.list();
|
||||
}
|
||||
|
||||
}
|
|
@ -729,7 +729,6 @@ public class CorridaHibernateDAO extends GenericHibernateDAO<Corrida, Corrida.Id
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -842,4 +841,15 @@ public class CorridaHibernateDAO extends GenericHibernateDAO<Corrida, Corrida.Id
|
|||
}
|
||||
return lsCorridas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean existeCorrida(Long id) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("id.corridaId", id.intValue()));
|
||||
c.setMaxResults(1);
|
||||
if (c.uniqueResult() != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.dao.hibernate;
|
|||
import com.rjconsultores.ventaboletos.dao.GenericDAO;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.HibernateException;
|
||||
|
@ -104,4 +105,8 @@ public class GenericHibernateDAO<T, ID extends Serializable> extends HibernateDa
|
|||
return HibernateFix.count(c.list());
|
||||
|
||||
}
|
||||
|
||||
public void suscribirTodos(Collection<T> entidades) {
|
||||
getHibernateTemplate().saveOrUpdateAll(entidades);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
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;
|
||||
|
@ -13,10 +15,13 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
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 javax.persistence.Version;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -51,6 +56,8 @@ public class Conexion implements Serializable {
|
|||
private Long conexionctrlId;
|
||||
@Column(name = "CORRIDA_ID")
|
||||
private Long corridaId;
|
||||
@Transient
|
||||
private List<ConexionDescuento> conexionesDescuentos;
|
||||
|
||||
public Long getCorridaId() {
|
||||
return corridaId;
|
||||
|
@ -61,10 +68,12 @@ public class Conexion implements Serializable {
|
|||
}
|
||||
|
||||
public Conexion() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public Conexion(Long conexionId) {
|
||||
this.conexionId = conexionId;
|
||||
conexionesDescuentos = new ArrayList<ConexionDescuento>();
|
||||
}
|
||||
|
||||
public Long getConexionId() {
|
||||
|
@ -166,4 +175,13 @@ public class Conexion implements Serializable {
|
|||
public void setDestinoId(Integer destinoId) {
|
||||
this.destinoId = destinoId;
|
||||
}
|
||||
|
||||
public List<ConexionDescuento> getConexionesDescuentos() {
|
||||
return conexionesDescuentos;
|
||||
}
|
||||
|
||||
public void setConexionesDescuentos(List<ConexionDescuento> conexionesDescuentos) {
|
||||
this.conexionesDescuentos = conexionesDescuentos;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,16 +41,6 @@ public class ConexionCtrl implements Serializable {
|
|||
private Integer origenId;
|
||||
@Column(name = "DESTINO_ID")
|
||||
private Integer destinoId;
|
||||
@Column(name = "INDFIXA")
|
||||
private Integer indfixa;
|
||||
|
||||
public Integer getIndfixa() {
|
||||
return indfixa;
|
||||
}
|
||||
|
||||
public void setIndfixa(Integer indfixa) {
|
||||
this.indfixa = indfixa;
|
||||
}
|
||||
|
||||
public ConexionCtrl() {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
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.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@SequenceGenerator(name = "CONEXION_DESCUENTO_SEQ", sequenceName = "CONEXION_DESCUENTO_SEQ", allocationSize = 1)
|
||||
@Table(name = "CONEXION_DESCUENTO")
|
||||
public class ConexionDescuento {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CONEXION_DESCUENTO_SEQ")
|
||||
@Column(name = "CONEXIONDESCUENTO_ID")
|
||||
private Long idConexionDescuento;
|
||||
|
||||
@Column
|
||||
private Boolean activo;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "CONEXION_ID")
|
||||
private Conexion conexion;
|
||||
|
||||
@ManyToOne(targetEntity = ClaseServicio.class)
|
||||
@JoinColumn(name = "CLASSESERVICIO_ID")
|
||||
private ClaseServicio claseServicio;
|
||||
|
||||
@Column
|
||||
private Short secuencia;
|
||||
|
||||
@Column
|
||||
private Integer grupo;
|
||||
|
||||
@Column
|
||||
private BigDecimal descuento;
|
||||
|
||||
@Column
|
||||
private Date fecModif;
|
||||
|
||||
public Long getIdConexionDescuento() {
|
||||
return idConexionDescuento;
|
||||
}
|
||||
|
||||
public void setIdConexionDescuento(Long idConexionDescuento) {
|
||||
this.idConexionDescuento = idConexionDescuento;
|
||||
}
|
||||
|
||||
public Boolean getActivo() {
|
||||
return activo;
|
||||
}
|
||||
|
||||
public void setActivo(Boolean activo) {
|
||||
this.activo = activo;
|
||||
}
|
||||
|
||||
public Conexion getConexion() {
|
||||
return conexion;
|
||||
}
|
||||
|
||||
public void setConexion(Conexion conexion) {
|
||||
this.conexion = conexion;
|
||||
}
|
||||
|
||||
public ClaseServicio getClaseServicio() {
|
||||
return claseServicio;
|
||||
}
|
||||
|
||||
public void setClaseServicio(ClaseServicio claseServicio) {
|
||||
this.claseServicio = claseServicio;
|
||||
}
|
||||
|
||||
public Short getSecuencia() {
|
||||
return secuencia;
|
||||
}
|
||||
|
||||
public void setSecuencia(Short secuencia) {
|
||||
this.secuencia = secuencia;
|
||||
}
|
||||
|
||||
public Integer getGrupo() {
|
||||
return grupo;
|
||||
}
|
||||
|
||||
public void setGrupo(Integer grupo) {
|
||||
this.grupo = grupo;
|
||||
}
|
||||
|
||||
public BigDecimal getDescuento() {
|
||||
return descuento;
|
||||
}
|
||||
|
||||
public void setDescuento(BigDecimal descuento) {
|
||||
this.descuento = descuento;
|
||||
}
|
||||
|
||||
public Date getFecModif() {
|
||||
return fecModif;
|
||||
}
|
||||
|
||||
public void setFecModif(Date fecModif) {
|
||||
this.fecModif = fecModif;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ConexionDescuento)) {
|
||||
return false;
|
||||
}
|
||||
ConexionDescuento other = (ConexionDescuento) obj;
|
||||
if(this.getClaseServicio()==null &&other.getClaseServicio()==null){
|
||||
return true;
|
||||
}
|
||||
return this.getClaseServicio().equals(other.getClaseServicio());
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ConexionConf;
|
||||
|
@ -10,4 +11,6 @@ public interface ConexionConfService extends GenericService<ConexionConf, Long>
|
|||
public ConexionConf buscar(Long conexionCtrlId, Integer numgrupo);
|
||||
|
||||
public List<ConexionConf> buscarPorConexionCtrl(ConexionCtrl entidad);
|
||||
|
||||
public void suscribirTodos(Collection<ConexionConf> conexionesConf);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Conexion;
|
||||
import com.rjconsultores.ventaboletos.entidad.ConexionDescuento;
|
||||
|
||||
public interface ConexionDescuentoService {
|
||||
public List<ConexionDescuento> buscarPorConexion(Conexion conexion);
|
||||
|
||||
public ConexionDescuento suscribir(ConexionDescuento conexionDescuento);
|
||||
|
||||
public void borrar(ConexionDescuento conexionDescuento);
|
||||
|
||||
public void suscribirTodos(List<ConexionDescuento> conexionesDescuentos);
|
||||
}
|
|
@ -27,4 +27,6 @@ public interface ConexionService {
|
|||
|
||||
public void borrar(List<Conexion> lsConexion);
|
||||
|
||||
public void suscribirTodos(List<Conexion> conexiones);
|
||||
|
||||
}
|
||||
|
|
|
@ -77,4 +77,6 @@ public interface CorridaService extends GenericService<Corrida, Corrida.Id> {
|
|||
|
||||
public Corrida buscaCorrridaFutura(Ruta ruta, Date fecInicio);
|
||||
|
||||
public Boolean existeCorrida(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -72,4 +72,6 @@ public interface TramoService {
|
|||
* @return
|
||||
*/
|
||||
public String gerarDescripcionTramo(Parada origen, Parada destino, Via via);
|
||||
|
||||
public Boolean existe(Parada origem, Parada destino);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -62,4 +64,10 @@ public class ConexionConfServiceImpl implements ConexionConfService {
|
|||
public List<ConexionConf> buscarPorConexionCtrl(ConexionCtrl entidad) {
|
||||
return conexionConfDAO.buscarPorConexionCtrl(entidad);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void suscribirTodos(Collection<ConexionConf> conexionesConf) {
|
||||
conexionConfDAO.suscribirTodos(conexionesConf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.hibernate.ConexionDescuentoHibernateDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Conexion;
|
||||
import com.rjconsultores.ventaboletos.entidad.ConexionDescuento;
|
||||
import com.rjconsultores.ventaboletos.service.ConexionDescuentoService;
|
||||
|
||||
@Service("conexionDescuentoService")
|
||||
public class ConexionDescuentoServiceImpl implements ConexionDescuentoService {
|
||||
@Autowired
|
||||
ConexionDescuentoHibernateDAO conexionDescuentoHDAO;
|
||||
|
||||
@Override
|
||||
public List<ConexionDescuento> buscarPorConexion(Conexion conexion) {
|
||||
return conexionDescuentoHDAO.bucarPorConexion(conexion.getConexionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ConexionDescuento suscribir(ConexionDescuento conexionDescuento) {
|
||||
conexionDescuento.setActivo(true);
|
||||
conexionDescuento.setFecModif(Calendar.getInstance().getTime());
|
||||
if (conexionDescuento.getIdConexionDescuento() == null) {
|
||||
return conexionDescuentoHDAO.suscribir(conexionDescuento);
|
||||
}
|
||||
return conexionDescuentoHDAO.actualizacion(conexionDescuento);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void borrar(ConexionDescuento conexionDescuento) {
|
||||
conexionDescuento.setActivo(false);
|
||||
this.suscribir(conexionDescuento);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void suscribirTodos(List<ConexionDescuento> conexionesDescuentos) {
|
||||
conexionDescuentoHDAO.suscribirTodos(conexionesDescuentos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -78,4 +78,10 @@ public class ConexionServiceImpl implements ConexionService {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void suscribirTodos(List<Conexion> conexiones) {
|
||||
conexionDAO.suscribirTodos(conexiones);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,6 +191,10 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
return corridaDAO.buscarFiltro(ori, des, hora, cs);
|
||||
}
|
||||
|
||||
public Boolean existeCorrida(Long id){
|
||||
return corridaDAO.existeCorrida(id);
|
||||
}
|
||||
|
||||
private Boolean geraDiaSemana(Integer diaSemana, EsquemaCorrida esquemaCorrida) {
|
||||
Boolean retorno = Boolean.FALSE;
|
||||
switch (diaSemana) {
|
||||
|
|
|
@ -271,4 +271,12 @@ public class TramoServiceImpl implements TramoService {
|
|||
return tramoDAO.actualizacion(tramo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean existe(Parada origem, Parada destino) {
|
||||
if(tramoDAO.obtenerPorOrigemDestino(origem, destino).getTramoId()!=null){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue