/** * Returns the number of installations the given content pack entity ID is used in. * * @param entityId the native entity ID * @return number of installations */ public long countInstallationOfEntityById(ModelId entityId) { final String field = String.format(Locale.ROOT, "%s.%s", ContentPackInstallation.FIELD_ENTITIES, NativeEntityDescriptor.FIELD_META_ID); return dbCollection.getCount(DBQuery.is(field, entityId)); }
@Override public boolean exists(String roleName) { return dbCollection.getCount(is(NAME_LOWER, roleName.toLowerCase(Locale.ENGLISH))) == 1; }
public long countInstallationOfEntityByIdAndFoundOnSystem(ModelId entityId) { final DBQuery.Query query = DBQuery.elemMatch(ContentPackInstallation.FIELD_ENTITIES, DBQuery.and( DBQuery.is(NativeEntityDescriptor.FIELD_ENTITY_FOUND_ON_SYSTEM, true), DBQuery.is(NativeEntityDescriptor.FIELD_META_ID, entityId.id()))); return dbCollection.getCount(query); } }
public boolean hasConflict(ConfigurationVariable variable) { final DBQuery.Query query; if (isNullOrEmpty(variable.id())) { query = DBQuery.is(ConfigurationVariable.FIELD_NAME, variable.name()); } else { // updating an existing variable, don't match against itself query = DBQuery.and( DBQuery.is(ConfigurationVariable.FIELD_NAME, variable.name()), DBQuery.notEquals("_id", variable.id() ) ); } return db.getCount(query) > 0; }
/** * calls {@link DBCollection#getCount(com.mongodb.DBObject, com.mongodb.DBObject)} with null fields. * * @param query * query to match * @return The count * @throws MongoException * If an error occurred */ public long getCount(DBQuery.Query query) throws MongoException { return getCount(query, null); }
/** * returns the number of documents that match a query. * * @param query * query to match * @return The count * @throws MongoException * If an error occurred */ public long count(DBObject query) throws MongoException { return getCount(query, null); }
/** * calls {@link DBCollection#getCount(com.mongodb.DBObject, com.mongodb.DBObject)} with null fields. * * @param query * query to match * @return The count * @throws MongoException * If an error occurred */ public long getCount(DBObject query) throws MongoException { return getCount(query, null); }
/** * calls {@link DBCollection#getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long)} with limit=0 and * skip=0 * * @param query * query to match * @param fields * fields to return * @return The count * @throws MongoException * If an error occurred */ public long getCount(DBObject query, DBObject fields) throws MongoException { return getCount(query, fields, 0, 0); }
/** * calls {@link DBCollection#getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long)} with limit=0 and * skip=0 * * @param query * query to match * @param fields * fields to return * @return The count * @throws MongoException * If an error occurred */ public long getCount(DBQuery.Query query, DBObject fields) throws MongoException { return getCount(query, fields, 0, 0); }
/** * returns the number of documents in this collection. * * @return The count * @throws MongoException * If an error occurred */ public long count() throws MongoException { return getCount(new BasicDBObject(), null); }
/** * calls {@link DBCollection#getCount(com.mongodb.DBObject, com.mongodb.DBObject)} with an empty query and null * fields. * * @return number of documents that match query * @throws MongoException * If an error occurred */ public long getCount() throws MongoException { return getCount(new BasicDBObject(), null); }
@Override public boolean exists(String roleName) { return dbCollection.getCount(is(NAME_LOWER, roleName.toLowerCase(Locale.ENGLISH))) == 1; }