carla 2012-11-08 20:35:07 +00:00
parent c7edf6752e
commit f04cc3ea3f
6 changed files with 830 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package com.rjconsultores.ventaboletos.dao;
import java.util.List;
import com.rjconsultores.ventaboletos.entidad.Cliente;
public interface ClienteDAO extends GenericDAO<Cliente, Integer> {
public List<Cliente> buscar(String nombCliente);
}

View File

@ -0,0 +1,50 @@
package com.rjconsultores.ventaboletos.dao.hibernate;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
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.ClienteDAO;
import com.rjconsultores.ventaboletos.entidad.Cliente;
@Repository("clienteDAO")
public class ClienteHibernateDAO extends GenericHibernateDAO<Cliente, Integer>
implements ClienteDAO {
@Autowired
public ClienteHibernateDAO(
@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
@Override
public List<Cliente> obtenerTodos() {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
c.addOrder(Order.asc("id"));
return c.list();
}
public List<Cliente> buscar(String nombCliente) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.eq("nombcliente", nombCliente));
return c.list();
}
}

View File

@ -0,0 +1,398 @@
/*
* 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 java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author RJ
*/
@Entity
@SequenceGenerator(name = "CLIENTE_SEQ", sequenceName = "CLIENTE_SEQ", allocationSize = 1)
@Table(name = "CLIENTE")
public class Cliente implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CLIENTE_SEQ")
@Column(name = "CLIENTE_ID")
private Integer clienteId;
@Column(name = "NOMBCLIENTE")
private String nombcliente;
@Column(name = "APELLIDOPATERNO")
private String apellidopaterno;
@Column(name = "APELLIDOMATERNO")
private String apellidomaterno;
@Column(name = "FECNACIMIENTO")
@Temporal(TemporalType.TIMESTAMP)
private Date fecnacimiento;
@Column(name = "NUMRFC")
private String numrfc;
@Column(name = "NUMTELEFONO")
private String numtelefono;
@Column(name = "NUMTELEFONODOS")
private String numtelefonodos;
@Column(name = "NUMFAX")
private String numfax;
@Column(name = "NUMEXTENSION")
private String numextension;
@Column(name = "NUMEXTENSIONDOS")
private String numextensiondos;
@Column(name = "TIPOOCUPACION_ID")
private TipoOcupacion tipoocupacionId;
@Column(name = "MEDIOINFORMATIVO_ID")
private Integer medioinformativoId;
@Column(name = "MOTIVOVIAJE_ID")
private MotivoViaje motivoviajeId;
@Column(name = "INDSEXO")
private String indsexo;
@Column(name = "NUMCURP")
private String numcurp;
@Column(name = "CANTHIJOS")
private Integer canthijos;
@Column(name = "DESCCORREO")
private String desccorreo;
@Column(name = "EDAD")
private Integer edad;
@Column(name = "ESTADOCIVIL_ID")
private Integer estadocivilId;
@Column(name = "GRADOESTUDIO_ID")
private Integer gradoestudioId;
@Column(name = "EQUIVALENCIA_ID")
private String equivalenciaId;
@Column(name = "ACTIVO")
private Boolean activo;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIO_ID")
private Integer usuarioId;
@Column(name = "DESCCONTRASENA")
private String desccontrasena;
@Column(name = "NUMLADA")
private String numlada;
@Column(name = "INDCAMBIOCONTRASENA")
private Integer indcambiocontrasena;
//
// @OneToMany(cascade = CascadeType.ALL)
// @JoinColumn(name = "CLIENTE_ID", referencedColumnName = "CLIENTE_ID")
// private List<ClienteDireccion> lsClienteDireccion;
public Cliente() {
}
public Cliente(Integer clienteId) {
this.clienteId = clienteId;
}
public Integer getClienteId() {
return clienteId;
}
public void setClienteId(Integer clienteId) {
this.clienteId = clienteId;
}
public String getNombcliente() {
return nombcliente;
}
public void setNombcliente(String nombcliente) {
this.nombcliente = nombcliente;
}
public String getApellidopaterno() {
return apellidopaterno;
}
public void setApellidopaterno(String apellidopaterno) {
this.apellidopaterno = apellidopaterno;
}
public String getApellidomaterno() {
return apellidomaterno;
}
public void setApellidomaterno(String apellidomaterno) {
this.apellidomaterno = apellidomaterno;
}
public Date getFecnacimiento() {
return fecnacimiento;
}
public void setFecnacimiento(Date fecnacimiento) {
this.fecnacimiento = fecnacimiento;
}
public String getNumrfc() {
return numrfc;
}
public void setNumrfc(String numrfc) {
this.numrfc = numrfc;
}
public String getNumtelefono() {
return numtelefono;
}
public void setNumtelefono(String numtelefono) {
this.numtelefono = numtelefono;
}
public String getNumtelefonodos() {
return numtelefonodos;
}
public void setNumtelefonodos(String numtelefonodos) {
this.numtelefonodos = numtelefonodos;
}
public String getNumfax() {
return numfax;
}
public void setNumfax(String numfax) {
this.numfax = numfax;
}
public String getNumextension() {
return numextension;
}
public void setNumextension(String numextension) {
this.numextension = numextension;
}
public String getNumextensiondos() {
return numextensiondos;
}
public void setNumextensiondos(String numextensiondos) {
this.numextensiondos = numextensiondos;
}
public TipoOcupacion getTipoocupacionId() {
return tipoocupacionId;
}
public void setTipoocupacionId(TipoOcupacion tipoocupacionId) {
this.tipoocupacionId = tipoocupacionId;
}
public Integer getMedioinformativoId() {
return medioinformativoId;
}
public void setMedioinformativoId(Integer medioinformativoId) {
this.medioinformativoId = medioinformativoId;
}
public MotivoViaje getMotivoviajeId() {
return motivoviajeId;
}
public void setMotivoviajeId(MotivoViaje motivoviajeId) {
this.motivoviajeId = motivoviajeId;
}
public String getIndsexo() {
return indsexo;
}
public void setIndsexo(String indsexo) {
this.indsexo = indsexo;
}
public String getNumcurp() {
return numcurp;
}
public void setNumcurp(String numcurp) {
this.numcurp = numcurp;
}
public Integer getCanthijos() {
return canthijos;
}
public void setCanthijos(Integer canthijos) {
this.canthijos = canthijos;
}
public String getDesccorreo() {
return desccorreo;
}
public void setDesccorreo(String desccorreo) {
this.desccorreo = desccorreo;
}
public Integer getEdad() {
return edad;
}
public void setEdad(Integer edad) {
this.edad = edad;
}
public Integer getEstadocivilId() {
return estadocivilId;
}
public void setEstadocivilId(Integer estadocivilId) {
this.estadocivilId = estadocivilId;
}
public Integer getGradoestudioId() {
return gradoestudioId;
}
public void setGradoestudioId(Integer gradoestudioId) {
this.gradoestudioId = gradoestudioId;
}
public String getEquivalenciaId() {
return equivalenciaId;
}
public void setEquivalenciaId(String equivalenciaId) {
this.equivalenciaId = equivalenciaId;
}
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 String getDesccontrasena() {
return desccontrasena;
}
public void setDesccontrasena(String desccontrasena) {
this.desccontrasena = desccontrasena;
}
public String getNumlada() {
return numlada;
}
public void setNumlada(String numlada) {
this.numlada = numlada;
}
public Integer getIndcambiocontrasena() {
return indcambiocontrasena;
}
public void setIndcambiocontrasena(Integer indcambiocontrasena) {
this.indcambiocontrasena = indcambiocontrasena;
}
// public List<ClienteDireccion> getLsClienteDireccion() {
// return lsClienteDireccion;
// }
//
// public void setLsClienteDireccion(List<ClienteDireccion> lsClienteDireccion) {
// this.lsClienteDireccion = lsClienteDireccion;
// }
@Override
public int hashCode() {
int hash = 0;
hash += (clienteId != null ? clienteId.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Cliente)) {
return false;
}
Cliente other = (Cliente) object;
if ((this.clienteId == null && other.clienteId != null) || (this.clienteId != null && !this.clienteId.equals(other.clienteId))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.rjconsultores.ventaboletos.entidad.Cliente[ clienteId=" + clienteId + " ]";
}
}

View File

@ -0,0 +1,279 @@
/*
* 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.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 RJ
*/
@Entity
@SequenceGenerator(name = "CLIENTE_DIRECCION_SEQ", sequenceName = "CLIENTE_DIRECCION_SEQ", allocationSize = 1)
@Table(name = "CLIENTE_DIRECCION")
public class ClienteDireccion implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CLIENTE_DIRECCION_SEQ")
@Column(name = "CLIENTEDIRECCION_ID")
private Integer clientedireccionId;
@Column(name = "DESCCALLE")
private String desccalle;
@Column(name = "DESCCALLECOMP")
private String desccallecomp;
@Column(name = "DESCDELEGACION")
private String descdelegacion;
@Column(name = "TIPODOMICILIO_ID")
private Short tipodomicilioId;
@Column(name = "DESCPLANO")
private String descplano;
@Column(name = "DESCCOORDENADA")
private String desccoordenada;
@Column(name = "FECHORINICIOENTREGA")
@Temporal(TemporalType.TIMESTAMP)
private Date fechorinicioentrega;
@Column(name = "FECHORFINENTREGA")
@Temporal(TemporalType.TIMESTAMP)
private Date fechorfinentrega;
@Column(name = "COLONIA_ID")
private Integer coloniaId;
@Column(name = "ACTIVO")
private Short activo;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIO_ID")
private Integer usuarioId;
@Column(name = "NUMINTERIOR")
private String numinterior;
@Column(name = "NUMEXTERIOR")
private String numexterior;
@Column(name = "DESCCOLONIA")
private String desccolonia;
@Column(name = "CODPOSTAL")
private String codpostal;
@Column(name = "DESCIUDAD")
private String desciudad;
@Column(name = "DESESTADO")
private String desestado;
// @JoinColumn(name = "CLIENTE_ID", referencedColumnName = "CLIENTE_ID")
// @ManyToOne
// private Cliente clienteId;
public ClienteDireccion() {
}
public ClienteDireccion(Integer clientedireccionId) {
this.clientedireccionId = clientedireccionId;
}
public Integer getClientedireccionId() {
return clientedireccionId;
}
public void setClientedireccionId(Integer clientedireccionId) {
this.clientedireccionId = clientedireccionId;
}
// public Cliente getClienteId() {
// return clienteId;
// }
//
// public void setClienteId(Cliente clienteId) {
// this.clienteId = clienteId;
// }
public String getDesccalle() {
return desccalle;
}
public void setDesccalle(String desccalle) {
this.desccalle = desccalle;
}
public String getDesccallecomp() {
return desccallecomp;
}
public void setDesccallecomp(String desccallecomp) {
this.desccallecomp = desccallecomp;
}
public String getDescdelegacion() {
return descdelegacion;
}
public void setDescdelegacion(String descdelegacion) {
this.descdelegacion = descdelegacion;
}
public Short getTipodomicilioId() {
return tipodomicilioId;
}
public void setTipodomicilioId(Short tipodomicilioId) {
this.tipodomicilioId = tipodomicilioId;
}
public String getDescplano() {
return descplano;
}
public void setDescplano(String descplano) {
this.descplano = descplano;
}
public String getDesccoordenada() {
return desccoordenada;
}
public void setDesccoordenada(String desccoordenada) {
this.desccoordenada = desccoordenada;
}
public Date getFechorinicioentrega() {
return fechorinicioentrega;
}
public void setFechorinicioentrega(Date fechorinicioentrega) {
this.fechorinicioentrega = fechorinicioentrega;
}
public Date getFechorfinentrega() {
return fechorfinentrega;
}
public void setFechorfinentrega(Date fechorfinentrega) {
this.fechorfinentrega = fechorfinentrega;
}
public Integer getColoniaId() {
return coloniaId;
}
public void setColoniaId(Integer coloniaId) {
this.coloniaId = coloniaId;
}
public Short getActivo() {
return activo;
}
public void setActivo(Short 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 String getNuminterior() {
return numinterior;
}
public void setNuminterior(String numinterior) {
this.numinterior = numinterior;
}
public String getNumexterior() {
return numexterior;
}
public void setNumexterior(String numexterior) {
this.numexterior = numexterior;
}
public String getDesccolonia() {
return desccolonia;
}
public void setDesccolonia(String desccolonia) {
this.desccolonia = desccolonia;
}
public String getCodpostal() {
return codpostal;
}
public void setCodpostal(String codpostal) {
this.codpostal = codpostal;
}
public String getDesciudad() {
return desciudad;
}
public void setDesciudad(String desciudad) {
this.desciudad = desciudad;
}
public String getDesestado() {
return desestado;
}
public void setDesestado(String desestado) {
this.desestado = desestado;
}
@Override
public int hashCode() {
int hash = 0;
hash += (clientedireccionId != null ? clientedireccionId.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof ClienteDireccion)) {
return false;
}
ClienteDireccion other = (ClienteDireccion) object;
if ((this.clientedireccionId == null && other.clientedireccionId != null) || (this.clientedireccionId != null && !this.clientedireccionId.equals(other.clientedireccionId))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.rjconsultores.ventaboletos.entidad.ClienteDireccion[ clientedireccionId=" + clientedireccionId + " ]";
}
}

View File

@ -0,0 +1,17 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rjconsultores.ventaboletos.service;
import java.util.List;
import com.rjconsultores.ventaboletos.entidad.Cliente;
public interface ClienteService extends GenericService<Cliente, Integer> {
public List<Cliente> buscar(String numCliente);
}

View File

@ -0,0 +1,70 @@
/*
* 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.ClienteDAO;
import com.rjconsultores.ventaboletos.entidad.Cliente;
import com.rjconsultores.ventaboletos.service.ClienteService;
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 Desenvolvimento
*/
@Service("clienteService")
public class ClienteServiceImpl implements ClienteService {
@Autowired
private ClienteDAO clienteDAO;
public List<Cliente> obtenerTodos() {
return clienteDAO.obtenerTodos();
}
public Cliente obtenerID(Integer id) {
return clienteDAO.obtenerID(id);
}
@Transactional
public Cliente suscribir(Cliente entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
return clienteDAO.suscribir(entidad);
}
@Transactional
public Cliente actualizacion(Cliente entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
return clienteDAO.actualizacion(entidad);
}
@Transactional
public void borrar(Cliente entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.FALSE);
clienteDAO.actualizacion(entidad);
}
public List<Cliente> buscar(String numbCliente) {
return clienteDAO.buscar(numbCliente);
}
}