@Override public Set<Output> loadAll() { try (org.mongojack.DBCursor<OutputImpl> outputs = coll.find()) { return ImmutableSet.copyOf((Iterable<OutputImpl>) outputs); } }
@Override public Set<Role> loadAll() throws NotFoundException { try (DBCursor<RoleImpl> rolesCursor = dbCollection.find()) { return ImmutableSet.copyOf((Iterable<? extends Role>) rolesCursor); } }
@Override public Collection<PipelineDao> loadAll() { try (DBCursor<PipelineDao> daos = dbCollection.find()) { return ImmutableSet.copyOf((Iterator<PipelineDao>) daos); } catch (MongoException e) { log.error("Unable to load pipelines", e); return Collections.emptySet(); } }
@Override public Set<PipelineConnections> loadAll() { try (DBCursor<PipelineConnections> connections = dbCollection.find()) { return ImmutableSet.copyOf((Iterable<PipelineConnections>) connections); } catch (MongoException e) { log.error("Unable to load pipeline connections", e); return Collections.emptySet(); } }
public void forEach(Consumer<? super LookupTableDto> action) { try (DBCursor<LookupTableDto> dbCursor = db.find()) { dbCursor.forEachRemaining(action); } } }
public Collection<DataAdapterDto> findAll() { try (DBCursor<DataAdapterDto> cursor = db.find()) { return asImmutableList(cursor); } } }
@Override public SortedSet<IndexRange> findAll() { try (DBCursor<MongoIndexRange> cursor = collection.find(DBQuery.notExists("start"))) { return ImmutableSortedSet.copyOf(IndexRange.COMPARATOR, (Iterator<? extends IndexRange>) cursor); } }
@Override public List<AlarmCallbackConfiguration> getForStreamId(String streamId) { try (DBCursor<AlarmCallbackConfigurationImpl> dbCursor = coll.find(DBQuery.is("stream_id", streamId))) { return ImmutableList.copyOf((Iterable<AlarmCallbackConfigurationImpl>) dbCursor); } }
@Override public Set<Output> loadByIds(Collection<String> ids) { final DBQuery.Query query = DBQuery.in(OutputImpl.FIELD_ID, ids); try (org.mongojack.DBCursor<OutputImpl> dbCursor = coll.find(query)) { return ImmutableSet.copyOf((Iterable<? extends Output>) dbCursor); } }
public Set<ContentPackInstallation> findByContentPackId(ModelId id) { final DBQuery.Query query = DBQuery.is(ContentPackInstallation.FIELD_CONTENT_PACK_ID, id); try (final DBCursor<ContentPackInstallation> installations = dbCollection.find(query)) { return ImmutableSet.copyOf((Iterator<ContentPackInstallation>) installations); } }
public Collection<CacheDto> findAll() { try (DBCursor<CacheDto> cursor = db.find()) { return asImmutableList(cursor); } } }
@Override public Set<GrokPattern> bulkLoad(Collection<String> patternIds) { final DBCursor<GrokPattern> dbCursor = dbCollection.find(DBQuery.in("_id", patternIds)); return ImmutableSet.copyOf((Iterator<GrokPattern>) dbCursor); }
public Collection<CacheDto> findByIds(Set<String> idSet) { final DBQuery.Query query = DBQuery.in("_id", idSet.stream().map(ObjectId::new).collect(Collectors.toList())); try (DBCursor<CacheDto> cursor = db.find(query)) { return asImmutableList(cursor); } }
@Override public Collection<RuleDao> loadAll() { try(DBCursor<RuleDao> ruleDaos = dbCollection.find().sort(DBSort.asc("title"))) { return ImmutableSet.copyOf((Iterable<RuleDao>) ruleDaos); } catch (MongoException e) { log.error("Unable to load processing rules", e); return Collections.emptySet(); } }
/** * {@inheritDoc} */ @Override public List<IndexSetConfig> findAll() { return ImmutableList.copyOf((Iterator<? extends IndexSetConfig>) collection.find().sort(DBSort.asc("title"))); }
/** * Returns an unordered stream of database entries for the given {@link DBQuery.Query}. * <p> * The returned stream needs to be closed to free the underlying database resources. * * @param query the query to execute * @return stream of database entries that match the query */ protected Stream<DTO> streamQuery(DBQuery.Query query) { final DBCursor<DTO> cursor = db.find(query); return Streams.stream((Iterable<DTO>) cursor).onClose(cursor::close); }
private DBCursor<ClusterEvent> eventCursor(NodeId nodeId) { // Resorting to ugly MongoDB Java Client because of https://github.com/devbliss/mongojack/issues/88 final BasicDBList consumersList = new BasicDBList(); consumersList.add(nodeId.toString()); final DBObject query = new BasicDBObject("consumers", new BasicDBObject("$nin", consumersList)); return dbCollection.find(query).sort(DBSort.asc("timestamp")); }
public PaginatedList<DataAdapterDto> findPaginated(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { try (DBCursor<DataAdapterDto> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1))) { return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); } }
public PaginatedList<LookupTableDto> findPaginated(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { try (DBCursor<LookupTableDto> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1))) { return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); } }
public PaginatedList<CacheDto> findPaginated(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) { try (DBCursor<CacheDto> cursor = db.find(query) .sort(sort) .limit(perPage) .skip(perPage * Math.max(0, page - 1))) { return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage); } }