From db5f99a2ea9a8a4e0f4050be75f7dffe7c1702a8 Mon Sep 17 00:00:00 2001 From: julio Date: Wed, 25 Jun 2014 19:59:08 +0000 Subject: [PATCH] P3 - Bloqueio por tipo de Passagem (fixed bug #5381) git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@36227 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/PtovtaCatIndDAO.java | 6 + .../hibernate/PtovtaCatIndHibernateDAO.java | 20 +++ .../ventaboletos/entidad/PtovtaCatInd.java | 147 ++++++++++++++++++ .../ventaboletos/entidad/PuntoVenta.java | 93 +++++++---- .../service/PtovtaCatIndService.java | 6 + .../service/impl/PtovtaCatIndServiceImpl.java | 59 +++++++ .../service/impl/PuntoVentaServiceImpl.java | 2 - 7 files changed, 300 insertions(+), 33 deletions(-) create mode 100644 src/com/rjconsultores/ventaboletos/dao/PtovtaCatIndDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaCatIndHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/PtovtaCatInd.java create mode 100644 src/com/rjconsultores/ventaboletos/service/PtovtaCatIndService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/PtovtaCatIndServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/PtovtaCatIndDAO.java b/src/com/rjconsultores/ventaboletos/dao/PtovtaCatIndDAO.java new file mode 100644 index 000000000..9ecc19f4a --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/PtovtaCatIndDAO.java @@ -0,0 +1,6 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.PtovtaCatInd; + +public interface PtovtaCatIndDAO extends GenericDAO { +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaCatIndHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaCatIndHibernateDAO.java new file mode 100644 index 000000000..63a0ae323 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PtovtaCatIndHibernateDAO.java @@ -0,0 +1,20 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import com.rjconsultores.ventaboletos.dao.PtovtaCatIndDAO; +import com.rjconsultores.ventaboletos.entidad.PtovtaCatInd; + +@Repository("ptovtaCatIndDAO") +public class PtovtaCatIndHibernateDAO extends GenericHibernateDAO + implements PtovtaCatIndDAO { + + @Autowired + public PtovtaCatIndHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PtovtaCatInd.java b/src/com/rjconsultores/ventaboletos/entidad/PtovtaCatInd.java new file mode 100644 index 000000000..b7f903ec4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/PtovtaCatInd.java @@ -0,0 +1,147 @@ +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.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@SequenceGenerator(name = "PTOVTA_CAT_IND_SEQ", sequenceName = "PTOVTA_CAT_IND_SEQ", allocationSize = 1) +@Table(name = "PTOVTA_CAT_IND") +public class PtovtaCatInd implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "PTOVTA_CAT_IND_SEQ") + @Column(name = "PTOVTACATEGORIA_ID") + private Integer ptovtaCategoriaId; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @JoinColumn(name = "CATEGORIA_ID", referencedColumnName = "CATEGORIA_ID") + @ManyToOne + private Categoria categoria; + @JoinColumn(name = "PUNTOVENTA_ID", referencedColumnName = "PUNTOVENTA_ID") + @ManyToOne + private PuntoVenta puntoVenta; + + public Integer getPtovtaCategoriaId() { + return ptovtaCategoriaId; + } + + public void setPtovtaCategoriaId(Integer ptovtaCategoriaId) { + this.ptovtaCategoriaId = ptovtaCategoriaId; + } + + 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 Categoria getCategoria() { + return categoria; + } + + public void setCategoria(Categoria categoria) { + this.categoria = categoria; + } + + public PuntoVenta getPuntoVenta() { + return puntoVenta; + } + + public void setPuntoVenta(PuntoVenta puntoVenta) { + this.puntoVenta = puntoVenta; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((activo == null) ? 0 : activo.hashCode()); + result = prime * result + ((categoria == null) ? 0 : categoria.hashCode()); + result = prime * result + ((fecmodif == null) ? 0 : fecmodif.hashCode()); + result = prime * result + ((ptovtaCategoriaId == null) ? 0 : ptovtaCategoriaId.hashCode()); + result = prime * result + ((puntoVenta == null) ? 0 : puntoVenta.hashCode()); + result = prime * result + ((usuarioId == null) ? 0 : usuarioId.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; + PtovtaCatInd other = (PtovtaCatInd) obj; + if (activo == null) { + if (other.activo != null) + return false; + } else if (!activo.equals(other.activo)) + return false; + if (categoria == null) { + if (other.categoria != null) + return false; + } else if (!categoria.equals(other.categoria)) + return false; + if (fecmodif == null) { + if (other.fecmodif != null) + return false; + } else if (!fecmodif.equals(other.fecmodif)) + return false; + if (ptovtaCategoriaId == null) { + if (other.ptovtaCategoriaId != null) + return false; + } else if (!ptovtaCategoriaId.equals(other.ptovtaCategoriaId)) + return false; + if (puntoVenta == null) { + if (other.puntoVenta != null) + return false; + } else if (!puntoVenta.equals(other.puntoVenta)) + return false; + if (usuarioId == null) { + if (other.usuarioId != null) + return false; + } else if (!usuarioId.equals(other.usuarioId)) + return false; + return true; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java index 2c7f914f5..c22acea25 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java +++ b/src/com/rjconsultores/ventaboletos/entidad/PuntoVenta.java @@ -138,7 +138,7 @@ public class PuntoVenta implements Serializable { @Column(name = "INDVALIDASTOCK") private Boolean indValidaStock; @Column(name = "INDPERMISOTASAEMBARQUE") - private Boolean indPermisoTasaEmbarque; + private Boolean indPermisoTasaEmbarque; @Column(name = "TIEMPOCANCELACION") private Integer tiempoCancelacion; @OneToOne(cascade = CascadeType.ALL) @@ -151,26 +151,30 @@ public class PuntoVenta implements Serializable { @Column(name = "INDCTRLESTCENTRAL") private Boolean usaCrtlEstCentral; - + @Column(name = "NUMDOCPUNTOVENTA") private String numDoCPuntoVenta; - + @Column(name = "RAZONSOCIAL") private String razonSocial; - + @OneToMany(cascade = CascadeType.ALL, mappedBy = "puntoventaId") @LazyCollection(LazyCollectionOption.FALSE) private List ptovtaEmpresaBloqueadaList; - + @OneToMany(cascade = CascadeType.ALL, mappedBy = "puntoventaId") @LazyCollection(LazyCollectionOption.FALSE) private List ptovtaCheckinList; - + @OneToMany(cascade = CascadeType.ALL, mappedBy = "puntoventaId") @LazyCollection(LazyCollectionOption.FALSE) private List ptovtaSeguroList; - - public PtovtaEmpresaBloqueada addEmpresaBloqueada(Empresa e){ + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "puntoVenta") + @LazyCollection(LazyCollectionOption.FALSE) + private List ptovtaCatIndList; + + public PtovtaEmpresaBloqueada addEmpresaBloqueada(Empresa e) { PtovtaEmpresaBloqueada eb = new PtovtaEmpresaBloqueada(); eb.setEmpresa(e); eb.setPuntoventaId(this); @@ -180,20 +184,20 @@ public class PuntoVenta implements Serializable { this.ptovtaEmpresaBloqueadaList.add(eb); return eb; } - - public void removeEmpresaBloqueada(PtovtaEmpresaBloqueada e){ + + public void removeEmpresaBloqueada(PtovtaEmpresaBloqueada e) { this.ptovtaEmpresaBloqueadaList.remove(e); } - - public void removeEmpresaBloqueada(Empresa e){ - for (PtovtaEmpresaBloqueada eb : ptovtaEmpresaBloqueadaList){ - if (eb.getEmpresa().equals(e)){ + + public void removeEmpresaBloqueada(Empresa e) { + for (PtovtaEmpresaBloqueada eb : ptovtaEmpresaBloqueadaList) { + if (eb.getEmpresa().equals(e)) { this.ptovtaEmpresaBloqueadaList.remove(e); break; } } } - + public PtovtaTipoEstoque getPtovtaTipoEstoque() { return ptovtaTipoEstoque; } @@ -613,7 +617,7 @@ public class PuntoVenta implements Serializable { public void setIndValidaStock(Boolean indValidaStock) { this.indValidaStock = indValidaStock; - } + } public Boolean getIndPermisoTasaEmbarque() { return indPermisoTasaEmbarque; @@ -665,8 +669,8 @@ public class PuntoVenta implements Serializable { public List getPtovtaEmpresaBloqueadaList() { List lista = new ArrayList(); - for (PtovtaEmpresaBloqueada eb : ptovtaEmpresaBloqueadaList ){ - if (eb.getActivo()){ + for (PtovtaEmpresaBloqueada eb : ptovtaEmpresaBloqueadaList) { + if (eb.getActivo()) { lista.add(eb); } } @@ -679,8 +683,8 @@ public class PuntoVenta implements Serializable { public List getPtovtaCheckinList() { List lista = new ArrayList(); - for (PtoVtaCheckin ck : ptovtaCheckinList ){ - if (ck.getActivo()){ + for (PtoVtaCheckin ck : ptovtaCheckinList) { + if (ck.getActivo()) { lista.add(ck); } } @@ -690,8 +694,8 @@ public class PuntoVenta implements Serializable { public void setPtovtaCheckinList(List ptovtaCheckinList) { this.ptovtaCheckinList = ptovtaCheckinList; } - - public PtoVtaCheckin addPtovtaCheckin(PtoVtaCheckin pto){ + + public PtoVtaCheckin addPtovtaCheckin(PtoVtaCheckin pto) { PtoVtaCheckin pt = new PtoVtaCheckin(); pt.setPuntoventaId(pto.getPuntoventaId()); pt.setParadaId(pto.getParadaId()); @@ -701,15 +705,15 @@ public class PuntoVenta implements Serializable { this.ptovtaCheckinList.add(pt); return pt; } - - public void removePtovtaCheckin(PtoVtaCheckin pto){ + + public void removePtovtaCheckin(PtoVtaCheckin pto) { this.ptovtaCheckinList.remove(pto); } - + public List getPtovtaSeguroList() { List lista = new ArrayList(); - for (PtoVtaSeguro ck : ptovtaSeguroList ){ - if (ck.getActivo()){ + for (PtoVtaSeguro ck : ptovtaSeguroList) { + if (ck.getActivo()) { lista.add(ck); } } @@ -719,8 +723,8 @@ public class PuntoVenta implements Serializable { public void setPtovtaSeguroList(List ptovtaSeguroList) { this.ptovtaSeguroList = ptovtaSeguroList; } - - public PtoVtaSeguro addPtovtaSeguro(PtoVtaSeguro pto){ + + public PtoVtaSeguro addPtovtaSeguro(PtoVtaSeguro pto) { PtoVtaSeguro pt = new PtoVtaSeguro(); pt.setPuntoventaId(pto.getPuntoventaId()); pt.setEmpresa(pto.getEmpresa()); @@ -732,9 +736,36 @@ public class PuntoVenta implements Serializable { this.ptovtaSeguroList.add(pt); return pt; } - - public void removePtovtaSeguro(PtoVtaSeguro pto){ + + public void removePtovtaSeguro(PtoVtaSeguro pto) { this.ptovtaSeguroList.remove(pto); } + public List getPtovtaCatIndList() { + List lista = new ArrayList(); + for (PtovtaCatInd ck : ptovtaCatIndList) { + if (ck.getActivo()) { + lista.add(ck); + } + } + return lista; + } + + public void setPtovtaCatIndList(List ptovtaCatIndList) { + this.ptovtaCatIndList = ptovtaCatIndList; + } + + public PtovtaCatInd addPtovtaCatInd(PtovtaCatInd pto) { + pto.setActivo(Boolean.TRUE); + pto.setFecmodif(Calendar.getInstance().getTime()); + pto.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + + this.ptovtaCatIndList.add(pto); + return pto; + } + + public void removePtovtaCatInd(PtovtaCatInd pto) { + this.ptovtaCatIndList.remove(pto); + } + } diff --git a/src/com/rjconsultores/ventaboletos/service/PtovtaCatIndService.java b/src/com/rjconsultores/ventaboletos/service/PtovtaCatIndService.java new file mode 100644 index 000000000..847c470a8 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/PtovtaCatIndService.java @@ -0,0 +1,6 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.PtovtaCatInd; + +public interface PtovtaCatIndService extends GenericService { +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PtovtaCatIndServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PtovtaCatIndServiceImpl.java new file mode 100644 index 000000000..cfdef1f35 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/PtovtaCatIndServiceImpl.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.PtovtaCatIndDAO; +import com.rjconsultores.ventaboletos.entidad.PtovtaCatInd; +import com.rjconsultores.ventaboletos.service.PtovtaCatIndService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("ptovtaCatIndService") +public class PtovtaCatIndServiceImpl implements PtovtaCatIndService { + + @Autowired + private PtovtaCatIndDAO ptovtaCatIndDAO; + + @Override + public List obtenerTodos() { + return ptovtaCatIndDAO.obtenerTodos(); + } + + @Override + public PtovtaCatInd obtenerID(Integer id) { + return ptovtaCatIndDAO.obtenerID(id); + } + + @Override + @Transactional + public PtovtaCatInd suscribir(PtovtaCatInd entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + return ptovtaCatIndDAO.suscribir(entidad); + } + + @Override + @Transactional + public PtovtaCatInd actualizacion(PtovtaCatInd entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + return ptovtaCatIndDAO.actualizacion(entidad); + } + + @Override + @Transactional + public void borrar(PtovtaCatInd entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + ptovtaCatIndDAO.actualizacion(entidad); + + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java index ba4be04b4..cebbd9d5a 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/PuntoVentaServiceImpl.java @@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.rjconsultores.ventaboletos.dao.EstacionDAO; import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO; import com.rjconsultores.ventaboletos.dao.UsuarioUbicacionDAO; import com.rjconsultores.ventaboletos.entidad.Empresa; @@ -20,7 +19,6 @@ import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.entidad.Usuario; import com.rjconsultores.ventaboletos.service.PuntoVentaService; -import com.rjconsultores.ventaboletos.service.UsuarioUbicacionService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; /**