From 9f3cdd58c66d4985dbd7c72c57c22ac80f120b91 Mon Sep 17 00:00:00 2001 From: gleimar Date: Wed, 5 Sep 2012 22:00:48 +0000 Subject: [PATCH] git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@21087 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/ConexionDAO.java | 11 ++ .../dao/hibernate/ConexionHibernateDAO.java | 134 +++++++++++++++ .../ventaboletos/entidad/Conexion.java | 160 +++++++++++++++++ .../ventaboletos/entidad/ConexionCtrl.java | 155 +++++++++++++++++ .../entidad/ConexionCtrlTemp.java | 131 ++++++++++++++ .../ventaboletos/entidad/ConexionTemp.java | 161 ++++++++++++++++++ .../ventaboletos/entidad/ParamConexion.java | 133 +++++++++++++++ .../ventaboletos/service/ConexionService.java | 12 ++ .../service/impl/ConexionServiceImpl.java | 23 +++ 9 files changed, 920 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/ConexionDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/Conexion.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/ConexionCtrl.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/ConexionCtrlTemp.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/ConexionTemp.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/ParamConexion.java create mode 100644 src/com/rjconsultores/ventaboletos/service/ConexionService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/ConexionServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/ConexionDAO.java b/src/com/rjconsultores/ventaboletos/dao/ConexionDAO.java new file mode 100644 index 000000000..f4613a5fa --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/ConexionDAO.java @@ -0,0 +1,11 @@ +package com.rjconsultores.ventaboletos.dao; + +public interface ConexionDAO { + + /** + * Apaga os dados temporários das tabelas de conexion_temp e conexion_ctrl_temp + * @param usuarioId TODO + */ + public void generarConexiones(Integer usuarioId); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionHibernateDAO.java new file mode 100644 index 000000000..20b81ffed --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConexionHibernateDAO.java @@ -0,0 +1,134 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.hibernate.Query; +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.ConexionDAO; +import com.rjconsultores.ventaboletos.entidad.Conexion; +import com.rjconsultores.ventaboletos.entidad.ConexionCtrlTemp; +import com.rjconsultores.ventaboletos.entidad.ConexionTemp; + +@Repository("conexionDAO") +public class ConexionHibernateDAO extends GenericHibernateDAO implements ConexionDAO { + private static Logger log = Logger.getLogger(ConexionHibernateDAO.class); + + @Autowired + public ConexionHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + + @Override + public void generarConexiones(Integer usuarioId) { + this.getSession().createQuery("DELETE ConexionTemp"); + this.getSession().createQuery("DELETE ConexionCtrlTemp"); + + Query queryParadas = this.getSession().createQuery("select t.origem.paradaId,t.destino.paradaId from Tramo t where t.activo = 1 order by t.origem.paradaId "); + List lsParadas = queryParadas.list(); + + StringBuilder sb = new StringBuilder(""); + sb.append("SELECT "); + sb.append(" t.origem.paradaId, "); + sb.append(" t.destino.paradaId, "); + sb.append(" t2.origem.paradaId, "); + sb.append(" t2.destino.paradaId, "); + sb.append(" MAX(t.kmReal), "); + sb.append(" MAX(tcs.tiemporecorrido), "); + sb.append(" MAX(t2.kmReal), "); + sb.append(" MAX(tcs2.tiemporecorrido) "); + sb.append(" "); + sb.append("FROM "); + sb.append(" Tramo t, "); + sb.append(" Tramo t2, "); + sb.append(" TramoServicio tcs, "); + sb.append(" TramoServicio tcs2 "); + sb.append(" "); + sb.append("where "); + sb.append(" t.origem.paradaId = :origen "); + sb.append(" and t.activo=1 "); + sb.append(" "); + sb.append(" and t2.destino.paradaId = :destino "); + sb.append(" and t2.activo=1 "); + sb.append(" and t2.origem= t.destino "); + sb.append(" "); + sb.append(" and tcs.tramo=t "); + sb.append(" and tcs.activo=1 "); + sb.append(" "); + sb.append(" and tcs2.tramo=t2 "); + sb.append(" and tcs2.activo=1 "); + sb.append(" "); + sb.append("group by "); + sb.append(" t.origem.paradaId, "); + sb.append(" t.destino.paradaId, "); + sb.append(" t2.origem.paradaId, "); + sb.append(" t2.destino.paradaId "); + + Map mapConexionCtrlId = new LinkedHashMap(); + int grupo = 0; + for (Object[] obj : lsParadas) { + Integer origenId = (Integer) obj[0]; + Integer destinoId = (Integer) obj[1]; + + Query query = getSession().createQuery(sb.toString()); + query.setParameter("origen", origenId); + query.setParameter("destino", destinoId); + + List list = query.list(); + + for (Object[] objConexion : list) { + Integer origen1 = (Integer) objConexion[0]; + Integer destino1 = (Integer) objConexion[1]; + Integer origen2 = (Integer) objConexion[2]; + Integer destino2 = (Integer) objConexion[3]; + + String claveConexionCtrl = origen1 + "-" + destino2; + + Long conexionCtrlId = mapConexionCtrlId.get(claveConexionCtrl); + + if (conexionCtrlId == null) { + ConexionCtrlTemp c = new ConexionCtrlTemp(); + c.setActivo(true); + c.setOrigenId(origen1); + c.setDestinoId(destino2); + c.setFecmodif(new java.util.Date()); + c.setUsuarioId(usuarioId); + + conexionCtrlId=(Long) this.getSession().save(c); + mapConexionCtrlId.put(claveConexionCtrl, conexionCtrlId); + + } + grupo++; + + ConexionTemp cTemp = new ConexionTemp(); + cTemp.setActivo(true); + cTemp.setConexionctrlId(conexionCtrlId); + cTemp.setOrigenId(origen1); + cTemp.setDestinoId(destino1); + cTemp.setNumgrupo(grupo); + cTemp.setNumsecuencia((short) 1); + cTemp.setUsuarioId(usuarioId); + + ConexionTemp cTemp2 = new ConexionTemp(); + cTemp2.setActivo(true); + cTemp2.setConexionctrlId(conexionCtrlId); + cTemp2.setOrigenId(origen2); + cTemp2.setDestinoId(destino2); + cTemp2.setNumgrupo(grupo); + cTemp2.setNumsecuencia((short) 2); + cTemp2.setUsuarioId(usuarioId); + + getSession().save(cTemp); + getSession().save(cTemp2); + } + + } + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/Conexion.java b/src/com/rjconsultores/ventaboletos/entidad/Conexion.java new file mode 100644 index 000000000..b665144fb --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/Conexion.java @@ -0,0 +1,160 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +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; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author gleimar + */ +@Entity +@Table(name = "CONEXION") +public class Conexion implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @Column(name = "CONEXION_ID") + private Long conexionId; + @Column(name = "NUMGRUPO") + private Short numgrupo; + @Column(name = "NUMSECUENCIA") + private Short numsecuencia; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @JoinColumn(name = "ORIGEN_ID", referencedColumnName = "PARADA_ID") + @ManyToOne + private Parada origenId; + @JoinColumn(name = "DESTINO_ID", referencedColumnName = "PARADA_ID") + @ManyToOne + private Parada destinoId; + @JoinColumn(name = "CONEXIONCTRL_ID", referencedColumnName = "CONEXIONCTRL_ID") + @ManyToOne + private ConexionCtrl conexionctrlId; + + public Conexion() { + } + + public Conexion(Long conexionId) { + this.conexionId = conexionId; + } + + public Long getConexionId() { + return conexionId; + } + + public void setConexionId(Long conexionId) { + this.conexionId = conexionId; + } + + public Short getNumgrupo() { + return numgrupo; + } + + public void setNumgrupo(Short numgrupo) { + this.numgrupo = numgrupo; + } + + public Short getNumsecuencia() { + return numsecuencia; + } + + public void setNumsecuencia(Short numsecuencia) { + this.numsecuencia = numsecuencia; + } + + 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; + } + + 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 + public int hashCode() { + int hash = 0; + hash += (conexionId != null ? conexionId.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 Conexion)) { + return false; + } + Conexion other = (Conexion) object; + if ((this.conexionId == null && other.conexionId != null) || (this.conexionId != null && !this.conexionId.equals(other.conexionId))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "com.rjconsultores.entidad.Conexion[ conexionId=" + conexionId + " ]"; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrl.java b/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrl.java new file mode 100644 index 000000000..5a20cf8fa --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrl.java @@ -0,0 +1,155 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +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.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +/** + * + * @author gleimar + */ +@Entity +@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 Short activo; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @JoinColumn(name = "ORIGEN_ID", referencedColumnName = "PARADA_ID") + @ManyToOne + private Parada origenId; + @JoinColumn(name = "DESTINO_ID", referencedColumnName = "PARADA_ID") + @ManyToOne + private Parada destinoId; + @OneToMany(mappedBy = "conexionctrlId") + private List conexionList; + @OneToMany(mappedBy = "conexionctrlId") + private List conexionTempList; + + public ConexionCtrl() { + } + + public ConexionCtrl(Long conexionctrlId) { + this.conexionctrlId = conexionctrlId; + } + + public Long getConexionctrlId() { + return conexionctrlId; + } + + public void setConexionctrlId(Long conexionctrlId) { + this.conexionctrlId = conexionctrlId; + } + + public Date getFecmodif() { + return fecmodif; + } + + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + + public Short getActivo() { + return activo; + } + + public void setActivo(Short activo) { + this.activo = activo; + } + + public Integer getUsuarioId() { + return usuarioId; + } + + public void setUsuarioId(Integer 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 getConexionList() { + return conexionList; + } + + public void setConexionList(List conexionList) { + this.conexionList = conexionList; + } + + @XmlTransient + public List getConexionTempList() { + return conexionTempList; + } + + public void setConexionTempList(List conexionTempList) { + this.conexionTempList = conexionTempList; + } + + @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 String toString() { + return "com.rjconsultores.entidad.ConexionCtrl[ conexionctrlId=" + conexionctrlId + " ]"; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrlTemp.java b/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrlTemp.java new file mode 100644 index 000000000..38606e871 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/ConexionCtrlTemp.java @@ -0,0 +1,131 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +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; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author gleimar + */ +@Entity +@SequenceGenerator(name = "CONEXION_CTRL_SEQ", sequenceName = "CONEXION_CTRL_SEQ", allocationSize = 1) +@Table(name = "CONEXION_CTRL_TEMP") +public class ConexionCtrlTemp implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "CONEXION_CTRL_SEQ") + @Column(name = "CONEXIONCTRL_ID") + private Long conexionctrlId; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @Column(name = "ORIGEN_ID") + private Integer origenId; + @Column(name = "DESTINO_ID") + private Integer destinoId; + + public ConexionCtrlTemp() { + } + + public ConexionCtrlTemp(Long conexionctrlId) { + this.conexionctrlId = conexionctrlId; + } + + public Long getConexionctrlId() { + return conexionctrlId; + } + + public void setConexionctrlId(Long conexionctrlId) { + this.conexionctrlId = conexionctrlId; + } + + 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() { + 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 ConexionCtrlTemp)) { + return false; + } + ConexionCtrlTemp other = (ConexionCtrlTemp) 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.ConexionCtrlTemp[ 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; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/ConexionTemp.java b/src/com/rjconsultores/ventaboletos/entidad/ConexionTemp.java new file mode 100644 index 000000000..da81de54e --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/ConexionTemp.java @@ -0,0 +1,161 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +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; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author gleimar + */ +@Entity +@Table(name = "CONEXION_TEMP") +@SequenceGenerator(name = "CONEXION_SEQ", sequenceName = "CONEXION_SEQ", allocationSize = 1) +public class ConexionTemp implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "CONEXION_SEQ") + @Column(name = "CONEXION_ID") + private Long conexionId; + @Column(name = "NUMGRUPO") + private Integer numgrupo; + @Column(name = "NUMSECUENCIA") + private Short numsecuencia; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @Column(name = "ORIGEN_ID") + private Integer origenId; + @Column(name = "DESTINO_ID") + private Integer destinoId; + @Column(name = "CONEXIONCTRL_ID") + private Long conexionctrlId; + + public ConexionTemp() { + } + + public ConexionTemp(Long conexionId) { + this.conexionId = conexionId; + } + + public Long getConexionId() { + return conexionId; + } + + public void setConexionId(Long conexionId) { + this.conexionId = conexionId; + } + + public Integer getNumgrupo() { + return numgrupo; + } + + public void setNumgrupo(Integer numgrupo) { + this.numgrupo = numgrupo; + } + + public Short getNumsecuencia() { + return numsecuencia; + } + + public void setNumsecuencia(Short numsecuencia) { + this.numsecuencia = numsecuencia; + } + + 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() { + int hash = 0; + hash += (conexionId != null ? conexionId.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 ConexionTemp)) { + return false; + } + ConexionTemp other = (ConexionTemp) object; + if ((this.conexionId == null && other.conexionId != null) || (this.conexionId != null && !this.conexionId.equals(other.conexionId))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "com.rjconsultores.entidad.ConexionTemp[ 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; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/ParamConexion.java b/src/com/rjconsultores/ventaboletos/entidad/ParamConexion.java new file mode 100644 index 000000000..28b4c40ac --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/ParamConexion.java @@ -0,0 +1,133 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +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; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author gleimar + */ +@Entity +@Table(name = "PARAM_CONEXION") +public class ParamConexion implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @Column(name = "PARAM_CONEXION_ID") + private Integer paramConexionId; + @Column(name = "DESCPARAMETRO") + private String descparametro; + @Column(name = "NOMBPARAMETRO") + private String nombparametro; + @Column(name = "VALOR_PARAMETRO") + private Integer valorParametro; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "ACTIVO") + private Short activo; + + public ParamConexion() { + } + + public ParamConexion(Integer paramConexionId) { + this.paramConexionId = paramConexionId; + } + + public Integer getParamConexionId() { + return paramConexionId; + } + + public void setParamConexionId(Integer paramConexionId) { + this.paramConexionId = paramConexionId; + } + + public String getDescparametro() { + return descparametro; + } + + public void setDescparametro(String descparametro) { + this.descparametro = descparametro; + } + + public String getNombparametro() { + return nombparametro; + } + + public void setNombparametro(String nombparametro) { + this.nombparametro = nombparametro; + } + + public Integer getValorParametro() { + return valorParametro; + } + + public void setValorParametro(Integer valorParametro) { + this.valorParametro = valorParametro; + } + + public Integer getUsuarioId() { + return usuarioId; + } + + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } + + public Date getFecmodif() { + return fecmodif; + } + + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + + public Short getActivo() { + return activo; + } + + public void setActivo(Short activo) { + this.activo = activo; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (paramConexionId != null ? paramConexionId.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 ParamConexion)) { + return false; + } + ParamConexion other = (ParamConexion) object; + if ((this.paramConexionId == null && other.paramConexionId != null) || (this.paramConexionId != null && !this.paramConexionId.equals(other.paramConexionId))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "com.rjconsultores.entidad.ParamConexion[ paramConexionId=" + paramConexionId + " ]"; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/ConexionService.java b/src/com/rjconsultores/ventaboletos/service/ConexionService.java new file mode 100644 index 000000000..84537aa15 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/ConexionService.java @@ -0,0 +1,12 @@ +package com.rjconsultores.ventaboletos.service; + +public interface ConexionService { + + + /** + * Gera as conexões possíveis para os tramos do sistema + * + */ + public void gerarConexiones(); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ConexionServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ConexionServiceImpl.java new file mode 100644 index 000000000..898b44ec8 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/ConexionServiceImpl.java @@ -0,0 +1,23 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.rjconsultores.ventaboletos.dao.ConexionDAO; +import com.rjconsultores.ventaboletos.service.ConexionService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("conexionService") +public class ConexionServiceImpl implements ConexionService { + + @Autowired + private ConexionDAO conexionDAO; + + @Override + @Transactional + public void gerarConexiones() { + conexionDAO.generarConexiones(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + } + +}