Ajuste cadastro de Cliente na Adm
fixes bug #6605 Tempo: 6 horas git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@47763 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
bc75d07c33
commit
19b3f80b9f
|
@ -0,0 +1,11 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.ClienteCurso;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Curso;
|
||||||
|
|
||||||
|
public interface ClienteCursoDAO extends GenericDAO<ClienteCurso, Integer> {
|
||||||
|
|
||||||
|
public ClienteCurso buscarClienteCurso(Cliente cliente, Curso curso);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
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.ClienteCursoDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.ClienteCurso;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Curso;
|
||||||
|
|
||||||
|
@Repository("clienteCursoDAO")
|
||||||
|
public class ClienteCursoHibernateDAO extends GenericHibernateDAO<ClienteCurso, Integer>
|
||||||
|
implements ClienteCursoDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ClienteCursoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ClienteCurso> obtenerTodos() {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClienteCurso buscarClienteCurso(Cliente cliente, Curso curso) {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
c.add(Restrictions.eq("cliente", cliente));
|
||||||
|
c.add(Restrictions.eq("curso", curso));
|
||||||
|
|
||||||
|
return (ClienteCurso) c.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
package com.rjconsultores.ventaboletos.entidad;
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -16,6 +17,8 @@ import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.JoinTable;
|
||||||
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
|
@ -117,9 +120,12 @@ public class Cliente implements Serializable {
|
||||||
@OneToMany(cascade = CascadeType.ALL)
|
@OneToMany(cascade = CascadeType.ALL)
|
||||||
@JoinColumn(name = "CLIENTE_ID", referencedColumnName = "CLIENTE_ID")
|
@JoinColumn(name = "CLIENTE_ID", referencedColumnName = "CLIENTE_ID")
|
||||||
private List<ClienteDescuento> lsClienteDescuento;
|
private List<ClienteDescuento> lsClienteDescuento;
|
||||||
@ManyToOne(cascade = CascadeType.ALL)
|
|
||||||
@JoinColumn(name = "CURSO_ID", referencedColumnName = "CURSO_ID")
|
@ManyToMany
|
||||||
private Curso curso;
|
@JoinTable(name = "CLIENTE_CURSO", joinColumns = { @JoinColumn(name = "CLIENTE_ID") },
|
||||||
|
inverseJoinColumns = { @JoinColumn(name = "CURSO_ID") })
|
||||||
|
private List<Curso> cursoList;
|
||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.ALL)
|
@ManyToOne(cascade = CascadeType.ALL)
|
||||||
@JoinColumn(name = "ESCOLA_ID", referencedColumnName = "ESCOLA_ID")
|
@JoinColumn(name = "ESCOLA_ID", referencedColumnName = "ESCOLA_ID")
|
||||||
private Escola escola;
|
private Escola escola;
|
||||||
|
@ -419,12 +425,24 @@ public class Cliente implements Serializable {
|
||||||
this.lsClienteDescuento = lsClienteDescuento;
|
this.lsClienteDescuento = lsClienteDescuento;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Curso getCurso() {
|
public List<Curso> getCursoList() {
|
||||||
return curso;
|
|
||||||
|
List<Curso> aux = new ArrayList<Curso>();
|
||||||
|
if (cursoList == null) {
|
||||||
|
return aux;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurso(Curso curso) {
|
for (Curso curso : cursoList) {
|
||||||
this.curso = curso;
|
if (curso.getActivo()) {
|
||||||
|
aux.add(curso);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return aux;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCursoList(List<Curso> cursoList) {
|
||||||
|
this.cursoList = cursoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Escola getEscola() {
|
public Escola getEscola() {
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
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.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@SequenceGenerator(name = "CLIENTE_CURSO_SEQ", sequenceName = "CLIENTE_CURSO_SEQ", allocationSize = 1)
|
||||||
|
@Table(name = "CLIENTE_CURSO")
|
||||||
|
public class ClienteCurso implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
@Id
|
||||||
|
@Basic(optional = false)
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CLIENTE_CURSO_SEQ")
|
||||||
|
@Column(name = "CLIENTECURSO_ID")
|
||||||
|
private Integer clientecursoId;
|
||||||
|
@Column(name = "ACTIVO")
|
||||||
|
private Boolean activo;
|
||||||
|
@Column(name = "FECMODIF")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date fecmodif;
|
||||||
|
@Column(name = "USUARIO_ID")
|
||||||
|
private Integer usuarioId;
|
||||||
|
|
||||||
|
@JoinColumn(name = "CURSO_ID", referencedColumnName = "CURSO_ID")
|
||||||
|
@ManyToOne
|
||||||
|
private Curso curso;
|
||||||
|
@JoinColumn(name = "CLIENTE_ID", referencedColumnName = "CLIENTE_ID")
|
||||||
|
@ManyToOne
|
||||||
|
private Cliente cliente;
|
||||||
|
|
||||||
|
public Integer getClientecursoId() {
|
||||||
|
return clientecursoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientecursoId(Integer clientecursoId) {
|
||||||
|
this.clientecursoId = clientecursoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Curso getCurso() {
|
||||||
|
return curso;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurso(Curso curso) {
|
||||||
|
this.curso = curso;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cliente getCliente() {
|
||||||
|
return cliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCliente(Cliente cliente) {
|
||||||
|
this.cliente = cliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
@ -9,6 +10,9 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.JoinTable;
|
||||||
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
|
@ -35,6 +39,11 @@ public class Curso implements Serializable {
|
||||||
@Column(name = "USUARIO_ID")
|
@Column(name = "USUARIO_ID")
|
||||||
private Integer usuarioId;
|
private Integer usuarioId;
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable(name = "CLIENTE_CURSO", joinColumns = { @JoinColumn(name = "CURSO_ID") },
|
||||||
|
inverseJoinColumns = { @JoinColumn(name = "CLIENTE_ID") })
|
||||||
|
private List<Cliente> clienteList;
|
||||||
|
|
||||||
public Integer getCursoId() {
|
public Integer getCursoId() {
|
||||||
return cursoId;
|
return cursoId;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +84,14 @@ public class Curso implements Serializable {
|
||||||
this.usuarioId = usuarioId;
|
this.usuarioId = usuarioId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Cliente> getClienteList() {
|
||||||
|
return clienteList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClienteList(List<Cliente> clienteList) {
|
||||||
|
this.clienteList = clienteList;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.nomcurso;
|
return this.nomcurso;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.ClienteCurso;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Curso;
|
||||||
|
|
||||||
|
public interface ClienteCursoService extends GenericService<ClienteCurso, Integer> {
|
||||||
|
|
||||||
|
public ClienteCurso buscarClienteCurso(Cliente cliente, Curso curso);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
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.ClienteCursoDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.ClienteCurso;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Curso;
|
||||||
|
import com.rjconsultores.ventaboletos.service.ClienteCursoService;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
|
@Service("clienteCursoService")
|
||||||
|
public class ClienteCursoServiceImpl implements ClienteCursoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ClienteCursoDAO clienteCursoDAO;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ClienteCurso> obtenerTodos() {
|
||||||
|
return clienteCursoDAO.obtenerTodos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClienteCurso obtenerID(Integer id) {
|
||||||
|
return clienteCursoDAO.obtenerID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public ClienteCurso suscribir(ClienteCurso entidad) {
|
||||||
|
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
|
return clienteCursoDAO.suscribir(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public ClienteCurso actualizacion(ClienteCurso entidad) {
|
||||||
|
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
|
return clienteCursoDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void borrar(ClienteCurso entidad) {
|
||||||
|
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.FALSE);
|
||||||
|
|
||||||
|
clienteCursoDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClienteCurso buscarClienteCurso(Cliente cliente, Curso curso) {
|
||||||
|
return clienteCursoDAO.buscarClienteCurso(cliente, curso);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue