List of usage examples for com.mongodb BasicDBObject getObjectId
public ObjectId getObjectId(final String field, final ObjectId def)
From source file:com.ikanow.infinit.e.processing.generic.GenericProcessingController.java
License:Open Source License
static ObjectId getRootCommunity(ObjectId parentCommunityId) { for (;;) {/* w w w . j a v a 2 s . co m*/ BasicDBObject query = new BasicDBObject("_id", parentCommunityId); BasicDBObject field = new BasicDBObject("parentId", 1); BasicDBObject retVal = (BasicDBObject) MongoDbManager.getSocial().getCommunity().findOne(query, field); if (null == retVal) { // (shouldn't ever happen) return parentCommunityId; } ObjectId tmp = retVal.getObjectId("parentId", null); if (null == tmp) { // (no more parents) return parentCommunityId; } if (tmp.equals(parentCommunityId)) { // (shouldn't ever happen but will prevent infinite loop) return parentCommunityId; } parentCommunityId = tmp; } }