@Override public long countReportNodesByExecutionID(String executionID) { assert executionID != null; return collection.count("{executionID: #}"); }
private Iterator<Long> doCount(MongoCollection collection, String opQuery, Object[] parameters) { long count; if (opQuery != null) { if (parameters.length > 0) { count = collection.count(opQuery, parameters); } else { count = collection.count(opQuery); } } else { count = collection.count(); } List<Long> countResult = new ArrayList<>(); countResult.add(count); return countResult.iterator(); }
@Override public long count(String query, Object... queryParams) throws MongoDataException { try { return getCollection().count(query, queryParams); } catch (MongoException ex) { String msg = "Unable to count documents of type " + clazz.getName() + " that match the " + "query " + query + " with params " + Arrays.toString(queryParams); log.error(msg, ex); throw new MongoDataException(msg, ex); } }
@Override public long count() throws MongoDataException { try { return getCollection().count(); } catch (MongoException ex) { String msg = "Unable to count all documents of type " + clazz.getName(); log.error(msg, ex); throw new MongoDataException(msg, ex); } }
@Override public long count(String query) throws MongoDataException { try { return getCollection().count(query); } catch (MongoException ex) { String msg = "Unable to count documents of type " + clazz.getName() + " that match the " + "query " + query; log.error(msg, ex); throw new MongoDataException(msg, ex); } }
@Override public boolean isAdminDefined() { try { return users.get().count("{roles: {$all: [ # ]}}", getAdminRole()) > 0; } catch (Exception e) { return false; } }
@Override public boolean isAdminDefined() { try { return users.get().count("{roles: {$all: [ # ]}}", getAdminRole()) > 0; } catch (Exception e) { return false; } }
@Override public int _countByCriteria(Table table) { int count = 0; Map<String, Object> coditon = new HashMap<String, Object>(); try { QueryCriteria queryCriteria = table.getQueryCriteria(); DB db = database.getDB(); Jongo jongo = new Jongo(db); for(Criteria criteria:queryCriteria.getOredCriteria()){ for(Criterion criterion:criteria.getAllCriteria()){ coditon = buildCriteria(criterion, coditon); } } long size = jongo.getCollection(queryCriteria.getTable()).count(JsonUtils.objToJson(coditon)); count = (int) size; } catch (MongoException e) { LOG.error("mongo find error", e); } return count; }