예제 #1
0
 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());
 }
예제 #2
0
 private TreeItem<DbTreeValue> createDbItem(MongoDatabase d) {
   return new DynamicTreeItem(
       new DbTreeValue(d, d.getName(), TreeValueType.DATABASE),
       new FontAwesomeIconView(FontAwesomeIcon.DATABASE),
       executor,
       popupService,
       this::buildDbChilds);
 }
예제 #3
0
  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));
  }
예제 #4
0
 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;
   }
 }
예제 #5
0
  @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();
  }
예제 #6
0
 private MongoCollection<Document> getCollection() {
   return mongoDatabase.getMongoDb().getCollection(collectionName);
 }