diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/MarcaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/MarcaHibernateDAO.java index 75dbeeced..2dff54a51 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/MarcaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/MarcaHibernateDAO.java @@ -11,6 +11,7 @@ import java.util.List; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.Transformer; +import org.apache.commons.lang.StringUtils; import org.hibernate.Criteria; import org.hibernate.FetchMode; import org.hibernate.Query; @@ -26,54 +27,49 @@ import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.Marca; import com.rjconsultores.ventaboletos.entidad.Usuario; - /** - * + * * @author Administrador */ @Repository("marcaDAO") public class MarcaHibernateDAO extends GenericHibernateDAO - implements MarcaDAO { + implements MarcaDAO { - @Autowired - public MarcaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { - setSessionFactory(factory); - } + @Autowired + public MarcaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } - @Override - public List obtenerTodos() { - Criteria c = getSession().createCriteria(getPersistentClass()); - c.add(Restrictions.eq("activo", Boolean.TRUE)); - c.addOrder(Order.asc("descmarca")); + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.addOrder(Order.asc("descmarca")); - return c.list(); - - } + return c.list(); - public List buscarPorNome(String nomeMarca) { - Criteria c = getSession().createCriteria(getPersistentClass()); - c.add(Restrictions.eq("activo", Boolean.TRUE)); - c.add(Restrictions.eq("descmarca", nomeMarca)); + } - return c.list(); - } + public List buscarPorNome(String nomeMarca) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("descmarca", nomeMarca)); - public List buscarTodosExceto(Usuario usuario, Integer... idMarca) { - 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 "; - - for(Integer marca: idMarca){ - - hql = hql + " and marca.marcaId <> "+ marca.shortValue(); - - } - - Query sq = getSession().createQuery(hql); - sq.setParameter("usuarioId", usuario.getUsuarioId()); + return c.list(); + } + + public List buscarTodosExceto(Usuario usuario, Integer... idMarca) { + 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 "; + + hql = hql + " and marca.marcaId not in ( " + StringUtils.join(idMarca, ",") + ")"; + + Query sq = getSession().createQuery(hql); + sq.setParameter("usuarioId", usuario); List lsMarca = sq.list(); return lsMarca; - } + } @Override public List buscarDescricaoIdMarca() { @@ -82,26 +78,24 @@ public class MarcaHibernateDAO extends GenericHibernateDAO List lsMarca = sq.list(); return lsMarca; } - - public List buscarMarcaPorEmpresa(List empresa) { - if ( (empresa == null) || (empresa.isEmpty())){ + 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(); + return ((Empresa) input).getEmpresaId(); } }); - + Criteria c = makeCriteria(); c.add(Restrictions.eq("activo", true)); c.add(Restrictions.in("empresa", idsEmpresa)); c.setFetchMode("logotipomarca", FetchMode.DEFAULT); - + return c.list(); } diff --git a/src/com/rjconsultores/ventaboletos/entidad/CategoriaCorrida.java b/src/com/rjconsultores/ventaboletos/entidad/CategoriaCorrida.java index d4fa8a21d..261eee1e8 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/CategoriaCorrida.java +++ b/src/com/rjconsultores/ventaboletos/entidad/CategoriaCorrida.java @@ -46,6 +46,7 @@ public class CategoriaCorrida implements Serializable { private Integer usuarioId; @JoinColumn(name = "CORRIDA_ID", referencedColumnName = "CORRIDA_ID") @ManyToOne + @NotFound(action=NotFoundAction.IGNORE) private CorridaCtrl corridaCtrl; @JoinColumn(name = "CATEGORIACTRL_ID", referencedColumnName = "CATEGORIACTRL_ID") @ManyToOne diff --git a/src/com/rjconsultores/ventaboletos/entidad/CategoriaCtrl.java b/src/com/rjconsultores/ventaboletos/entidad/CategoriaCtrl.java index 08ebad590..5cdf449a0 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/CategoriaCtrl.java +++ b/src/com/rjconsultores/ventaboletos/entidad/CategoriaCtrl.java @@ -23,6 +23,9 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.SequenceGenerator; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + /** * * @author Administrador @@ -57,6 +60,7 @@ public class CategoriaCtrl implements Serializable { @OneToMany(mappedBy = "categoriaCtrl", cascade = CascadeType.ALL) private List categoriaMarcaList; @OneToMany(mappedBy = "categoriaCtrl", cascade = CascadeType.ALL) + @NotFound(action=NotFoundAction.IGNORE) private List categoriaCorridaList; @OneToMany(mappedBy = "categoriaCtrl", cascade = CascadeType.ALL) private List categoriaMercadoList; diff --git a/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java index e626d638d..3db986309 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java @@ -69,6 +69,10 @@ public class RutaServiceImpl implements RutaService { entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE); + + if (entidad.getVentaOffLine() == null){ + entidad.setVentaOffLine(false); + } entidad = rutaDAO.suscribir(entidad); if (lsParadasSequencia != null) { diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TramoRutaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TramoRutaServiceImpl.java index 3e296a422..9fbbda69e 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/TramoRutaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/TramoRutaServiceImpl.java @@ -124,7 +124,13 @@ public class TramoRutaServiceImpl implements TramoRutaService { ruta.setClaseServicio(rutaTramoVO.getClaseServicio()); ruta.setOrgaoConcedente(rutaTramoVO.getOrgaoConcedente()); ruta.setIndNombreObligatorio(rutaTramoVO.getSolicitaNombrePasajero()); - ruta.setVentaOffLine(rutaTramoVO.getVentaHandHeld()); + + if (rutaTramoVO.getVentaHandHeld() == null){ + ruta.setVentaOffLine(false); + }else{ + ruta.setVentaOffLine(rutaTramoVO.getVentaHandHeld()); + } + ruta.setLsRutaEmpresa(lsRutaEmpresa); ruta.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); ruta.setActivo(Boolean.TRUE);