fixes bug #6507
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@46365 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
63c5b82639
commit
60aba1e0d9
|
@ -0,0 +1,10 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Ciudad;
|
||||
import com.rjconsultores.ventaboletos.entidad.Escola;
|
||||
|
||||
public interface EscolaDAO extends GenericDAO<Escola, Integer> {
|
||||
public List<Escola> buscar(String nombescola, Ciudad ciudad);
|
||||
}
|
|
@ -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.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.EscolaDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ciudad;
|
||||
import com.rjconsultores.ventaboletos.entidad.Escola;
|
||||
|
||||
@Repository("escolaDAO")
|
||||
public class EscolaHibernateDAO extends GenericHibernateDAO<Escola, Integer>
|
||||
implements EscolaDAO {
|
||||
|
||||
@Autowired
|
||||
public EscolaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Escola> obtenerTodos() {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.addOrder(Order.asc("nombEscola"));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Escola> buscar(String nombescola, Ciudad ciudad) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.add(Restrictions.eq("nombescola", nombescola));
|
||||
c.add(Restrictions.eq("ciudad", ciudad));
|
||||
c.addOrder(Order.asc("nombescola"));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
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.OneToMany;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@SequenceGenerator(name = "ESCOLA_SEQ", sequenceName = "ESCOLA_SEQ", allocationSize = 1)
|
||||
@Table(name = "ESCOLA")
|
||||
public class Escola implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "ESCOLA_SEQ")
|
||||
@Basic(optional = false)
|
||||
@Column(name = "ESCOLA_ID")
|
||||
private Integer escolaId;
|
||||
@Column(name = "NOMESCOLA")
|
||||
private String nombescola;
|
||||
@JoinColumn(name = "CIUDAD_ID", referencedColumnName = "CIUDAD_ID")
|
||||
@ManyToOne
|
||||
private Ciudad ciudad;
|
||||
@Column(name = "ACTIVO")
|
||||
private Boolean activo;
|
||||
@Column(name = "FECMODIF")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date fecmodif;
|
||||
@Column(name = "USUARIO_ID")
|
||||
private Integer usuarioId;
|
||||
|
||||
public Integer getEscolaId() {
|
||||
return escolaId;
|
||||
}
|
||||
public void setEscolaId(Integer escolaId) {
|
||||
this.escolaId = escolaId;
|
||||
}
|
||||
public String getNombescola() {
|
||||
return nombescola;
|
||||
}
|
||||
public void setNombescola(String nombescola) {
|
||||
this.nombescola = nombescola;
|
||||
}
|
||||
public Ciudad getCiudad() {
|
||||
return ciudad;
|
||||
}
|
||||
public void setCiudad(Ciudad ciudad) {
|
||||
this.ciudad = ciudad;
|
||||
}
|
||||
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,22 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Ciudad;
|
||||
import com.rjconsultores.ventaboletos.entidad.Escola;
|
||||
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||
import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
|
||||
|
||||
public interface EscolaService {
|
||||
public List<Escola> obtenerTodos();
|
||||
|
||||
public Escola obtenerID(Integer id);
|
||||
|
||||
public Escola suscribir(Escola entidad);
|
||||
|
||||
public Escola actualizacion(Escola entidad);
|
||||
|
||||
public void borrar(Escola entidad) throws RegistroConDependenciaException;
|
||||
|
||||
public List<Escola> buscar(String nombescola, Ciudad ciudad);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
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.CiudadDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.EscolaDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ciudad;
|
||||
import com.rjconsultores.ventaboletos.entidad.Escola;
|
||||
import com.rjconsultores.ventaboletos.service.EscolaService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
@Service("escolaService")
|
||||
public class EscolaServiceImpl implements EscolaService {
|
||||
|
||||
@Autowired
|
||||
private EscolaDAO EscolaDAO;
|
||||
@Autowired
|
||||
private CiudadDAO ciudadDAO;
|
||||
|
||||
public List<Escola> obtenerTodos() {
|
||||
return EscolaDAO.obtenerTodos();
|
||||
}
|
||||
|
||||
public Escola obtenerID(Integer id) {
|
||||
return EscolaDAO.obtenerID(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Escola suscribir(Escola entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return EscolaDAO.suscribir(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Escola actualizacion(Escola entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return EscolaDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void borrar(Escola entidad) throws RegistroConDependenciaException {
|
||||
|
||||
if (ciudadDAO.count("Escola", entidad) > 0l) {
|
||||
throw new RegistroConDependenciaException();
|
||||
}
|
||||
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.FALSE);
|
||||
|
||||
EscolaDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
public List<Escola> buscar(String nombEscola, Ciudad ciudad) {
|
||||
return EscolaDAO.buscar(nombEscola, ciudad);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue