From b903b25aba2ce4d6a826f9adea2f050ca9537a90 Mon Sep 17 00:00:00 2001 From: "lucas.taia" Date: Tue, 6 May 2014 20:22:34 +0000 Subject: [PATCH] desenvolvimento (bug #5284) git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@35335 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/PtoVtaSeguroDAO.java | 8 + .../hibernate/PtoVtaSeguroHibernateDAO.java | 43 +++++ .../ventaboletos/entidad/PtoVtaSeguro.java | 160 ++++++++++++++++++ .../ventaboletos/entidad/PuntoVenta.java | 35 ++++ .../service/PtoVtaSeguroService.java | 7 + .../service/impl/PtoVtaSeguroServiceImpl.java | 52 ++++++ 6 files changed, 305 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/PtoVtaSeguroDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/PtoVtaSeguroHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/PtoVtaSeguro.java create mode 100644 src/com/rjconsultores/ventaboletos/service/PtoVtaSeguroService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/PtoVtaSeguroServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/PtoVtaSeguroDAO.java b/src/com/rjconsultores/ventaboletos/dao/PtoVtaSeguroDAO.java new file mode 100644 index 000000000..6a9e4bafc --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/PtoVtaSeguroDAO.java @@ -0,0 +1,8 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.PtoVtaSeguro; + +public interface PtoVtaSeguroDAO extends GenericDAO { + + +} \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PtoVtaSeguroHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PtoVtaSeguroHibernateDAO.java new file mode 100644 index 000000000..b3d91e063 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PtoVtaSeguroHibernateDAO.java @@ -0,0 +1,43 @@ +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.PtoVtaSeguroDAO; +import com.rjconsultores.ventaboletos.entidad.PtoVtaSeguro; + +@Repository("ptoVtaSeguroDAO") +public class PtoVtaSeguroHibernateDAO extends GenericHibernateDAO + implements PtoVtaSeguroDAO { + + @Autowired + public PtoVtaSeguroHibernateDAO( + @Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.addOrder(Order.asc("ptoVtaSeguroId")); + + return c.list(); + } + + public List buscar(int id) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("ptoVtaSeguroId", id)); + + return c.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PtoVtaSeguro.java b/src/com/rjconsultores/ventaboletos/entidad/PtoVtaSeguro.java new file mode 100644 index 000000000..4e1ab2885 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/PtoVtaSeguro.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.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/** + * + * @author RJ + */ +@Entity +@SequenceGenerator(name = "PTOVTA_SEGURO_SEQ", sequenceName = "PTOVTA_SEGURO_SEQ", allocationSize = 1) +@Table(name = "PTOVTA_SEGURO") +public class PtoVtaSeguro implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "PTOVTA_SEGURO_SEQ") + @Column(name = "PTOVTASEGURO_ID") + private Integer ptoVtaSeguroId; + + @OneToOne + @JoinColumn(name = "EMPRESA_ID") + private Empresa empresa; + + @Basic(optional = false) + @Column(name = "INDVENDSEGOPCIONAL") + private Boolean indVendeSegOpcional; + + @Basic(optional = false) + @Column(name = "INDESTANSEGOPCIONAL") + private Boolean indEstanSegOpcional; + + @Basic(optional = false) + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + @Column(name = "USUARIO_ID") + private int usuarioId; + + @JoinColumn(name = "PUNTOVENTA_ID", referencedColumnName = "PUNTOVENTA_ID") + @OneToOne + private PuntoVenta puntoventaId; + + public PtoVtaSeguro() { + } + + public PtoVtaSeguro(Integer ptoVtaSeguroId) { + this.ptoVtaSeguroId = ptoVtaSeguroId; + } + + public Integer getPtoVtaSeguroId() { + return ptoVtaSeguroId; + } + + public void setPtoVtaSeguroId(Integer ptoVtaSeguroId) { + this.ptoVtaSeguroId = ptoVtaSeguroId; + } + + public Empresa getEmpresa() { + return empresa; + } + + public void setEmpresa(Empresa empresa) { + this.empresa = empresa; + } + + public Boolean getIndVendeSegOpcional() { + return indVendeSegOpcional; + } + + public void setIndVendeSegOpcional(Boolean indVendeSegOpcional) { + this.indVendeSegOpcional = indVendeSegOpcional; + } + + public Boolean getIndEstanSegOpcional() { + return indEstanSegOpcional; + } + + public void setIndEstanSegOpcional(Boolean indEstanSegOpcional) { + this.indEstanSegOpcional = indEstanSegOpcional; + } + + 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 int getUsuarioId() { + return usuarioId; + } + + public void setUsuarioId(int usuarioId) { + this.usuarioId = usuarioId; + } + + public PuntoVenta getPuntoventaId() { + return puntoventaId; + } + + public void setPuntoventaId(PuntoVenta puntoventaId) { + this.puntoventaId = puntoventaId; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (ptoVtaSeguroId != null ? ptoVtaSeguroId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + if (!(object instanceof PtoVtaSeguro)) { + return false; + } + PtoVtaSeguro other = (PtoVtaSeguro) object; + if ((this.ptoVtaSeguroId == null && other.ptoVtaSeguroId != null) || (this.ptoVtaSeguroId != null && !this.ptoVtaSeguroId.equals(other.ptoVtaSeguroId))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "com.rjconsultores.ventaboletos.entidad.PtoVtaSeguro[ ptoVtaSeguroId=" + ptoVtaSeguroId + " ]"; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java index 88c8e9f3a..2c7f914f5 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java +++ b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java @@ -166,6 +166,10 @@ public class PuntoVenta implements Serializable { @LazyCollection(LazyCollectionOption.FALSE) private List ptovtaCheckinList; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "puntoventaId") + @LazyCollection(LazyCollectionOption.FALSE) + private List ptovtaSeguroList; + public PtovtaEmpresaBloqueada addEmpresaBloqueada(Empresa e){ PtovtaEmpresaBloqueada eb = new PtovtaEmpresaBloqueada(); eb.setEmpresa(e); @@ -701,5 +705,36 @@ public class PuntoVenta implements Serializable { public void removePtovtaCheckin(PtoVtaCheckin pto){ this.ptovtaCheckinList.remove(pto); } + + public List getPtovtaSeguroList() { + List lista = new ArrayList(); + for (PtoVtaSeguro ck : ptovtaSeguroList ){ + if (ck.getActivo()){ + lista.add(ck); + } + } + return lista; + } + + public void setPtovtaSeguroList(List ptovtaSeguroList) { + this.ptovtaSeguroList = ptovtaSeguroList; + } + + public PtoVtaSeguro addPtovtaSeguro(PtoVtaSeguro pto){ + PtoVtaSeguro pt = new PtoVtaSeguro(); + pt.setPuntoventaId(pto.getPuntoventaId()); + pt.setEmpresa(pto.getEmpresa()); + pt.setIndVendeSegOpcional(pto.getIndVendeSegOpcional()); + pt.setIndEstanSegOpcional(pto.getIndEstanSegOpcional()); + pt.setActivo(Boolean.TRUE); + pt.setFecmodif(Calendar.getInstance().getTime()); + pt.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + this.ptovtaSeguroList.add(pt); + return pt; + } + + public void removePtovtaSeguro(PtoVtaSeguro pto){ + this.ptovtaSeguroList.remove(pto); + } } diff --git a/src/com/rjconsultores/ventaboletos/service/PtoVtaSeguroService.java b/src/com/rjconsultores/ventaboletos/service/PtoVtaSeguroService.java new file mode 100644 index 000000000..d5a70cd59 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/PtoVtaSeguroService.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.PtoVtaSeguro; + +public interface PtoVtaSeguroService extends GenericService { + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PtoVtaSeguroServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PtoVtaSeguroServiceImpl.java new file mode 100644 index 000000000..2c40fd09c --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/PtoVtaSeguroServiceImpl.java @@ -0,0 +1,52 @@ +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.PtoVtaSeguroDAO; +import com.rjconsultores.ventaboletos.entidad.PtoVtaSeguro; +import com.rjconsultores.ventaboletos.service.PtoVtaSeguroService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("ptoVtaSeguroService") +public class PtoVtaSeguroServiceImpl implements PtoVtaSeguroService { + + @Autowired + private PtoVtaSeguroDAO ptoVtaSeguroServiceDAO; + + @Override + public List obtenerTodos() { + return ptoVtaSeguroServiceDAO.obtenerTodos(); + } + + @Override + public PtoVtaSeguro obtenerID(Integer id) { + return ptoVtaSeguroServiceDAO.obtenerID(id); + } + + @Override + @Transactional(readOnly = false) + public PtoVtaSeguro suscribir(PtoVtaSeguro entidad) { + return ptoVtaSeguroServiceDAO.suscribir(entidad); + } + + @Override + @Transactional(readOnly = false) + public PtoVtaSeguro actualizacion(PtoVtaSeguro entidad) { + return ptoVtaSeguroServiceDAO.actualizacion(entidad); + } + + @Override + @Transactional(readOnly = false) + public void borrar(PtoVtaSeguro entidad) { + entidad.setActivo(Boolean.FALSE); + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + ptoVtaSeguroServiceDAO.actualizacion(entidad); + } + +}