From 8b5887dbe5d6907200608c75a699406b2b097ced Mon Sep 17 00:00:00 2001 From: thiago Date: Fri, 24 Feb 2017 20:32:43 +0000 Subject: [PATCH] =?UTF-8?q?fixed=20bug=20#8662=20-=20Altera=C3=A7=C3=A3o?= =?UTF-8?q?=20em=20c=C3=B3digo=20para=20permitir=20a=20restri=C3=A7=C3=A3o?= =?UTF-8?q?=20do=20tipo=20de=20OCD=20por=20ponto=20de=20venda.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@66279 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/OCDPtoVtaParamDAO.java | 14 +++ .../hibernate/OCDPtoVtaParamHibernateDAO.java | 51 ++++++++++ .../ventaboletos/entidad/OCDParam.java | 42 +++++++++ .../ventaboletos/entidad/OCDPtoVtaParam.java | 94 +++++++++++++++++++ .../service/OCDPtoVtaParamService.java | 22 +++++ .../impl/OCDPtoVtaParamServiceImpl.java | 52 ++++++++++ 6 files changed, 275 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/OCDPtoVtaParamDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/OCDPtoVtaParamHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/OCDPtoVtaParam.java create mode 100644 src/com/rjconsultores/ventaboletos/service/OCDPtoVtaParamService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/OCDPtoVtaParamServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/OCDPtoVtaParamDAO.java b/src/com/rjconsultores/ventaboletos/dao/OCDPtoVtaParamDAO.java new file mode 100644 index 000000000..8751f0bf2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/OCDPtoVtaParamDAO.java @@ -0,0 +1,14 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.OCDPtoVtaParam; + +/** + * @author Thiago + * + */ +public interface OCDPtoVtaParamDAO extends GenericDAO { + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/OCDPtoVtaParamHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/OCDPtoVtaParamHibernateDAO.java new file mode 100644 index 000000000..c38962b7f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/OCDPtoVtaParamHibernateDAO.java @@ -0,0 +1,51 @@ +/** + * + */ +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.OCDPtoVtaParamDAO; +import com.rjconsultores.ventaboletos.entidad.OCDPtoVtaParam; +import com.rjconsultores.ventaboletos.entidad.PtoVtaCheckin; + +/** + * @author Thiago + * + */ +@Repository("ocdPtoVtaParamDAO") +public class OCDPtoVtaParamHibernateDAO extends GenericHibernateDAO +implements OCDPtoVtaParamDAO { + + @Autowired + public OCDPtoVtaParamHibernateDAO( + @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("ptoVtaCheckinId")); + + return c.list(); + } + + public List buscar(int id) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("ptoVtaCheckinId", id)); + + return c.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/OCDParam.java b/src/com/rjconsultores/ventaboletos/entidad/OCDParam.java index 4aae6b575..36f5a4cf1 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/OCDParam.java +++ b/src/com/rjconsultores/ventaboletos/entidad/OCDParam.java @@ -1,8 +1,11 @@ package com.rjconsultores.ventaboletos.entidad; import java.math.BigDecimal; +import java.util.Calendar; import java.util.Date; +import java.util.List; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -10,11 +13,17 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; + +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + @Entity @Table(name = "OCD_PARAM") public class OCDParam implements java.io.Serializable { @@ -40,6 +49,7 @@ public class OCDParam implements java.io.Serializable { private Boolean indOcdDinheiro; private Boolean indtotalbilhete; private BigDecimal tiempoLimitePenalizacion; + private List listOCDPtoVtaParam; public OCDParam(Long ocdparamId, BigDecimal penalizacion, Integer diasPagar, PuntoVenta puntoventa, Empresa empresa, @@ -211,6 +221,38 @@ public class OCDParam implements java.io.Serializable { public void setTiempoLimitePenalizacion(BigDecimal tiempoLimitePenalizacion) { this.tiempoLimitePenalizacion = tiempoLimitePenalizacion; + } + + public OCDPtoVtaParam addOCDPtoVtaParam(OCDPtoVtaParam ocdPtoVtaParam) { + OCDPtoVtaParam ocd = new OCDPtoVtaParam(); + ocd.setPuntoventa(ocdPtoVtaParam.getPuntoventa()); + ocd.setOcdParam(ocdPtoVtaParam.getOcdParam()); + ocd.setActivo(Boolean.TRUE); + ocd.setFecmodif(Calendar.getInstance().getTime()); + ocd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + this.listOCDPtoVtaParam.add(ocd); + return ocd; + } + public void removePtovtaOCDParam(OCDPtoVtaParam ocdPtoVtaParam) { + this.listOCDPtoVtaParam.remove(ocdPtoVtaParam); + + } + + /** + * @return the listOCDPtoVtaParam + * + */ + @OneToMany(cascade = CascadeType.ALL, mappedBy = "ocdParam") + @LazyCollection(LazyCollectionOption.FALSE) + public List getListOCDPtoVtaParam() { + return listOCDPtoVtaParam; + } + + /** + * @param listOCDPtoVtaParam the listOCDPtoVtaParam to set + */ + public void setListOCDPtoVtaParam(List listOCDPtoVtaParam) { + this.listOCDPtoVtaParam = listOCDPtoVtaParam; } } \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/entidad/OCDPtoVtaParam.java b/src/com/rjconsultores/ventaboletos/entidad/OCDPtoVtaParam.java new file mode 100644 index 000000000..fd7bccc00 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/OCDPtoVtaParam.java @@ -0,0 +1,94 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.entidad; + +import java.util.Date; + +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; + +/** + * @author Thiago + * + */ +@Entity +@Table(name = "OCD_PTOVTA_PARAM") +public class OCDPtoVtaParam { + + private Long ocdPtoVtaParamId; + private OCDParam ocdParam; + private Boolean activo; + private Date fecmodif; + private Integer usuarioId; + private PuntoVenta puntoventa; + + @SequenceGenerator(name = "OCD_PTOVTA_PARAM_SEQ", sequenceName = "OCD_PTOVTA_PARAM_SEQ", allocationSize = 1) + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "OCD_PTOVTA_PARAM_SEQ") + @Column(name = "OCDPTOVTAPARAM_ID", unique = true, nullable = false, precision = 15, scale = 0) + public Long getOcdPtoVtaParamId() { + return ocdPtoVtaParamId; + } + + public void setOcdPtoVtaParamId(Long ocdPtoVtaParamId) { + this.ocdPtoVtaParamId = ocdPtoVtaParamId; + } + + @JoinColumn(name = "OCDPARAM_ID", referencedColumnName="OCDPARAM_ID") + @ManyToOne + public OCDParam getOcdParam() { + return ocdParam; + } + + public void setOcdParam(OCDParam ocdParam) { + this.ocdParam = ocdParam; + } + @Column(name = "ACTIVO", precision = 1, scale = 0) + public Boolean getActivo() { + return activo; + } + + public void setActivo(Boolean activo) { + this.activo = activo; + } + + @Temporal(TemporalType.DATE) + @Column(name = "FECMODIF", length = 7) + public Date getFecmodif() { + return fecmodif; + } + + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + + @Column(name = "USUARIO_ID", precision = 7, scale = 0) + public Integer getUsuarioId() { + return usuarioId; + } + + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } + + @JoinColumn(name = "PUNTOVENTA_ID") + @ManyToOne + public PuntoVenta getPuntoventa() { + return puntoventa; + } + + public void setPuntoventa(PuntoVenta puntoventa) { + this.puntoventa = puntoventa; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/OCDPtoVtaParamService.java b/src/com/rjconsultores/ventaboletos/service/OCDPtoVtaParamService.java new file mode 100644 index 000000000..7cefd6ec9 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/OCDPtoVtaParamService.java @@ -0,0 +1,22 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.OCDPtoVtaParam; + +/** + * @author Thiago + * + */ +public interface OCDPtoVtaParamService extends GenericService { + + public List obtenerTodos(); + + public OCDPtoVtaParam obtenerID(Long id); + + public void borrar(OCDPtoVtaParam entidad); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/OCDPtoVtaParamServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/OCDPtoVtaParamServiceImpl.java new file mode 100644 index 000000000..f01a2c316 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/OCDPtoVtaParamServiceImpl.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.OCDPtoVtaParamDAO; +import com.rjconsultores.ventaboletos.entidad.OCDPtoVtaParam; +import com.rjconsultores.ventaboletos.service.OCDPtoVtaParamService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("ocdPtoVtaParamService") +public class OCDPtoVtaParamServiceImpl implements OCDPtoVtaParamService { + + @Autowired + private OCDPtoVtaParamDAO ocdPtoVtaParamDAO; + + @Override + public List obtenerTodos() { + return ocdPtoVtaParamDAO.obtenerTodos(); + } + + @Override + public OCDPtoVtaParam obtenerID(Long id) { + return ocdPtoVtaParamDAO.obtenerID(id); + } + + @Override + @Transactional(readOnly = false) + public OCDPtoVtaParam suscribir(OCDPtoVtaParam entidad) { + return ocdPtoVtaParamDAO.suscribir(entidad); + } + + @Override + @Transactional(readOnly = false) + public OCDPtoVtaParam actualizacion(OCDPtoVtaParam entidad) { + return ocdPtoVtaParamDAO.actualizacion(entidad); + } + + @Override + @Transactional(readOnly = false) + public void borrar(OCDPtoVtaParam entidad) { + entidad.setActivo(Boolean.FALSE); + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + ocdPtoVtaParamDAO.actualizacion(entidad); + } + +}