Search in sources :

Example 21 with DocumentCollection

use of org.openntf.domino.DocumentCollection in project org.openntf.domino by OpenNTF.

the class IndexDatabase method scanDatabase.

// @SuppressWarnings("unused")
// private int sortedDocCount_ = 0;
/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#scanDatabase(org.openntf.domino.Database, org.openntf.domino.helpers.DocumentScanner)
	 */
@Override
public DocumentScanner scanDatabase(final Database db, final DocumentScanner scanner) {
    // System.out.println("Scanning database " + db.getApiPath());
    curDocCount_ = 0;
    scanner.setCaseSensitive(getCaseSensitive());
    scanner.setStateManager(this, db.getReplicaID());
    Date last = scanner.getLastScanDate();
    if (last == null) {
        last = new Date(0);
    }
    int count = db.getModifiedNoteCount(last);
    if (count > 0) {
        DocumentCollection rawColl = db.getModifiedDocuments(last);
        DocumentSorter sorter = new DocumentSorter(rawColl, MOD_SORT_LIST);
        System.out.println("Scanning database " + db.getApiPath() + " with last date of " + last.getTime() + " and found " + rawColl.getCount() + " updates to scan");
        scanner.processSorter(sorter);
    }
    return scanner;
}
Also used : DocumentSorter(org.openntf.domino.helpers.DocumentSorter) DocumentCollection(org.openntf.domino.DocumentCollection) Date(java.util.Date)

Example 22 with DocumentCollection

use of org.openntf.domino.DocumentCollection in project org.openntf.domino by OpenNTF.

the class View method getAllDocuments.

/*
	 * (non-Javadoc)
	 *
	 * @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();
        // 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;
}
Also used : ViewEntry(org.openntf.domino.ViewEntry) NoteCollection(org.openntf.domino.NoteCollection) Database(org.openntf.domino.Database) DocumentCollection(org.openntf.domino.DocumentCollection) Document(org.openntf.domino.Document)

Example 23 with DocumentCollection

use of org.openntf.domino.DocumentCollection in project org.openntf.domino by OpenNTF.

the class View method getAllDocumentsByKey.

/*
	 * (non-Javadoc)
	 *
	 * @see org.openntf.domino.View#getAllDocumentsByKey(java.lang.Object, boolean)
	 */
@SuppressWarnings("rawtypes")
@Override
public DocumentCollection getAllDocumentsByKey(final Object key, final boolean exact) {
    List<lotus.domino.Base> recycleThis = new ArrayList<lotus.domino.Base>();
    try {
        Object domKey = toDominoFriendly(key, getAncestorSession(), recycleThis);
        lotus.domino.DocumentCollection lotusColl;
        if (domKey instanceof java.util.Vector) {
            lotusColl = getDelegate().getAllDocumentsByKey((java.util.Vector) domKey, exact);
        } else {
            lotusColl = getDelegate().getAllDocumentsByKey(domKey, exact);
        }
        DocumentCollection dc = fromLotus(lotusColl, DocumentCollection.SCHEMA, getAncestorDatabase());
        dc.setParentView(this);
        return dc;
    } catch (NotesException e) {
        DominoUtils.handleException(e);
    } finally {
        s_recycle(recycleThis);
    }
    return null;
}
Also used : NotesException(lotus.domino.NotesException) ArrayList(java.util.ArrayList) DocumentCollection(org.openntf.domino.DocumentCollection) Vector(java.util.Vector)

Aggregations

DocumentCollection (org.openntf.domino.DocumentCollection)23 Database (org.openntf.domino.Database)9 NotesException (lotus.domino.NotesException)8 Document (org.openntf.domino.Document)8 Session (org.openntf.domino.Session)7 OpenNTFNotesException (org.openntf.domino.exceptions.OpenNTFNotesException)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 DateTime (org.openntf.domino.DateTime)4 HashMap (java.util.HashMap)3 Vector (java.util.Vector)3 View (org.openntf.domino.View)3 DocumentSorter (org.openntf.domino.helpers.DocumentSorter)3 Encapsulated (org.openntf.domino.types.Encapsulated)3 IOException (java.io.IOException)2 Serializable (java.io.Serializable)2 Map (java.util.Map)2 Test (org.junit.Test)2 Item (org.openntf.domino.Item)2 NoteCollection (org.openntf.domino.NoteCollection)2