rodrigo 2012-08-13 22:10:46 +00:00
parent d7232be4fa
commit 7d84e96f94
5 changed files with 243 additions and 0 deletions

View File

@ -0,0 +1,10 @@
package com.rjconsultores.ventaboletos.dao;
import java.util.List;
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
public interface OrgaoConcedenteDAO extends GenericDAO<OrgaoConcedente, Integer>{
public List<OrgaoConcedente> buscar(String desc);
}

View File

@ -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<OrgaoConcedente, Integer>
implements OrgaoConcedenteDAO {
@Autowired
public OrgaoConcedenteHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
@SuppressWarnings("unchecked")
@Override
public List<OrgaoConcedente> obtenerTodos() {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
return c.list();
}
@SuppressWarnings("unchecked")
@Override
public List<OrgaoConcedente> buscar(String desc) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.like("descOrgao", desc));
c.add(Restrictions.eq("activo", Boolean.TRUE));
return c.list();
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,10 @@
package com.rjconsultores.ventaboletos.service;
import java.util.List;
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
public interface OrgaoConcedenteService extends GenericService<OrgaoConcedente, Integer> {
public List<OrgaoConcedente> buscar(String desc);
}

View File

@ -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<OrgaoConcedente> 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<OrgaoConcedente> buscar(String desc) {
return orgaoConcedenteDAO.buscar(desc);
}
}