git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@21113 d1611594-4594-4d17-8e1d-87c2c4800839
parent
9793254c16
commit
4b6bd609be
|
@ -1,12 +1,13 @@
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.transform.AliasToBeanResultTransformer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -15,23 +16,51 @@ import com.rjconsultores.ventaboletos.dao.ConexionDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Conexion;
|
import com.rjconsultores.ventaboletos.entidad.Conexion;
|
||||||
import com.rjconsultores.ventaboletos.entidad.ConexionCtrlTemp;
|
import com.rjconsultores.ventaboletos.entidad.ConexionCtrlTemp;
|
||||||
import com.rjconsultores.ventaboletos.entidad.ConexionTemp;
|
import com.rjconsultores.ventaboletos.entidad.ConexionTemp;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.conexion.ConexionVO;
|
||||||
|
|
||||||
@Repository("conexionDAO")
|
@Repository("conexionDAO")
|
||||||
public class ConexionHibernateDAO extends GenericHibernateDAO<Conexion, Integer> implements ConexionDAO {
|
public class ConexionHibernateDAO extends GenericHibernateDAO<Conexion, Integer> implements ConexionDAO {
|
||||||
private static Logger log = Logger.getLogger(ConexionHibernateDAO.class);
|
private static Logger log = Logger.getLogger(ConexionHibernateDAO.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ConexionHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
public ConexionHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ConexionVO> buscarConexiones(Integer origenId, Integer destinoId) {
|
||||||
|
StringBuilder sb = new StringBuilder("");
|
||||||
|
sb.append("select po1.descparada as conOrigen, pd1.descparada as conDestino ,c.numgrupo as grupo ,po2.descparada as tramoOrigen, pd2.descparada as tramoDestino ");
|
||||||
|
sb.append("from ");
|
||||||
|
sb.append(" ConexionCtrl cc, ");
|
||||||
|
sb.append(" Conexion c, ");
|
||||||
|
sb.append(" Parada po1, ");
|
||||||
|
sb.append(" Parada pd1, ");
|
||||||
|
sb.append(" Parada po2, ");
|
||||||
|
sb.append(" Parada pd2 ");
|
||||||
|
sb.append("where ");
|
||||||
|
sb.append(" cc.conexionctrlId = c.conexionctrlId ");
|
||||||
|
sb.append(" and po1.paradaId = cc.origenId ");
|
||||||
|
sb.append(" and pd1.paradaId = cc.destinoId ");
|
||||||
|
sb.append(" and po2.paradaId = c.origenId ");
|
||||||
|
sb.append(" and pd2.paradaId = c.destinoId ");
|
||||||
|
sb.append(" ");
|
||||||
|
sb.append(" ");
|
||||||
|
sb.append("order by po1.descparada, pd1.descparada ,c.numgrupo, po2.descparada, pd2.descparada ");
|
||||||
|
|
||||||
|
Query query = getSession().createQuery(sb.toString());
|
||||||
|
query.setResultTransformer(new AliasToBeanResultTransformer(ConexionVO.class));
|
||||||
|
|
||||||
|
return query.list();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generarConexiones(Integer usuarioId) {
|
public void generarConexiones(Integer usuarioId) {
|
||||||
this.getSession().createQuery("DELETE ConexionTemp");
|
this.getSession().createQuery("DELETE ConexionTemp").executeUpdate();
|
||||||
this.getSession().createQuery("DELETE ConexionCtrlTemp");
|
this.getSession().createQuery("DELETE ConexionCtrlTemp").executeUpdate();
|
||||||
|
|
||||||
Query queryParadas = this.getSession().createQuery("select t.origem.paradaId,t.destino.paradaId from Tramo t where t.activo = 1 order by t.origem.paradaId ");
|
Query queryParadas = this.getSession().createQuery("select distinct t.origem.paradaId,t.destino.paradaId from Tramo t where t.activo = 1 order by t.origem.paradaId ");
|
||||||
List<Object[]> lsParadas = queryParadas.list();
|
List<Object[]> lsParadas = queryParadas.list();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder("");
|
StringBuilder sb = new StringBuilder("");
|
||||||
|
@ -71,7 +100,7 @@ public class ConexionHibernateDAO extends GenericHibernateDAO<Conexion, Integer>
|
||||||
sb.append(" t2.origem.paradaId, ");
|
sb.append(" t2.origem.paradaId, ");
|
||||||
sb.append(" t2.destino.paradaId ");
|
sb.append(" t2.destino.paradaId ");
|
||||||
|
|
||||||
Map<String, Long> mapConexionCtrlId = new LinkedHashMap<String, Long>();
|
Map<String, Long> mapConexionCtrlId = new HashMap<String, Long>();
|
||||||
int grupo = 0;
|
int grupo = 0;
|
||||||
for (Object[] obj : lsParadas) {
|
for (Object[] obj : lsParadas) {
|
||||||
Integer origenId = (Integer) obj[0];
|
Integer origenId = (Integer) obj[0];
|
||||||
|
@ -89,7 +118,7 @@ public class ConexionHibernateDAO extends GenericHibernateDAO<Conexion, Integer>
|
||||||
Integer origen2 = (Integer) objConexion[2];
|
Integer origen2 = (Integer) objConexion[2];
|
||||||
Integer destino2 = (Integer) objConexion[3];
|
Integer destino2 = (Integer) objConexion[3];
|
||||||
|
|
||||||
String claveConexionCtrl = origen1 + "-" + destino2;
|
String claveConexionCtrl = origenId + "-" + destinoId;
|
||||||
|
|
||||||
Long conexionCtrlId = mapConexionCtrlId.get(claveConexionCtrl);
|
Long conexionCtrlId = mapConexionCtrlId.get(claveConexionCtrl);
|
||||||
|
|
||||||
|
@ -101,7 +130,7 @@ public class ConexionHibernateDAO extends GenericHibernateDAO<Conexion, Integer>
|
||||||
c.setFecmodif(new java.util.Date());
|
c.setFecmodif(new java.util.Date());
|
||||||
c.setUsuarioId(usuarioId);
|
c.setUsuarioId(usuarioId);
|
||||||
|
|
||||||
conexionCtrlId=(Long) this.getSession().save(c);
|
conexionCtrlId = (Long) this.getSession().save(c);
|
||||||
mapConexionCtrlId.put(claveConexionCtrl, conexionCtrlId);
|
mapConexionCtrlId.put(claveConexionCtrl, conexionCtrlId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -130,7 +159,19 @@ public class ConexionHibernateDAO extends GenericHibernateDAO<Conexion, Integer>
|
||||||
getSession().save(cTemp);
|
getSession().save(cTemp);
|
||||||
getSession().save(cTemp2);
|
getSession().save(cTemp2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.getSession().createQuery("DELETE Conexion").executeUpdate();
|
||||||
|
this.getSession().createQuery("DELETE ConexionCtrl").executeUpdate();
|
||||||
|
|
||||||
|
sb = new StringBuilder("");
|
||||||
|
sb.append("INSERT INTO ConexionCtrl (conexionctrlId,fecmodif,activo,usuarioId,origenId,destinoId) ");
|
||||||
|
sb.append("SELECT conexionctrlId,fecmodif,activo,usuarioId,origenId,destinoId from ConexionCtrlTemp )");
|
||||||
|
this.getSession().createQuery(sb.toString()).executeUpdate();
|
||||||
|
|
||||||
|
sb = new StringBuilder("");
|
||||||
|
sb.append("INSERT INTO Conexion (conexionId,numgrupo,numsecuencia,activo,fecmodif,usuarioId,origenId,destinoId,conexionctrlId) ");
|
||||||
|
sb.append("SELECT conexionId,numgrupo,numsecuencia,activo,fecmodif,usuarioId,origenId,destinoId,conexionctrlId from ConexionTemp )");
|
||||||
|
this.getSession().createQuery(sb.toString()).executeUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class Conexion implements Serializable {
|
||||||
@Column(name = "CONEXION_ID")
|
@Column(name = "CONEXION_ID")
|
||||||
private Long conexionId;
|
private Long conexionId;
|
||||||
@Column(name = "NUMGRUPO")
|
@Column(name = "NUMGRUPO")
|
||||||
private Short numgrupo;
|
private Integer numgrupo;
|
||||||
@Column(name = "NUMSECUENCIA")
|
@Column(name = "NUMSECUENCIA")
|
||||||
private Short numsecuencia;
|
private Short numsecuencia;
|
||||||
@Column(name = "ACTIVO")
|
@Column(name = "ACTIVO")
|
||||||
|
@ -43,15 +43,18 @@ public class Conexion implements Serializable {
|
||||||
private Date fecmodif;
|
private Date fecmodif;
|
||||||
@Column(name = "USUARIO_ID")
|
@Column(name = "USUARIO_ID")
|
||||||
private Integer usuarioId;
|
private Integer usuarioId;
|
||||||
@JoinColumn(name = "ORIGEN_ID", referencedColumnName = "PARADA_ID")
|
@Column(name = "ORIGEN_ID")
|
||||||
|
private Integer origenId;
|
||||||
|
@Column(name = "DESTINO_ID")
|
||||||
|
private Integer destinoId;
|
||||||
|
@Column(name = "CONEXIONCTRL_ID")
|
||||||
|
private Long conexionctrlId;
|
||||||
|
@JoinColumn(name = "ORIGEN_ID", referencedColumnName = "PARADA_ID",insertable=false,updatable=false)
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Parada origenId;
|
private Parada origen;
|
||||||
@JoinColumn(name = "DESTINO_ID", referencedColumnName = "PARADA_ID")
|
@JoinColumn(name = "DESTINO_ID", referencedColumnName = "PARADA_ID",insertable=false,updatable=false)
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Parada destinoId;
|
private Parada destino;
|
||||||
@JoinColumn(name = "CONEXIONCTRL_ID", referencedColumnName = "CONEXIONCTRL_ID")
|
|
||||||
@ManyToOne
|
|
||||||
private ConexionCtrl conexionctrlId;
|
|
||||||
|
|
||||||
public Conexion() {
|
public Conexion() {
|
||||||
}
|
}
|
||||||
|
@ -68,11 +71,11 @@ public class Conexion implements Serializable {
|
||||||
this.conexionId = conexionId;
|
this.conexionId = conexionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Short getNumgrupo() {
|
public Integer getNumgrupo() {
|
||||||
return numgrupo;
|
return numgrupo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumgrupo(Short numgrupo) {
|
public void setNumgrupo(Integer numgrupo) {
|
||||||
this.numgrupo = numgrupo;
|
this.numgrupo = numgrupo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,29 +111,6 @@ public class Conexion implements Serializable {
|
||||||
this.usuarioId = usuarioId;
|
this.usuarioId = usuarioId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Parada getOrigenId() {
|
|
||||||
return origenId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrigenId(Parada origenId) {
|
|
||||||
this.origenId = origenId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Parada getDestinoId() {
|
|
||||||
return destinoId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDestinoId(Parada destinoId) {
|
|
||||||
this.destinoId = destinoId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConexionCtrl getConexionctrlId() {
|
|
||||||
return conexionctrlId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConexionctrlId(ConexionCtrl conexionctrlId) {
|
|
||||||
this.conexionctrlId = conexionctrlId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -157,4 +137,28 @@ public class Conexion implements Serializable {
|
||||||
return "com.rjconsultores.entidad.Conexion[ conexionId=" + conexionId + " ]";
|
return "com.rjconsultores.entidad.Conexion[ conexionId=" + conexionId + " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getConexionctrlId() {
|
||||||
|
return conexionctrlId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConexionctrlId(Long conexionctrlId) {
|
||||||
|
this.conexionctrlId = conexionctrlId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrigenId() {
|
||||||
|
return origenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrigenId(Integer origenId) {
|
||||||
|
this.origenId = origenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDestinoId() {
|
||||||
|
return destinoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDestinoId(Integer destinoId) {
|
||||||
|
this.destinoId = destinoId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,19 +40,14 @@ public class ConexionCtrl implements Serializable {
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date fecmodif;
|
private Date fecmodif;
|
||||||
@Column(name = "ACTIVO")
|
@Column(name = "ACTIVO")
|
||||||
private Short activo;
|
private Boolean activo;
|
||||||
@Column(name = "USUARIO_ID")
|
@Column(name = "USUARIO_ID")
|
||||||
private Integer usuarioId;
|
private Integer usuarioId;
|
||||||
@JoinColumn(name = "ORIGEN_ID", referencedColumnName = "PARADA_ID")
|
@Column(name = "ORIGEN_ID")
|
||||||
@ManyToOne
|
private Integer origenId;
|
||||||
private Parada origenId;
|
@Column(name = "DESTINO_ID")
|
||||||
@JoinColumn(name = "DESTINO_ID", referencedColumnName = "PARADA_ID")
|
private Integer destinoId;
|
||||||
@ManyToOne
|
|
||||||
private Parada destinoId;
|
|
||||||
@OneToMany(mappedBy = "conexionctrlId")
|
|
||||||
private List<Conexion> conexionList;
|
|
||||||
@OneToMany(mappedBy = "conexionctrlId")
|
|
||||||
private List<ConexionTemp> conexionTempList;
|
|
||||||
|
|
||||||
public ConexionCtrl() {
|
public ConexionCtrl() {
|
||||||
}
|
}
|
||||||
|
@ -77,11 +72,11 @@ public class ConexionCtrl implements Serializable {
|
||||||
this.fecmodif = fecmodif;
|
this.fecmodif = fecmodif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Short getActivo() {
|
public Boolean getActivo() {
|
||||||
return activo;
|
return activo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivo(Short activo) {
|
public void setActivo(Boolean activo) {
|
||||||
this.activo = activo;
|
this.activo = activo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,39 +88,7 @@ public class ConexionCtrl implements Serializable {
|
||||||
this.usuarioId = usuarioId;
|
this.usuarioId = usuarioId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Parada getOrigenId() {
|
|
||||||
return origenId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrigenId(Parada origenId) {
|
|
||||||
this.origenId = origenId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Parada getDestinoId() {
|
|
||||||
return destinoId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDestinoId(Parada destinoId) {
|
|
||||||
this.destinoId = destinoId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlTransient
|
|
||||||
public List<Conexion> getConexionList() {
|
|
||||||
return conexionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConexionList(List<Conexion> conexionList) {
|
|
||||||
this.conexionList = conexionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlTransient
|
|
||||||
public List<ConexionTemp> getConexionTempList() {
|
|
||||||
return conexionTempList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConexionTempList(List<ConexionTemp> conexionTempList) {
|
|
||||||
this.conexionTempList = conexionTempList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -152,4 +115,20 @@ public class ConexionCtrl implements Serializable {
|
||||||
return "com.rjconsultores.entidad.ConexionCtrl[ conexionctrlId=" + conexionctrlId + " ]";
|
return "com.rjconsultores.entidad.ConexionCtrl[ conexionctrlId=" + conexionctrlId + " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getOrigenId() {
|
||||||
|
return origenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrigenId(Integer origenId) {
|
||||||
|
this.origenId = origenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDestinoId() {
|
||||||
|
return destinoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDestinoId(Integer destinoId) {
|
||||||
|
this.destinoId = destinoId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue