/** * Return number of users or groups with provided constraints. * * @param user if true search for users, otherwise search for groups. * @param matchFields the field to math with values. It is a table of table with : * <ul> * <li>fiedname : the name of the field</li> * <li>fieldtype : for example StringProperty. If null the field is considered as document field</li> * <li>pattern matching : based on HQL "like" command</li> * </ul> * @param nb the maximum number of result to return. * @param start the index of the first found user or group to return. * @param context the {@link XWikiContext}. * @return the of found users or groups. * @throws XWikiException error when calling for * {@link XWikiStoreInterface#search(String, int, int, List, XWikiContext)} */ protected int countAllMatchedUsersOrGroups(boolean user, Object[][] matchFields, XWikiContext context) throws XWikiException { List<Object> parameterValues = new ArrayList<Object>(); String where = createMatchUserOrGroupWhereClause(user, matchFields, null, parameterValues); String sql = "select count(distinct doc) from XWikiDocument doc" + where; List< ? > list = context.getWiki().getStore().search(sql, 0, 0, parameterValues, context); if (list == null || list.size() == 0) { return 0; } return ((Number) list.get(0)).intValue(); }
String where = createMatchUserOrGroupWhereClause(user, matchFields, order, parameterValues);