From 7283c21b3a17d0cb37fdc4f0d028447bb242beb7 Mon Sep 17 00:00:00 2001 From: "lucas.taia" Date: Fri, 13 Mar 2015 22:56:03 +0000 Subject: [PATCH] correcao (fixes bug 6109) git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@42153 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/UsuarioSesionDAO.java | 15 ++ .../hibernate/UsuarioSesionHibernateDAO.java | 40 +++++ .../ventaboletos/entidad/UsuarioSesion.java | 167 ++++++++++++++++++ .../service/UsuarioSesionService.java | 14 ++ .../service/impl/UsuarioSesionImpl.java | 59 +++++++ 5 files changed, 295 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/UsuarioSesionDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/UsuarioSesionHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/UsuarioSesion.java create mode 100644 src/com/rjconsultores/ventaboletos/service/UsuarioSesionService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/UsuarioSesionImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/UsuarioSesionDAO.java b/src/com/rjconsultores/ventaboletos/dao/UsuarioSesionDAO.java new file mode 100644 index 000000000..af44c53a5 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/UsuarioSesionDAO.java @@ -0,0 +1,15 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.UsuarioSesion; + +/** + * + * @author RJ Consultores + */ +public interface UsuarioSesionDAO extends GenericDAO { + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/UsuarioSesionHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/UsuarioSesionHibernateDAO.java new file mode 100644 index 000000000..1bd96527b --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/UsuarioSesionHibernateDAO.java @@ -0,0 +1,40 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Order; +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.UsuarioSesionDAO; +import com.rjconsultores.ventaboletos.entidad.UsuarioSesion; + +/** + * + * @author RJ Consultores + */ +@Repository("usuarioSesionDAO") +public class UsuarioSesionHibernateDAO extends GenericHibernateDAO + implements UsuarioSesionDAO { + + @Autowired + public UsuarioSesionHibernateDAO(@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(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/UsuarioSesion.java b/src/com/rjconsultores/ventaboletos/entidad/UsuarioSesion.java new file mode 100644 index 000000000..3be3ed28e --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/UsuarioSesion.java @@ -0,0 +1,167 @@ +/* + * 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.OneToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/** + * + * @author RJ Consultores + */ +@Entity +@SequenceGenerator(name = "USUARIO_SESION_SEQ", sequenceName = "USUARIO_SESION_SEQ", allocationSize = 1) +@Table(name = "USUARIO_SESION") +public class UsuarioSesion implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "USUARIO_SESION_SEQ") + @Basic(optional = false) + @Column(name = "USUARIOSESION_ID") + private Integer usuarioSesionId; + + @JoinColumn(name = "SISTEMA_ID", referencedColumnName = "SISTEMA_ID") + @ManyToOne + private Sistema sistema; + + @Column(name = "INDFIRMADO") + private Boolean indFirmado; + + @Column(name = "FECHORINICIO") + @Temporal(TemporalType.TIMESTAMP) + private Date fecHorInicio; + + @Column(name = "FECHORACTIVIDAD") + @Temporal(TemporalType.TIMESTAMP) + private Date fecHorActividad; + + @OneToOne + @JoinColumn(name = "USUARIO_ID", referencedColumnName = "USUARIO_ID") + private Usuario usuario; + + @JoinColumn(name = "EMPRESA_ID", referencedColumnName = "EMPRESA_ID") + @ManyToOne + private Empresa empresa; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + public Integer getUsuarioSesionId() { + return usuarioSesionId; + } + + public void setUsuarioSesionId(Integer usuarioSesionId) { + this.usuarioSesionId = usuarioSesionId; + } + + public Sistema getSistema() { + return sistema; + } + + public void setSistema(Sistema sistema) { + this.sistema = sistema; + } + + public Boolean getIndFirmado() { + return indFirmado; + } + + public void setIndFirmado(Boolean indFirmado) { + this.indFirmado = indFirmado; + } + + public Date getFecHorInicio() { + return fecHorInicio; + } + + public void setFecHorInicio(Date fecHorInicio) { + this.fecHorInicio = fecHorInicio; + } + + public Date getFecHorActividad() { + return fecHorActividad; + } + + public void setFecHorActividad(Date fecHorActividad) { + this.fecHorActividad = fecHorActividad; + } + + public Usuario getUsuario() { + return usuario; + } + + public void setUsuario(Usuario usuario) { + this.usuario = usuario; + } + + public Empresa getEmpresa() { + return empresa; + } + + public void setEmpresa(Empresa empresa) { + this.empresa = empresa; + } + + 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; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (usuarioSesionId != null ? usuarioSesionId.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 UsuarioSesion)) { + return false; + } + UsuarioSesion other = (UsuarioSesion) object; + if ((this.usuarioSesionId == null && other.usuarioSesionId != null) || (this.usuarioSesionId != null && !this.usuarioSesionId.equals(other.usuarioSesionId))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "com.rjconsultores.ventaboletos.entidad.UsuarioSesion[usuarioSesionId=" + usuarioSesionId + "]"; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/UsuarioSesionService.java b/src/com/rjconsultores/ventaboletos/service/UsuarioSesionService.java new file mode 100644 index 000000000..2fd375ea0 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/UsuarioSesionService.java @@ -0,0 +1,14 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.UsuarioSesion; + +/** + * + * @author RJ Consultores + */ +public interface UsuarioSesionService extends GenericService { +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/UsuarioSesionImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/UsuarioSesionImpl.java new file mode 100644 index 000000000..173a5be51 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/UsuarioSesionImpl.java @@ -0,0 +1,59 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +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.UsuarioSesionDAO; +import com.rjconsultores.ventaboletos.entidad.UsuarioSesion; +import com.rjconsultores.ventaboletos.service.UsuarioSesionService; + +/** + * + * @author RJ Consultores + */ +@Service("usuarioSesionService") +public class UsuarioSesionImpl implements UsuarioSesionService { + + @Autowired + private UsuarioSesionDAO usuarioSesionDAO; + + public List obtenerTodos() { + return usuarioSesionDAO.obtenerTodos(); + } + + public UsuarioSesion obtenerID(Integer id) { + return usuarioSesionDAO.obtenerID(id); + } + + @Transactional + public UsuarioSesion suscribir(UsuarioSesion entidad) { + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return usuarioSesionDAO.suscribir(entidad); + } + + @Transactional + public UsuarioSesion actualizacion(UsuarioSesion entidad) { + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return usuarioSesionDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(UsuarioSesion entidad) { + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + usuarioSesionDAO.actualizacion(entidad); + } +}