Search in sources :

Example 11 with Database

use of lotus.domino.Database in project openliberty-domino by OpenNTF.

the class IdentityServlet method getUsersForGroup.

@SuppressWarnings("unchecked")
public String getUsersForGroup(String groupSecurityName, int limit) throws NotesException {
    Session session = NotesFactory.createSession();
    try {
        // TODO Look up and expand group
        // TODO work with multiple group-allowed directories
        // $NON-NLS-1$ //$NON-NLS-2$
        Database names = session.getDatabase("", "names.nsf");
        Document tempDoc = names.createDocument();
        // $NON-NLS-1$
        tempDoc.replaceItemValue("GroupName", groupSecurityName);
        // $NON-NLS-1$
        List<String> members = session.evaluate(" @Text(@Trim(@Unique(@Sort(@DbLookup(''; '':'names.nsf'; '$VIMGroups'; GroupName; 'Members'))))) ", tempDoc);
        // $NON-NLS-1$
        return String.join("\n", members);
    } finally {
        session.recycle();
    }
}
Also used : Database(lotus.domino.Database) Document(lotus.domino.Document) Session(lotus.domino.Session)

Example 12 with Database

use of lotus.domino.Database in project org.openntf.domino by OpenNTF.

the class LegacyCollectionTest method run.

@Override
public void run() {
    try {
        System.out.println("Starting NotesRunner");
        Session session = NotesFactory.createSession();
        Long sessId = getLotusId(session);
        sessionid.set(sessId);
        Database db = session.getDatabase("", "names.nsf");
        System.out.println("Db id:" + getLotusId(db));
        int i = 0;
        try {
            lotus.domino.DocumentCollection allDocs = db.getAllDocuments();
            System.out.println("All Collection has " + allDocs.getCount() + " documents");
            int[] nids = new int[allDocs.getCount()];
            lotus.domino.Document doc = allDocs.getFirstDocument();
            lotus.domino.Document nextDoc = null;
            while (doc != null) {
                nextDoc = allDocs.getNextDocument(doc);
                nids[i++] = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            System.out.println("noteid array has " + nids.length + " entries");
            allDocs.recycle();
            // lotus.domino.DocumentCollection newColl = db.getModifiedDocuments(session.createDateTime(new java.util.Date()));
            lotus.domino.DocumentCollection newColl = db.getAllUnreadDocuments();
            System.out.println("New Coll has " + newColl.getCount() + " documents");
            // lotus.domino.DocumentCollection emptyColl = db.createDocumentCollection();
            newColl.intersect(nids[0]);
            System.out.println("New Coll has " + newColl.getCount() + " documents");
            for (int nid : nids) {
                newColl.merge(nid);
            }
            System.out.println("Merged Collection has " + newColl.getCount() + " documents");
            newColl.recycle();
        } catch (Throwable t) {
            t.printStackTrace();
            System.out.println("Exception at loop point " + i);
        }
        session.recycle();
    } catch (Throwable t) {
        t.printStackTrace();
    }
    System.out.println("FINI!");
}
Also used : Database(lotus.domino.Database) Session(lotus.domino.Session)

Example 13 with Database

use of lotus.domino.Database in project org.openntf.domino by OpenNTF.

the class NotesRunner method run1.

public void run1(final Session session) throws NotesException {
    Long sessId = getLotusId(session);
    sessionid.set(sessId);
    Database db = session.getDatabase("", "names.nsf");
    System.out.println("Db id:" + getLotusId(db));
    Name name = null;
    int i = 0;
    try {
        for (i = 0; i <= 100000; i++) {
            name = session.createName(UUID.randomUUID().toString());
            getLotusId(name);
            DateTime dt = session.createDateTime(new Date());
            getLotusId(dt);
            DateTime end = session.createDateTime(new Date());
            getLotusId(end);
            DateRange dr = session.createDateRange(dt, end);
            getLotusId(dr);
            Document doc = db.createDocument();
            getLotusId(doc);
            Item i1 = doc.replaceItemValue("Foo", dr);
            getLotusId(i1);
            Item i2 = doc.replaceItemValue("Bar", dr.getText());
            getLotusId(i2);
            Item i3 = doc.replaceItemValue("Blah", dr.getStartDateTime().getLocalTime());
            getLotusId(i3);
            lotus.domino.ColorObject color = session.createColorObject();
            getLotusId(color);
            color.setRGB(128, 128, 128);
            Item i4 = doc.replaceItemValue("color", color.getNotesColor());
            getLotusId(i4);
            i1.recycle();
            i2.recycle();
            i3.recycle();
            i4.recycle();
            DateTime create = doc.getCreated();
            getLotusId(create);
            @SuppressWarnings("unused") String lc = create.getLocalTime();
            // if (i % 10000 == 0) {
            // System.out.println(Thread.currentThread().getName() + " Name " + i + " is " + name.getCommon() + " "
            // + "Local time is " + lc + "  " + dr.getText());
            // }
            dr.recycle();
            doc.recycle();
            dt.recycle();
            end.recycle();
            create.recycle();
            color.recycle();
            name.recycle();
        }
    } catch (Throwable t) {
        t.printStackTrace();
        System.out.println("Exception at loop point " + i);
    }
}
Also used : Document(lotus.domino.Document) DateTime(lotus.domino.DateTime) Date(java.util.Date) Name(lotus.domino.Name) Item(lotus.domino.Item) DateRange(lotus.domino.DateRange) Database(lotus.domino.Database)

Example 14 with Database

use of lotus.domino.Database in project org.openntf.domino by OpenNTF.

the class NotesRunner method run4.

public void run4(final Session session) throws NotesException {
    Database db = session.getDatabase("", "events4.nsf");
    NoteCollection cacheNC = db.createNoteCollection(false);
    cacheNC.setSelectDocuments(true);
    cacheNC.buildCollection();
    cacheNC.recycle();
    DocumentCollection cacheDc = db.getAllDocuments();
    Document cacheDoc = cacheDc.getFirstDocument();
    cacheDoc.recycle();
    cacheDc.recycle();
    db.recycle();
    db = session.getDatabase("", "events4.nsf");
    DocumentCollection dc = db.getAllDocuments();
    Document doc = dc.getFirstDocument();
    Document nextDoc = null;
    int dcCount = dc.getCount();
    int j = 0;
    String[] dcUnids = new String[dcCount];
    long dcStart = System.nanoTime();
    while (doc != null) {
        nextDoc = dc.getNextDocument(doc);
        dcUnids[j++] = doc.getUniversalID();
        doc.recycle();
        doc = nextDoc;
    }
    System.out.println("DocumentCollection strategy got UNIDs for " + dcCount + " docs in " + (System.nanoTime() - dcStart) / 1000 + "us");
    dc.recycle();
    db.recycle();
    db = session.getDatabase("", "events4.nsf");
    NoteCollection nc3 = db.createNoteCollection(false);
    nc3.setSelectDocuments(true);
    nc3.buildCollection();
    int nc3Count = nc3.getCount();
    String[] nc3Unids = new String[nc3Count];
    int[] nids = nc3.getNoteIDs();
    int k = 0;
    long nc3Start = System.nanoTime();
    for (int id : nids) {
        nc3Unids[k++] = nc3.getUNID(Integer.toHexString(id));
    }
    System.out.println("NoteCollection strategy ints got UNIDs for " + nc3Count + " notes in " + (System.nanoTime() - nc3Start) / 1000 + "us");
    nc3.recycle();
    db.recycle();
    db = session.getDatabase("", "events4.nsf");
    NoteCollection nc = db.createNoteCollection(false);
    nc.setSelectDocuments(true);
    nc.buildCollection();
    int ncCount = nc.getCount();
    String[] ncUnids = new String[ncCount];
    String nid = nc.getFirstNoteID();
    long ncStart = System.nanoTime();
    for (int i = 0; i < ncCount; i++) {
        ncUnids[i] = nc.getUNID(nid);
        nid = nc.getNextNoteID(nid);
    }
    System.out.println("NoteCollection strategy first/next got UNIDs for " + ncCount + " notes in " + (System.nanoTime() - ncStart) / 1000 + "us");
    nc.recycle();
    db.recycle();
    db = session.getDatabase("", "events4.nsf");
    NoteCollection nc2 = db.createNoteCollection(false);
    nc2.setSelectDocuments(true);
    nc2.buildCollection();
    int nc2Count = nc2.getCount();
    String[] nc2Unids = new String[nc2Count];
    nid = nc2.getFirstNoteID();
    long nc2Start = System.nanoTime();
    for (int i = 0; i < nc2Count; i++) {
        Document nc2doc = db.getDocumentByID(nid);
        nc2Unids[i] = nc2doc.getUniversalID();
        nc2doc.recycle();
        nid = nc2.getNextNoteID(nid);
    }
    System.out.println("NoteCollection strategy doc got UNIDs for " + nc2Count + " notes in " + (System.nanoTime() - nc2Start) / 1000 + "us");
    nc2.recycle();
    db.recycle();
}
Also used : NoteCollection(lotus.domino.NoteCollection) Database(lotus.domino.Database) DocumentCollection(lotus.domino.DocumentCollection) Document(lotus.domino.Document)

Example 15 with Database

use of lotus.domino.Database in project org.openntf.domino by OpenNTF.

the class NotesRunner method run2.

public void run2(final Session session) throws NotesException {
    Database db = session.getDatabase("", "log.nsf");
    Document doc = db.createDocument();
    Item names = doc.replaceItemValue("Names", "CN=Nathan T Freeman/O=REDPILL");
    names.setAuthors(true);
    doc.replaceItemValue("form", "test");
    doc.save(true);
    String nid = doc.getNoteID();
    doc.recycle();
    doc = db.getDocumentByID(nid);
    Vector<Double> numbers = new Vector<Double>();
    numbers.add(new Double(1));
    numbers.add(new Double(2));
    doc.replaceItemValue("Names", numbers);
    doc.save(true);
    doc.recycle();
    doc = db.getDocumentByID(nid);
    names = doc.getFirstItem("Names");
    System.out.println("Names is " + names.getType() + " with " + names.isNames() + " and " + names.isAuthors() + " and value " + names.getText());
    doc.recycle();
    db.recycle();
}
Also used : Item(lotus.domino.Item) Database(lotus.domino.Database) Document(lotus.domino.Document) Vector(java.util.Vector)

Aggregations

Database (lotus.domino.Database)32 Session (lotus.domino.Session)18 Document (lotus.domino.Document)16 NotesException (lotus.domino.NotesException)13 DocumentCollection (lotus.domino.DocumentCollection)5 NoteCollection (lotus.domino.NoteCollection)5 View (lotus.domino.View)4 IOException (java.io.IOException)3 Vector (java.util.Vector)3 DateTime (lotus.domino.DateTime)3 DominoQuery (lotus.domino.DominoQuery)3 Item (lotus.domino.Item)3 ViewEntry (lotus.domino.ViewEntry)3 DominoDocument (com.ibm.xsp.model.domino.wrapped.DominoDocument)2 Document (jakarta.nosql.document.Document)2 URI (java.net.URI)2 Path (java.nio.file.Path)2 Date (java.util.Date)2 ExecutionException (java.util.concurrent.ExecutionException)2 ACL (lotus.domino.ACL)2