* @see org.openntf.domino.View#getAllDocuments()
*/
@Override
public DocumentCollection getAllDocuments() {
Database db = getAncestorDatabase();
DocumentCollection result = db.createDocumentCollection();
// When it's a folder, there's no selection formula, so do it the "dumb" way for now
if (isFolder()) {
// TODO See if there's a better way
for (ViewEntry entry : getAllEntries()) {
if (entry.isDocument()) {
result.add(entry.getDocument());
}
}
} else {
// According to Tommy Valand's research, the fastest method is to build a NoteCollection with a matching selection formula
// http://dontpanic82.blogspot.com/2013/06/benchmark-fetching-noteids-and.html
NoteCollection nc = getNoteCollection();
int[] nids = nc.getNoteIDs();
// Arrays.sort(nids);
// for (org.openntf.domino.Document doc : result) {
// int nid = Integer.valueOf(doc.getNoteID(), 16);
// if (!(Arrays.binarySearch(nids, nid) >= 0)) {
// result.subtract(nid);
// }
// }
// for (int nid : nids) {
// result.intersect(nid);
// }
// TODO due to a bug in 9.0, this is being reverted to highly inefficient behavior...
for (int nid : nids) {
Document doc = db.getDocumentByID(Integer.toHexString(nid));
result.add(doc);
}
}
return result;
}