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.