/** * Get the name of the database that the results of the map reduce were saved into. If the map reduce was an inline operation (i.e . * the results were returned directly from calling the map reduce) this will return null. * * @return the name of the database that holds the collection that the map reduce results are stored in */ public String getDatabaseName() { return collection.getDB().getName(); }
MongoNamespace getNamespace() { return new MongoNamespace(getDB().getName(), getName()); }
/** * Removes the specified user from the database. * * @param userName user to be removed * @return the result of executing this operation * @throws MongoException if the operation failed * @mongodb.driver.manual administration/security-access-control/ Access Control * @deprecated Use {@code DB.command} to call the dropUser command */ @Deprecated public WriteResult removeUser(final String userName) { try { executor.execute(new com.mongodb.operation.DropUserOperation(getName(), userName, getWriteConcern()), getReadConcern()); return new WriteResult(1, true, null); } catch (MongoWriteConcernException e) { throw createWriteConcernException(e); } }
/** * Drops this database. Removes all data on disk. Use with caution. * * @throws MongoException if the operation failed * @mongodb.driver.manual reference/command/dropDatabase/ Drop Database */ public void dropDatabase() { try { getExecutor().execute(new DropDatabaseOperation(getName(), getWriteConcern()), getReadConcern()); } catch (MongoWriteConcernException e) { throw createWriteConcernException(e); } }
CommandResult executeCommand(final BsonDocument commandDocument, final ReadPreference readPreference) { return new CommandResult(executor.execute(new CommandReadOperation<BsonDocument>(getName(), commandDocument, new BsonDocumentCodec()), readPreference, getReadConcern())); }
public void installSampleData() { File file = new File("zips.json"); try { if (!file.exists()) { file = new File(System.getProperty("java.io.tmpdir"), "zips.json"); if (!file.exists()) { download(new URL("http://media.mongodb.org/zips.json"), file); } } DBCollection zips = getDb().getCollection("zips"); if (zips.count() == 0) { new ProcessExecutor().command(MONGO_IMPORT, "--db", getDb().getName(), "--collection", "zipcodes", "--file", file.getAbsolutePath()) .redirectError(System.err) .execute(); } } catch (Exception e) { e.printStackTrace(); } Assume.assumeTrue("Failed to process media files", file.exists()); }
CommandResult executeCommand(final BsonDocument commandDocument) { return new CommandResult(executor.execute(new CommandWriteOperation<BsonDocument>(getName(), commandDocument, new BsonDocumentCodec()), getReadConcern())); }
String entityName = entity.getClass().getName(); throw new MappingException(format("Could not map %s with ID: %s in database '%s'", entityName, id, datastore.getDB().getName()), e);
protected TestBase(final MongoClient mongoClient) { this.mongoClient = mongoClient; this.db = getMongoClient().getDB(TEST_DB_NAME); this.database = getMongoClient().getDatabase(TEST_DB_NAME); this.ds = getMorphia().createDatastore(getMongoClient(), getDb().getName()); }
MongoCredential credential = createCredential(userName, getName(), password); boolean userExists = false; try { userExists = executor.execute(new com.mongodb.operation.UserExistsOperation(getName(), userName), primary(), getReadConcern()); } catch (MongoCommandException e) { if (e.getCode() != 13) {
@Test public void testReferencesWithoutMapping() { Child child1 = new Child(); getDs().save(child1); Parent parent1 = new Parent(); parent1.children.add(child1); getDs().save(parent1); List<Parent> parentList = toList(getDs().find(Parent.class).find()); Assert.assertEquals(1, parentList.size()); // reset Datastore to reset internal Mapper cache, so Child class // already cached by previous save is cleared Datastore localDs = getMorphia().createDatastore(getMongoClient(), new Mapper(), getDb().getName()); parentList = toList(localDs.find(Parent.class).find()); Assert.assertEquals(1, parentList.size()); }
return new CreateCollectionOperation(getName(), collectionName, getWriteConcern()) .capped(capped) .collation(collation)
logger.error("Collection " + tableInfo.getTableName() + "does not exist in db " + db.getName()); throw new SchemaGenerationException("Collection " + tableInfo.getTableName() + " does not exist in db " + db.getName(), "mongoDb", databaseName, tableInfo.getTableName()); + "does not exist in db " + db.getName()); throw new SchemaGenerationException("Collection " + tableInfo.getTableName() + " does not exist in db " + db.getName(), "mongoDb", databaseName, tableInfo.getTableName()); + "does not exist in db " + db.getName()); throw new SchemaGenerationException("Collection " + tableInfo.getTableName() + " does not exist in db " + db.getName(), "mongoDb", databaseName, tableInfo.getTableName());
new Object[] { name(candidateTypeName), dataStoreDB.getName(), candidateCollectionName });
@Override protected String getMainSchemaName() throws MetaModelException { return _mongoDb.getName(); }
/** * Parameterized constructor with collection. * * @param collection * the collection to set */ public PropertyStoreMongoDB(DBCollection collection) { this.propertiesCollection = collection; this.collectionName = collection.getName(); this.dbName = collection.getDB().getName(); }
/** * Parameterized constructor with collection. * * @param collection * the collection to set */ public FeatureStoreMongoDB(DBCollection collection) { this.featuresCollection = collection; this.collectionName = featuresCollection.getName(); this.dbName = featuresCollection.getDB().getName(); }
public static Operation putDatabaseDetails (Operation op, DB db) { op.put("dbName", db.getName()); Mongo mongo=db.getMongo(); ServerAddress address=mongo.getAddress(); op.put("host", address.getHost()); op.put("port", address.getPort()); return op; } }
CommandResult executeCommand(final BsonDocument commandDocument, final ReadPreference readPreference) { return new CommandResult(executor.execute(new CommandReadOperation<BsonDocument>(getName(), commandDocument, new BsonDocumentCodec()), readPreference, getReadConcern())); }
@Override public void storeExtractedText( BinaryValue source, String extractedText ) throws BinaryStoreException { if (!db.collectionExists(source.getKey().toString())) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(source.getKey(), db.getName())); } DBCollection content = db.getCollection(source.getKey().toString()); setAttribute(content, FIELD_EXTRACTED_TEXT, extractedText); }