List of usage examples for org.hibernate.criterion Projections groupProperty
public static PropertyProjection groupProperty(String propertyName)
From source file:ar.com.zauber.commons.repository.aggregate.ProjectionAggregateFunctionVisitor.java
License:Apache License
/** crea projecciones en base a {@link PropertyAggregateFunction}. */ private static Projection createPropertyProjection(final PropertyAggregateFunction paf) { final String propertyName = paf.getProperty(); final Projection projection; if (paf instanceof AveragePropertyAggregateFunction) { projection = Projections.avg(propertyName); } else if (paf instanceof CountDistinctPropertyAggregateFunction) { projection = Projections.countDistinct(propertyName); } else if (paf instanceof CountPropertyAggregateFunction) { projection = Projections.count(propertyName); } else if (paf instanceof MaxPropertyAggregateFunction) { projection = Projections.max(propertyName); } else if (paf instanceof MinPropertyAggregateFunction) { projection = Projections.min(propertyName); } else if (paf instanceof SumPropertyAggregateFunction) { projection = Projections.sum(propertyName); } else if (paf instanceof GroupPropertyAggregateFilter) { projection = Projections.groupProperty(propertyName); } else {//from w ww . ja v a2 s.co m throw new IllegalArgumentException("don't know how to process " + paf.getClass()); } return projection; }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
protected Criteria buildArkRoleModuleFunctionVoCriteria( ArkRoleModuleFunctionVO arkRoleModuleFunctionVoCriteria) { Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class, "arpt"); if (arkRoleModuleFunctionVoCriteria.getArkRole() != null) { criteria.add(Restrictions.eq("arpt.arkRole", arkRoleModuleFunctionVoCriteria.getArkRole())); }/*from ww w . j av a 2 s . c o m*/ if (arkRoleModuleFunctionVoCriteria.getArkModule() != null) { criteria.add(Restrictions.eq("arpt.arkModule", arkRoleModuleFunctionVoCriteria.getArkModule())); } if (arkRoleModuleFunctionVoCriteria.getArkFunction() != null) { criteria.add(Restrictions.eq("arpt.arkFunction", arkRoleModuleFunctionVoCriteria.getArkFunction())); } ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("arpt.arkRole"), "arkRole"); projectionList.add(Projections.groupProperty("arpt.arkModule"), "arkModule"); projectionList.add(Projections.groupProperty("arpt.arkFunction"), "arkFunction"); criteria.setProjection(projectionList); ResultTransformer resultTransformer = Transformers.aliasToBean(ArkRoleModuleFunctionVO.class); criteria.setResultTransformer(resultTransformer); return criteria; }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public List<ArkRoleModuleFunctionVO> getArkRoleModuleFunctionVoList(ArkRole arkRole) { Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class, "arpt"); criteria.add(Restrictions.eq("arpt.arkRole", arkRole)); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("arpt.arkRole"), "arkRole"); projectionList.add(Projections.groupProperty("arpt.arkModule"), "arkModule"); projectionList.add(Projections.groupProperty("arpt.arkFunction"), "arkFunction"); criteria.setProjection(projectionList); ResultTransformer resultTransformer = Transformers.aliasToBean(ArkRoleModuleFunctionVO.class); criteria.setResultTransformer(resultTransformer); return criteria.list(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public List<ArkModule> getArkModuleList(ArkRole arkRole) { Criteria criteria = getSession().createCriteria(ArkModuleRole.class); if (arkRole != null) { criteria.add(Restrictions.eq("arkRole", arkRole)); }/*w w w .j a va 2 s . c o m*/ 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
public List<ArkFunction> getArkFunctionListByArkModule(ArkModule arkModule) { Criteria criteria = getSession().createCriteria(ArkModuleFunction.class); if (arkModule.getId() != null) { criteria.add(Restrictions.eq("arkModule", arkModule)); }/*from w w w .j av a2 s . 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<ArkModule> getArkModuleListByArkRole(ArkRole arkRole) { Criteria criteria = getSession().createCriteria(ArkModuleRole.class); if (arkRole != null) { criteria.add(Restrictions.eq("arkRole", arkRole)); }/* w w w . ja va 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
public List<ArkRole> getArkRoleListByArkModule(ArkModule arkModule) { Criteria criteria = getSession().createCriteria(ArkModuleRole.class); if (arkModule.getId() != null) { criteria.add(Restrictions.eq("arkModule", arkModule)); }/*w ww . jav a 2s .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.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<String> getArkRolePermission(ArkFunction arkFunction, String userRole, ArkModule arkModule) throws EntityNotFoundException { Collection<String> stringPermissions = new ArrayList<String>(); ArkRole arkRole = getArkRoleByName(userRole); Criteria criteria = getSession().createCriteria(ArkRolePolicyTemplate.class); if (arkModule != null) { criteria.add(Restrictions.eq("arkModule", arkModule)); }/* w w w .jav a2s . co m*/ if (arkFunction != null) { criteria.add(Restrictions.eq("arkFunction", arkFunction)); } if (arkRole != null) { criteria.add(Restrictions.eq("arkRole", arkRole)); criteria.createAlias("arkPermission", "permission"); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("permission.name")); criteria.setProjection(projectionList); stringPermissions = criteria.list(); } return stringPermissions; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
/** * Returns a list of All Permissions in Ark System * /*from www . j a va 2 s . c om*/ * @return */ @SuppressWarnings("unchecked") public Collection<String> getArkPermission() { Collection<String> arkStringPermissions = new ArrayList<String>(); Criteria criteria = getSession().createCriteria(ArkPermission.class); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("name")); criteria.setProjection(projectionList); arkStringPermissions = criteria.list(); return arkStringPermissions; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Study> getStudyListForUser(ArkUserVO arkUserVo) { List<Study> studyList = new ArrayList<Study>(0); Study searchStudy = arkUserVo.getStudy(); try {// w w w.j a v a 2s. com if (isUserAdminHelper(arkUserVo.getArkUserEntity().getLdapUserName(), RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR)) { studyList = getAllStudiesForSuperAdmin(arkUserVo.getStudy());// Get all Studies } else { /* Get only the studies the ArkUser is linked to via the ArkUserRole */ Criteria criteria = getSession().createCriteria(ArkUserRole.class); criteria.add(Restrictions.eq("arkUser", arkUserVo.getArkUserEntity())); Criteria studyCriteria = criteria.createCriteria("study"); applyStudySearchCriteria(searchStudy, studyCriteria); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("study"), "study"); criteria.setProjection(projectionList); studyList = criteria.list(); } } catch (EntityNotFoundException e1) { log.error("The specified Ark User does not exist " + arkUserVo.getArkUserEntity().getLdapUserName()); e1.printStackTrace(); } return studyList; }