use of org.openntf.domino.View in project org.openntf.domino by OpenNTF.
the class NoteListTest method run2.
public void run2() {
long testStartTime = System.nanoTime();
Session session = this.getSession();
try {
Database db = session.getDatabase("", "imdb/movies.nsf");
// db.setDelayUpdates(true);
marktime = System.nanoTime();
timelog("Beginning view build...");
View byLength = db.getView("byLength");
View btitles = db.createView("BTitles", "@Begins(Title; \"B\")", byLength);
// View btitles = db.createView("BTitles", "@Begins(Title; \"B\")");
ViewColumn length = btitles.createColumn(1, "Title", "Title");
length.setSorted(true);
timelog("View defined.");
btitles.refresh();
timelog("Completed view build.");
ViewEntryCollection vec = btitles.getAllEntries();
int count = vec.getCount();
timelog("Found " + count + " documents in the view");
btitles.remove();
timelog("Removed view.");
btitles.recycle();
db.recycle();
} catch (Throwable t) {
t.printStackTrace();
} finally {
long testEndTime = System.nanoTime();
System.out.println("Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms");
}
}
use of org.openntf.domino.View in project org.openntf.domino by OpenNTF.
the class SerializeTest method testViewNameConflict.
@Test
public void testViewNameConflict() throws IOException, ClassNotFoundException {
Session sess = Factory.getSession(SessionType.CURRENT);
Database db = sess.getDatabase("log.nsf");
View vw = db.getView("name1");
assertNotNull("you need 4 views for this test in your log.nsf: 'name1|sameAlias','name2|sameAlias', 'sameName|alias1', 'sameName|alias2'", vw);
View ret = test(vw, true);
assertFalse(vw == ret);
vw = db.getView("name2");
ret = test(vw, true);
assertFalse(vw == ret);
vw = db.getView("alias1");
ret = test(vw, true);
assertFalse(vw == ret);
vw = db.getView("alias2");
ret = test(vw, true);
assertFalse(vw == ret);
}
use of org.openntf.domino.View in project org.openntf.domino by OpenNTF.
the class SerializeTest method testView.
@Test
public void testView() throws IOException, ClassNotFoundException {
Session sess = Factory.getSession(SessionType.CURRENT);
View vw = sess.getDatabase("log.nsf").getViews().get(0);
View ret = test(vw, false);
assertTrue(vw == ret);
}
use of org.openntf.domino.View in project org.openntf.domino by OpenNTF.
the class Connect17Documents method run.
@Override
public void run() {
Session sess = Factory.getSession(SessionType.NATIVE);
Database extLib = sess.getDatabase("odademo/oda_1.nsf");
View contacts = extLib.getView("AllContacts");
View threads = extLib.getView("AllThreadsByAuthor");
Document doc = contacts.getFirstDocument();
// Clears changes this function already made
resetDoc(doc);
Document newDoc = extLib.createDocument();
doc.copyAllItems(newDoc, true);
String prevDocAsJson = doc.toJson(true);
doc.appendItemValue("State", "AZ");
doc.replaceItemValue("DateTimeField", new Date());
doc.replaceItemValue("DateOnlyField", new java.sql.Date(System.currentTimeMillis()));
System.out.println(doc.getFirstItem("DateOnlyField").getValues());
doc.replaceItemValue("TimeOnlyField", new java.sql.Time(System.currentTimeMillis()));
System.out.println(doc.getFirstItem("TimeOnlyField").getValues());
doc.replaceItemValue("EmptyDate", "");
Date blankDate = doc.getItemValue("EmptyDate", Date.class);
System.out.println(blankDate);
ArrayList<String> list = new ArrayList<String>();
list.add("Value 1");
list.add("Value 2");
doc.replaceItemValue("MVField", list);
doc.replaceItemValue("DocAsJson", prevDocAsJson);
HashMap<String, String> mapField = new HashMap<String, String>();
DocumentCollection dc = threads.getAllDocumentsByKey(doc.getItemValueString("FullName"));
for (Document tmp : dc) {
mapField.put(tmp.getUniversalID(), tmp.getItemValueString("Title"));
}
doc.put("MapField", mapField);
BigDecimal decimal = new BigDecimal("2.5");
doc.replaceItemValue("BigDecimalField", decimal);
doc.replaceItemValue("EnumField", Fixes.FORCE_HEX_LOWER_CASE);
doc.save();
HashMap tmp = doc.getItemValue("MapField", HashMap.class);
System.out.println(tmp.size());
System.out.println(doc.getMetaversalID());
System.out.println(doc.getItemValueString("EnumField"));
java.sql.Date sqlDt = doc.getItemValue("DateTimeField", java.sql.Date.class);
System.out.println(sqlDt);
java.sql.Time sqlTime = doc.getItemValue("DateTimeField", java.sql.Time.class);
System.out.println(sqlTime);
System.out.println(doc.getItemValues("BigDecimalField", BigDecimal.class));
System.out.println(doc.getFirstItem("MVField").getTypeEx());
ArrayList<String> blank = new ArrayList<String>();
doc.replaceItemValue("MVField", blank);
System.out.println(doc.hasItem("MVField"));
NamesList names = new NamesList();
names.add("CN=Paul Withers/O=Intec");
names.add("CN=Admin/O=Intec=PW");
newDoc.replaceItemValue("Names", names);
AuthorsList authors = new AuthorsList();
authors.addAll(names);
newDoc.replaceItemValue("Authors", authors);
ReadersList readers = new ReadersList();
readers.addAll(names);
newDoc.replaceItemValue("Readers", readers);
Item dt = newDoc.replaceItemValue("TestDate", "");
Vector<DateTime> dates = new Vector();
DateTime dt1 = sess.createDateTime("01/01/2017");
DateTime dt2 = sess.createDateTime("02/01/2017");
dates.add(dt1);
dates.add(dt2);
dt.setValues(dates);
newDoc.save();
}
use of org.openntf.domino.View in project org.openntf.domino by OpenNTF.
the class Connect17ODA method run.
@SuppressWarnings("unchecked")
@Override
public void run() {
try {
Session sess = Factory.getSession(SessionType.NATIVE);
TreeSet<String> names = new TreeSet<String>();
Database extLib = sess.getDatabase("odademo/oda_1.nsf");
View states = extLib.getView("AllStates");
ViewEntry entState = states.getAllEntries().getFirstEntry();
View byState = extLib.getView("AllContactsByState");
ArrayList<Object> stateVals = new ArrayList(entState.getColumnValuesEx());
ViewEntryCollection ec = byState.getAllEntriesByKey(stateVals.get(0));
for (ViewEntry ent : ec) {
names.add((String) ent.getColumnValues().get(8));
}
System.out.println(names.toString());
} catch (Exception e) {
XspOpenLogUtil.logError(e);
}
}
Aggregations