From 7d84e96f946daa4d22b5f36c3c43a700e0fc2367 Mon Sep 17 00:00:00 2001 From: rodrigo Date: Mon, 13 Aug 2012 22:10:46 +0000 Subject: [PATCH] git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@20435 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/OrgaoConcedenteDAO.java | 10 ++ .../OrgaoConcedenteHibernateDAO.java | 42 ++++++ .../ventaboletos/entidad/OrgaoConcedente.java | 122 ++++++++++++++++++ .../service/OrgaoConcedenteService.java | 10 ++ .../impl/OrgaoConcedenteServiceImpl.java | 59 +++++++++ 5 files changed, 243 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/OrgaoConcedenteDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/OrgaoConcedenteHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/OrgaoConcedente.java create mode 100644 src/com/rjconsultores/ventaboletos/service/OrgaoConcedenteService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/OrgaoConcedenteServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/OrgaoConcedenteDAO.java b/src/com/rjconsultores/ventaboletos/dao/OrgaoConcedenteDAO.java new file mode 100644 index 000000000..b3bc62706 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/OrgaoConcedenteDAO.java @@ -0,0 +1,10 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; + +public interface OrgaoConcedenteDAO extends GenericDAO{ + + public List buscar(String desc); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/OrgaoConcedenteHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/OrgaoConcedenteHibernateDAO.java new file mode 100644 index 000000000..ff408269a --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/OrgaoConcedenteHibernateDAO.java @@ -0,0 +1,42 @@ +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.OrgaoConcedenteDAO; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; + +@Repository("orgaoConcedenteDAO") +public class OrgaoConcedenteHibernateDAO extends GenericHibernateDAO + implements OrgaoConcedenteDAO { + + @Autowired + public OrgaoConcedenteHibernateDAO(@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(); + } + + @SuppressWarnings("unchecked") + @Override + public List buscar(String desc) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.like("descOrgao", desc)); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return c.list(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/OrgaoConcedente.java b/src/com/rjconsultores/ventaboletos/entidad/OrgaoConcedente.java new file mode 100644 index 000000000..be6d49ed8 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/OrgaoConcedente.java @@ -0,0 +1,122 @@ +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.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@SequenceGenerator(name = "ORGAO_CONCEDENTE_SEQ", sequenceName = "ORGAO_CONCEDENTE_SEQ", allocationSize = 1) +@Table(name = "ORGAO_CONCEDENTE") +public class OrgaoConcedente implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "ORGAO_CONCEDENTE_SEQ") + @Column(name = "ORGAOCONCEDENTE_ID") + private Integer orgaoConcedenteId; + @Column(name = "DESCORGAO") + private String descOrgao; + @Column(name = "INDDEFAULTSEGURO") + private Boolean indDefaultSeguro; + @Column(name = "INDSUBSEGURO") + private Boolean indSubSeguro; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public Integer getOrgaoConcedenteId() { + return orgaoConcedenteId; + } + + public void setOrgaoConcedenteId(Integer orgaoConcedenteId) { + this.orgaoConcedenteId = orgaoConcedenteId; + } + + public String getDescOrgao() { + return descOrgao; + } + + public void setDescOrgao(String descOrgao) { + this.descOrgao = descOrgao; + } + + public Boolean getIndSubSeguro() { + return indSubSeguro; + } + + public void setIndSubSeguro(Boolean indSubSeguro) { + this.indSubSeguro = indSubSeguro; + } + + public Boolean getIndDefaultSeguro() { + return indDefaultSeguro; + } + + public void setIndDefaultSeguro(Boolean indDefaultSeguro) { + this.indDefaultSeguro = indDefaultSeguro; + } + + 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 + ((orgaoConcedenteId == null) ? 0 : orgaoConcedenteId.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; + OrgaoConcedente other = (OrgaoConcedente) obj; + if (orgaoConcedenteId == null) { + if (other.orgaoConcedenteId != null) + return false; + } else if (!orgaoConcedenteId.equals(other.orgaoConcedenteId)) + return false; + return true; + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/OrgaoConcedenteService.java b/src/com/rjconsultores/ventaboletos/service/OrgaoConcedenteService.java new file mode 100644 index 000000000..d40c74732 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/OrgaoConcedenteService.java @@ -0,0 +1,10 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; + +public interface OrgaoConcedenteService extends GenericService { + + public List buscar(String desc); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/OrgaoConcedenteServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/OrgaoConcedenteServiceImpl.java new file mode 100644 index 000000000..33691e37f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/OrgaoConcedenteServiceImpl.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.OrgaoConcedenteDAO; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; +import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("orgaoConcedenteService") +public class OrgaoConcedenteServiceImpl implements OrgaoConcedenteService { + + @Autowired + private OrgaoConcedenteDAO orgaoConcedenteDAO; + + public List obtenerTodos() { + return orgaoConcedenteDAO.obtenerTodos(); + } + + public OrgaoConcedente obtenerID(Integer id) { + return orgaoConcedenteDAO.obtenerID(id); + } + + @Transactional + public OrgaoConcedente suscribir(OrgaoConcedente entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return orgaoConcedenteDAO.suscribir(entidad); + } + + @Transactional + public OrgaoConcedente actualizacion(OrgaoConcedente entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return orgaoConcedenteDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(OrgaoConcedente entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + orgaoConcedenteDAO.actualizacion(entidad); + } + + public List buscar(String desc) { + return orgaoConcedenteDAO.buscar(desc); + } +}