Search in sources :

Example 11 with View

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");
    }
}
Also used : ViewColumn(org.openntf.domino.ViewColumn) Database(org.openntf.domino.Database) ViewEntryCollection(org.openntf.domino.ViewEntryCollection) View(org.openntf.domino.View) Session(org.openntf.domino.Session)

Example 12 with View

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);
}
Also used : Database(org.openntf.domino.Database) View(org.openntf.domino.View) Session(org.openntf.domino.Session) Test(org.junit.Test)

Example 13 with View

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);
}
Also used : View(org.openntf.domino.View) Session(org.openntf.domino.Session) Test(org.junit.Test)

Example 14 with View

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();
}
Also used : NamesList(org.openntf.domino.types.NamesList) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Document(org.openntf.domino.Document) DocumentCollection(org.openntf.domino.DocumentCollection) View(org.openntf.domino.View) Date(java.util.Date) BigDecimal(java.math.BigDecimal) DateTime(org.openntf.domino.DateTime) Item(org.openntf.domino.Item) AuthorsList(org.openntf.domino.types.AuthorsList) Database(org.openntf.domino.Database) ReadersList(org.openntf.domino.types.ReadersList) Vector(java.util.Vector) Session(org.openntf.domino.Session)

Example 15 with View

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);
    }
}
Also used : ViewEntry(org.openntf.domino.ViewEntry) TreeSet(java.util.TreeSet) Database(org.openntf.domino.Database) ArrayList(java.util.ArrayList) ViewEntryCollection(org.openntf.domino.ViewEntryCollection) View(org.openntf.domino.View) Session(org.openntf.domino.Session)

Aggregations

View (org.openntf.domino.View)33 Session (org.openntf.domino.Session)20 Database (org.openntf.domino.Database)19 Document (org.openntf.domino.Document)9 ViewEntry (org.openntf.domino.ViewEntry)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 ViewNavigator (org.openntf.domino.ViewNavigator)5 HashMap (java.util.HashMap)4 ViewColumn (org.openntf.domino.ViewColumn)4 Map (java.util.Map)3 Vector (java.util.Vector)3 DocumentCollection (org.openntf.domino.DocumentCollection)3 ViewEntryCollection (org.openntf.domino.ViewEntryCollection)3 JsonJavaObject (com.ibm.commons.util.io.json.JsonJavaObject)2 JsonObject (com.ibm.commons.util.io.json.JsonObject)2 Edge (com.tinkerpop.blueprints.Edge)2 Vertex (com.tinkerpop.blueprints.Vertex)2 EdgeFrame (com.tinkerpop.frames.EdgeFrame)2