From c85e0579c455ca9fdc054eb3fa8541e227e28dba Mon Sep 17 00:00:00 2001 From: frederico Date: Fri, 10 Aug 2018 18:12:43 +0000 Subject: [PATCH] bug#11650 dev:Lucas qua:Wallysson git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@84140 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/PricingEspecificoCategoriaDAO.java | 9 ++ ...ricingEspecificoCategoriaHibernateDAO.java | 40 +++++ .../entidad/PricingEspecifico.java | 26 ++-- .../entidad/PricingEspecificoCategoria.java | 145 ++++++++++++++++++ .../PricingEspecificoCategoriaService.java | 6 + ...PricingEspecificoCategoriaServiceImpl.java | 58 +++++++ .../impl/PricingEspecificoServiceImpl.java | 1 - 7 files changed, 273 insertions(+), 12 deletions(-) create mode 100644 src/com/rjconsultores/ventaboletos/dao/PricingEspecificoCategoriaDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/PricingEspecificoCategoriaHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/PricingEspecificoCategoria.java create mode 100644 src/com/rjconsultores/ventaboletos/service/PricingEspecificoCategoriaService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/PricingEspecificoCategoriaServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/PricingEspecificoCategoriaDAO.java b/src/com/rjconsultores/ventaboletos/dao/PricingEspecificoCategoriaDAO.java new file mode 100644 index 000000000..866ab1e67 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/PricingEspecificoCategoriaDAO.java @@ -0,0 +1,9 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.PricingEspecificoCategoria; + +public interface PricingEspecificoCategoriaDAO extends GenericDAO { + + Boolean isDuplicado(PricingEspecificoCategoria entidad); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/PricingEspecificoCategoriaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/PricingEspecificoCategoriaHibernateDAO.java new file mode 100644 index 000000000..24b1c6a82 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/PricingEspecificoCategoriaHibernateDAO.java @@ -0,0 +1,40 @@ +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.PricingEspecificoCategoriaDAO; +import com.rjconsultores.ventaboletos.entidad.PricingEspecificoCategoria; + +@Repository("pricingEspecificoCategoriaDAO") +public class PricingEspecificoCategoriaHibernateDAO extends GenericHibernateDAO implements PricingEspecificoCategoriaDAO { + + @Autowired + public PricingEspecificoCategoriaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @SuppressWarnings("unchecked") + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return c.list(); + } + + @Override + public Boolean isDuplicado(PricingEspecificoCategoria entidad) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("categoria.categoriaId", entidad.getCategoria().getCategoriaId())); + + return c.list().isEmpty(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/PricingEspecifico.java b/src/com/rjconsultores/ventaboletos/entidad/PricingEspecifico.java index fc0467f58..d217de0a2 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/PricingEspecifico.java +++ b/src/com/rjconsultores/ventaboletos/entidad/PricingEspecifico.java @@ -83,9 +83,6 @@ public class PricingEspecifico implements Serializable, Cloneable { @JoinColumn(name = "CLASESERVICIO_ID", referencedColumnName = "CLASESERVICIO_ID") @ManyToOne private ClaseServicio claseServicio; - @JoinColumn(name = "CATEGORIA_ID", referencedColumnName = "CATEGORIA_ID") - @ManyToOne - private Categoria categoria; @Column(name = "CORRIDA_ID") private Integer corridaId; @Column(name = "EXIBEVENDA") @@ -102,6 +99,10 @@ public class PricingEspecifico implements Serializable, Cloneable { @Where(clause="ACTIVO=1") private List pricingEspecificoCanalVendasList; + @OneToMany(mappedBy = "pricingEspecifico", cascade = CascadeType.ALL) + @LazyCollection(LazyCollectionOption.FALSE) + @Where(clause="ACTIVO=1") + private List pricingEspecificoCategoriaList; public PricingEspecifico() { } @@ -222,14 +223,6 @@ public class PricingEspecifico implements Serializable, Cloneable { this.claseServicio = claseServicio; } - public Categoria getCategoria() { - return categoria; - } - - public void setCategoria(Categoria categoria) { - this.categoria = categoria; - } - public String getNombPricing() { return nombPricing; } @@ -288,6 +281,17 @@ public class PricingEspecifico implements Serializable, Cloneable { this.pricingEspecificoCanalVendasList = pricingEspecificoCanalVendasList; } + public List getPricingEspecificoCategoriaList() { + if (this.pricingEspecificoCategoriaList == null) { + this.pricingEspecificoCategoriaList = new ArrayList(); + } + return pricingEspecificoCategoriaList; + } + + public void setPricingEspecificoCategoriaList(List pricingEspecificoCategoriaList) { + this.pricingEspecificoCategoriaList = pricingEspecificoCategoriaList; + } + @Override public int hashCode() { int hash = 0; diff --git a/src/com/rjconsultores/ventaboletos/entidad/PricingEspecificoCategoria.java b/src/com/rjconsultores/ventaboletos/entidad/PricingEspecificoCategoria.java new file mode 100644 index 000000000..32537dccb --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/PricingEspecificoCategoria.java @@ -0,0 +1,145 @@ +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 = "PRICING_ESP_CATEGORIA_SEQ", sequenceName = "PRICING_ESP_CATEGORIA_SEQ", allocationSize = 1) +@Table(name = "PRICING_ESPECIFICO_CATEGORIA") +public class PricingEspecificoCategoria implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer pricingEspecificoCategoriaId; + private PricingEspecifico pricingEspecifico; + private Categoria categoria; + private Boolean activo; + private Date fecmodif; + private Integer usuarioId; + + public PricingEspecificoCategoria() { + super(); + } + + public PricingEspecificoCategoria(Categoria categoria, PricingEspecifico pricingEspecifico, Integer usuarioId) { + this.pricingEspecifico = pricingEspecifico; + this.categoria = categoria; + this.usuarioId = usuarioId; + this.activo = true; + this.fecmodif = new Date(); + } + + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "PRICING_ESP_CATEGORIA_SEQ") + @Column(name = "PRICINGESPECIFICO_CATEGORIAID") + public Integer getPricingEspecificoCategoriaId() { + return pricingEspecificoCategoriaId; + } + + public void setPricingEspecificoCategoriaId(Integer pricingEspecificoCategoriaId) { + this.pricingEspecificoCategoriaId = pricingEspecificoCategoriaId; + } + + @JoinColumn(name = "PRICINGESPECIFICO_ID", referencedColumnName = "PRICINGESPECIFICO_ID") + @ManyToOne + public PricingEspecifico getPricingEspecifico() { + return pricingEspecifico; + } + + public void setPricingEspecifico(PricingEspecifico pricingEspecifico) { + this.pricingEspecifico = pricingEspecifico; + } + + @ManyToOne + @JoinColumn(name = "CATEGORIA_ID", referencedColumnName = "CATEGORIA_ID") + public Categoria getCategoria() { + return categoria; + } + + public void setCategoria(Categoria categoria) { + this.categoria = categoria; + } + + @Basic(optional = false) + @Column(name = "ACTIVO") + public Boolean getActivo() { + return activo; + } + + public void setActivo(Boolean activo) { + this.activo = activo; + } + + @Basic(optional = false) + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + public Date getFecmodif() { + return fecmodif; + } + + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + + @Basic(optional = false) + @Column(name = "USUARIO_ID") + public Integer getUsuarioId() { + return usuarioId; + } + + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((activo == null) ? 0 : activo.hashCode()); + result = prime * result + ((pricingEspecifico == null) ? 0 : pricingEspecifico.hashCode()); + result = prime * result + ((categoria == null) ? 0 : categoria.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; + PricingEspecificoCategoria other = (PricingEspecificoCategoria) obj; + if (activo == null) { + if (other.activo != null) + return false; + } else if (!activo.equals(other.activo)) + return false; + if (pricingEspecifico == null) { + if (other.pricingEspecifico != null) + return false; + } else if (!pricingEspecifico.equals(other.pricingEspecifico)) + return false; + if (categoria == null) { + if (other.categoria != null) + return false; + } else if (!categoria.equals(other.categoria)) + return false; + return true; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/PricingEspecificoCategoriaService.java b/src/com/rjconsultores/ventaboletos/service/PricingEspecificoCategoriaService.java new file mode 100644 index 000000000..ee139fc52 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/PricingEspecificoCategoriaService.java @@ -0,0 +1,6 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.PricingEspecificoCategoria; + +public interface PricingEspecificoCategoriaService extends GenericService { +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PricingEspecificoCategoriaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PricingEspecificoCategoriaServiceImpl.java new file mode 100644 index 000000000..61f19ca49 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/PricingEspecificoCategoriaServiceImpl.java @@ -0,0 +1,58 @@ +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.PricingEspecificoCategoriaDAO; +import com.rjconsultores.ventaboletos.entidad.PricingEspecificoCategoria; +import com.rjconsultores.ventaboletos.service.PricingEspecificoCategoriaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("pricingEspecificoCategoriaService") +public class PricingEspecificoCategoriaServiceImpl implements PricingEspecificoCategoriaService { + @Autowired + private PricingEspecificoCategoriaDAO pricingEspecificoCategoriaDAO; + + @Override + public List obtenerTodos() { + return pricingEspecificoCategoriaDAO.obtenerTodos(); + } + + @Override + public PricingEspecificoCategoria obtenerID(Long id) { + return pricingEspecificoCategoriaDAO.obtenerID(id); + } + + @Override + @Transactional + public PricingEspecificoCategoria suscribir(PricingEspecificoCategoria entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setActivo(Boolean.TRUE); + + return pricingEspecificoCategoriaDAO.suscribir(entidad); + } + + @Override + @Transactional + public PricingEspecificoCategoria actualizacion(PricingEspecificoCategoria entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + + return pricingEspecificoCategoriaDAO.actualizacion(entidad); + } + + @Override + @Transactional + public void borrar(PricingEspecificoCategoria entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + pricingEspecificoCategoriaDAO.actualizacion(entidad); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/PricingEspecificoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/PricingEspecificoServiceImpl.java index b264aeb7f..b1228d4a8 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/PricingEspecificoServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/PricingEspecificoServiceImpl.java @@ -85,7 +85,6 @@ public class PricingEspecificoServiceImpl implements PricingEspecificoService { PricingEspecifico clonePricing = new PricingEspecifico(); clonePricing.setNombPricing(nome); - clonePricing.setCategoria(pricingToClone.getCategoria()); clonePricing.setClaseServicio(pricingToClone.getClaseServicio()); clonePricing.setCorridaId(pricingToClone.getCorridaId()); clonePricing.setFechorfin(pricingToClone.getFechorfin());