Search in sources :

Example 1 with NSFSEARCHPROC

use of com.darwino.domino.napi.proc.NSFSEARCHPROC in project org.openntf.nsfodp by OpenNTF.

the class DarwinoNDatabase method eachDesignNote.

@Override
public void eachDesignNote(BiConsumer<Integer, NNote> consumer) {
    NSFSEARCHPROC proc = new NSFSEARCHPROC() {

        @Override
        public short callback(long searchMatchPtr, long summaryBufferPtr) throws DominoException {
            SEARCH_MATCH searchMatch = new SEARCH_MATCH();
            C.memcpy(searchMatch.getDataPtr(), 0, searchMatchPtr, 0, SEARCH_MATCH.sizeOf);
            short noteClass = searchMatch.getNoteClass();
            int noteId = searchMatch.getId().getNoteId();
            byte retFlags = searchMatch.getSERetFlags();
            boolean deleted = (noteClass & DominoAPI.NOTE_CLASS_NOTIFYDELETION) != 0;
            // The use of "since" means that non-matching notes will be returned; check this flag to make sure
            boolean isSearchMatch = (retFlags & DominoAPI.SE_FMATCH) != 0;
            if (isSearchMatch && !deleted) {
                try (NNote note = getNoteByID(noteId)) {
                    consumer.accept(noteId, note);
                }
            }
            return DominoAPI.NOERROR;
        }
    };
    try {
        // $NON-NLS-1$
        database.search("@All", proc, (short) 0, DominoAPI.NOTE_CLASS_ALLNONDATA, null, null);
    } catch (DominoException e) {
        throw new NDominoException(e.getStatus(), e);
    } catch (FormulaException e) {
        throw new NDominoException(0, e);
    }
}
Also used : NNote(org.openntf.nsfodp.commons.odp.notesapi.NNote) NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException) NSFSEARCHPROC(com.darwino.domino.napi.proc.NSFSEARCHPROC) SEARCH_MATCH(com.darwino.domino.napi.struct.SEARCH_MATCH) FormulaException(com.darwino.domino.napi.wrap.FormulaException) DominoException(com.darwino.domino.napi.DominoException) NDominoException(org.openntf.nsfodp.commons.odp.notesapi.NDominoException)

Aggregations

DominoException (com.darwino.domino.napi.DominoException)1 NSFSEARCHPROC (com.darwino.domino.napi.proc.NSFSEARCHPROC)1 SEARCH_MATCH (com.darwino.domino.napi.struct.SEARCH_MATCH)1 FormulaException (com.darwino.domino.napi.wrap.FormulaException)1 NDominoException (org.openntf.nsfodp.commons.odp.notesapi.NDominoException)1 NNote (org.openntf.nsfodp.commons.odp.notesapi.NNote)1