-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Applying a filter
PostPosted: Thu Oct 16, 2008 3:26 pm 
Newbie

Joined: Thu Oct 16, 2008 2:43 pm
Posts: 1
Hi all.

I'm having some problems to apply a filter in a list.

I'm recovering the list like this:

Code:
Hibernate.initialize(PropertyUtils.getProperty(vo,nomeColDet));


And i need to apply this filter:

Code:
org.hibernate.Filter f = sess.enableFilter(fA.name());



Here is where i apply the filter:

Code:
  protected void aplicaUmFiltro( Class classe, Filter fA) throws PlcException {
           
        PlcAopProfilingHelper.getInstance().exibeProfilingIda(this.getClass().getName(), logPersistencia);

        Session sess = getSession(PlcAnotacaoHelper.getInstance().getFabricaNome(classe));               
       
        org.hibernate.Filter f = sess.enableFilter(fA.name());
       
        // Depois varre todos os argumentos. Se o filtro tiver todos os argumentos
        // informados, deixa-o habilitado
        Set s = f.getFilterDefinition().getParameterNames();
       
        Iterator j = s.iterator();
        while (j.hasNext()) {
           
            String argumento = (String) j.next();
            Object argumentoValor = null;
            PlcBaseContextVO context = getContext();
            if (context.getPerfilUsu() !=null && context.getPerfilUsu().getPlcSegurancaVertical() != null &&
                    context.getPerfilUsu().getPlcSegurancaVertical().containsKey(argumento))
                argumentoValor = context.getPerfilUsu().getPlcSegurancaVertical().get(argumento);
           
            if (argumentoValor == null)
                argumentoValor = aplicaUmFiltroInformaArgOmitidoApi(classe,fA,f,argumento);
       
            if (argumentoValor != null) {
                if (List.class.isAssignableFrom(argumentoValor.getClass())) {
                    if (log.isDebugEnabled())
                        log.debug("FILTRO: Vai colocar valor de lista "+argumentoValor + " no argumento de filtro"+argumento);
                    f.setParameterList(argumento,(List)argumentoValor);
                } else {
                    if (log.isDebugEnabled())
                        log.debug("FILTRO: Vai colocar valor  "+argumentoValor + " no argumento de filtro"+argumento);
                    // Lógica de aprovação
                    if (argumento.equals("sitHistoricoPlc") && "pesquisaPendentes".equals(context.getAcaoOriginal()))
                        f.setParameter(argumento,"P");
                    else
                        f.setParameter(argumento,argumentoValor);
                }
            } else {
                // Se não encontrar um argumento advindo da lógica de profile ou método específico,
                // entao desabilita o filtro
                sess.disableFilter(fA.name());
                 PlcAopProfilingHelper.getInstance().exibeProfilingVolta(this.getClass().getName(), logPersistencia);

                return;
            }
               
        }
       
        if (log.isDebugEnabled())
            log.debug("Vai usar filtro com valores "+fA);

         PlcAopProfilingHelper.getInstance().exibeProfilingVolta(this.getClass().getName(), logPersistencia);
       
    }



And here is where i want to apply the filter:
Code:
if (PropertyUtils.isReadable(vo,nomeColDet) && !getContext().isPorDemanda(nomeColDet))
                                Hibernate.initialize(PropertyUtils.getProperty(vo,nomeColDet));




How can i do this?

Thank u all.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.