Search in sources :

Example 1 with DBCursor

use of org.mongojack.DBCursor in project graylog2-server by Graylog2.

the class ContentPackInstallationPersistenceService method findByContentPackIds.

public Set<ContentPackInstallation> findByContentPackIds(Set<ModelId> ids) {
    final Set<String> stringIds = ids.stream().map(x -> x.toString()).collect(Collectors.toSet());
    final DBObject query = BasicDBObjectBuilder.start().push(ContentPackInstallation.FIELD_CONTENT_PACK_ID).append("$in", stringIds).get();
    final DBCursor<ContentPackInstallation> result = dbCollection.find(query);
    return ImmutableSet.copyOf((Iterable<ContentPackInstallation>) result);
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ModelId(org.graylog2.contentpacks.model.ModelId) Iterator(java.util.Iterator) BasicDBObjectBuilder(com.mongodb.BasicDBObjectBuilder) DBCursor(org.mongojack.DBCursor) BasicDBObject(com.mongodb.BasicDBObject) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ContentPackInstallation(org.graylog2.contentpacks.model.ContentPackInstallation) JacksonDBCollection(org.mongojack.JacksonDBCollection) Set(java.util.Set) DBQuery(org.mongojack.DBQuery) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) WriteResult(org.mongojack.WriteResult) Inject(javax.inject.Inject) DBObject(com.mongodb.DBObject) ContentPackMetadata(org.graylog2.rest.models.system.contentpacks.responses.ContentPackMetadata) Locale(java.util.Locale) Map(java.util.Map) ObjectId(org.bson.types.ObjectId) Optional(java.util.Optional) MongoConnection(org.graylog2.database.MongoConnection) NativeEntityDescriptor(org.graylog2.contentpacks.model.entities.NativeEntityDescriptor) ContentPackInstallation(org.graylog2.contentpacks.model.ContentPackInstallation) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 BasicDBObject (com.mongodb.BasicDBObject)1 BasicDBObjectBuilder (com.mongodb.BasicDBObjectBuilder)1 DBObject (com.mongodb.DBObject)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 ObjectId (org.bson.types.ObjectId)1 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)1 ContentPackInstallation (org.graylog2.contentpacks.model.ContentPackInstallation)1 ModelId (org.graylog2.contentpacks.model.ModelId)1 NativeEntityDescriptor (org.graylog2.contentpacks.model.entities.NativeEntityDescriptor)1 MongoConnection (org.graylog2.database.MongoConnection)1 ContentPackMetadata (org.graylog2.rest.models.system.contentpacks.responses.ContentPackMetadata)1