gleimar 2013-02-18 18:54:37 +00:00
parent 6474559df2
commit f7c0bb1722
5 changed files with 51 additions and 42 deletions

View File

@ -11,6 +11,7 @@ import java.util.List;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Transformer; import org.apache.commons.collections.Transformer;
import org.apache.commons.lang.StringUtils;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
import org.hibernate.Query; import org.hibernate.Query;
@ -26,7 +27,6 @@ import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Marca; import com.rjconsultores.ventaboletos.entidad.Marca;
import com.rjconsultores.ventaboletos.entidad.Usuario; import com.rjconsultores.ventaboletos.entidad.Usuario;
/** /**
* *
* @author Administrador * @author Administrador
@ -60,16 +60,12 @@ public class MarcaHibernateDAO extends GenericHibernateDAO<Marca, Short>
public List<Marca> buscarTodosExceto(Usuario usuario, Integer... idMarca) { public List<Marca> buscarTodosExceto(Usuario usuario, Integer... idMarca) {
String hql = " select new com.rjconsultores.ventaboletos.entidad.Marca(marca.marcaId, marca.descmarca) from Marca marca, UsuarioEmpresa ue" + String hql = " select new com.rjconsultores.ventaboletos.entidad.Marca(marca.marcaId, marca.descmarca) from Marca marca, UsuarioEmpresa ue" +
" where marca.empresa = ue.empresa and ue.usuarioLog := usuarioId "; " where marca.empresa = ue.empresa and ue.usuarioLog = :usuarioId ";
for(Integer marca: idMarca){ hql = hql + " and marca.marcaId not in ( " + StringUtils.join(idMarca, ",") + ")";
hql = hql + " and marca.marcaId <> "+ marca.shortValue();
}
Query sq = getSession().createQuery(hql); Query sq = getSession().createQuery(hql);
sq.setParameter("usuarioId", usuario.getUsuarioId()); sq.setParameter("usuarioId", usuario);
List<Marca> lsMarca = sq.list(); List<Marca> lsMarca = sq.list();
return lsMarca; return lsMarca;
@ -83,17 +79,15 @@ public class MarcaHibernateDAO extends GenericHibernateDAO<Marca, Short>
return lsMarca; return lsMarca;
} }
public List<Marca> buscarMarcaPorEmpresa(List<Empresa> empresa) { public List<Marca> buscarMarcaPorEmpresa(List<Empresa> empresa) {
if ( (empresa == null) || (empresa.isEmpty())){ if ((empresa == null) || (empresa.isEmpty())) {
return Collections.emptyList(); return Collections.emptyList();
} }
Collection idsEmpresa = CollectionUtils.transformedCollection(empresa, new Transformer() { Collection idsEmpresa = CollectionUtils.transformedCollection(empresa, new Transformer() {
@Override @Override
public Object transform(Object input) { public Object transform(Object input) {
return ((Empresa)input).getEmpresaId(); return ((Empresa) input).getEmpresaId();
} }
}); });

View File

@ -46,6 +46,7 @@ public class CategoriaCorrida implements Serializable {
private Integer usuarioId; private Integer usuarioId;
@JoinColumn(name = "CORRIDA_ID", referencedColumnName = "CORRIDA_ID") @JoinColumn(name = "CORRIDA_ID", referencedColumnName = "CORRIDA_ID")
@ManyToOne @ManyToOne
@NotFound(action=NotFoundAction.IGNORE)
private CorridaCtrl corridaCtrl; private CorridaCtrl corridaCtrl;
@JoinColumn(name = "CATEGORIACTRL_ID", referencedColumnName = "CATEGORIACTRL_ID") @JoinColumn(name = "CATEGORIACTRL_ID", referencedColumnName = "CATEGORIACTRL_ID")
@ManyToOne @ManyToOne

View File

@ -23,6 +23,9 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.SequenceGenerator; import javax.persistence.SequenceGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
/** /**
* *
* @author Administrador * @author Administrador
@ -57,6 +60,7 @@ public class CategoriaCtrl implements Serializable {
@OneToMany(mappedBy = "categoriaCtrl", cascade = CascadeType.ALL) @OneToMany(mappedBy = "categoriaCtrl", cascade = CascadeType.ALL)
private List<CategoriaMarca> categoriaMarcaList; private List<CategoriaMarca> categoriaMarcaList;
@OneToMany(mappedBy = "categoriaCtrl", cascade = CascadeType.ALL) @OneToMany(mappedBy = "categoriaCtrl", cascade = CascadeType.ALL)
@NotFound(action=NotFoundAction.IGNORE)
private List<CategoriaCorrida> categoriaCorridaList; private List<CategoriaCorrida> categoriaCorridaList;
@OneToMany(mappedBy = "categoriaCtrl", cascade = CascadeType.ALL) @OneToMany(mappedBy = "categoriaCtrl", cascade = CascadeType.ALL)
private List<CategoriaMercado> categoriaMercadoList; private List<CategoriaMercado> categoriaMercadoList;

View File

@ -70,6 +70,10 @@ public class RutaServiceImpl implements RutaService {
entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE); entidad.setActivo(Boolean.TRUE);
if (entidad.getVentaOffLine() == null){
entidad.setVentaOffLine(false);
}
entidad = rutaDAO.suscribir(entidad); entidad = rutaDAO.suscribir(entidad);
if (lsParadasSequencia != null) { if (lsParadasSequencia != null) {
generarSecuencias(entidad, lsParadasSequencia); generarSecuencias(entidad, lsParadasSequencia);

View File

@ -124,7 +124,13 @@ public class TramoRutaServiceImpl implements TramoRutaService {
ruta.setClaseServicio(rutaTramoVO.getClaseServicio()); ruta.setClaseServicio(rutaTramoVO.getClaseServicio());
ruta.setOrgaoConcedente(rutaTramoVO.getOrgaoConcedente()); ruta.setOrgaoConcedente(rutaTramoVO.getOrgaoConcedente());
ruta.setIndNombreObligatorio(rutaTramoVO.getSolicitaNombrePasajero()); ruta.setIndNombreObligatorio(rutaTramoVO.getSolicitaNombrePasajero());
if (rutaTramoVO.getVentaHandHeld() == null){
ruta.setVentaOffLine(false);
}else{
ruta.setVentaOffLine(rutaTramoVO.getVentaHandHeld()); ruta.setVentaOffLine(rutaTramoVO.getVentaHandHeld());
}
ruta.setLsRutaEmpresa(lsRutaEmpresa); ruta.setLsRutaEmpresa(lsRutaEmpresa);
ruta.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); ruta.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
ruta.setActivo(Boolean.TRUE); ruta.setActivo(Boolean.TRUE);