List of usage examples for org.hibernate Criteria list
public List list() throws HibernateException;
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
public boolean arkUserHasModuleAccess(ArkUser arkUser, ArkModule arkModule) { boolean hasModuleAccess = false; Criteria criteria = getSession().createCriteria(ArkUserRole.class); try {//w ww .j a v a2 s . c o m // Restrict by user if NOT Super Administrator if (!isUserAdminHelper(arkUser.getLdapUserName(), RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)) { criteria.add(Restrictions.eq("arkUser", arkUser)); } // Restrict by arkModule criteria.add(Restrictions.eq("arkModule", arkModule)); List<?> list = criteria.list(); hasModuleAccess = (list.size() > 0); } catch (EntityNotFoundException e) { log.error(e.getMessage(), e); } catch (NullPointerException e) { log.error(e.getMessage(), e); } return hasModuleAccess; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ArkModule> getArkModuleListByArkUser(ArkUser arkUser) { Criteria criteria = getSession().createCriteria(ArkUserRole.class); ArkModule arkModule = null;//www . ja v a 2 s. co m try { // Restrict by user if NOT Super Administrator if (!isUserAdminHelper(arkUser.getLdapUserName(), RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)) { criteria.add(Restrictions.eq("arkUser", arkUser)); } } catch (EntityNotFoundException e) { log.error(e.getMessage(), e); } catch (NullPointerException e) { log.error(e.getMessage(), e); } ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("arkModule"), "arkModule"); criteria.setProjection(projectionList); criteria.addOrder(Order.asc("arkModule.id")); criteria.createAlias("arkModule", "am"); criteria.add(Restrictions.eq("am.enabled", true)); return criteria.list(); }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ArkUser> getArkUserListByStudy(ArkUser arkUser, Study study) { Criteria criteria = getSession().createCriteria(ArkUserRole.class); // Restrict by user if NOT Super Administrator try {/*from w w w.j a v a2 s.com*/ if (!isUserAdminHelper(arkUser.getLdapUserName(), RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)) { criteria.add(Restrictions.eq("study", study)); } } catch (EntityNotFoundException e) { log.info("User Name doen not exsists"); } ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("arkUser"), "arkUser"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(ArkUserRole.class)); List<ArkUserRole> arkUserRoles = (List<ArkUserRole>) criteria.list(); List<ArkUser> arkUserLst = new ArrayList<ArkUser>(); for (ArkUserRole arkRolePol : arkUserRoles) { arkUserLst.add(arkRolePol.getArkUser()); } //Added on 2015-12-10 filter study wise users. //changed on 2016-04-28. return arkUserLst; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Study> getParentStudyList() { List<Study> studyList = new ArrayList<Study>(0); // Restrict on study criteria (by default, NOT 'Archive' status) Criteria studyCriteria = getSession().createCriteria(Study.class); StudyStatus status;/*w w w . j a va 2 s . c o m*/ try { status = getStudyStatus("Archive"); studyCriteria.add(Restrictions.ne("studyStatus", status)); } catch (StatusNotAvailableException e) { log.error(e.getMessage(), e); } // Can only select studies with null parent, or where the study is a parent studyCriteria.add(Restrictions.disjunction().add(Restrictions.isNull("parentStudy")) .add(Restrictions.eqProperty("parentStudy.id", "id"))); studyCriteria.addOrder(Order.asc("name")); studyList = studyCriteria.list(); return studyList; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Study> getAssignedChildStudyListForUser(ArkUserVO arkUserVo) { List<Study> studyList = new ArrayList<Study>(0); try {/*from w w w . j a va 2s . com*/ ArkUser arkUser = getArkUser(arkUserVo.getArkUserEntity().getLdapUserName()); /* Get only the studies the ArkUser is linked to via the ArkUserRole */ Criteria criteria = getSession().createCriteria(ArkUserRole.class); criteria.add(Restrictions.eq("arkUser", arkUser)); // Restrict to child studies (without parent) Criteria studyCriteria = criteria.createCriteria("study"); studyCriteria.add(Restrictions.eq("parentStudy", arkUserVo.getStudy())); studyCriteria.add(Restrictions.neProperty("id", "parentStudy.id")); studyCriteria.addOrder(Order.asc("name")); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("study"), "study"); criteria.setProjection(projectionList); studyList = criteria.list(); } catch (EntityNotFoundException e) { log.error(e.getMessage(), e); } return studyList; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
/** * List of Permission for function. // w w w. j a va 2s . com * * Just I need the list of permission list for a particular function I manage to use the hibernate projectionList property. * Group by Permission. * But still used setResultTransformer to transform the list which include the permission list. * @return */ public List<ArkPermission> getArkPremissionListForRoleAndModule(ArkRolePolicyTemplate arkRolePolicyTemplate) { Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class); criteria.add(Restrictions.eq("arkRole", arkRolePolicyTemplate.getArkRole())); criteria.add(Restrictions.eq("arkModule", arkRolePolicyTemplate.getArkModule())); criteria.add(Restrictions.eq("arkFunction", arkRolePolicyTemplate.getArkFunction())); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("arkPermission"), "arkPermission"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(ArkRolePolicyTemplate.class)); List<ArkRolePolicyTemplate> arkRolePolicyTemplatesLst = (List<ArkRolePolicyTemplate>) criteria.list(); List<ArkPermission> arkPermissionLst = new ArrayList<ArkPermission>(); for (ArkRolePolicyTemplate arkRolePol : arkRolePolicyTemplatesLst) { arkPermissionLst.add(arkRolePol.getArkPermission()); } return arkPermissionLst; }
From source file:au.org.theark.core.dao.AuditDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<LssConsentHistory> getLssConsentHistoryList(LinkSubjectStudy linkSubjectStudy) { Criteria criteria = getSession().createCriteria(LssConsentHistory.class); criteria.add(Restrictions.eq("linkSubjectStudy", linkSubjectStudy)); criteria.addOrder(Order.desc("id")); return criteria.list(); }
From source file:au.org.theark.core.dao.AuditDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ConsentHistory> getConsentHistoryList(Consent consent) { Criteria criteria = getSession().createCriteria(ConsentHistory.class); criteria.add(Restrictions.eq("linkSubjectStudy", consent.getLinkSubjectStudy())); if (consent.getStudyComp() != null) { criteria.add(Restrictions.eq("studyComp", consent.getStudyComp())); } else {/*from w w w . java2 s . c o m*/ criteria.add(Restrictions.isNull("studyComp")); } criteria.addOrder(Order.desc("id")); return criteria.list(); }
From source file:au.org.theark.core.dao.AuditDao.java
License:Open Source License
@Override public List<AuditEntity> getAuditEntityList() { Criteria criteria = getSession().createCriteria(AuditEntity.class); return criteria.list(); }
From source file:au.org.theark.core.dao.AuditDao.java
License:Open Source License
@Override public List<AuditPackage> getAuditPackageList() { Criteria criteria = getSession().createCriteria(AuditPackage.class); // criteria.setProjection(Projections.distinct(Projections.id())); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria.list(); }