private List<TreeItem<DbTreeValue>> buildDbChilds(DbTreeValue value) { MongoDatabase db = value.getMongoDatabase(); return db.listCollectionDetails() .stream() .map( cd -> new TreeItem<>( new DbTreeValue(db, cd, TreeValueType.COLLECTION), new FontAwesomeIconView(FontAwesomeIcon.TABLE))) .peek(ti -> buildCollectionDetail(db, ti)) .collect(Collectors.toList()); }
private TreeItem<DbTreeValue> createDbItem(MongoDatabase d) { return new DynamicTreeItem( new DbTreeValue(d, d.getName(), TreeValueType.DATABASE), new FontAwesomeIconView(FontAwesomeIcon.DATABASE), executor, popupService, this::buildDbChilds); }
public ObjectListPresentation explain() { MongoCollection<Document> collection = getCollection(); FindIterable findIterable = new FindIterable( new MongoNamespace(mongoDatabase.getName(), collectionName), collection.getCodecRegistry(), // collection.getReadPreference(), getExecutor(), findQuery, findOptions); BsonDocument res = findIterable.explainIterator(ExplainVerbosity.QUERY_PLANNER); return JsApiUtils.singletonIter(JsApiUtils.convertBsonToDocument(res)); }
private OperationExecutor getExecutor() { try { // this is hack to get executor // hope will be removed when 3 series driver have explain function com.mongodb.client.MongoDatabase mongoDb = mongoDatabase.getMongoDb(); Field f = mongoDb.getClass().getDeclaredField("executor"); f.setAccessible(true); return (OperationExecutor) f.get(mongoDb); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { log.error("Exception:", e); return null; } }
@JsIgnore @Override public MongoCursor<Document> iterator(int skip, int limit) { MongoCollection<Document> collection = getCollection(); findOptions.skip(skip); findOptions.limit(limit); if (projection != null) { findOptions.projection(projection); } if (sort != null) { findOptions.sort(dbObjectFromMap(sort)); } return new FindIterable( new MongoNamespace(mongoDatabase.getName(), collectionName), collection.getCodecRegistry(), // collection.getReadPreference(), getExecutor(), findQuery, findOptions) .iterator(); }
private MongoCollection<Document> getCollection() { return mongoDatabase.getMongoDb().getCollection(collectionName); }