Example usage for org.hibernate Criteria list

List of usage examples for org.hibernate Criteria list

Introduction

In this page you can find the example usage for org.hibernate Criteria list.

Prototype

public List list() throws HibernateException;

Source Link

Document

Get the results.

Usage

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkModuleFunction> getArkModuleFunctionByArkModule(ArkModule arkModule) {
    Criteria criteria = getSession().createCriteria(ArkModuleFunction.class);
    criteria.add(Restrictions.eq("arkModule", arkModule));
    return (List<ArkModuleFunction>) criteria.list();
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkFunction> getArkFunctionListByArkModule(ArkModule arkModule) {
    Criteria criteria = getSession().createCriteria(ArkModuleFunction.class);
    if (arkModule.getId() != null) {
        criteria.add(Restrictions.eq("arkModule", arkModule));
    }//  w w w  .jav  a 2s . c om
    criteria.createAlias("arkModule", "module");
    criteria.addOrder(Order.asc("module.name"));
    criteria.addOrder(Order.asc("functionSequence"));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arkFunction"), "arkFunction");
    criteria.setProjection(projectionList);
    return criteria.list();
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkRole> searchPageableArkRoles(ArkRole arkRoleCriteria, int first, int count) {
    Criteria criteria = buildArkRoleCriteria(arkRoleCriteria);
    criteria.setFirstResult(first);//w w w.  ja  v a2s. c  o  m
    criteria.setMaxResults(count);
    List<ArkRole> list = criteria.list();
    return list;
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkModule> getArkModuleListByArkRole(ArkRole arkRole) {
    Criteria criteria = getSession().createCriteria(ArkModuleRole.class);
    if (arkRole != null) {
        criteria.add(Restrictions.eq("arkRole", arkRole));
    }//from w  w w.  j  a v  a  2 s. c o  m
    criteria.createAlias("arkModule", "module");
    criteria.addOrder(Order.asc("module.name"));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arkModule"), "arkModule");
    criteria.setProjection(projectionList);
    return criteria.list();
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

private List<ArkModuleRole> getArkModuleRoleByArkModule(ArkModule arkModule) {
    Criteria criteria = getSession().createCriteria(ArkModuleRole.class);

    if (arkModule.getId() != null) {
        criteria.add(Restrictions.eq("arkModule", arkModule));
    }// w ww.  j  a v  a 2s. c o m

    criteria.createAlias("arkModule", "module");
    criteria.addOrder(Order.asc("module.name"));

    return criteria.list();
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkRole> getArkRoleListByArkModule(ArkModule arkModule) {
    Criteria criteria = getSession().createCriteria(ArkModuleRole.class);
    if (arkModule.getId() != null) {
        criteria.add(Restrictions.eq("arkModule", arkModule));
    }//w w  w  . j av  a2 s  . c o m

    // Restrict searching/selecting of Super Administrator
    criteria.add(Restrictions.ne("arkModule",
            getArkRoleByName(au.org.theark.core.security.RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)));

    criteria.createAlias("arkRole", "role");
    criteria.addOrder(Order.asc("role.name"));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("arkRole"), "arkRole");
    criteria.setProjection(projectionList);
    return criteria.list();
}

From source file:au.org.theark.admin.model.dao.AdminDao.java

License:Open Source License

public List<ArkModuleRole> searchPageableArkModuleRoles(ArkModuleRole arkModulRoleCriteria, int first,
        int count) {
    Criteria criteria = buildArkModuleRoleCriteria(arkModulRoleCriteria);
    criteria.setFirstResult(first);/*from w  w  w  .jav a  2 s . co  m*/
    criteria.setMaxResults(count);
    List<ArkModuleRole> list = criteria.list();
    return list;
}

From source file:au.org.theark.core.dao.ArkAuthorisationDao.java

License:Open Source License

/**
 * Returns a list of ArkRole objects from the backend. This does not use the Stateless session. Can be used by front-end client's.
 * // ww w. j av  a  2s .  c  o m
 * @return List<ArkRole>
 */
@SuppressWarnings("unchecked")
public List<ArkRole> getArkRoles() {

    Criteria criteria = getSession().createCriteria(ArkRole.class);
    List<ArkRole> arkRoleList = criteria.list();
    return arkRoleList;
}

From source file:au.org.theark.core.dao.ArkAuthorisationDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<ArkUserRole> getArkSuperAdministratorList() throws EntityNotFoundException {
    Criteria criteria = getSession().createCriteria(ArkUserRole.class);
    ArkRole arkRole = getArkRoleByName(RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR);
    criteria.add(Restrictions.eq("arkRole", arkRole));
    return criteria.list();
}

From source file:au.org.theark.core.dao.ArkAuthorisationDao.java

License:Open Source License

/**
 * Use this method when we want to load the Collection of Administrator roles as a Collectio<String>. The method looks up Ark Super Administrator
 * and Administrator roles given a LdapUserName. It populates it into a Collection<String> that represent a unique set of administration roles for
 * this user. It does not take into account the Module or Study. This is usually when the user has logged in first and we want to know if the user
 * has a role of type Administator so he can have access to Create function.
 * /*from www .  j  a  va  2  s .c o  m*/
 * @param ldapUserName
 * @return Collection<String>
 * @throws EntityNotFoundException
 */
@SuppressWarnings("unchecked")
public Collection<String> getUserAdminRoles(String ldapUserName) throws EntityNotFoundException {

    ArkUser arkUser = getArkUser(ldapUserName);

    StatelessSession session = getStatelessSession();
    Criteria criteria = session.createCriteria(ArkUserRole.class);// getSession().createCriteria(ArkUserRole.class);
    ArkRole arkRoleSuperAdmin = getArkRoleByName(RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR);
    ArkRole arkRoleAdmin = getArkRoleByName(RoleConstants.ARK_ROLE_ADMINISTATOR);
    criteria.add(Restrictions.or(Restrictions.eq("arkRole", arkRoleSuperAdmin),
            Restrictions.eq("arkRole", arkRoleAdmin)));
    criteria.add(Restrictions.eq("arkUser", arkUser));
    List<ArkUserRole> arkUserRoleList = (List<ArkUserRole>) criteria.list();
    Set<String> roles = new HashSet<String>(0);
    for (ArkUserRole arkUserRole : arkUserRoleList) {
        String roleName = arkUserRole.getArkRole().getName();
        roles.add(roleName);
    }

    Collection<String> userRoles = new ArrayList<String>();
    for (String roleName : roles) {
        userRoles.add(roleName);
    }
    session.close();
    return userRoles;
}