use of com.ibm.xsp.extlib.component.picker.data.IPickerResult 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();
}
}
use of com.ibm.xsp.extlib.component.picker.data.IPickerResult 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();
}
}
Aggregations