From b74a6c52753709e0d326b85167174ac6ceccece2 Mon Sep 17 00:00:00 2001 From: rafael Date: Mon, 3 Sep 2012 21:06:18 +0000 Subject: [PATCH] Seguro Tarifa git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@20998 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/SeguroTarifaDAO.java | 22 ++++-- .../hibernate/SeguroTarifaHibernateDAO.java | 37 ++++++---- .../ventaboletos/entidad/SeguroTarifa.java | 73 ++++++++++--------- .../service/SeguroTarifaService.java | 9 ++- .../service/impl/SeguroTarifaServiceImpl.java | 47 +++++++++++- 5 files changed, 125 insertions(+), 63 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/SeguroTarifaDAO.java b/src/com/rjconsultores/ventaboletos/dao/SeguroTarifaDAO.java index d6397db56..385d550e6 100644 --- a/src/com/rjconsultores/ventaboletos/dao/SeguroTarifaDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/SeguroTarifaDAO.java @@ -1,12 +1,18 @@ package com.rjconsultores.ventaboletos.dao; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; +import com.rjconsultores.ventaboletos.entidad.SeguroTarifa; +import java.util.List; -public interface SeguroTarifaDAO { - /** - * Indica se existe seguroTarifa para o orgaoConcedenteId informado - * - * @param orgaoConcedenteId - * @return - */ - public boolean existe(Integer orgaoConcedenteId); +public interface SeguroTarifaDAO extends GenericDAO { + + /** + * Indica se existe seguroTarifa para o orgaoConcedenteId informado + * + * @param orgaoConcedenteId + * @return + */ + public boolean existe(Integer orgaoConcedenteId); + + public List buscarPorOrgao(OrgaoConcedente orgao); } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/SeguroTarifaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/SeguroTarifaHibernateDAO.java index d061af40e..a70c505db 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/SeguroTarifaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/SeguroTarifaHibernateDAO.java @@ -9,25 +9,34 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import com.rjconsultores.ventaboletos.entidad.SeguroTarifa; +import java.util.List; @Repository("seguroTarifaDAO") public class SeguroTarifaHibernateDAO extends GenericHibernateDAO implements SeguroTarifaDAO { - @Autowired - public SeguroTarifaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { - setSessionFactory(factory); - } + @Autowired + public SeguroTarifaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } - @Override - public boolean existe(Integer orgaoConcedenteId) { - Criteria c= makeCriteria(); - c.add(Restrictions.eq("orgaoconcedente.orgaoConcedenteId", orgaoConcedenteId)); - c.add(Restrictions.eq("activo", Boolean.TRUE)); - c.setProjection(Projections.rowCount()); - - - return HibernateFix.count(c.list()) > 0; - } + @Override + public boolean existe(Integer orgaoConcedenteId) { + Criteria c = makeCriteria(); + c.add(Restrictions.eq("orgaoconcedente.orgaoConcedenteId", orgaoConcedenteId)); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.setProjection(Projections.rowCount()); + + return HibernateFix.count(c.list()) > 0; + } + + public List buscarPorOrgao(OrgaoConcedente orgao) { + Criteria c = makeCriteria(); + c.add(Restrictions.eq("orgaoconcedente", orgao)); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return c.list(); + } } diff --git a/src/com/rjconsultores/ventaboletos/entidad/SeguroTarifa.java b/src/com/rjconsultores/ventaboletos/entidad/SeguroTarifa.java index 9a42d090e..1387c5859 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/SeguroTarifa.java +++ b/src/com/rjconsultores/ventaboletos/entidad/SeguroTarifa.java @@ -11,9 +11,12 @@ 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; @@ -23,14 +26,17 @@ import javax.persistence.TemporalType; * @author gleimar */ @Entity +@SequenceGenerator(name = "SEGURO_TARIFA_SEQ", sequenceName = "SEGURO_TARIFA_SEQ", allocationSize = 1) @Table(name = "SEGURO_TARIFA") public class SeguroTarifa implements Serializable { + private static final long serialVersionUID = 1L; @Id @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEGURO_TARIFA_SEQ") @Column(name = "SEGUROTARIFA_ID") private Integer segurotarifaId; - @Column(name = "VALORTARIFA") + @Column(name = "VALORTAXA") private BigDecimal valortarifa; @Column(name = "VALORTARIFAATE") private BigDecimal valortarifaate; @@ -44,7 +50,7 @@ public class SeguroTarifa implements Serializable { private Date fecmodif; @Column(name = "USUARIO_ID") private Integer usuarioId; - + public SeguroTarifa() { } @@ -68,8 +74,6 @@ public class SeguroTarifa implements Serializable { this.valortarifa = valortarifa; } - - @Override public int hashCode() { int hash = 0; @@ -95,44 +99,43 @@ public class SeguroTarifa implements Serializable { return "com.rjconsultores.ventaboletos.entidad.SeguroTarifa[ segurotarifaId=" + segurotarifaId + " ]"; } - public BigDecimal getValortarifaate() { - return valortarifaate; - } + public BigDecimal getValortarifaate() { + return valortarifaate; + } - public void setValortarifaate(BigDecimal valortarifaate) { - this.valortarifaate = valortarifaate; - } + public void setValortarifaate(BigDecimal valortarifaate) { + this.valortarifaate = valortarifaate; + } - public OrgaoConcedente getOrgaoconcedente() { - return orgaoconcedente; - } + public OrgaoConcedente getOrgaoconcedente() { + return orgaoconcedente; + } - public void setOrgaoconcedente(OrgaoConcedente orgaoconcedente) { - this.orgaoconcedente = orgaoconcedente; - } + public void setOrgaoconcedente(OrgaoConcedente orgaoconcedente) { + this.orgaoconcedente = orgaoconcedente; + } - public Boolean getActivo() { - return activo; - } + public Boolean getActivo() { + return activo; + } - public void setActivo(Boolean activo) { - this.activo = activo; - } + public void setActivo(Boolean activo) { + this.activo = activo; + } - public Date getFecmodif() { - return fecmodif; - } + public Date getFecmodif() { + return fecmodif; + } - public void setFecmodif(Date fecmodif) { - this.fecmodif = fecmodif; - } + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } - public Integer getUsuarioId() { - return usuarioId; - } + public Integer getUsuarioId() { + return usuarioId; + } - public void setUsuarioId(Integer usuarioId) { - this.usuarioId = usuarioId; - } - + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } } diff --git a/src/com/rjconsultores/ventaboletos/service/SeguroTarifaService.java b/src/com/rjconsultores/ventaboletos/service/SeguroTarifaService.java index e36e20357..eba6ecc50 100644 --- a/src/com/rjconsultores/ventaboletos/service/SeguroTarifaService.java +++ b/src/com/rjconsultores/ventaboletos/service/SeguroTarifaService.java @@ -1,7 +1,12 @@ package com.rjconsultores.ventaboletos.service; -import com.rjconsultores.ventaboletos.exception.BusinessException; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; +import com.rjconsultores.ventaboletos.entidad.SeguroTarifa; +import java.util.List; -public interface SeguroTarifaService { + +public interface SeguroTarifaService extends GenericService{ + + public List buscarPorOrgao(OrgaoConcedente orgao); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/SeguroTarifaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/SeguroTarifaServiceImpl.java index e8e889a12..45f82b025 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/SeguroTarifaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/SeguroTarifaServiceImpl.java @@ -1,17 +1,56 @@ package com.rjconsultores.ventaboletos.service.impl; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; +import com.rjconsultores.ventaboletos.entidad.SeguroTarifa; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO; import com.rjconsultores.ventaboletos.service.SeguroTarifaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; +import java.util.Calendar; +import org.springframework.transaction.annotation.Transactional; @Service("seguroTarifaService") public class SeguroTarifaServiceImpl implements SeguroTarifaService { - - @Autowired - private SeguroTarifaDAO seguroTarifaDAO; - + @Autowired + private SeguroTarifaDAO seguroTarifaDAO; + public List obtenerTodos() { + return seguroTarifaDAO.obtenerTodos(); + } + + public SeguroTarifa obtenerID(Integer id) { + return seguroTarifaDAO.obtenerID(id); + } + + @Transactional + public SeguroTarifa suscribir(SeguroTarifa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + return seguroTarifaDAO.suscribir(entidad); + } + + @Transactional + public SeguroTarifa actualizacion(SeguroTarifa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + return seguroTarifaDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(SeguroTarifa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + seguroTarifaDAO.borrar(entidad); + } + + public List buscarPorOrgao(OrgaoConcedente orgao) { + return seguroTarifaDAO.buscarPorOrgao(orgao); + } }