List of usage examples for org.hibernate.criterion Restrictions eq
public static SimpleExpression eq(String propertyName, Object value)
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. * /* w w w.j a v 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 ww . j ava 2s . 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();//from w w w. j a va 2 s.c o m 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
@SuppressWarnings("unchecked") public List<ArkUserRole> getArkUserRoleList(Study study, ArkUser arkUser) { // Criteria criteria = getSession().createCriteria(LinkStudyArkModule.class, "linkStudyArkModule"); // criteria.add(Restrictions.eq("study", study)); // criteria.createAlias("arkUserRoleList", "userRole", Criteria.LEFT_JOIN); // criteria.add(Restrictions.or(Restrictions.eq("userRole.arkUser", arkUser), Restrictions.isNull("userRole.arkUser"))); // criteria.add(Restrictions.eq("userRole.study", study)); //// w w w . j a v a2 s .c om // ProjectionList projection = Projections.projectionList(); // projection.add(Projections.property("userRole.id"), "id"); // projection.add(Projections.property("userRole.arkUser"), "arkUser"); // projection.add(Projections.property("userRole.arkRole"), "arkRole"); // projection.add(Projections.property("linkStudyArkModule.arkModule"), "arkModule"); // projection.add(Projections.property("linkStudyArkModule.study"), "study"); // // criteria.setProjection(projection); // // criteria.setResultTransformer(Transformers.aliasToBean(ArkUserRole.class)); // List<ArkUserRole> listOfResults = criteria.list(); Criteria criteria = getSession().createCriteria(ArkUserRole.class); criteria.add(Restrictions.eq("study", study)); criteria.add(Restrictions.eq("arkUser", arkUser)); List<ArkUserRole> listOfResults = criteria.list(); return listOfResults; }
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 * //w ww . j a va 2 s. c o 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
/** * Get a List of ArkUserRole objects for a given study and Module. This method can be used to determine a list of Ark Modules arkUsers are linked * to for a given study.//from w w w . j av a 2 s . co m * * @param study * @param arkModule * @return */ @SuppressWarnings("unchecked") public List<ArkUserRole> getArkUserLinkedModule(Study study, ArkModule arkModule) { List<ArkUserRole> arkUserRoleList = new ArrayList<ArkUserRole>(); Criteria criteria = getSession().createCriteria(ArkUserRole.class); criteria.add(Restrictions.eq("arkModule", arkModule)); criteria.add(Restrictions.eq("study", study)); arkUserRoleList = criteria.list(); return arkUserRoleList; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
/** * //from ww w. j av a 2s .c om * Returns an existing collection of LinkStudyArkModule objects for a given Study * * @param study * @return List<LinkStudyArkModule> */ @SuppressWarnings("unchecked") public List<LinkStudyArkModule> getLinkStudyArkModulesList(Study study) { Criteria criteria = getSession().createCriteria(LinkStudyArkModule.class); criteria.add(Restrictions.eq("study", study)); return criteria.list(); }
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 {/* w w w . j a v a2s . com*/ 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 {// w w w . j ava 2 s. 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; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ArkRolePolicyTemplate> getArkRolePolicyTemplate(ArkRole arkRole, ArkModule arkModule) { List<ArkRolePolicyTemplate> arkRolePolicyTemplateList = new ArrayList<ArkRolePolicyTemplate>(0); Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class); criteria.add(Restrictions.eq("arkRole", arkRole)); if (!arkRole.getName() .equalsIgnoreCase(au.org.theark.core.security.RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)) { criteria.add(Restrictions.eq("arkModule", arkModule)); }//from www . ja va2 s . c o m arkRolePolicyTemplateList = (List<ArkRolePolicyTemplate>) criteria.list(); return arkRolePolicyTemplateList; }