From 4cbd5de4e970fdb9437c0d4d2bc756874df00f18 Mon Sep 17 00:00:00 2001 From: wilian Date: Thu, 4 Feb 2016 17:09:49 +0000 Subject: [PATCH] mantis #6989 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@52647 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/TarifaMinimaDAO.java | 6 + .../hibernate/TarifaMinimaHibernateDAO.java | 15 +++ .../ventaboletos/entidad/TarifaMinima.java | 19 ++- .../entidad/TarifaMinimaCategoria.java | 120 ++++++++++++++++++ .../service/TarifaMinimaService.java | 6 + .../service/impl/TarifaMinimaServiceImpl.java | 18 +++ 6 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 src/com/rjconsultores/ventaboletos/entidad/TarifaMinimaCategoria.java diff --git a/src/com/rjconsultores/ventaboletos/dao/TarifaMinimaDAO.java b/src/com/rjconsultores/ventaboletos/dao/TarifaMinimaDAO.java index f53f3e246..d0f302f9a 100644 --- a/src/com/rjconsultores/ventaboletos/dao/TarifaMinimaDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/TarifaMinimaDAO.java @@ -11,6 +11,7 @@ import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.Plaza; import com.rjconsultores.ventaboletos.entidad.TarifaMinima; +import com.rjconsultores.ventaboletos.entidad.TarifaMinimaCategoria; import java.math.BigDecimal; import java.util.List; @@ -45,4 +46,9 @@ public interface TarifaMinimaDAO extends GenericDAO { public List buscarPorClaseServicioMoneda(ClaseServicio claseServicio, Moneda moneda); + + public TarifaMinimaCategoria adicionarTarifaMinimaCategoria(TarifaMinimaCategoria tarifaMinimaCategoria); + + public void removerTarifaMinimaCategoria(TarifaMinimaCategoria tarifaMinimaCategoria); + } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/TarifaMinimaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/TarifaMinimaHibernateDAO.java index f60aa07de..05627dc6a 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/TarifaMinimaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/TarifaMinimaHibernateDAO.java @@ -12,6 +12,7 @@ import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.Plaza; import com.rjconsultores.ventaboletos.entidad.TarifaMinima; +import com.rjconsultores.ventaboletos.entidad.TarifaMinimaCategoria; import java.math.BigDecimal; import java.util.List; @@ -24,6 +25,7 @@ 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 org.springframework.transaction.annotation.Transactional; /** * @@ -203,4 +205,17 @@ public class TarifaMinimaHibernateDAO extends GenericHibernateDAO tarifaMinimaCategorias; public TarifaMinima() { } @@ -193,4 +202,12 @@ public class TarifaMinima implements Serializable { public String toString() { return "com.rjconsultores.ventaboletos.entidad.TarifaMinima[tarifaminimaId=" + tarifaminimaId + "]"; } + + public java.util.List getTarifaMinimaCategorias() { + return tarifaMinimaCategorias; + } + + public void setTarifaMinimaCategorias(java.util.List tarifaMinimaCategorias) { + this.tarifaMinimaCategorias = tarifaMinimaCategorias; + } } diff --git a/src/com/rjconsultores/ventaboletos/entidad/TarifaMinimaCategoria.java b/src/com/rjconsultores/ventaboletos/entidad/TarifaMinimaCategoria.java new file mode 100644 index 000000000..12f597e99 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/TarifaMinimaCategoria.java @@ -0,0 +1,120 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +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 = "TARIFA_MINIMA_CATEGORIA_SEQ", sequenceName = "TARIFA_MINIMA_CATEGORIA_SEQ", allocationSize = 1) +@Table(name = "TARIFA_MINIMA_CATEGORIA") +public class TarifaMinimaCategoria implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "TARIFAMINIMACATEGORIA_ID") + @GeneratedValue(strategy = GenerationType.AUTO, generator = "TARIFA_MINIMA_CATEGORIA_SEQ") + private Long tarifaminimacategoriaId; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "CATEGORIA_ID") + private Categoria categoria; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "TARIFAMINIMA_ID") + private TarifaMinima tarifaMinima; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public Long getTarifaminimacategoriaId() { + return tarifaminimacategoriaId; + } + + public void setTarifaminimacategoriaId(Long tarifaminimacategoriaId) { + this.tarifaminimacategoriaId = tarifaminimacategoriaId; + } + + public Categoria getCategoria() { + return categoria; + } + + public void setCategoria(Categoria categoria) { + this.categoria = categoria; + } + + public TarifaMinima getTarifaMinima() { + return tarifaMinima; + } + + public void setTarifaMinima(TarifaMinima tarifaMinima) { + this.tarifaMinima = tarifaMinima; + } + + 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() { + final int prime = 31; + int result = 1; + result = prime * result + ((tarifaminimacategoriaId == null) ? 0 : tarifaminimacategoriaId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + TarifaMinimaCategoria other = (TarifaMinimaCategoria) obj; + if (tarifaminimacategoriaId == null) { + if (other.tarifaminimacategoriaId != null) + return false; + } else if (!tarifaminimacategoriaId.equals(other.tarifaminimacategoriaId)) + return false; + return true; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/service/TarifaMinimaService.java b/src/com/rjconsultores/ventaboletos/service/TarifaMinimaService.java index c5e7e3635..e838e9496 100644 --- a/src/com/rjconsultores/ventaboletos/service/TarifaMinimaService.java +++ b/src/com/rjconsultores/ventaboletos/service/TarifaMinimaService.java @@ -11,6 +11,7 @@ import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.Plaza; import com.rjconsultores.ventaboletos.entidad.TarifaMinima; +import com.rjconsultores.ventaboletos.entidad.TarifaMinimaCategoria; import java.math.BigDecimal; import java.util.List; @@ -42,4 +43,9 @@ public interface TarifaMinimaService extends GenericService buscarPorMarca(Marca marca, Moneda moneda); public List buscarPorClaseServico(ClaseServicio claseServicio, Moneda moneda); + + public TarifaMinimaCategoria adicionarTarifaMinimaCategoria(TarifaMinimaCategoria tarifaMinimaCategoria); + + public void removerTarifaMinimaCategoria(TarifaMinimaCategoria tarifaMinimaCategoria); + } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TarifaMinimaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TarifaMinimaServiceImpl.java index 503b3b993..ff21492fa 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/TarifaMinimaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/TarifaMinimaServiceImpl.java @@ -12,11 +12,13 @@ import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.Plaza; import com.rjconsultores.ventaboletos.entidad.TarifaMinima; +import com.rjconsultores.ventaboletos.entidad.TarifaMinimaCategoria; import com.rjconsultores.ventaboletos.service.TarifaMinimaService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import java.math.BigDecimal; import java.util.Calendar; +import java.util.Date; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -112,4 +114,20 @@ public class TarifaMinimaServiceImpl implements TarifaMinimaService { public List buscarPorPlazaMoneda(Plaza plaza, Moneda moneda) { return tarifaMinimaDAO.buscarPorPlazaMoneda(plaza, moneda); } + + @Override + public TarifaMinimaCategoria adicionarTarifaMinimaCategoria(TarifaMinimaCategoria tarifaMinimaCategoria) { + tarifaMinimaCategoria.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + tarifaMinimaCategoria.setFecmodif(new Date()); + tarifaMinimaCategoria.setActivo(Boolean.TRUE); + return tarifaMinimaDAO.adicionarTarifaMinimaCategoria(tarifaMinimaCategoria); + } + + @Override + public void removerTarifaMinimaCategoria(TarifaMinimaCategoria tarifaMinimaCategoria) { + tarifaMinimaCategoria.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + tarifaMinimaCategoria.setFecmodif(new Date()); + tarifaMinimaCategoria.setActivo(Boolean.FALSE); + tarifaMinimaDAO.removerTarifaMinimaCategoria(tarifaMinimaCategoria); + } }