@Override public DBQuery.Query buildQuery(String key, Object value) { return DBQuery.is(key, value); } }
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); } }
/** * {@inheritDoc} */ @Override public Optional<IndexSetConfig> get(ObjectId id) { final DBQuery.Query query = DBQuery.is("_id", id); final IndexSetConfig indexSetConfig = collection.findOne(query); return Optional.ofNullable(indexSetConfig); }
private DBQuery.Query getFindAnyStreamQuery(List<String> streamIds) { final List<DBQuery.Query> streamQueries = streamIds.stream() .map(streamId -> DBQuery.is(AlertImpl.FIELD_STREAM_ID, streamId)) .collect(Collectors.toList()); return DBQuery.or(streamQueries.toArray(new DBQuery.Query[streamQueries.size()])); }
@Override public Configuration save(Configuration configuration) { return db.findAndModify(DBQuery.is("_id", configuration.id()), new BasicDBObject(), new BasicDBObject(), false, configuration, true, true); }
public Set<ContentPackInstallation> findByContentPackIdAndRevision(ModelId id, int revision) { final DBQuery.Query query = DBQuery .is(ContentPackInstallation.FIELD_CONTENT_PACK_ID, id) .is(ContentPackInstallation.FIELD_CONTENT_PACK_REVISION, revision); try (final DBCursor<ContentPackInstallation> installations = dbCollection.find(query)) { return ImmutableSet.copyOf((Iterator<ContentPackInstallation>) installations); } }
@Override public Output update(String id, Map<String, Object> deltas) { DBUpdate.Builder update = new DBUpdate.Builder(); for (Map.Entry<String, Object> fields : deltas.entrySet()) update = update.set(fields.getKey(), fields.getValue()); return coll.findAndModify(DBQuery.is(OutputImpl.FIELD_ID, id), null, null, false, update, true, false); }
public Optional<LookupTableDto> get(String idOrName) { try { return Optional.ofNullable(db.findOneById(new ObjectId(idOrName))); } catch (IllegalArgumentException e) { // not an ObjectId, try again with name return Optional.ofNullable(db.findOne(DBQuery.is("name", idOrName))); } }
public Optional<IndexFieldTypesDTO> get(String idOrIndexName) { try { return Optional.ofNullable(db.findOneById(new ObjectId(idOrIndexName))); } catch (IllegalArgumentException e) { // Not an ObjectId, try again with index_name return Optional.ofNullable(db.findOne(DBQuery.is(IndexFieldTypesDTO.FIELD_INDEX_NAME, idOrIndexName))); } }
public Optional<CacheDto> get(String idOrName) { try { return Optional.ofNullable(db.findOneById(new ObjectId(idOrName))); } catch (IllegalArgumentException e) { // not an ObjectId, try again with name return Optional.ofNullable(db.findOne(DBQuery.is("name", idOrName))); } }
@Override public PipelineConnections load(String streamId) throws NotFoundException { final PipelineConnections oneById = dbCollection.findOne(DBQuery.is("stream_id", streamId)); if (oneById == null) { throw new NotFoundException("No pipeline connections with for stream " + streamId); } return oneById; }
public Optional<DataAdapterDto> get(String idOrName) { try { return Optional.ofNullable(db.findOneById(new ObjectId(idOrName))); } catch (IllegalArgumentException e) { // not an ObjectId, try again with name return Optional.ofNullable(db.findOne(DBQuery.is("name", idOrName))); } }
@Override public RuleDao loadByName(String name) throws NotFoundException { final DBQuery.Query query = DBQuery.is("title", name); final RuleDao rule = dbCollection.findOne(query); if (rule == null) { throw new NotFoundException("No rule with name " + name); } return rule; }
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); } }
@Override public PipelineDao loadByName(String name) throws NotFoundException { final DBQuery.Query query = DBQuery.is("title", name); final PipelineDao pipeline = dbCollection.findOne(query); if (pipeline == null) { throw new NotFoundException("No pipeline with name " + name); } return pipeline; }
@Nullable public Collector findByNameExcludeId(String name, String id) { return db.findOne( DBQuery.and( DBQuery.is("name", name), DBQuery.notEquals("_id", id)) ); }
public void delete(String idOrIndexName) { try { db.removeById(new ObjectId(idOrIndexName)); } catch (IllegalArgumentException e) { // Not an ObjectId, try again with index_name db.remove(DBQuery.is(IndexFieldTypesDTO.FIELD_INDEX_NAME, idOrIndexName)); } }
@Override public List<Decorator> findForGlobal() { return toInterfaceList(coll.find(DBQuery.or( DBQuery.notExists(DecoratorImpl.FIELD_STREAM), DBQuery.is(DecoratorImpl.FIELD_STREAM, Optional.empty()) )).toArray()); }