private void buildCollectionDetail(MongoDatabase db, TreeItem<DbTreeValue> ti) { DbTreeValue indexCategory = new DbTreeValue(db, "Indexes", TreeValueType.CATEGORY); indexCategory.setCollectionName(ti.getValue().getDisplayValue()); ti.getChildren() .add( new DynamicTreeItem( indexCategory, new FontAwesomeIconView(FontAwesomeIcon.FOLDER), executor, popupService, this::buildIndexes)); }
private List<TreeItem<DbTreeValue>> buildIndexes(DbTreeValue value) { MongoCollection<Document> collection = value.getMongoDatabase().getMongoDb().getCollection(value.getCollectionName()); return StreamSupport.stream(collection.listIndexes().spliterator(), false) .map( d -> { DbTreeValue val = new DbTreeValue( value.getMongoDatabase(), (String) d.get("name"), TreeValueType.INDEX); val.setCollectionName(value.getDisplayValue()); return new TreeItem<>(val, new FontAwesomeIconView(FontAwesomeIcon.ASTERISK)); }) .collect(Collectors.toList()); }