fixes bug#6568
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@47156 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
e0b1baa30c
commit
edf56a5402
|
@ -0,0 +1,10 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PracaPedagio;
|
||||||
|
|
||||||
|
public interface PracaPedagioDAO extends GenericDAO<PracaPedagio, Integer> {
|
||||||
|
|
||||||
|
List<PracaPedagio> buscar(String descricaoPracaPedagio);
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
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.PracaPedagioDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PracaPedagio;
|
||||||
|
|
||||||
|
@Repository("pracaPedagioDAO")
|
||||||
|
public class PracaPedagioHibernateDAO extends GenericHibernateDAO<PracaPedagio, Integer> implements PracaPedagioDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public PracaPedagioHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public List<PracaPedagio> obtenerTodos() {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
return (List<PracaPedagio>) c.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public List<PracaPedagio> buscar(String descricaoPracaPedagio) {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
c.add(Restrictions.eq("descricao", descricaoPracaPedagio));
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
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="CASETA_PEAJE_SEQ", sequenceName="CASETA_PEAJE_SEQ", allocationSize=1)
|
||||||
|
@Table(name="CASETA_PEAJE")
|
||||||
|
public class PracaPedagio implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CASETA_PEAJE_SEQ")
|
||||||
|
@Basic(optional = false)
|
||||||
|
@Column(name = "CASETAPEAJE_ID")
|
||||||
|
private Integer pracaPedagioId;
|
||||||
|
|
||||||
|
@Column(name="DESCCASETA", unique = true)
|
||||||
|
private String descricao;
|
||||||
|
|
||||||
|
@Column(name="IMPORTEIDA")
|
||||||
|
private BigDecimal quantiaIda;
|
||||||
|
|
||||||
|
@Column(name="IMPORTEVUELTA")
|
||||||
|
private BigDecimal quantiaVolta;
|
||||||
|
|
||||||
|
@Column(name = "ACTIVO")
|
||||||
|
private Boolean activo;
|
||||||
|
|
||||||
|
@Column(name = "FECMODIF")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date fecmodif;
|
||||||
|
|
||||||
|
@Column(name = "USUARIO_ID")
|
||||||
|
private Integer usuarioId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 0;
|
||||||
|
hash += pracaPedagioId != null ? pracaPedagioId.hashCode() : 0;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
if (!(object instanceof PracaPedagio)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PracaPedagio other = (PracaPedagio) object;
|
||||||
|
if ((this.pracaPedagioId == null && other.pracaPedagioId != null) || (this.pracaPedagioId != null && !this.pracaPedagioId.equals(other.pracaPedagioId))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.pracaPedagioId + " - " + this.descricao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPracaPedagioId() {
|
||||||
|
return pracaPedagioId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPracaPedagioId(Integer pracaPedagioId) {
|
||||||
|
this.pracaPedagioId = pracaPedagioId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescricao() {
|
||||||
|
return descricao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescricao(String descricao) {
|
||||||
|
this.descricao = descricao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getQuantiaIda() {
|
||||||
|
return quantiaIda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantiaIda(BigDecimal quantiaIda) {
|
||||||
|
this.quantiaIda = quantiaIda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getQuantiaVolta() {
|
||||||
|
return quantiaVolta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantiaVolta(BigDecimal quantiaVolta) {
|
||||||
|
this.quantiaVolta = quantiaVolta;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PracaPedagio;
|
||||||
|
|
||||||
|
public interface PracaPedagioService extends GenericService<PracaPedagio, Integer> {
|
||||||
|
public List<PracaPedagio> buscar(String descricaoPracaPedagio);
|
||||||
|
public Boolean validarDescricaoPracaPedagio(PracaPedagio pracaPedagio);
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
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.PracaPedagioDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PracaPedagio;
|
||||||
|
import com.rjconsultores.ventaboletos.service.PracaPedagioService;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
|
@Service("pracaPedagioService")
|
||||||
|
public class PracaPedagioServiceImpl implements PracaPedagioService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PracaPedagioDAO pracaPedagioDAO;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PracaPedagio> obtenerTodos() {
|
||||||
|
return pracaPedagioDAO.obtenerTodos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public PracaPedagio obtenerID(Integer id) {
|
||||||
|
return pracaPedagioDAO.obtenerID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public PracaPedagio suscribir(PracaPedagio entidad) {
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
return pracaPedagioDAO.suscribir(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public PracaPedagio actualizacion(PracaPedagio entidad) {
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
return pracaPedagioDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void borrar(PracaPedagio entidad) {
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.FALSE);
|
||||||
|
pracaPedagioDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PracaPedagio> buscar(String descricaoPracaPedagio) {
|
||||||
|
return pracaPedagioDAO.buscar(descricaoPracaPedagio);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean validarDescricaoPracaPedagio(PracaPedagio pracaPedagio) {
|
||||||
|
List<PracaPedagio> pracas = buscar(pracaPedagio.getDescricao());
|
||||||
|
|
||||||
|
if(pracaPedagio.getPracaPedagioId() == null) {
|
||||||
|
if(pracas.isEmpty()){
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(pracas.isEmpty() || pracas.get(0).getPracaPedagioId().equals(pracaPedagio.getPracaPedagioId())) {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
} else {
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue