Example usage for org.hibernate Filter setParameter

List of usage examples for org.hibernate Filter setParameter

Introduction

In this page you can find the example usage for org.hibernate Filter setParameter.

Prototype

public Filter setParameter(String name, Object value);

Source Link

Document

Set the named parameter's value for this filter.

Usage

From source file:org.jspresso.framework.application.backend.persistence.hibernate.HibernateBackendController.java

License:Open Source License

private void configureHibernateGlobalFilter(Filter filter) {
    String filterLanguage = null;
    if (getLocale() != null) {
        filterLanguage = getLocale().getLanguage();
    }/*from w ww .  ja  v  a 2  s  .  c om*/
    if (filterLanguage == null) {
        filterLanguage = "";
    }
    String filterLogin = null;
    if (getApplicationSession().getPrincipal() != null) {
        filterLogin = getApplicationSession().getUsername();
    }
    if (filterLogin == null) {
        filterLogin = "";
    }
    filter.setParameter(JSPRESSO_SESSION_GLOBALS_LANGUAGE, filterLanguage);
    filter.setParameter(JSPRESSO_SESSION_GLOBALS_LOGIN, filterLogin);
}

From source file:org.openeos.erp.core.ui.internal.ClientFilterProvider.java

License:Apache License

public void enableFilter(Session session) {
    Client client = (Client) sessionObjectsService
            .getSessionObject(ClientContextObjectContributor.CONTEXT_OBJECT_CLIENT_NAME);
    if (client != null) {
        LOG.debug("New session created, enabling filter for client selection");
        Filter filter = session.enableFilter(CLIENT_FILTER_NAME);
        filter.setParameter("client", client.getId());
        List<String> organizationList = new ArrayList<String>();
        for (Organization org : ((Client) session.get(Client.class, client.getId())).getOrganizations()) {
            organizationList.add(org.getId());
        }/*w ww  . ja  v  a2s.com*/
        filter = session.enableFilter(CLIENT_ORGANIZATION_FILTER_NAME);
        if (organizationList.size() == 0) {
            organizationList.add(
                    "NULL_EXPECT_NEVER_HAS_THIS_KEY_BECAUSE_THE_STRING_HAS_MORE_LEN THAN THE PERMITTED_KEY");
        }
        filter.setParameterList("organizationList", organizationList);

    } else {
        LOG.debug("Client filter not enabling because client is not established");
    }

}

From source file:org.sigmah.server.domain.DomainFilters.java

License:Open Source License

public static void applyVisibleFilter(User user, EntityManager em) {
    /* Hide entities that this user does not have permission to view */
    org.hibernate.Session session = ((HibernateEntityManager) em).getSession();

    Filter filter = session.enableFilter("userVisible");
    filter.setParameter("currentUserId", user.getId());

}

From source file:py.una.pol.karaku.dao.filter.KarakuEntityFilterHandler.java

License:Open Source License

public void doBefore(final JoinPoint joinPoint, final EntityFilter annotation) {

    Filter f = sessionFactory.getCurrentSession().enableFilter(annotation.filter());
    String expression;/*from ww w. java2  s.co  m*/
    Integer paramNumber;
    Expression exp;
    Object subject;
    Object[] params = joinPoint.getArgs();
    for (FilterAttribute attribute : annotation.params()) {
        if (ELParser.isMethodParamExpression(attribute.path())) {
            paramNumber = ELParser.getParamNumber(attribute.path());
            expression = ELParser.removeParamNumber(attribute.path());
            exp = parser.parseExpression(expression);
            subject = params[paramNumber];
        } else {
            exp = parser.parseExpression(attribute.path());
            subject = joinPoint.getTarget();
        }
        f.setParameter(attribute.name(), exp.getValue(subject));
    }
}