From c5136b410a7896533500c26427bd2ed3f61d9f85 Mon Sep 17 00:00:00 2001 From: wilian Date: Tue, 4 Aug 2015 21:04:14 +0000 Subject: [PATCH] fixes bug #6537 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@46545 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/PacoteConvenioDAO.java | 10 +++ .../hibernate/PacoteConvenioHibernateDAO.java | 41 +++++++++ .../ventaboletos/entidad/PacoteConvenio.java | 88 +++++++++++++++++++ .../service/PacoteConvenioService.java | 10 +++ .../impl/PacoteConvenioServiceImpl.java | 59 +++++++++++++ 5 files changed, 208 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/PacoteConvenioDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteConvenioHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/PacoteConvenio.java create mode 100644 src/com/rjconsultores/ventaboletos/service/PacoteConvenioService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/PacoteConvenioServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/PacoteConvenioDAO.java b/src/com/rjconsultores/ventaboletos/dao/PacoteConvenioDAO.java new file mode 100644 index 000000000..746702cb1 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/PacoteConvenioDAO.java @@ -0,0 +1,10 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.PacoteConvenio; + +public interface PacoteConvenioDAO extends GenericDAO { + + public List buscar(String nomconvenio); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteConvenioHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteConvenioHibernateDAO.java new file mode 100644 index 000000000..b552055e6 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PacoteConvenioHibernateDAO.java @@ -0,0 +1,41 @@ +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.PacoteConvenioDAO; +import com.rjconsultores.ventaboletos.entidad.PacoteConvenio; + +@Repository("pacoteConvenioDAO") +public class PacoteConvenioHibernateDAO extends GenericHibernateDAO implements PacoteConvenioDAO { + + @Autowired + public PacoteConvenioHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + @SuppressWarnings("unchecked") + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return c.list(); + } + + @SuppressWarnings("unchecked") + public List buscar(String nomconvenio) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + c.add(Restrictions.eq("nomconvenio", nomconvenio)); + + return c.list(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PacoteConvenio.java b/src/com/rjconsultores/ventaboletos/entidad/PacoteConvenio.java new file mode 100644 index 000000000..fda565adc --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/PacoteConvenio.java @@ -0,0 +1,88 @@ +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 +@Table(name = "PACOTE_CONVENIO") +@SequenceGenerator(name = "PACOTE_CONVENIO_SEQ", sequenceName = "PACOTE_CONVENIO_SEQ", allocationSize = 1) +public class PacoteConvenio implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "PACOTE_CONVENIO_SEQ") + @Column(name = "PACOTECONVENIO_ID") + private Long pacoteconvenioId; + + @Column(name = "NOMCONVENIO") + private String nomconvenio; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.DATE) + private Date fecmodif; + + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public Long getPacoteconvenioId() { + return pacoteconvenioId; + } + + public void setPacoteconvenioId(Long pacoteconvenioId) { + this.pacoteconvenioId = pacoteconvenioId; + } + + public String getNomconvenio() { + return nomconvenio; + } + + public void setNomconvenio(String nomconvenio) { + this.nomconvenio = nomconvenio; + } + + 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 String toString() { + return getNomconvenio(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/PacoteConvenioService.java b/src/com/rjconsultores/ventaboletos/service/PacoteConvenioService.java new file mode 100644 index 000000000..28bdf1258 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/PacoteConvenioService.java @@ -0,0 +1,10 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.PacoteConvenio; + +public interface PacoteConvenioService extends GenericService { + + public List buscar(String nomconvenio); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PacoteConvenioServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PacoteConvenioServiceImpl.java new file mode 100644 index 000000000..6a13b6ccd --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/PacoteConvenioServiceImpl.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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.rjconsultores.ventaboletos.dao.PacoteConvenioDAO; +import com.rjconsultores.ventaboletos.entidad.PacoteConvenio; +import com.rjconsultores.ventaboletos.service.PacoteConvenioService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("pacoteConvenioService") +public class PacoteConvenioServiceImpl implements PacoteConvenioService { + + @Autowired + private PacoteConvenioDAO pacoteConvenioDAO; + + public List obtenerTodos() { + return pacoteConvenioDAO.obtenerTodos(); + } + + public PacoteConvenio obtenerID(Long id) { + return pacoteConvenioDAO.obtenerID(id); + } + + @Transactional + public PacoteConvenio suscribir(PacoteConvenio entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return pacoteConvenioDAO.suscribir(entidad); + } + + @Transactional + public PacoteConvenio actualizacion(PacoteConvenio entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return pacoteConvenioDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(PacoteConvenio entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + pacoteConvenioDAO.actualizacion(entidad); + } + + public List buscar(String deschotel) { + return pacoteConvenioDAO.buscar(deschotel); + } +}