From b59ba1dabd115ba9372ee4874a2ffea9cf42ec29 Mon Sep 17 00:00:00 2001 From: rodrigo Date: Tue, 14 Aug 2012 19:08:52 +0000 Subject: [PATCH] git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@20490 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/CoeficienteTarifaDAO.java | 10 ++ .../CoeficienteTarifaHibernateDAO.java | 46 +++++++ .../entidad/CoeficienteTarifa.java | 113 ++++++++++++++++++ .../service/CoeficienteTarifaService.java | 7 ++ .../impl/CoeficienteTarifaServiceImpl.java | 59 +++++++++ 5 files changed, 235 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/CoeficienteTarifaDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/CoeficienteTarifaHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/CoeficienteTarifa.java create mode 100644 src/com/rjconsultores/ventaboletos/service/CoeficienteTarifaService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/CoeficienteTarifaServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/CoeficienteTarifaDAO.java b/src/com/rjconsultores/ventaboletos/dao/CoeficienteTarifaDAO.java new file mode 100644 index 000000000..941c43316 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/CoeficienteTarifaDAO.java @@ -0,0 +1,10 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.CoeficienteTarifa; + +public interface CoeficienteTarifaDAO extends GenericDAO { + + public List buscar(String nomb); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/CoeficienteTarifaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/CoeficienteTarifaHibernateDAO.java new file mode 100644 index 000000000..825fdc658 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/CoeficienteTarifaHibernateDAO.java @@ -0,0 +1,46 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.MatchMode; +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.CoeficienteTarifaDAO; +import com.rjconsultores.ventaboletos.entidad.CoeficienteTarifa; + +@Repository("coeficienteTarifaDAO") +public class CoeficienteTarifaHibernateDAO extends GenericHibernateDAO + implements CoeficienteTarifaDAO { + + @Autowired + public CoeficienteTarifaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @SuppressWarnings("unchecked") + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.addOrder(Order.asc("descCoeficiente")); + + return c.list(); + } + + @SuppressWarnings("unchecked") + @Override + public List buscar(String nomb) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.ilike("descCoeficiente", nomb, MatchMode.START)); + c.addOrder(Order.asc("descCoeficiente")); + + return c.list(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/CoeficienteTarifa.java b/src/com/rjconsultores/ventaboletos/entidad/CoeficienteTarifa.java new file mode 100644 index 000000000..e027d84c2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/CoeficienteTarifa.java @@ -0,0 +1,113 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.math.BigDecimal; +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 = "COEFICIENTE_TARIFA_SEQ", sequenceName = "COEFICIENTE_TARIFA_SEQ", allocationSize = 1) +@Table(name = "COEFICIENTE_TARIFA") +public class CoeficienteTarifa implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "COEFICIENTE_TARIFA_SEQ") + @Column(name = "COEFICIENTETARIFA_ID") + private Integer coeficienteId; + @Column(name = "DESCCOEFICIENTE") + private String descCoeficiente; + @Column(name = "COEFICIENTE") + private BigDecimal coeficiente; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + public Integer getCoeficienteId() { + return coeficienteId; + } + + public void setCoeficienteId(Integer coeficienteId) { + this.coeficienteId = coeficienteId; + } + + public String getDescCoeficiente() { + return descCoeficiente; + } + + public void setDescCoeficiente(String descCoeficiente) { + this.descCoeficiente = descCoeficiente; + } + + public BigDecimal getCoeficiente() { + return coeficiente; + } + + public void setCoeficiente(BigDecimal coeficiente) { + this.coeficiente = coeficiente; + } + + 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 + ((coeficienteId == null) ? 0 : coeficienteId.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; + CoeficienteTarifa other = (CoeficienteTarifa) obj; + if (coeficienteId == null) { + if (other.coeficienteId != null) + return false; + } else if (!coeficienteId.equals(other.coeficienteId)) + return false; + return true; + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/CoeficienteTarifaService.java b/src/com/rjconsultores/ventaboletos/service/CoeficienteTarifaService.java new file mode 100644 index 000000000..00e2c8092 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/CoeficienteTarifaService.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.CoeficienteTarifa; + +public interface CoeficienteTarifaService extends GenericService{ + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/CoeficienteTarifaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/CoeficienteTarifaServiceImpl.java new file mode 100644 index 000000000..30087099d --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/CoeficienteTarifaServiceImpl.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.CoeficienteTarifaDAO; +import com.rjconsultores.ventaboletos.entidad.CoeficienteTarifa; +import com.rjconsultores.ventaboletos.service.CoeficienteTarifaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("coeficienteTarifaService") +public class CoeficienteTarifaServiceImpl implements CoeficienteTarifaService { + + @Autowired + private CoeficienteTarifaDAO coeficienteTarifaDAO; + + public List obtenerTodos() { + return coeficienteTarifaDAO.obtenerTodos(); + } + + public CoeficienteTarifa obtenerID(Integer id) { + return coeficienteTarifaDAO.obtenerID(id); + } + + @Transactional + public CoeficienteTarifa suscribir(CoeficienteTarifa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return coeficienteTarifaDAO.suscribir(entidad); + } + + @Transactional + public CoeficienteTarifa actualizacion(CoeficienteTarifa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return coeficienteTarifaDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(CoeficienteTarifa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + coeficienteTarifaDAO.actualizacion(entidad); + } + + public List buscar(String nomb) { + return coeficienteTarifaDAO.buscar(nomb); + } +}