Search in sources :

Example 1 with ViewEntryCollection

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

the class Connect17Standard method run.

@SuppressWarnings("unchecked")
@Override
public void run() {
    org.openntf.domino.Session sess = Factory.getSession(SessionType.NATIVE);
    try {
        TreeSet<String> names = new TreeSet<String>();
        Session session = TypeUtils.toLotus(sess);
        // Point to ExtLib demo, create a view called AllContactsByState
        // Copy AllContacts but adding a categorised column for State
        Database extLib = session.getDatabase(session.getServerName(), "odademo/oda_1.nsf");
        View states = extLib.getView("AllStates");
        states.setAutoUpdate(false);
        ViewEntry entState = states.getAllEntries().getFirstEntry();
        View byState = extLib.getView("AllContactsByState");
        byState.setAutoUpdate(false);
        Vector<String> key = new Vector<String>();
        Vector<String> stateVals = entState.getColumnValues();
        key.add(stateVals.get(0));
        ViewEntryCollection ec = byState.getAllEntriesByKey(key, true);
        ViewEntry ent = ec.getFirstEntry();
        while (null != ent) {
            Vector<Object> vals = ent.getColumnValues();
            names.add((String) vals.get(7));
            ViewEntry tmpEnt = ec.getNextEntry();
            ent.recycle(vals);
            ent.recycle();
            ent = tmpEnt;
        }
        System.out.println(names.toString());
    } catch (NotesException e) {
        e.printStackTrace();
    }
}
Also used : View(lotus.domino.View) NotesException(lotus.domino.NotesException) ViewEntry(lotus.domino.ViewEntry) TreeSet(java.util.TreeSet) Database(lotus.domino.Database) ViewEntryCollection(lotus.domino.ViewEntryCollection) Vector(java.util.Vector) Session(lotus.domino.Session)

Example 2 with ViewEntryCollection

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

the class OpenntfNABNamePickerData 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 {
        getReturnNameFormat();
        EntryMetaData meta = createOpenntfEntryMetaData(options);
        meta.setKey(getReturnNameFormatAsKey());
        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;
                        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) EmptyPickerResult(com.ibm.xsp.extlib.component.picker.data.EmptyPickerResult) IPickerResult(com.ibm.xsp.extlib.component.picker.data.IPickerResult) DominoViewEntry(com.ibm.xsp.model.domino.wrapped.DominoViewEntry) ViewEntry(lotus.domino.ViewEntry) ViewEntryCollection(lotus.domino.ViewEntryCollection)

Example 3 with ViewEntryCollection

use of lotus.domino.ViewEntryCollection 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)3 View (lotus.domino.View)3 ViewEntry (lotus.domino.ViewEntry)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 ArrayList (java.util.ArrayList)2 ViewNavigator (lotus.domino.ViewNavigator)2 TreeSet (java.util.TreeSet)1 Vector (java.util.Vector)1 Database (lotus.domino.Database)1 Session (lotus.domino.Session)1