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();
}
}
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();
}
}
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();
}
}
Aggregations