Example usage for com.mongodb MongoURI getCollection

List of usage examples for com.mongodb MongoURI getCollection

Introduction

In this page you can find the example usage for com.mongodb MongoURI getCollection.

Prototype

@Nullable
public String getCollection() 

Source Link

Document

Gets the collection name.

Usage

From source file:de.belaso.mongolyn.ui.MongolynUtils.java

License:Open Source License

public static DBCollection getDBCollection(final TaskRepository repository) throws CoreException {
    MongoURI mongoURI = new MongoURI(repository.getRepositoryUrl());
    String collection = mongoURI.getCollection();
    if (collection == null || collection.isEmpty()) {
        collection = "mongolyn"; // using hard coded collection
    }/*from w w w .  java2  s .c om*/
    return openDB(repository).getCollection(collection);
}

From source file:v7views.mongo.InitMongo.java

License:Open Source License

public static V7Collection getCollection(ServletContext context, String name) {
    BSONBackedObject conf = getConfig(context);
    Object data = conf.getField("collections." + name);
    if (data instanceof String) {
        MongoURI uri = new MongoURI((String) data);
        return new V7Collection(getMongo(context).getDB(uri.getDatabase()).getCollection(uri.getCollection()));
    }/* ww  w .  j a  v a2  s .com*/
    BSONBackedObject b = (BSONBackedObject) data;
    V7Collection base = getCollection(context, b.getStringField("collection"));
    return new V7Collection(base, b.getObjectField("filter"));
}