/** * Get the collection name the event was originated at. * * @return can be {@literal null}. */ @Nullable public String getCollectionName() { return raw != null ? raw.getNamespace().getCollectionName() : null; }
public Void doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException { collection.drop(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Dropped collection [{}]", collection.getNamespace() != null ? collection.getNamespace().getCollectionName() : collectionName); } return null; } });
@Override public BsonValue create() { return changeStreamLevel == ChangeStreamLevel.COLLECTION ? new BsonString(getNamespace().getCollectionName()) : new BsonInt32(1); } };
protected Map<String, String> getAttributes(ProcessContext context, FlowFile input, Document query, MongoCollection collection) { final Map<String, String> attributes = new HashMap<>(); attributes.put(CoreAttributes.MIME_TYPE.key(), "application/json"); if (context.getProperty(QUERY_ATTRIBUTE).isSet()) { final String queryAttr = context.getProperty(QUERY_ATTRIBUTE).evaluateAttributeExpressions(input).getValue(); attributes.put(queryAttr, query.toJson()); } attributes.put(DB_NAME, collection.getNamespace().getDatabaseName()); attributes.put(COL_NAME, collection.getNamespace().getCollectionName()); return attributes; } }
AggregateOperationImpl(final MongoNamespace namespace, final List<BsonDocument> pipeline, final Decoder<T> decoder, final AggregationLevel aggregationLevel) { this(namespace, pipeline, decoder, defaultAggregateTarget(notNull("aggregationLevel", aggregationLevel), notNull("namespace", namespace).getCollectionName()), defaultPipelineCreator(pipeline)); }
private BsonDocument getCommand(final ConnectionDescription description) { BsonDocument commandDocument = new BsonDocument("drop", new BsonString(namespace.getCollectionName())); appendWriteConcernToCommand(writeConcern, commandDocument, description); return commandDocument; }
private BsonDocument getCommand(final ConnectionDescription description) { BsonDocument command = new BsonDocument("createIndexes", new BsonString(namespace.getCollectionName())); List<BsonDocument> values = new ArrayList<BsonDocument>(); for (IndexRequest request : requests) { values.add(getIndex(request)); } command.put("indexes", new BsonArray(values)); putIfNotZero(command, "maxTimeMS", maxTimeMS); appendWriteConcernToCommand(writeConcern, command, description); return command; }
@Override public Boolean doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException { return doCount(collection.getNamespace().getCollectionName(), mappedQuery, new CountOptions().limit(1).collation(collation)) > 0; } }
private BsonDocument asGetMoreCommandDocument(final long cursorId) { BsonDocument document = new BsonDocument("getMore", new BsonInt64(cursorId)) .append("collection", new BsonString(namespace.getCollectionName())); int batchSizeForGetMoreCommand = Math.abs(getNumberToReturn(limit, this.batchSize, count.get())); if (batchSizeForGetMoreCommand != 0) { document.append("batchSize", new BsonInt32(batchSizeForGetMoreCommand)); } if (maxTimeMS != 0) { document.append("maxTimeMS", new BsonInt64(maxTimeMS)); } return document; }
private BsonDocument asKillCursorsCommandDocument() { return new BsonDocument("killCursors", new BsonString(namespace.getCollectionName())) .append("cursors", new BsonArray(singletonList(new BsonInt64(serverCursor.getId())))); } }
private BsonDocument getCommand() { BsonDocument command = new BsonDocument("listIndexes", new BsonString(namespace.getCollectionName())) .append("cursor", getCursorDocumentFromBatchSize(batchSize == 0 ? null : batchSize)); if (maxTimeMS > 0) { command.put("maxTimeMS", new BsonInt64(maxTimeMS)); } return command; }
private BsonDocument asGetMoreCommandDocument() { return new BsonDocument(COMMAND_NAME, new BsonInt64(cursorId)) .append("collection", new BsonString(namespace.getCollectionName())) .append("batchSize", new BsonInt32(numberToReturn)); }
private static BsonDocument namespaceToDocument(final MongoNamespace namespace) { Assertions.notNull("namespace", namespace); return new BsonDocument("db", new BsonString(namespace.getDatabaseName())) .append("coll", new BsonString(namespace.getCollectionName())); }
private BsonDocument getCommand(final SessionContext sessionContext) { BsonDocument document = new BsonDocument("parallelCollectionScan", new BsonString(namespace.getCollectionName())) .append("numCursors", new BsonInt32(getNumCursors())); appendReadConcernToCommand(sessionContext, document); return document; } }
private BsonDocument asGetMoreCommandDocument() { BsonDocument document = new BsonDocument("getMore", new BsonInt64(serverCursor.getId())) .append("collection", new BsonString(namespace.getCollectionName())); int batchSizeForGetMoreCommand = Math.abs(getNumberToReturn(limit, this.batchSize, count)); if (batchSizeForGetMoreCommand != 0) { document.append("batchSize", new BsonInt32(batchSizeForGetMoreCommand)); } if (maxTimeMS != 0) { document.append("maxTimeMS", new BsonInt64(maxTimeMS)); } return document; }
private BsonDocument getCommand(final ConnectionDescription description) { BsonDocument command = new BsonDocument("dropIndexes", new BsonString(namespace.getCollectionName())); if (indexName != null) { command.put("index", new BsonString(indexName)); } else { command.put("index", indexKeys); } putIfNotZero(command, "maxTimeMS", maxTimeMS); appendWriteConcernToCommand(writeConcern, command, description); return command; } }
private BsonDocument asCommandDocument() { BsonArray array = new BsonArray(); for (long cursor : cursors) { array.add(new BsonInt64(cursor)); } return new BsonDocument(COMMAND_NAME, namespace == null ? new BsonInt32(1) : new BsonString(namespace.getCollectionName())) .append("cursors", array); }
protected BsonDocument getBaseCommandDocument(final String commandName) { BsonDocument baseCommandDocument = new BsonDocument(commandName, new BsonString(getNamespace().getCollectionName())) .append("ordered", BsonBoolean.valueOf(isOrdered())); baseCommandDocument.append("writeConcern", WriteConcern.UNACKNOWLEDGED.asDocument()); return baseCommandDocument; }
private BsonDocument getCommand(final SessionContext sessionContext) { BsonDocument commandDocument = new BsonDocument("distinct", new BsonString(namespace.getCollectionName())); appendReadConcernToCommand(sessionContext, commandDocument); commandDocument.put("key", new BsonString(fieldName)); putIfNotNullOrEmpty(commandDocument, "query", filter); putIfNotZero(commandDocument, "maxTimeMS", maxTimeMS); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } return commandDocument; } }
@Override protected Message<ChangeStreamDocument<Document>, Object> createMessage(ChangeStreamDocument<Document> source, Class<Object> targetType, RequestOptions options) { MongoNamespace namespace = source.getNamespace() != null ? source.getNamespace() : createNamespaceFromOptions(options); return new ChangeStreamEventMessage<>(new ChangeStreamEvent<>(source, targetType, mongoConverter), MessageProperties .builder().databaseName(namespace.getDatabaseName()).collectionName(namespace.getCollectionName()).build()); }