Seguro KM
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@20934 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
0114cbc3e7
commit
2cd884e910
|
@ -1,6 +1,10 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
public interface SeguroKmDAO {
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import com.rjconsultores.ventaboletos.entidad.SeguroKm;
|
||||
import java.util.List;
|
||||
|
||||
public interface SeguroKmDAO extends GenericDAO<SeguroKm, Integer> {
|
||||
|
||||
/**
|
||||
* Indica se existe seguroKm para o orgaoConcedenteId informado
|
||||
|
@ -9,5 +13,7 @@ public interface SeguroKmDAO {
|
|||
* @return
|
||||
*/
|
||||
public boolean existe(Integer orgaoConcedenteId);
|
||||
|
||||
public List<SeguroKm> buscarPorOrgao(OrgaoConcedente orgao);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import java.util.List;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Projections;
|
||||
|
@ -14,21 +16,27 @@ import com.rjconsultores.ventaboletos.entidad.SeguroKm;
|
|||
@Repository("seguroKmDAO")
|
||||
public class SeguroKmHibernateDAO extends GenericHibernateDAO<SeguroKm, Integer> implements SeguroKmDAO {
|
||||
|
||||
@Autowired
|
||||
public SeguroKmHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
@Autowired
|
||||
public SeguroKmHibernateDAO(@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<SeguroKm> buscarPorOrgao(OrgaoConcedente orgao) {
|
||||
Criteria c = makeCriteria();
|
||||
c.add(Restrictions.eq("orgaoconcedente", orgao));
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,26 +11,29 @@ 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.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author gleimar
|
||||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(name = "SEGURO_KM_SEQ", sequenceName = "SEGURO_KM_SEQ", allocationSize = 1)
|
||||
@Table(name = "SEGURO_KM")
|
||||
public class SeguroKm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Basic(optional = false)
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEGURO_KM_SEQ")
|
||||
@Column(name = "SEGUROKM_ID")
|
||||
private Integer segurokmId;
|
||||
@Column(name = "KMATE")
|
||||
|
@ -79,8 +82,6 @@ public class SeguroKm implements Serializable {
|
|||
this.valortaxa = valortaxa;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
|
@ -106,36 +107,35 @@ public class SeguroKm implements Serializable {
|
|||
return "com.rjconsultores.ventaboletos.entidad.SeguroKm[ segurokmId=" + segurokmId + " ]";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import com.rjconsultores.ventaboletos.entidad.SeguroKm;
|
||||
import java.util.List;
|
||||
|
||||
public interface SeguroKmService {
|
||||
|
||||
public interface SeguroKmService extends GenericService<SeguroKm, Integer>{
|
||||
|
||||
public List<SeguroKm> buscarPorOrgao(OrgaoConcedente orgao);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import com.rjconsultores.ventaboletos.entidad.SeguroKm;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.SeguroKmDAO;
|
||||
import com.rjconsultores.ventaboletos.service.SeguroKmService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
import java.util.Calendar;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service("seguroKmService")
|
||||
public class SeguroKmServiceImpl implements SeguroKmService {
|
||||
|
||||
@Autowired
|
||||
private SeguroKmDAO seguroKmDAO;
|
||||
|
||||
public List<SeguroKm> buscarPorOrgao(OrgaoConcedente orgao) {
|
||||
return seguroKmDAO.buscarPorOrgao(orgao);
|
||||
}
|
||||
|
||||
public List<SeguroKm> obtenerTodos() {
|
||||
return seguroKmDAO.obtenerTodos();
|
||||
}
|
||||
|
||||
public SeguroKm obtenerID(Integer id) {
|
||||
return seguroKmDAO.obtenerID(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SeguroKm suscribir(SeguroKm entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return seguroKmDAO.suscribir(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SeguroKm actualizacion(SeguroKm entidad) {
|
||||
return seguroKmDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void borrar(SeguroKm entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.FALSE);
|
||||
|
||||
seguroKmDAO.borrar(entidad);
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.SeguroKmDAO;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
import com.rjconsultores.ventaboletos.service.SeguroKmService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
@Service("seguroKmService")
|
||||
public class SeguroServiceKmImpl implements SeguroKmService{
|
||||
|
||||
@Autowired
|
||||
private SeguroKmDAO seguroKmDAO;
|
||||
}
|
Loading…
Reference in New Issue