From 7447b6d563eee0286c8028fbf5f7b0b19373569a Mon Sep 17 00:00:00 2001 From: walace Date: Fri, 6 Sep 2019 18:08:52 +0000 Subject: [PATCH] fixes bug#15119 qua: dev: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@97358 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/ConfTotemDAO.java | 12 ++ .../dao/hibernate/ConfTotemHibernateDAO.java | 44 +++++++ .../ventaboletos/entidad/ConfTotem.java | 110 ++++++++++++++++++ .../service/ConfTotemService.java | 12 ++ .../service/impl/ConfTotemServiceImpl.java | 59 ++++++++++ 5 files changed, 237 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/ConfTotemDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/ConfTotemHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/ConfTotem.java create mode 100644 src/com/rjconsultores/ventaboletos/service/ConfTotemService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/ConfTotemServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/ConfTotemDAO.java b/src/com/rjconsultores/ventaboletos/dao/ConfTotemDAO.java new file mode 100644 index 000000000..b22b71442 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/ConfTotemDAO.java @@ -0,0 +1,12 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.ConfTotem; + +/** + * + * @author Wallace + */ +public interface ConfTotemDAO extends GenericDAO { + + public ConfTotem buscar(String chave); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConfTotemHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConfTotemHibernateDAO.java new file mode 100644 index 000000000..255dc4a76 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConfTotemHibernateDAO.java @@ -0,0 +1,44 @@ +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.CustomDAO; +import com.rjconsultores.ventaboletos.entidad.Custom; + +/** + * + * @author Wallace + */ +@Repository("confTotemDAO") +public class ConfTotemHibernateDAO extends GenericHibernateDAO + implements CustomDAO { + + @Autowired + public ConfTotemHibernateDAO(@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(); + } + + public Custom buscar(String chave) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + c.add(Restrictions.ilike("chave", chave)); + + return c.list().isEmpty() ? null : (Custom) c.list().get(0); + } +} \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/entidad/ConfTotem.java b/src/com/rjconsultores/ventaboletos/entidad/ConfTotem.java new file mode 100644 index 000000000..4616cf76e --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/ConfTotem.java @@ -0,0 +1,110 @@ +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.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@SequenceGenerator(name = "CONF_TOTEM_SEQ", sequenceName = "CONF_TOTEM_SEQ",allocationSize=1) +@Table(name = "CONF_TOTEM") +public class ConfTotem implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "CONF_TOTEM_SEQ") + @Column(name = "CONFTOTEM_ID") + private Integer confTotemId; + @Column(name = "VALOR") + private Boolean valor; + @Column(name = "CHAVE") + private String chave; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public Integer getConfTotemId() { + return confTotemId; + } + public void setConfTotemId(Integer confTotemId) { + this.confTotemId = confTotemId; + } + + public ConfTotem() { + super(); + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((confTotemId == null) ? 0 : confTotemId.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; + ConfTotem other = (ConfTotem) obj; + if (confTotemId == null) { + if (other.confTotemId != null) + return false; + } else if (!confTotemId.equals(other.confTotemId)) + return false; + return true; + } + + public Boolean getValor() { + return valor; + } + public void setValor(Boolean valor) { + this.valor = valor; + } + + 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 String getChave() { + return chave; + } + public void setChave(String chave) { + this.chave = chave; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/ConfTotemService.java b/src/com/rjconsultores/ventaboletos/service/ConfTotemService.java new file mode 100644 index 000000000..2e0e74116 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/ConfTotemService.java @@ -0,0 +1,12 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.ConfTotem; + +/** + * + * @author Wallace + */ +public interface ConfTotemService extends GenericService { + + public ConfTotem buscar(String chave); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ConfTotemServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ConfTotemServiceImpl.java new file mode 100644 index 000000000..d755eb4b5 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/ConfTotemServiceImpl.java @@ -0,0 +1,59 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Calendar; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import com.rjconsultores.ventaboletos.dao.ConfTotemDAO; +import com.rjconsultores.ventaboletos.entidad.ConfTotem; +import com.rjconsultores.ventaboletos.service.ConfTotemService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +public class ConfTotemServiceImpl implements ConfTotemService { + + @Autowired + private ConfTotemDAO confTotemDAO; + + public List obtenerTodos() { + return confTotemDAO.obtenerTodos(); + } + + public ConfTotem obtenerID(Integer id) { + return confTotemDAO.obtenerID(id); + } + + @Transactional(propagation = Propagation.SUPPORTS) + public ConfTotem suscribir(ConfTotem entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado() != null ? UsuarioLogado.getUsuarioLogado().getUsuarioId() : null); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return confTotemDAO.suscribir(entidad); + } + + @Transactional + public ConfTotem actualizacion(ConfTotem entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return confTotemDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(ConfTotem entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + confTotemDAO.actualizacion(entidad); + } + + @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) + public ConfTotem buscar(String chave) { + return confTotemDAO.buscar(chave); + } +}