diff --git a/src/com/rjconsultores/ventaboletos/dao/ConexionConfDAO.java b/src/com/rjconsultores/ventaboletos/dao/ConexionConfDAO.java new file mode 100644 index 000000000..0fe4fb799 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/ConexionConfDAO.java @@ -0,0 +1,14 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.ConexionConf; +import com.rjconsultores.ventaboletos.entidad.ConexionCtrl; + +public interface ConexionConfDAO extends GenericDAO { + + public ConexionConf buscar(Long conexionCtrlId, Integer numgrupo); + + public List buscarPorConexionCtrl(ConexionCtrl conexionCtrl); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/ConexionCtrlDAO.java b/src/com/rjconsultores/ventaboletos/dao/ConexionCtrlDAO.java new file mode 100644 index 000000000..33706891a --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/ConexionCtrlDAO.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.ConexionCtrl; + +public interface ConexionCtrlDAO extends GenericDAO { + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/ConexionDAO.java b/src/com/rjconsultores/ventaboletos/dao/ConexionDAO.java index 7d5fb5e9f..ca3d5695f 100644 --- a/src/com/rjconsultores/ventaboletos/dao/ConexionDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/ConexionDAO.java @@ -2,15 +2,19 @@ package com.rjconsultores.ventaboletos.dao; import java.util.List; +import com.rjconsultores.ventaboletos.entidad.Conexion; import com.rjconsultores.ventaboletos.vo.conexion.ConexionVO; -public interface ConexionDAO { - +public interface ConexionDAO extends GenericDAO { + /** * Apaga os dados temporários das tabelas de conexion_temp e conexion_ctrl_temp - * @param usuarioId TODO + * + * @param usuarioId */ public void generarConexiones(Integer usuarioId); - public List buscarConexiones(Integer origenId,Integer destinoId); + public List buscarConexiones(Integer origenId, Integer destinoId); + + public List buscarPorConexionCtrl(Long conexcionCtrlId); } diff --git a/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java b/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java index 12b304db4..6965df321 100644 --- a/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/EmpresaDAO.java @@ -7,7 +7,6 @@ package com.rjconsultores.ventaboletos.dao; import java.util.List; import com.rjconsultores.ventaboletos.entidad.Empresa; -import com.rjconsultores.ventaboletos.entidad.Estado; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; /** diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionConfHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionConfHibernateDAO.java new file mode 100644 index 000000000..d11e27302 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionConfHibernateDAO.java @@ -0,0 +1,53 @@ +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.ConexionConfDAO; +import com.rjconsultores.ventaboletos.entidad.ConexionConf; +import com.rjconsultores.ventaboletos.entidad.ConexionCtrl; + +@Repository("conexionConfDAO") +public class ConexionConfHibernateDAO extends GenericHibernateDAO + implements ConexionConfDAO { + + @Autowired + public ConexionConfHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return c.list(); + } + + @Override + public ConexionConf buscar(Long conexionCtrlId, Integer numgrupo) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("grupo", numgrupo)); + + Criteria ctrl = c.createCriteria("conexionCtrl"); + ctrl.add(Restrictions.eq("conexionctrlId", conexionCtrlId)); + + return (ConexionConf) c.uniqueResult(); + } + + @Override + public List buscarPorConexionCtrl(ConexionCtrl conexionCtrl) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("conexionCtrl", conexionCtrl)); + + return c.list(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionCtrlHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionCtrlHibernateDAO.java new file mode 100644 index 000000000..9a8815cf5 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionCtrlHibernateDAO.java @@ -0,0 +1,19 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import com.rjconsultores.ventaboletos.dao.ConexionCtrlDAO; +import com.rjconsultores.ventaboletos.entidad.ConexionCtrl; + +@Repository("conexionCtrlDAO") +public class ConexionCtrlHibernateDAO extends GenericHibernateDAO + implements ConexionCtrlDAO { + + @Autowired + public ConexionCtrlHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionHibernateDAO.java index 2af7d2bd1..adab2bff6 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionHibernateDAO.java @@ -4,9 +4,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; +import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.SessionFactory; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.hibernate.transform.AliasToBeanResultTransformer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -19,8 +21,8 @@ import com.rjconsultores.ventaboletos.entidad.ConexionTemp; import com.rjconsultores.ventaboletos.vo.conexion.ConexionVO; @Repository("conexionDAO") -public class ConexionHibernateDAO extends GenericHibernateDAO implements ConexionDAO { - private static Logger log = Logger.getLogger(ConexionHibernateDAO.class); +public class ConexionHibernateDAO extends GenericHibernateDAO + implements ConexionDAO { @Autowired public ConexionHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { @@ -30,25 +32,26 @@ public class ConexionHibernateDAO extends GenericHibernateDAO @Override public List 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 "); - if (origenId != null){ - sb.append(" and cc.origenId = ").append(origenId); + sb.append(" select cc.conexionctrlId as conexionCtrlId, 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(" c.activo=1 "); + sb.append(" and 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 "); + if (origenId != null) { + sb.append(" and cc.origenId = ").append(origenId); } - if (destinoId != null){ - sb.append(" and cc.destinoId = ").append(destinoId); + if (destinoId != null) { + sb.append(" and cc.destinoId = ").append(destinoId); } sb.append(" "); sb.append(" "); @@ -58,7 +61,6 @@ public class ConexionHibernateDAO extends GenericHibernateDAO query.setResultTransformer(new AliasToBeanResultTransformer(ConexionVO.class)); return query.list(); - } @Override @@ -107,8 +109,8 @@ public class ConexionHibernateDAO extends GenericHibernateDAO sb.append(" t2.destino.paradaId "); Map mapConexionCtrlId = new HashMap(); - int grupo = 0; for (Object[] obj : lsParadas) { + int grupo = 0; Integer origenId = (Integer) obj[0]; Integer destinoId = (Integer) obj[1]; @@ -138,7 +140,6 @@ public class ConexionHibernateDAO extends GenericHibernateDAO conexionCtrlId = (Long) this.getSession().save(c); mapConexionCtrlId.put(claveConexionCtrl, conexionCtrlId); - } grupo++; @@ -167,17 +168,52 @@ public class ConexionHibernateDAO extends GenericHibernateDAO } } - this.getSession().createQuery("DELETE Conexion").executeUpdate(); - this.getSession().createQuery("DELETE ConexionCtrl").executeUpdate(); + // deletando, exceto conexoes que foram criadas manualmente: + this.getSession().createQuery("DELETE Conexion c WHERE c.conexionctrlId NOT IN (SELECT cc.conexionCtrl.conexionctrlId FROM ConexionConf cc)").executeUpdate(); + this.getSession().createQuery("DELETE ConexionCtrl cct WHERE cct.conexionctrlId NOT IN (SELECT cc.conexionCtrl.conexionctrlId FROM ConexionConf cc)").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 )"); + sb.append(" INSERT INTO ConexionCtrl (conexionctrlId,fecmodif,activo,usuarioId,origenId,destinoId) "); + sb.append(" SELECT cct.conexionctrlId, "); + sb.append(" cct.fecmodif, "); + sb.append(" cct.activo, "); + sb.append(" cct.usuarioId, "); + sb.append(" cct.origenId, "); + sb.append(" cct.destinoId "); + sb.append(" FROM ConexionCtrlTemp cct "); + sb.append(" WHERE cct.origenId || '_' || cct.destinoId NOT IN "); + sb.append(" ( SELECT cc.origenId || '_' || cc.destinoId "); + sb.append(" FROM ConexionCtrl cc "); + sb.append(" WHERE cc.activo = 1) "); 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 )"); + sb.append(" INSERT INTO Conexion (conexionId,numgrupo,numsecuencia,activo,fecmodif,usuarioId,origenId,destinoId,conexionctrlId) "); + sb.append(" SELECT ct.conexionId, "); + sb.append(" ct.numgrupo, "); + sb.append(" ct.numsecuencia, "); + sb.append(" ct.activo, "); + sb.append(" ct.fecmodif, "); + sb.append(" ct.usuarioId, "); + sb.append(" ct.origenId, "); + sb.append(" ct.destinoId, "); + sb.append(" ct.conexionctrlId "); + sb.append(" FROM ConexionTemp ct "); + sb.append(" WHERE ct.origenId || '_' || ct.destinoId NOT IN "); + sb.append(" ( SELECT c.origenId || '_' || c.destinoId "); + sb.append(" FROM Conexion c "); + sb.append(" WHERE c.activo = 1) "); this.getSession().createQuery(sb.toString()).executeUpdate(); } + + @Override + public List buscarPorConexionCtrl(Long conexionCtrlId) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("conexionctrlId", conexionCtrlId)); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.addOrder(Order.asc("numgrupo")); + c.addOrder(Order.asc("numsecuencia")); + + return c.list(); + } } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java index f98bfae7e..7e4372087 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java @@ -18,7 +18,6 @@ import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.EmpresaDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; -import com.rjconsultores.ventaboletos.entidad.Estado; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; /** diff --git a/src/com/rjconsultores/ventaboletos/entidad/Conexion.java b/src/com/rjconsultores/ventaboletos/entidad/Conexion.java index 75442807b..ef1d3e971 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Conexion.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Conexion.java @@ -10,9 +10,10 @@ import java.util.Date; import javax.persistence.Basic; 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; import javax.persistence.Temporal; import javax.persistence.TemporalType; @@ -22,11 +23,13 @@ import javax.persistence.TemporalType; * @author gleimar */ @Entity +@SequenceGenerator(name = "CONEXION_SEQ", sequenceName = "CONEXION_SEQ", allocationSize = 1) @Table(name = "CONEXION") public class Conexion implements Serializable { private static final long serialVersionUID = 1L; @Id @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "CONEXION_SEQ") @Column(name = "CONEXION_ID") private Long conexionId; @Column(name = "NUMGRUPO") @@ -46,12 +49,6 @@ public class Conexion implements Serializable { private Integer destinoId; @Column(name = "CONEXIONCTRL_ID") private Long conexionctrlId; - @JoinColumn(name = "ORIGEN_ID", referencedColumnName = "PARADA_ID", insertable = false, updatable = false) - @ManyToOne - private Parada origen; - @JoinColumn(name = "DESTINO_ID", referencedColumnName = "PARADA_ID", insertable = false, updatable = false) - @ManyToOne - private Parada destino; public Conexion() { } @@ -117,7 +114,6 @@ public class Conexion implements Serializable { @Override public boolean equals(Object object) { - // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Conexion)) { return false; } diff --git a/src/com/rjconsultores/ventaboletos/entidad/ConexionConf.java b/src/com/rjconsultores/ventaboletos/entidad/ConexionConf.java new file mode 100644 index 000000000..3365812fb --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/ConexionConf.java @@ -0,0 +1,163 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +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; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@SequenceGenerator(name = "CONEXION_CONF_SEQ", sequenceName = "CONEXION_CONF_SEQ", allocationSize = 1) +@Table(name = "CONEXION_CONF") +public class ConexionConf implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @Column(name = "CONEXIONCONF_ID") + @GeneratedValue(strategy = GenerationType.AUTO, generator = "CONEXION_CONF_SEQ") + private Long conexionConfId; + @ManyToOne + @JoinColumn(name = "CONEXIONCTRL_ID", referencedColumnName = "CONEXIONCTRL_ID") + private ConexionCtrl conexionCtrl; + @Column(name = "GRUPO") + private Integer grupo; + @Column(name = "PORSEC1") + private BigDecimal porSec1; + @Column(name = "PORSEC2") + private BigDecimal porSec2; + @Column(name = "TIEMPOMIN") + private Integer tiempoMin; + @Column(name = "TIEMPOMAX") + private Integer tiempoMax; + @Column(name = "INDDISPONIBLE") + private Boolean indisponible; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public Long getConexionConfId() { + return conexionConfId; + } + + public void setConexionConfId(Long conexionConfId) { + this.conexionConfId = conexionConfId; + } + + public ConexionCtrl getConexionCtrl() { + return conexionCtrl; + } + + public void setConexionCtrl(ConexionCtrl conexionCtrl) { + this.conexionCtrl = conexionCtrl; + } + + public Integer getGrupo() { + return grupo; + } + + public void setGrupo(Integer grupo) { + this.grupo = grupo; + } + + public BigDecimal getPorSec1() { + return porSec1; + } + + public void setPorSec1(BigDecimal porSec1) { + this.porSec1 = porSec1; + } + + public BigDecimal getPorSec2() { + return porSec2; + } + + public void setPorSec2(BigDecimal porSec2) { + this.porSec2 = porSec2; + } + + public Integer getTiempoMin() { + return tiempoMin; + } + + public void setTiempoMin(Integer tiempoMin) { + this.tiempoMin = tiempoMin; + } + + public Integer getTiempoMax() { + return tiempoMax; + } + + public void setTiempoMax(Integer tiempoMax) { + this.tiempoMax = tiempoMax; + } + + public Boolean getIndisponible() { + return indisponible; + } + + public void setIndisponible(Boolean indisponible) { + this.indisponible = indisponible; + } + + 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; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((conexionConfId == null) ? 0 : conexionConfId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ConexionConf other = (ConexionConf) obj; + if (conexionConfId == null) { + if (other.conexionConfId != null) + return false; + } else if (!conexionConfId.equals(other.conexionConfId)) + return false; + return true; + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrl.java b/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrl.java index ef3270df4..0c2fc0132 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrl.java +++ b/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrl.java @@ -9,100 +9,101 @@ 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.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** - * + * * @author gleimar */ @Entity +@SequenceGenerator(name = "CONEXION_CTRL_SEQ", sequenceName = "CONEXION_CTRL_SEQ", allocationSize = 1) @Table(name = "CONEXION_CTRL") public class ConexionCtrl implements Serializable { - private static final long serialVersionUID = 1L; - @Id - @Column(name = "CONEXIONCTRL_ID") - private Long conexionctrlId; - @Column(name = "FECMODIF") - @Temporal(TemporalType.TIMESTAMP) - private Date fecmodif; - @Column(name = "ACTIVO") - private Boolean activo; - @Column(name = "USUARIO_ID") - private Integer usuarioId; - @Column(name = "ORIGEN_ID") - private Integer origenId; - @Column(name = "DESTINO_ID") - private Integer destinoId; - + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "CONEXION_CTRL_SEQ") + @Column(name = "CONEXIONCTRL_ID") + private Long conexionctrlId; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @Column(name = "ORIGEN_ID") + private Integer origenId; + @Column(name = "DESTINO_ID") + private Integer destinoId; - public ConexionCtrl() { - } + public ConexionCtrl() { + } - public ConexionCtrl(Long conexionctrlId) { - this.conexionctrlId = conexionctrlId; - } + public ConexionCtrl(Long conexionctrlId) { + this.conexionctrlId = conexionctrlId; + } - public Long getConexionctrlId() { - return conexionctrlId; - } + public Long getConexionctrlId() { + return conexionctrlId; + } - public void setConexionctrlId(Long conexionctrlId) { - this.conexionctrlId = conexionctrlId; - } + public void setConexionctrlId(Long conexionctrlId) { + this.conexionctrlId = conexionctrlId; + } - public Date getFecmodif() { - return fecmodif; - } + public Date getFecmodif() { + return fecmodif; + } - public void setFecmodif(Date fecmodif) { - this.fecmodif = fecmodif; - } + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } - public Boolean getActivo() { - return activo; - } + public Boolean getActivo() { + return activo; + } - public void setActivo(Boolean activo) { - this.activo = activo; - } + public void setActivo(Boolean activo) { + this.activo = activo; + } - public Integer getUsuarioId() { - return usuarioId; - } + public Integer getUsuarioId() { + return usuarioId; + } - public void setUsuarioId(Integer usuarioId) { - this.usuarioId = usuarioId; - } - - + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } - @Override - public int hashCode() { - int hash = 0; - hash += (conexionctrlId != null ? conexionctrlId.hashCode() : 0); - return hash; - } + @Override + public int hashCode() { + int hash = 0; + hash += (conexionctrlId != null ? conexionctrlId.hashCode() : 0); + return hash; + } - @Override - public boolean equals(Object object) { - // TODO: Warning - this method won't work in the case the id fields are not set - if (!(object instanceof ConexionCtrl)) { - return false; - } - ConexionCtrl other = (ConexionCtrl) object; - if ((this.conexionctrlId == null && other.conexionctrlId != null) || (this.conexionctrlId != null && !this.conexionctrlId.equals(other.conexionctrlId))) { - return false; - } - return true; - } + @Override + public boolean equals(Object object) { + if (!(object instanceof ConexionCtrl)) { + return false; + } + ConexionCtrl other = (ConexionCtrl) object; + if ((this.conexionctrlId == null && other.conexionctrlId != null) || (this.conexionctrlId != null && !this.conexionctrlId.equals(other.conexionctrlId))) { + return false; + } + return true; + } - @Override - public String toString() { - return "com.rjconsultores.entidad.ConexionCtrl[ conexionctrlId=" + conexionctrlId + " ]"; - } + @Override + public String toString() { + return "com.rjconsultores.entidad.ConexionCtrl[ conexionctrlId=" + conexionctrlId + " ]"; + } public Integer getOrigenId() { return origenId; @@ -119,5 +120,4 @@ public class ConexionCtrl implements Serializable { public void setDestinoId(Integer destinoId) { this.destinoId = destinoId; } - } diff --git a/src/com/rjconsultores/ventaboletos/service/CategoriaService.java b/src/com/rjconsultores/ventaboletos/service/CategoriaService.java index c2be7a5c9..1a5d28485 100644 --- a/src/com/rjconsultores/ventaboletos/service/CategoriaService.java +++ b/src/com/rjconsultores/ventaboletos/service/CategoriaService.java @@ -4,24 +4,22 @@ */ package com.rjconsultores.ventaboletos.service; -import com.rjconsultores.ventaboletos.entidad.Categoria; -import com.rjconsultores.ventaboletos.entidad.CategoriaTipoPtoVta; -import com.rjconsultores.ventaboletos.entidad.TipoPuntoVenta; import java.util.List; +import com.rjconsultores.ventaboletos.entidad.Categoria; + /** - * + * * @author Administrador */ public interface CategoriaService extends GenericService { - public List buscar(String desccategoria); - /** - * Hance una búsqueda de todas las categorias que son visibles al usuario - * Ejemplo de categorias que no son vis - * @return - */ - public List obtenerTodasCategoriasVisibles(); + public List buscar(String desccategoria); - + /** + * Hance una búsqueda de todas las categorias que son visibles al usuario Ejemplo de categorias que no son vis + * + * @return + */ + public List obtenerTodasCategoriasVisibles(); } diff --git a/src/com/rjconsultores/ventaboletos/service/ConexionConfService.java b/src/com/rjconsultores/ventaboletos/service/ConexionConfService.java new file mode 100644 index 000000000..5d48b7f87 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/ConexionConfService.java @@ -0,0 +1,13 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.ConexionConf; +import com.rjconsultores.ventaboletos.entidad.ConexionCtrl; + +public interface ConexionConfService extends GenericService { + + public ConexionConf buscar(Long conexionCtrlId, Integer numgrupo); + + public List buscarPorConexionCtrl(ConexionCtrl entidad); +} diff --git a/src/com/rjconsultores/ventaboletos/service/ConexionCtrlService.java b/src/com/rjconsultores/ventaboletos/service/ConexionCtrlService.java new file mode 100644 index 000000000..9da4bdd5f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/ConexionCtrlService.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.ConexionCtrl; + +public interface ConexionCtrlService extends GenericService { + +} diff --git a/src/com/rjconsultores/ventaboletos/service/ConexionService.java b/src/com/rjconsultores/ventaboletos/service/ConexionService.java index 151a1b708..7e2fa91f8 100644 --- a/src/com/rjconsultores/ventaboletos/service/ConexionService.java +++ b/src/com/rjconsultores/ventaboletos/service/ConexionService.java @@ -2,16 +2,24 @@ package com.rjconsultores.ventaboletos.service; import java.util.List; +import com.rjconsultores.ventaboletos.entidad.Conexion; import com.rjconsultores.ventaboletos.vo.conexion.ConexionVO; public interface ConexionService { - - + /** * Gera as conexões possíveis para os tramos do sistema * */ public void gerarConexiones(); - public List buscarConexiones(Integer origenId,Integer destinoId); + public List buscarConexiones(Integer origenId, Integer destinoId); + + public Conexion suscribir(Conexion conexion); + + public Conexion actualizacion(Conexion conexion); + + public void borrar(Conexion conexion); + + public List buscarPorConexionCtrl(Long conexcionCtrlId); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ClienteDireccionServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ClienteDireccionServiceImpl.java index 6f6beb3d7..695d41fc0 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/ClienteDireccionServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/ClienteDireccionServiceImpl.java @@ -7,64 +7,57 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.rjconsultores.ventaboletos.dao.ClienteDAO; import com.rjconsultores.ventaboletos.dao.ClienteDireccionDAO; -import com.rjconsultores.ventaboletos.entidad.Cliente; import com.rjconsultores.ventaboletos.entidad.ClienteDireccion; import com.rjconsultores.ventaboletos.service.ClienteDireccionService; -import com.rjconsultores.ventaboletos.service.ClienteService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; /** -* -* @author Desenvolvimento -*/ + * + * @author Desenvolvimento + */ @Service("clienteDireccionService") -public class ClienteDireccionServiceImpl implements ClienteDireccionService{ +public class ClienteDireccionServiceImpl implements ClienteDireccionService { - @Autowired - private ClienteDireccionDAO clienteDAO; + @Autowired + private ClienteDireccionDAO clienteDAO; - public List obtenerTodos() { - return clienteDAO.obtenerTodos(); - } + public List obtenerTodos() { + return clienteDAO.obtenerTodos(); + } - public ClienteDireccion obtenerID(Integer id) { - return clienteDAO.obtenerID(id); - } + public ClienteDireccion obtenerID(Integer id) { + return clienteDAO.obtenerID(id); + } - @Transactional - public ClienteDireccion suscribir(ClienteDireccion entidad) { - entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.setFecmodif(Calendar.getInstance().getTime()); - entidad.setActivo(Boolean.TRUE); + @Transactional + public ClienteDireccion suscribir(ClienteDireccion entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); - return clienteDAO.suscribir(entidad); - } + return clienteDAO.suscribir(entidad); + } - @Transactional - public ClienteDireccion actualizacion(ClienteDireccion entidad) { - entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.setFecmodif(Calendar.getInstance().getTime()); - entidad.setActivo(Boolean.TRUE); + @Transactional + public ClienteDireccion actualizacion(ClienteDireccion entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); - return clienteDAO.actualizacion(entidad); - } + return clienteDAO.actualizacion(entidad); + } - - @Transactional - public void borrar(ClienteDireccion entidad) { - entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - entidad.setFecmodif(Calendar.getInstance().getTime()); - entidad.setActivo(Boolean.FALSE); + @Transactional + public void borrar(ClienteDireccion entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); - clienteDAO.actualizacion(entidad); - } - - - public List buscar(Integer clienteId) { - return clienteDAO.buscar(clienteId); - } + clienteDAO.actualizacion(entidad); + } - + public List buscar(Integer clienteId) { + return clienteDAO.buscar(clienteId); + } } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ConexionConfServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ConexionConfServiceImpl.java new file mode 100644 index 000000000..6aa26bba3 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/ConexionConfServiceImpl.java @@ -0,0 +1,65 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Calendar; +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.ConexionConfDAO; +import com.rjconsultores.ventaboletos.entidad.ConexionConf; +import com.rjconsultores.ventaboletos.entidad.ConexionCtrl; +import com.rjconsultores.ventaboletos.service.ConexionConfService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("conexionConfService") +public class ConexionConfServiceImpl implements ConexionConfService { + @Autowired + private ConexionConfDAO conexionConfDAO; + + public List obtenerTodos() { + return conexionConfDAO.obtenerTodos(); + } + + public ConexionConf obtenerID(Long id) { + return conexionConfDAO.obtenerID(id); + } + + @Transactional + public ConexionConf suscribir(ConexionConf entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return conexionConfDAO.suscribir(entidad); + } + + @Transactional + public ConexionConf actualizacion(ConexionConf entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return conexionConfDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(ConexionConf entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + conexionConfDAO.actualizacion(entidad); + } + + @Override + public ConexionConf buscar(Long conexionCtrlId, Integer numgrupo) { + return conexionConfDAO.buscar(conexionCtrlId, numgrupo); + } + + @Override + public List buscarPorConexionCtrl(ConexionCtrl entidad) { + return conexionConfDAO.buscarPorConexionCtrl(entidad); + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ConexionCtrlServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ConexionCtrlServiceImpl.java new file mode 100644 index 000000000..27dc00e18 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/ConexionCtrlServiceImpl.java @@ -0,0 +1,72 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Calendar; +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.ConexionCtrlDAO; +import com.rjconsultores.ventaboletos.entidad.Conexion; +import com.rjconsultores.ventaboletos.entidad.ConexionConf; +import com.rjconsultores.ventaboletos.entidad.ConexionCtrl; +import com.rjconsultores.ventaboletos.service.ConexionConfService; +import com.rjconsultores.ventaboletos.service.ConexionCtrlService; +import com.rjconsultores.ventaboletos.service.ConexionService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("conexionCtrlService") +public class ConexionCtrlServiceImpl implements ConexionCtrlService { + @Autowired + private ConexionCtrlDAO conexionCtrlDAO; + @Autowired + private ConexionService conexionDAO; + @Autowired + private ConexionConfService conexionConfDAO; + + public List obtenerTodos() { + return conexionCtrlDAO.obtenerTodos(); + } + + public ConexionCtrl obtenerID(Long id) { + return conexionCtrlDAO.obtenerID(id); + } + + @Transactional + public ConexionCtrl suscribir(ConexionCtrl entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return conexionCtrlDAO.suscribir(entidad); + } + + @Transactional + public ConexionCtrl actualizacion(ConexionCtrl entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return conexionCtrlDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(ConexionCtrl entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + List lsConexion = conexionDAO.buscarPorConexionCtrl(entidad.getConexionctrlId()); + for (Conexion conexion : lsConexion) { + conexionDAO.borrar(conexion); + } + + List lsConexionConf = conexionConfDAO.buscarPorConexionCtrl(entidad); + for (ConexionConf conexionConf : lsConexionConf) { + conexionConfDAO.borrar(conexionConf); + } + + conexionCtrlDAO.actualizacion(entidad); + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ConexionServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ConexionServiceImpl.java index ac7d87845..15691de3a 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/ConexionServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/ConexionServiceImpl.java @@ -1,5 +1,6 @@ package com.rjconsultores.ventaboletos.service.impl; +import java.util.Calendar; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -7,6 +8,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.rjconsultores.ventaboletos.dao.ConexionDAO; +import com.rjconsultores.ventaboletos.entidad.Conexion; import com.rjconsultores.ventaboletos.service.ConexionService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.vo.conexion.ConexionVO; @@ -27,4 +29,39 @@ public class ConexionServiceImpl implements ConexionService { public List buscarConexiones(Integer origenId, Integer destinoId) { return conexionDAO.buscarConexiones(origenId, destinoId); } + + @Override + @Transactional + public Conexion suscribir(Conexion conexion) { + conexion.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + conexion.setFecmodif(Calendar.getInstance().getTime()); + conexion.setActivo(Boolean.TRUE); + + return conexionDAO.suscribir(conexion); + } + + @Override + @Transactional + public Conexion actualizacion(Conexion conexion) { + conexion.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + conexion.setFecmodif(Calendar.getInstance().getTime()); + conexion.setActivo(Boolean.TRUE); + + return conexionDAO.actualizacion(conexion); + } + + @Override + public List buscarPorConexionCtrl(Long conexcionCtrlId) { + return conexionDAO.buscarPorConexionCtrl(conexcionCtrlId); + } + + @Override + @Transactional + public void borrar(Conexion conexion) { + conexion.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + conexion.setFecmodif(Calendar.getInstance().getTime()); + conexion.setActivo(Boolean.FALSE); + + conexionDAO.actualizacion(conexion); + } } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ParadaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ParadaServiceImpl.java index 60d574671..79766cbd6 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/ParadaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/ParadaServiceImpl.java @@ -4,6 +4,14 @@ */ package com.rjconsultores.ventaboletos.service.impl; +import java.util.Calendar; +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.rjconsultores.ventaboletos.dao.ParadaDAO; import com.rjconsultores.ventaboletos.dao.TramoDAO; import com.rjconsultores.ventaboletos.entidad.Ciudad; @@ -14,17 +22,6 @@ import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.service.ParadaService; import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.Predicate; -import org.apache.commons.lang.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.zkoss.util.resource.Labels; -import org.zkoss.zul.Messagebox; /** * diff --git a/src/com/rjconsultores/ventaboletos/vo/conexion/ConexionVO.java b/src/com/rjconsultores/ventaboletos/vo/conexion/ConexionVO.java index a0b7260c7..8e1694bbb 100644 --- a/src/com/rjconsultores/ventaboletos/vo/conexion/ConexionVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/conexion/ConexionVO.java @@ -6,35 +6,53 @@ public class ConexionVO { private Integer grupo; private String tramoOrigen; private String tramoDestino; + private Long conexionCtrlId; + public String getConOrigen() { return conOrigen; } + public void setConOrigen(String conOrigen) { this.conOrigen = conOrigen; } + public String getConDestino() { return conDestino; } + public void setConDestino(String conDestino) { this.conDestino = conDestino; } + public Integer getGrupo() { return grupo; } + public void setGrupo(Integer grupo) { this.grupo = grupo; } + public String getTramoOrigen() { return tramoOrigen; } + public void setTramoOrigen(String tramoOrigen) { this.tramoOrigen = tramoOrigen; } + public String getTramoDestino() { return tramoDestino; } + public void setTramoDestino(String tramoDestino) { this.tramoDestino = tramoDestino; } - + + public Long getConexionCtrlId() { + return conexionCtrlId; + } + + public void setConexionCtrlId(Long conexionCtrlId) { + this.conexionCtrlId = conexionCtrlId; + } }