Search in sources :

Example 6 with ViewEntry

use of lotus.domino.ViewEntry in project org.openntf.domino by OpenNTF.

the class OpenntfViewValuePickerData method readEntries.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ibm.xsp.extlib.component.picker.data.AbstractDominoViewPickerData#readEntries(com.ibm.xsp.extlib.component.picker.data.IPickerOptions
	 * )
	 */
@Override
public IPickerResult readEntries(final IPickerOptions options) {
    try {
        EntryMetaData meta = new _EntryMetaData(options);
        View view = meta.getView();
        view.setAutoUpdate(false);
        try {
            ArrayList<IPickerEntry> entries = new ArrayList<IPickerEntry>();
            int start = options.getStart();
            int count = options.getCount();
            String key = options.getKey();
            String _startKey = options.getStartKey();
            if (StringUtil.isNotEmpty(_startKey)) {
                key = _startKey;
            }
            String searchType = getSearchType();
            if (StringUtil.isEmpty(searchType)) {
                searchType = SEARCH_STARTFROM;
            }
            if (StringUtil.equals(searchType, SEARCH_MATCH)) {
                ViewEntryCollection vc = view.getAllEntriesByKey(key);
                ViewEntry ve = start > 0 ? vc.getNthEntry(start) : vc.getFirstEntry();
                for (int i = 0; i < count && ve != null; i++) {
                    entries.add(meta.createEntry(ve));
                    ve = vc.getNextEntry(ve);
                }
                int nEntries = vc.getCount();
                return new Result(entries, nEntries);
            }
            if (StringUtil.equals(searchType, SEARCH_FTSEARCH)) {
                applyFTSearch(options, view, key);
                ViewEntryCollection vc = view.getAllEntries();
                ViewEntry ve = start > 0 ? vc.getNthEntry(start) : vc.getFirstEntry();
                for (int i = 0; i < count && ve != null; i++) {
                    entries.add(meta.createEntry(ve));
                    ve = vc.getNextEntry(ve);
                }
                int nEntries = vc.getCount();
                return new Result(entries, nEntries);
            } else {
                ViewNavigator nav = view.createViewNav();
                try {
                    ViewEntry ve = null;
                    if (key != null) {
                        int searchOptions = DominoUtils.FIND_GREATER_THAN | DominoUtils.FIND_EQUAL | DominoUtils.FIND_PARTIAL | DominoUtils.FIND_CASE_INSENSITIVE;
                        // This is the one line that's different
                        ve = DominoUtils.getViewEntryByKeyWithOptions(Factory.getWrapperFactory().toLotus(view), key, searchOptions);
                    } else {
                        ve = nav.getCurrent();
                    }
                    if (start > 0) {
                        if (nav.skip(start) != start) {
                            // ok not all of them are skipped, stop the
                            // process
                            count = 0;
                        }
                    }
                    for (int i = 0; i < count && ve != null; i++) {
                        entries.add(meta.createEntry(ve));
                        ve = nav.getNext(ve);
                    }
                    int nEntries = -1;
                    return new Result(entries, nEntries);
                } finally {
                    nav.recycle();
                }
            }
        } finally {
        // Recycle the view?
        }
    } catch (Exception ex) {
        Platform.getInstance().log(ex);
        // Swallow the exception for the end user and return an empty picker
        return new EmptyPickerResult();
    }
}
Also used : ViewNavigator(lotus.domino.ViewNavigator) ArrayList(java.util.ArrayList) IPickerEntry(com.ibm.xsp.extlib.component.picker.data.IPickerEntry) EmptyPickerResult(com.ibm.xsp.extlib.component.picker.data.EmptyPickerResult) View(lotus.domino.View) NotesException(lotus.domino.NotesException) IPickerResult(com.ibm.xsp.extlib.component.picker.data.IPickerResult) EmptyPickerResult(com.ibm.xsp.extlib.component.picker.data.EmptyPickerResult) DominoViewEntry(com.ibm.xsp.model.domino.wrapped.DominoViewEntry) ViewEntry(lotus.domino.ViewEntry) ViewEntryCollection(lotus.domino.ViewEntryCollection)

Aggregations

NotesException (lotus.domino.NotesException)6 ViewEntry (lotus.domino.ViewEntry)6 View (lotus.domino.View)5 ViewNavigator (lotus.domino.ViewNavigator)4 ArrayList (java.util.ArrayList)3 Database (lotus.domino.Database)3 Session (lotus.domino.Session)3 ViewEntryCollection (lotus.domino.ViewEntryCollection)3 EmptyPickerResult (com.ibm.xsp.extlib.component.picker.data.EmptyPickerResult)2 IPickerEntry (com.ibm.xsp.extlib.component.picker.data.IPickerEntry)2 IPickerResult (com.ibm.xsp.extlib.component.picker.data.IPickerResult)2 DominoViewEntry (com.ibm.xsp.model.domino.wrapped.DominoViewEntry)2 IOException (java.io.IOException)2 Vector (java.util.Vector)2 Document (lotus.domino.Document)2 URI (java.net.URI)1 Path (java.nio.file.Path)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 InvalidKeyException (java.security.InvalidKeyException)1 KeyManagementException (java.security.KeyManagementException)1