bug #0009182 - git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@71154 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
39c0ca3912
commit
ec3a96a9bf
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.MotivoDevolucaoBilhete;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bruno Neves
|
||||
*/
|
||||
public interface MotivoDevolucaoBilheteDAO extends GenericDAO<MotivoDevolucaoBilhete, Integer> {
|
||||
|
||||
public List<MotivoDevolucaoBilhete> buscar(String descmotivo, String tipomotivo);
|
||||
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodosTipoMotivoB();
|
||||
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodosEspecificos(Integer[] motivos);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.MotivoDevolucaoBilheteDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.MotivoDevolucaoBilhete;
|
||||
import java.util.List;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.SessionFactory;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bruno Neves
|
||||
*/
|
||||
@Repository("motivoDevolucaoBilheteDAO")
|
||||
public class MotivoDevolucaoBilheteHibernateDAO extends GenericHibernateDAO<MotivoDevolucaoBilhete, Integer>
|
||||
implements MotivoDevolucaoBilheteDAO {
|
||||
|
||||
@Autowired
|
||||
public MotivoDevolucaoBilheteHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodos() {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.addOrder(Order.asc("descmotivo"));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
public List<MotivoDevolucaoBilhete> buscar(String descmotivo, String tipomotivo) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.add(Restrictions.eq("descmotivo", descmotivo));
|
||||
|
||||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodosTipoMotivoB() {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.addOrder(Order.asc("descmotivo"));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodosEspecificos(Integer[] motivos) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.add(Restrictions.in("motivodevolucaobilheteId", motivos));
|
||||
c.addOrder(Order.asc("descmotivo"));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
}
|
|
@ -81,8 +81,13 @@ public class PrecioFixoPedagioHibernateDAO extends GenericHibernateDAO<PrecioFix
|
|||
public List<PrecioFixoPedagio> buscarPrecioFixoPedagio(PrecioFixoPedagio obj) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("pracaPedagioId.casetaPeajeId", obj.getPracaPedagioId().getCasetaPeajeId()));
|
||||
if(obj.getOrgaoConcedenteId() != null){
|
||||
c.add(Restrictions.eq("orgaoConcedenteId.orgaoConcedenteId", obj.getOrgaoConcedenteId().getOrgaoConcedenteId()));
|
||||
}
|
||||
if(obj.getClasseId()!= null){
|
||||
c.add(Restrictions.eq("classeId.claseservicioId", obj.getClasseId().getClaseservicioId()));
|
||||
}
|
||||
|
||||
c.setMaxResults(1);
|
||||
return c.list();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
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.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bruno Neves
|
||||
*/
|
||||
/**
|
||||
* @author Bruno
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(name = "MOTIVO_DEVOLUCAO_BILHETE_SEQ", sequenceName = "MOTIVO_DEVOLUCAO_BILHETE_SEQ", allocationSize = 1)
|
||||
@Table(name = "MOTIVO_DEVOLUCAO_BILHETE")
|
||||
public class MotivoDevolucaoBilhete implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Basic(optional = false)
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "MOTIVO_DEVOLUCAO_BILHETE_SEQ")
|
||||
@Column(name = "MOTIVODEVOLUCAOBILHETE_ID")
|
||||
private Integer motivodevolucaobilheteId;
|
||||
@Column(name = "DESCMOTIVO")
|
||||
private String descmotivo;
|
||||
@Column(name = "ACTIVO")
|
||||
private Boolean activo;
|
||||
@Column(name = "FECMODIF")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date fecmodif;
|
||||
@Column(name = "USUARIO_ID")
|
||||
private Integer usuarioId;
|
||||
|
||||
|
||||
public MotivoDevolucaoBilhete() {
|
||||
}
|
||||
|
||||
|
||||
public Integer getMotivodevolucaobilheteId() {
|
||||
return motivodevolucaobilheteId;
|
||||
}
|
||||
|
||||
|
||||
public void setMotivodevolucaobilheteId(Integer motivodevolucaobilheteId) {
|
||||
this.motivodevolucaobilheteId = motivodevolucaobilheteId;
|
||||
}
|
||||
|
||||
|
||||
public String getDescmotivo() {
|
||||
return descmotivo;
|
||||
}
|
||||
|
||||
|
||||
public void setDescmotivo(String descmotivo) {
|
||||
this.descmotivo = descmotivo;
|
||||
}
|
||||
|
||||
|
||||
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 + ((motivodevolucaobilheteId == null) ? 0 : motivodevolucaobilheteId.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;
|
||||
MotivoDevolucaoBilhete other = (MotivoDevolucaoBilhete) obj;
|
||||
if (motivodevolucaobilheteId == null) {
|
||||
if (other.motivodevolucaobilheteId != null)
|
||||
return false;
|
||||
} else if (!motivodevolucaobilheteId.equals(other.motivodevolucaobilheteId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MotivoDevolucaoBilhete [motivodevolucaobilheteId=" + motivodevolucaobilheteId + ", descmotivo=" + descmotivo + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.MotivoDevolucaoBilhete;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bruno Neves
|
||||
*/
|
||||
public interface MotivoDevolucaoBilheteService extends GenericService<MotivoDevolucaoBilhete, Integer> {
|
||||
|
||||
public List<MotivoDevolucaoBilhete> buscar(String descmotivo, String tipomotivo);
|
||||
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodosTipoMotivoB();
|
||||
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodosEspecificos(Integer[] motivos);
|
||||
|
||||
public boolean validaMotivoDevolucaoBilheteConstante(MotivoDevolucaoBilhete motivoDevolucaoBilhete);
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.MotivoDevolucaoBilheteDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.MotivoDevolucaoBilhete;
|
||||
import com.rjconsultores.ventaboletos.service.MotivoDevolucaoBilheteService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bruno Neves
|
||||
*/
|
||||
@Service("motivoDevolucaoBilheteService")
|
||||
public class MotivoDevolucaoBilheteServiceImpl implements MotivoDevolucaoBilheteService {
|
||||
|
||||
@Autowired
|
||||
private MotivoDevolucaoBilheteDAO motivoDevolucaoBilheteDAO;
|
||||
public static final Integer MAX_CONS_MOV_CANCEL = Integer.valueOf(35);
|
||||
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodos() {
|
||||
return motivoDevolucaoBilheteDAO.obtenerTodos();
|
||||
}
|
||||
|
||||
public MotivoDevolucaoBilhete obtenerID(Integer id) {
|
||||
return motivoDevolucaoBilheteDAO.obtenerID(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public MotivoDevolucaoBilhete suscribir(MotivoDevolucaoBilhete entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return motivoDevolucaoBilheteDAO.suscribir(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public MotivoDevolucaoBilhete actualizacion(MotivoDevolucaoBilhete entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return motivoDevolucaoBilheteDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void borrar(MotivoDevolucaoBilhete entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.FALSE);
|
||||
|
||||
motivoDevolucaoBilheteDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
public List<MotivoDevolucaoBilhete> buscar(String descmotivo, String tipomotivo) {
|
||||
return motivoDevolucaoBilheteDAO.buscar(descmotivo, tipomotivo);
|
||||
}
|
||||
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodosTipoMotivoB() {
|
||||
return motivoDevolucaoBilheteDAO.obtenerTodosTipoMotivoB();
|
||||
}
|
||||
|
||||
public List<MotivoDevolucaoBilhete> obtenerTodosEspecificos(Integer[] motivos) {
|
||||
return motivoDevolucaoBilheteDAO.obtenerTodosEspecificos(motivos);
|
||||
}
|
||||
|
||||
public boolean validaMotivoDevolucaoBilheteConstante(MotivoDevolucaoBilhete motivoDevolucaoBilhete) {
|
||||
if (motivoDevolucaoBilhete.getMotivodevolucaobilheteId() <= MAX_CONS_MOV_CANCEL)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue