From 24c2872aacda3eb41bdcac078d142957e8f06dd2 Mon Sep 17 00:00:00 2001 From: "lucas.taia" Date: Thu, 1 May 2014 14:10:01 +0000 Subject: [PATCH] desenvolvimento (fixes bug #5251) git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@35213 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/SegVKMDAO.java | 18 +++ .../dao/hibernate/SegVKMHibernateDAO.java | 48 ++++++ .../ventaboletos/entidad/SegVKM.java | 137 ++++++++++++++++++ .../ventaboletos/service/SegVKMService.java | 18 +++ .../service/impl/SegVKMServiceImpl.java | 67 +++++++++ 5 files changed, 288 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/SegVKMDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/SegVKMHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/SegVKM.java create mode 100644 src/com/rjconsultores/ventaboletos/service/SegVKMService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/SegVKMServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/SegVKMDAO.java b/src/com/rjconsultores/ventaboletos/dao/SegVKMDAO.java new file mode 100644 index 000000000..2458906e9 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/SegVKMDAO.java @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.SegVKM; + +/** + * + * @author RJ + */ +public interface SegVKMDAO extends GenericDAO { + + public List buscar(String segVKm); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/SegVKMHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/SegVKMHibernateDAO.java new file mode 100644 index 000000000..b9cccf0ef --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/SegVKMHibernateDAO.java @@ -0,0 +1,48 @@ +/* + * 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.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.SegVKMDAO; +import com.rjconsultores.ventaboletos.entidad.SegVKM; + +/** + * + * @author Administrador + */ +@Repository("segVKMDAO") +public class SegVKMHibernateDAO extends GenericHibernateDAO + implements SegVKMDAO { + + @Autowired + public SegVKMHibernateDAO(@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 List buscar(String serie) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + c.add(Restrictions.eq("serie", serie)); + + return c.list(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/SegVKM.java b/src/com/rjconsultores/ventaboletos/entidad/SegVKM.java new file mode 100644 index 000000000..2bd126f82 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/SegVKM.java @@ -0,0 +1,137 @@ +/* + * 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.math.BigDecimal; +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; + +/** + * + * @author RJ + */ +@Entity +@SequenceGenerator(name = "SEGVKM_SEQ", sequenceName = "SEGVKM_SEQ", allocationSize = 1) +@Table(name = "SEGVKM") +public class SegVKM implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEGVKM_SEQ") + @Column(name = "SEGVKM_ID") + private Integer segVKMId; + @Column(name = "KM") + private BigDecimal km; + @Column(name = "VALOR") + private BigDecimal valor; + @Column(name = "SERIE") + private String serie; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public SegVKM() { + } + + public SegVKM(Integer segVKMId) { + this.segVKMId = segVKMId; + } + + public Integer getSegVKMId() { + return segVKMId; + } + + public void setSegVKMId(Integer segVKMId) { + this.segVKMId = segVKMId; + } + + public BigDecimal getKm() { + return km; + } + + public void setKm(BigDecimal km) { + this.km = km; + } + + public BigDecimal getValor() { + return valor; + } + + public void setValor(BigDecimal valor) { + this.valor = valor; + } + + public String getSerie() { + return serie; + } + + public void setSerie(String serie) { + this.serie = serie; + } + + 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 += (segVKMId != null ? segVKMId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + if (!(object instanceof SegVKM)) { + return false; + } + SegVKM other = (SegVKM) object; + if ((this.segVKMId == null && other.segVKMId != null) || (this.segVKMId != null && !this.segVKMId.equals(other.segVKMId))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "com.rjconsultores.ventaboletos.entidad.SegVKM[ segVKMId=" + segVKMId + " ]"; + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/SegVKMService.java b/src/com/rjconsultores/ventaboletos/service/SegVKMService.java new file mode 100644 index 000000000..21ab0ca5a --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/SegVKMService.java @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.SegVKM; + +/** + * + * @author RJ + */ +public interface SegVKMService extends GenericService { + + public List buscar(String serie); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/SegVKMServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/SegVKMServiceImpl.java new file mode 100644 index 000000000..194675174 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/SegVKMServiceImpl.java @@ -0,0 +1,67 @@ +/* + * 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.SegVKMDAO; +import com.rjconsultores.ventaboletos.entidad.SegVKM; +import com.rjconsultores.ventaboletos.service.SegVKMService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +/** + * + * @author RJ + */ +@Service("segVKMService") +public class SegVKMServiceImpl implements SegVKMService { + + @Autowired + private SegVKMDAO segVKMDAO; + + public List obtenerTodos() { + return segVKMDAO.obtenerTodos(); + } + + public SegVKM obtenerID(Integer id) { + return segVKMDAO.obtenerID(id); + } + + @Transactional + public SegVKM suscribir(SegVKM entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return segVKMDAO.suscribir(entidad); + } + + @Transactional + public SegVKM actualizacion(SegVKM entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return segVKMDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(SegVKM entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + segVKMDAO.actualizacion(entidad); + } + + public List buscar(String serie) { + return segVKMDAO.buscar(serie); + } +}