List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
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)); }/*from ww w .ja v a 2 s.c om*/ 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 a v a2 s . co 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
private Criteria buildArkModuleRoleCriteria(ArkModuleRole arkModuleRoleCriteria) { Criteria criteria = getSession().createCriteria(ArkModuleRole.class); if (arkModuleRoleCriteria.getArkModule() != null && arkModuleRoleCriteria.getArkModule().getId() != null) { criteria.add(Restrictions.eq("arkModule", arkModuleRoleCriteria.getArkModule())); }// ww w.j av a 2 s.c o m if (arkModuleRoleCriteria.getArkRole() != null && arkModuleRoleCriteria.getArkRole().getId() != null) { criteria.add(Restrictions.eq("arkRole", arkModuleRoleCriteria.getArkRole())); } criteria.createAlias("arkModule", "module"); criteria.addOrder(Order.asc("module.name")); return criteria; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<ArkModuleRole> getArkModuleAndLinkedRoles() { Collection<ArkModuleRole> arkModuleList = new ArrayList<ArkModuleRole>(); Criteria criteria = getSession().createCriteria(ArkModuleRole.class); criteria.createAlias("arkModule", "moduleName"); criteria.addOrder(Order.asc("moduleName.name")); arkModuleList = criteria.list();//from ww w. j a v a2 s. c o m //TODO: What are we iterating for if we are not doing anything? delete? /*for (Iterator iterator = arkModuleList.iterator(); iterator.hasNext();) { ArkModuleRole arkModuleRole = (ArkModuleRole) iterator.next(); }*/ return arkModuleList; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
/** * Get a list of Modules that are linked to the study and then get the roles linked to each module A VO List of ArkModuleVO will contain the * ArkModule and a list of ArkRoles. Note:This implementation will exclude Reporting Module from the list specifically. * //from ww w. j av a 2 s. c o m * @param study * @return Collection<ArkModuleVO> Minus the Reporting Module */ @SuppressWarnings("unchecked") public Collection<ArkModuleVO> getArkModulesAndRolesLinkedToStudy(Study study) { ArkModule arkModuleToExclude = getArkModuleByName(Constants.ARK_MODULE_REPORTING); Collection<LinkStudyArkModule> arkStudyLinkedModuleList = new ArrayList<LinkStudyArkModule>(); Collection<ArkModuleVO> arkModuleVOList = new ArrayList<ArkModuleVO>(); Criteria criteria = getSession().createCriteria(LinkStudyArkModule.class); criteria.add(Restrictions.eq("study", study)); //criteria.add(Restrictions.ne("arkModule", arkModuleToExclude)); criteria.createAlias("arkModule", "module"); criteria.addOrder(Order.asc("module.id")); arkStudyLinkedModuleList = criteria.list(); // For each one in the List get the associated Roles i.e for each module get the Roles for (LinkStudyArkModule linkStudyArkModule : arkStudyLinkedModuleList) { // Here is a Module linked to a study get the Roles linked to this module ArkModuleVO arkModuleVO = new ArkModuleVO(); arkModuleVO.setArkModule(linkStudyArkModule.getArkModule()); arkModuleVO.setArkModuleRoles(getArkRoleLinkedToModule(linkStudyArkModule.getArkModule())); arkModuleVOList.add(arkModuleVO); } // getArkUserRoleList(study,null); return arkModuleVOList; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<ArkModule> getArkModulesLinkedWithStudy(Study study) { Criteria criteria = getSession().createCriteria(LinkStudyArkModule.class); criteria.add(Restrictions.eq("study", study)); criteria.createAlias("arkModule", "module"); criteria.addOrder(Order.asc("module.id")); Collection<LinkStudyArkModule> arkStudyLinkedModuleList = criteria.list(); Collection<ArkModule> arkModuleList = new ArrayList<ArkModule>(); for (LinkStudyArkModule linkStudyArkModule : arkStudyLinkedModuleList) { arkModuleList.add(linkStudyArkModule.getArkModule()); }/*from w w w . j av a2 s.c o m*/ return arkModuleList; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public ArrayList<ArkRole> getArkRoleLinkedToModule(ArkModule arkModule) { Collection<ArkModuleRole> arkModuleList = new ArrayList<ArkModuleRole>(); Criteria criteria = getSession().createCriteria(ArkModuleRole.class); criteria.add(Restrictions.eq("arkModule", arkModule)); criteria.createAlias("arkRole", "role", JoinType.LEFT_OUTER_JOIN); criteria.addOrder(Order.asc("role.name")); arkModuleList = criteria.list();/*ww w .j a v a2s .c om*/ ArrayList<ArkRole> moduleArkRolesList = new ArrayList<ArkRole>(); for (ArkModuleRole arkModuleRole : arkModuleList) { ArkRole arkRole = arkModuleRole.getArkRole(); moduleArkRolesList.add(arkRole); } return moduleArkRolesList; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
/** * Get the ArkUserRole details for the given user for a specific study * /*from w ww . jav a2 s .co m*/ * @throws EntityNotFoundException */ @SuppressWarnings("unchecked") public List<ArkUserRole> getArkUserLinkedModuleAndRoles(ArkUserVO arkUserVO) throws EntityNotFoundException { ArkUser arkUser; List<ArkUserRole> arkUserRoleList = new ArrayList<ArkUserRole>(); arkUser = getArkUser(arkUserVO.getUserName()); arkUserVO.setArkUserPresentInDatabase(true); Criteria criteria = getSession().createCriteria(ArkUserRole.class); criteria.add(Restrictions.eq("arkUser", arkUser)); criteria.createAlias("arkModule", "module"); criteria.addOrder(Order.asc("module.id")); // Restrict by Study if NOT Super Administrator if (!isUserAdminHelper(arkUser.getLdapUserName(), au.org.theark.core.security.RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)) { criteria.add(Restrictions.eq("study", arkUserVO.getStudy())); } try { arkUserRoleList = criteria.list(); } catch (org.hibernate.TransientObjectException toe) { log.error(toe.getMessage(), toe); } return arkUserRoleList; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ArkUserRole> getArkRoleListByUser(ArkUserVO arkUserVo) { List<ArkUserRole> arkUserRoleList = new ArrayList<ArkUserRole>(0); Criteria criteria = getSession().createCriteria(ArkUserRole.class); criteria.add(Restrictions.eq("arkUser", arkUserVo.getArkUserEntity())); // Restrict by Study if NOT Super Administrator try {//from ww w . j a va2s . c o m if (!isUserAdminHelper(arkUserVo.getArkUserEntity().getLdapUserName(), RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)) { Criteria studycriteria = criteria.createCriteria("study"); studycriteria.addOrder(Order.asc("name")); } } catch (HibernateException e) { log.error(e.getMessage(), e); } catch (EntityNotFoundException e) { log.error(e.getMessage(), e); } criteria.addOrder(Order.asc("arkModule")); criteria.addOrder(Order.asc("arkRole")); arkUserRoleList = (List<ArkUserRole>) criteria.list(); return arkUserRoleList; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ArkUserRole> getArkRoleListByUserAndStudy(ArkUserVO arkUserVo, Study study) { List<ArkUserRole> arkUserRoleList; Criteria criteria = getSession().createCriteria(ArkUserRole.class); criteria.add(Restrictions.eq("arkUser", arkUserVo.getArkUserEntity())); try {//from w w w .j a va 2s. c o m if (!isUserAdminHelper(arkUserVo.getArkUserEntity().getLdapUserName(), RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR) && study != null && study.getId() != null) { criteria.add(Restrictions.eq("study", study)); } } catch (EntityNotFoundException e) { e.printStackTrace(); } //Criteria studycriteria = criteria.createCriteria("study"); //studycriteria.addOrder(Order.asc("name")); //criteria.addOrder(Order.asc("study.name")); criteria.addOrder(Order.asc("arkModule")); criteria.addOrder(Order.asc("arkRole")); arkUserRoleList = (List<ArkUserRole>) criteria.list(); return arkUserRoleList; }