Search in sources :

Example 11 with Session

use of org.openntf.domino.Session 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 Session

use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.

the class RichTextItemReplaceAttachmentText method run.

@Override
public void run() {
    Session session = Factory.getSession(SessionType.NATIVE);
    Database db = session.getDatabase("", "sarmy/USSBulletins.nsf");
    Document doc = db.getDocumentByUNID("5F96214CFE92013D86258027007687FA");
    RichTextItem rtItem = (RichTextItem) doc.getFirstItem("BulletinText");
    rtItem.replaceAttachment("Feature Requests 2008.ods", "c:/data/Feature Requests 2008.ods");
    rtItem.compact();
    doc.save(true, true);
}
Also used : RichTextItem(org.openntf.domino.RichTextItem) Database(org.openntf.domino.Database) Document(org.openntf.domino.Document) Session(org.openntf.domino.Session)

Example 13 with Session

use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.

the class SortedCollectionTest method run.

@Override
public void run() {
    Session session = Factory.getSession(SessionType.CURRENT);
    Database db = session.getDatabase("", "CollTest.nsf");
    DocumentCollection coll = db.getAllDocuments();
    // System.out.println("UNSORTED");
    for (Document doc : coll) {
    // System.out.println(doc.getItemValueString("MainSortValue") + " " + doc.getLastModifiedDate().getTime());
    }
    List<String> criteria = new ArrayList<String>();
    criteria.add("MainSortValue");
    criteria.add("@modifieddate");
    try {
        DocumentSorter sorter = new DocumentSorter(coll, criteria);
        // System.out.println("SORTING...");
        long startTime = System.nanoTime();
        DocumentCollection sortedColl = sorter.sort();
        long endTime = System.nanoTime();
        System.out.println("Completed resort in " + ((endTime - startTime) / 1000000) + "ms");
        // System.out.println("SORTED");
        for (Document doc : sortedColl) {
            System.out.println(doc.getItemValueString("MainSortValue") + " " + doc.getLastModifiedDate().getTime() + " " + Integer.valueOf(doc.getNoteID(), 16));
        }
        DocumentSorter.DocumentData[] dataset = sorter._debugGetDataset();
        for (DocumentSorter.DocumentData data : dataset) {
            StringBuilder sb = new StringBuilder();
            for (Serializable s : data._debugGetValues()) {
                sb.append(s);
                sb.append(',');
            }
            System.out.println(sb.toString());
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) DocumentCollection(org.openntf.domino.DocumentCollection) Document(org.openntf.domino.Document) Database(org.openntf.domino.Database) DocumentSorter(org.openntf.domino.helpers.DocumentSorter) Session(org.openntf.domino.Session)

Example 14 with Session

use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.

the class NameTest method testName.

protected org.openntf.domino.Name testName(final String what, final NotesBug... notesbug) throws NotesException {
    Session s = Factory.getSession(SessionType.CURRENT);
    lotus.domino.Session ls = s.getFactory().toLotus(s);
    org.openntf.domino.Name o = s.createName(what);
    lotus.domino.Name n = ls.createName(what);
    compareNames(n.getCanonical(), n, o, notesbug);
    return o;
}
Also used : Session(org.openntf.domino.Session)

Example 15 with Session

use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.

the class SerializeTest method testDatabaseReboot.

@Test
public void testDatabaseReboot() throws IOException, ClassNotFoundException {
    Session sess = Factory.getSession(SessionType.CURRENT);
    Database db = sess.getDatabase("log.nsf");
    Database ret = test(db, true);
    assertFalse(db == ret);
}
Also used : Database(org.openntf.domino.Database) Session(org.openntf.domino.Session) Test(org.junit.Test)

Aggregations

Session (org.openntf.domino.Session)101 Database (org.openntf.domino.Database)73 Document (org.openntf.domino.Document)28 Test (org.junit.Test)25 View (org.openntf.domino.View)20 DbDirectory (org.openntf.domino.DbDirectory)11 ArrayList (java.util.ArrayList)10 DocumentCollection (org.openntf.domino.DocumentCollection)7 Vector (java.util.Vector)5 ViewEntry (org.openntf.domino.ViewEntry)5 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 NotesException (lotus.domino.NotesException)4 Item (org.openntf.domino.Item)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Agent (org.openntf.domino.Agent)3 NoteCollection (org.openntf.domino.NoteCollection)3