gleimar 2013-01-25 13:47:14 +00:00
parent fcbd6fc97c
commit 84d2a620bb
3 changed files with 238 additions and 218 deletions

View File

@ -5,9 +5,14 @@
package com.rjconsultores.ventaboletos.dao.hibernate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Transformer;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
@ -81,20 +86,23 @@ public class MarcaHibernateDAO extends GenericHibernateDAO<Marca, Short>
public List<Marca> buscarMarcaPorEmpresa(List<Empresa> empresa) {
String hql = " select new com.rjconsultores.ventaboletos.entidad.Marca(marca.marcaId, marca.descmarca) from Marca marca " +
" where ";
for(Empresa e: empresa){
hql = hql + " marca.empresa.empresaId = "+ e.getEmpresaId() + " or";
if ( (empresa == null) || (empresa.isEmpty())){
return Collections.emptyList();
}
Collection idsEmpresa = CollectionUtils.transformedCollection(empresa, new Transformer() {
@Override
public Object transform(Object input) {
return ((Empresa)input).getEmpresaId();
}
});
hql = hql.substring(0,hql.length()-3);
Criteria c = makeCriteria();
c.add(Restrictions.eq("activo", true));
c.add(Restrictions.in("empresa", idsEmpresa));
c.setFetchMode("logotipomarca", FetchMode.DEFAULT);
Query sq = getSession().createQuery(hql);
List<Marca> lsMarca = sq.list();
return lsMarca;
return c.list();
}
}

View File

@ -24,6 +24,9 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
/**
*
* @author Administrador
@ -57,16 +60,20 @@ public class Marca implements Serializable {
@Column(name = "USUARIO_ID")
private Integer usuarioId;
@OneToMany(mappedBy = "marca")
@Fetch(FetchMode.SELECT)
private List<CategoriaMarca> categoriaMarcaList;
@OneToMany(mappedBy = "marca")
@Fetch(FetchMode.SELECT)
private List<ReservacionMarca> reservacionMarcaList;
@OneToMany(mappedBy = "marca")
private List<CancelacionCtrl> cancelacionCtrlList;
@Column(name = "EQUIVALENCIA_ID")
private String equivalenciaId;
@OneToMany(mappedBy = "marca")
@Fetch(FetchMode.SELECT)
private List<TarifaHist> tarifaHistList;
@OneToMany(mappedBy = "marca")
@Fetch(FetchMode.SELECT)
private List<Corrida> corridaList;
public Marca() {

View File

@ -26,12 +26,14 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
/**
*
*
* @author rodrigo
*/
@Entity
@ -39,264 +41,267 @@ import org.springframework.security.core.userdetails.UserDetails;
@Table(name = "USUARIO")
public class Usuario implements Serializable, Authentication, UserDetails {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "USUARIO_SEQ")
@Basic(optional = false)
@Column(name = "USUARIO_ID")
private Integer usuarioId;
@Column(name = "NOMBUSUARIO")
private String nombusuario;
@Column(name = "NOMBPATERNO")
private String nombpaterno;
@Column(name = "NOMBMATERNO")
private String nombmaterno;
@Column(name = "ACTIVO")
private Boolean activo;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIOMODIF_ID")
private Integer usuariomodifId;
@Column(name = "DESCCONTRASENA")
private String senha;
@Column(name = "CVEUSUARIO")
private String claveUsuario;
@Column(name = "DESCCORREO")
private String descCorreo;
@OneToMany(mappedBy = "usuario", cascade = CascadeType.ALL)
private List<UsuarioPerfil> usuarioPerfilList;
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "USUARIO_SEQ")
@Basic(optional = false)
@Column(name = "USUARIO_ID")
private Integer usuarioId;
@Column(name = "NOMBUSUARIO")
private String nombusuario;
@Column(name = "NOMBPATERNO")
private String nombpaterno;
@Column(name = "NOMBMATERNO")
private String nombmaterno;
@Column(name = "ACTIVO")
private Boolean activo;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIOMODIF_ID")
private Integer usuariomodifId;
@Column(name = "DESCCONTRASENA")
private String senha;
@Column(name = "CVEUSUARIO")
private String claveUsuario;
@Column(name = "DESCCORREO")
private String descCorreo;
@OneToMany(mappedBy = "usuario", cascade = CascadeType.ALL)
@Fetch(FetchMode.SELECT)
private List<UsuarioPerfil> usuarioPerfilList;
@Column(name = "INDCORTEAUTOMATICO")
private Boolean indCorteAutomatico;
@OneToOne
@JoinColumn(name = "EMPLEADO_ID")
private Empleado empleado;
@OneToOne
@JoinColumn(name = "EMPLEADO_ID")
private Empleado empleado;
@OneToMany(mappedBy = "usuarioLog", cascade = CascadeType.ALL,fetch=FetchType.EAGER)
@Fetch(FetchMode.SELECT)
private List<UsuarioEmpresa> usuarioEmpresaList;
@OneToMany(mappedBy = "usuarioLog", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List<UsuarioEmpresa> usuarioEmpresaList;
public String getClaveUsuario() {
return claveUsuario;
}
public String getClaveUsuario() {
return claveUsuario;
}
public void setClaveUsuario(String claveUsuario) {
this.claveUsuario = claveUsuario;
}
public void setClaveUsuario(String claveUsuario) {
this.claveUsuario = claveUsuario;
}
public Usuario() {
}
public Usuario() {
}
public Usuario(Integer usuarioId) {
this.usuarioId = usuarioId;
}
public Usuario(Integer usuarioId) {
this.usuarioId = usuarioId;
}
public Integer getUsuarioId() {
return usuarioId;
}
public Integer getUsuarioId() {
return usuarioId;
}
public void setUsuarioId(Integer usuarioId) {
this.usuarioId = usuarioId;
}
public void setUsuarioId(Integer usuarioId) {
this.usuarioId = usuarioId;
}
public String getNombusuario() {
return nombusuario;
}
public String getNombusuario() {
return nombusuario;
}
public void setNombusuario(String nombusuario) {
this.nombusuario = nombusuario;
}
public void setNombusuario(String nombusuario) {
this.nombusuario = nombusuario;
}
public String getNombpaterno() {
return nombpaterno;
}
public String getNombpaterno() {
return nombpaterno;
}
public void setNombpaterno(String nombpaterno) {
this.nombpaterno = nombpaterno;
}
public void setNombpaterno(String nombpaterno) {
this.nombpaterno = nombpaterno;
}
public String getNombmaterno() {
return nombmaterno;
}
public String getNombmaterno() {
return nombmaterno;
}
public void setNombmaterno(String nombmaterno) {
this.nombmaterno = nombmaterno;
}
public void setNombmaterno(String nombmaterno) {
this.nombmaterno = nombmaterno;
}
public Boolean getActivo() {
return activo;
}
public Boolean getActivo() {
return activo;
}
public void setActivo(Boolean activo) {
this.activo = activo;
}
public void setActivo(Boolean activo) {
this.activo = activo;
}
public Date getFecmodif() {
return fecmodif;
}
public Date getFecmodif() {
return fecmodif;
}
public void setFecmodif(Date fecmodif) {
this.fecmodif = fecmodif;
}
public void setFecmodif(Date fecmodif) {
this.fecmodif = fecmodif;
}
public Integer getUsuariomodifId() {
return usuariomodifId;
}
public Integer getUsuariomodifId() {
return usuariomodifId;
}
public void setUsuariomodifId(Integer usuariomodifId) {
this.usuariomodifId = usuariomodifId;
}
public void setUsuariomodifId(Integer usuariomodifId) {
this.usuariomodifId = usuariomodifId;
}
public String getSenha() {
return senha;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public List<UsuarioEmpresa> getUsuarioEmpresaList() {
List<UsuarioEmpresa> tmp = new ArrayList<UsuarioEmpresa>();
if (usuarioEmpresaList != null) {
for (UsuarioEmpresa ce : this.usuarioEmpresaList) {
if (ce.getActivo()) {
tmp.add(ce);
}
}
}
public void setSenha(String senha) {
this.senha = senha;
}
return tmp;
}
public List<UsuarioEmpresa> getUsuarioEmpresaList() {
List<UsuarioEmpresa> tmp = new ArrayList<UsuarioEmpresa>();
if (usuarioEmpresaList != null) {
for (UsuarioEmpresa ce : this.usuarioEmpresaList) {
if (ce.getActivo()) {
tmp.add(ce);
}
}
}
public void setUsuarioEmpresaList(List<UsuarioEmpresa> usuarioEmpresaList) {
this.usuarioEmpresaList = usuarioEmpresaList;
}
return tmp;
}
public List<UsuarioPerfil> getUsuarioPerfilList() {
List<UsuarioPerfil> tmp = new ArrayList<UsuarioPerfil>();
if (usuarioPerfilList != null) {
for (UsuarioPerfil cp : this.usuarioPerfilList) {
if (cp.getActivo()) {
tmp.add(cp);
}
}
}
public void setUsuarioEmpresaList(List<UsuarioEmpresa> usuarioEmpresaList) {
this.usuarioEmpresaList = usuarioEmpresaList;
}
return tmp;
}
public List<Empresa> getEmpresa() {
List<Empresa> tmp = new ArrayList<Empresa>();
if (usuarioEmpresaList != null) {
for (UsuarioEmpresa cp : this.usuarioEmpresaList) {
if ((cp.getActivo())) {
tmp.add(cp.getEmpresa());
}
}
}
public List<UsuarioPerfil> getUsuarioPerfilList() {
List<UsuarioPerfil> tmp = new ArrayList<UsuarioPerfil>();
if (usuarioPerfilList != null) {
for (UsuarioPerfil cp : this.usuarioPerfilList) {
if (cp.getActivo()) {
tmp.add(cp);
}
}
}
return tmp;
}
return tmp;
}
public void setUsuarioPerfilList(List<UsuarioPerfil> usuarioPerfilList) {
this.usuarioPerfilList = usuarioPerfilList;
}
public List<Empresa> getEmpresa() {
List<Empresa> tmp = new ArrayList<Empresa>();
if (usuarioEmpresaList != null) {
for (UsuarioEmpresa cp : this.usuarioEmpresaList) {
if ((cp.getActivo())) {
tmp.add(cp.getEmpresa());
}
}
}
public Empleado getEmpleado() {
return empleado;
}
return tmp;
}
public void setEmpleado(Empleado empleado) {
this.empleado = empleado;
}
public void setUsuarioPerfilList(List<UsuarioPerfil> usuarioPerfilList) {
this.usuarioPerfilList = usuarioPerfilList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (usuarioId != null ? usuarioId.hashCode() : 0);
return hash;
}
public Empleado getEmpleado() {
return empleado;
}
@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 Usuario)) {
return false;
}
Usuario other = (Usuario) object;
if ((this.usuarioId == null && other.usuarioId != null) || (this.usuarioId != null && !this.usuarioId.equals(other.usuarioId))) {
return false;
}
return true;
}
public void setEmpleado(Empleado empleado) {
this.empleado = empleado;
}
@Override
public String toString() {
return "com.rjconsultores.ventaboletos.entidad.Usuario[usuarioId=" + usuarioId + "]";
}
public Collection<GrantedAuthority> getAuthorities() {
return new ArrayList<GrantedAuthority>();
}
public Collection<GrantedAuthority> getAuthorities() {
return new ArrayList<GrantedAuthority>();
}
public String getPassword() {
return this.senha;
}
public String getPassword() {
return this.senha;
}
public String getUsername() {
return this.nombusuario;
}
public String getUsername() {
return this.nombusuario;
}
public boolean isAccountNonExpired() {
return true;
}
public boolean isAccountNonExpired() {
return true;
}
public boolean isAccountNonLocked() {
return true;
}
public boolean isAccountNonLocked() {
return true;
}
public boolean isCredentialsNonExpired() {
return true;
}
public boolean isCredentialsNonExpired() {
return true;
}
public boolean isEnabled() {
return true;
}
public boolean isEnabled() {
return true;
}
public Object getCredentials() {
return new Object();
}
public Object getCredentials() {
return new Object();
}
public Object getDetails() {
return new Object();
}
public Object getDetails() {
return new Object();
}
public Object getPrincipal() {
return this;
}
public Object getPrincipal() {
return this;
}
public boolean isAuthenticated() {
return Boolean.TRUE;
}
public boolean isAuthenticated() {
return Boolean.TRUE;
}
public void setAuthenticated(boolean bln) throws IllegalArgumentException {
}
public void setAuthenticated(boolean bln) throws IllegalArgumentException {
}
public String getName() {
return this.getNombusuario();
}
public String getName() {
return this.getNombusuario();
}
public String getDescCorreo() {
return descCorreo;
}
public String getDescCorreo() {
return descCorreo;
}
public void setDescCorreo(String descCorreo) {
this.descCorreo = descCorreo;
}
public Boolean getIndCorteAutomatico() {
public void setDescCorreo(String descCorreo) {
this.descCorreo = descCorreo;
}
public Boolean getIndCorteAutomatico() {
return indCorteAutomatico;
}
public void setIndCorteAutomatico(Boolean indCorteAutomatico) {
this.indCorteAutomatico = indCorteAutomatico;
}
@Override
public int hashCode() {
int hash = 0;
hash += (usuarioId != null ? usuarioId.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
if (!(object instanceof Usuario)) {
return false;
}
Usuario other = (Usuario) object;
if ((this.usuarioId == null && other.usuarioId != null) || (this.usuarioId != null && !this.usuarioId.equals(other.usuarioId))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.rjconsultores.ventaboletos.entidad.Usuario[usuarioId=" + usuarioId + "]";
}
}