List of usage examples for org.hibernate Criteria setMaxResults
public Criteria setMaxResults(int maxResults);
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public List<ArkRoleModuleFunctionVO> searchPageableArkRoleModuleFunctionVO( ArkRoleModuleFunctionVO arkRoleModuleFunctionVo, int first, int count) { Criteria criteria = buildArkRoleModuleFunctionVoCriteria(arkRoleModuleFunctionVo); criteria.setFirstResult(first);/*from ww w. j ava2s . c o m*/ criteria.setMaxResults(count); // Restrict to NOT show Super Administrator (safety) // NOTE arpt alias set in buildarkRoleModuleFunctionVoCriteria criteria.add((Restrictions.ne("arpt.arkRole", getArkRoleByName(au.org.theark.core.security.RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)))); List<ArkRoleModuleFunctionVO> list = criteria.list(); return list; }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public List<ArkModuleFunction> searchPageableArkModuleFunctions(ArkModuleFunction arkModuleFunctionCriteria, int first, int count) { Criteria criteria = buildArkModuleFunctionCriteria(arkModuleFunctionCriteria); criteria.setFirstResult(first);//from www .j a v a 2s. com criteria.setMaxResults(count); List<ArkModuleFunction> list = criteria.list(); return 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);/*from www . jav a 2 s. co 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<ArkModuleRole> searchPageableArkModuleRoles(ArkModuleRole arkModulRoleCriteria, int first, int count) { Criteria criteria = buildArkModuleRoleCriteria(arkModulRoleCriteria); criteria.setFirstResult(first);/*from w w w . ja v a2 s . c om*/ criteria.setMaxResults(count); List<ArkModuleRole> list = criteria.list(); return list; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
public boolean isUserAdminHelper(String ldapUserName, String roleName) throws EntityNotFoundException { boolean isAdminType = false; StatelessSession session = getStatelessSession(); // Check or get user ark_user object based on ldapUserName ArkUser arkUser = getArkUser(ldapUserName); Criteria criteria = session.createCriteria(ArkUserRole.class); ArkRole arkRole = getArkRoleByName(roleName); criteria.add(Restrictions.eq("arkRole", arkRole)); criteria.add(Restrictions.eq("arkUser", arkUser)); criteria.setMaxResults(1); ArkUserRole arkUserRole = (ArkUserRole) criteria.uniqueResult(); if (arkUserRole != null) { isAdminType = true;//from w w w. j av a 2 s .c o m } session.close(); return isAdminType; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
private boolean isUserAdminHelper(String ldapUserName, String roleName, ArkFunction arkFunction, ArkModule arkModule) throws EntityNotFoundException { boolean isAdminType = false; StatelessSession session = getStatelessSession(); // Check or get user ark_user object based on ldapUserName ArkUser arkUser = getArkUser(ldapUserName); Criteria criteria = session.createCriteria(ArkUserRole.class); ArkRole arkRole = getArkRoleByName(roleName); criteria.add(Restrictions.eq("arkRole", arkRole)); criteria.add(Restrictions.eq("arkUser", arkUser)); criteria.add(Restrictions.eq("arkModule", arkModule)); criteria.setMaxResults(1); ArkUserRole arkUserRole = (ArkUserRole) criteria.uniqueResult(); if (arkUserRole != null) { isAdminType = true;/*from w w w.j a v a2 s .c om*/ } session.close(); return isAdminType; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
public String getUserRoleForStudy(String ldapUserName, Study study) throws EntityNotFoundException { String roleName = ""; ArkUser arkUser = getArkUser(ldapUserName); StatelessSession session = getStatelessSession(); Criteria criteria = session.createCriteria(ArkUserRole.class);// getSession().createCriteria(ArkUserRole.class); criteria.createAlias("arkUser", "auserObject"); criteria.add(Restrictions.eq("arkUser", arkUser)); criteria.add(Restrictions.eq("auserObject.study", study)); criteria.setMaxResults(1); ArkUserRole arkUserRole = (ArkUserRole) criteria.uniqueResult(); if (arkUserRole != null) { roleName = arkUserRole.getArkRole().getName(); }//from w w w .j a v a 2 s. co m session.close(); return roleName; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
/** * Retrieve a Logged in user's role by providing the Ldap User Name, Usecase id, module id & or study id. We need the Ldap User Name & ArkUseCase * Id as a mandatory one.//from ww w .ja v a 2s .c om * * @throws EntityNotFoundException */ @SuppressWarnings("unchecked") public String getUserRole(String ldapUserName, ArkFunction arkFunction, ArkModule arkModule, Study study) throws EntityNotFoundException { String roleName = ""; ArkUser arkUser = getArkUser(ldapUserName); Criteria criteria = getSession().createCriteria(ArkUserRole.class); criteria.createAlias("arkUser", "auserObject"); criteria.add(Restrictions.eq("arkUser", arkUser)); // Even if there is a study in session the criteria must be applied only if the logged in user has a study registered for him. Ie if he is not a // Super Admin if (!isSuperAdministrator(ldapUserName) && study != null) { criteria.add(Restrictions.eq("study", study)); if (arkModule != null) { criteria.add(Restrictions.eq("arkModule", arkModule)); } // criteria.setMaxResults(1); List<ArkUserRole> list = (List<ArkUserRole>) criteria.list(); if (list.size() > 0) { ArkUserRole arkUserRole = (ArkUserRole) criteria.list().get(0); // ArkUserRole arkUserRole = (ArkUserRole)criteria.list().get(0); if (arkUserRole != null) { roleName = arkUserRole.getArkRole().getName(); } } } else { if (arkModule != null) { criteria.add(Restrictions.eq("arkModule", arkModule)); } criteria.setMaxResults(1); ArkUserRole arkUserRole = (ArkUserRole) criteria.uniqueResult(); if (arkUserRole != null) { roleName = arkUserRole.getArkRole().getName(); } } return roleName; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
public ArkFunction getArkFunctionByName(String functionName) { Criteria criteria = getSession().createCriteria(ArkFunction.class); criteria.add(Restrictions.eq("name", functionName)); criteria.setMaxResults(1); ArkFunction arkFunction = (ArkFunction) criteria.uniqueResult(); return arkFunction; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
public ArkModule getArkModuleByName(String moduleName) { Criteria criteria = getSession().createCriteria(ArkModule.class); criteria.add(Restrictions.eq("name", moduleName)); criteria.setMaxResults(1); ArkModule arkModule = (ArkModule) criteria.uniqueResult(); return arkModule; }