Search in sources :

Example 16 with Database

use of lotus.domino.Database 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();
    }
}
Also used : View(lotus.domino.View) NotesException(lotus.domino.NotesException) ViewEntry(lotus.domino.ViewEntry) TreeSet(java.util.TreeSet) Database(lotus.domino.Database) ViewEntryCollection(lotus.domino.ViewEntryCollection) Vector(java.util.Vector) Session(lotus.domino.Session)

Example 17 with Database

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

the class LegacyCollectionPerfTest 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("", "events4.nsf");
        System.out.println("Db id:" + getLotusId(db));
        try {
            lotus.domino.Document doc = null;
            lotus.domino.Document nextDoc = null;
            lotus.domino.DocumentCollection allDocs = db.getAllDocuments();
            System.out.println("All Collection has " + allDocs.getCount() + " documents");
            int[] nids = new int[allDocs.getCount()];
            long walkStartTime = System.nanoTime();
            doc = allDocs.getFirstDocument();
            int i = 0;
            while (doc != null) {
                nextDoc = allDocs.getNextDocument(doc);
                nids[i++] = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            long walkEndTime = System.nanoTime();
            System.out.println("DOCWALK: noteid array has " + allDocs.getCount() + " entries in " + (walkEndTime - walkStartTime) / 1000 + "us");
            long ncStartTime = System.nanoTime();
            NoteCollection nc = db.createNoteCollection(false);
            nc.add(allDocs);
            nids = nc.getNoteIDs();
            long ncBuildTime = System.nanoTime();
            System.out.println("NOTECOLL: noteid array has " + nids.length + " entries in " + (ncBuildTime - ncStartTime) / 1000 + "us");
            // for (int j = 0; j < nids.length; j++) {
            // doc = db.getDocumentByID(Integer.toString(nids[j], 16));
            // }
            // long ncWalkTime = System.nanoTime();
            // System.out.println("NOTECOLL: noteid array walked " + nids.length + " entries in " + (ncWalkTime - ncBuildTime) / 1000
            // + "us");
            long mergeStartTime = System.nanoTime();
            DocumentCollection mergeColl = db.search("@False", db.getLastModified(), 1);
            for (int j = 0; j < nids.length; j++) {
                mergeColl.merge(nids[j]);
            }
            long mergeBuildTime = System.nanoTime();
            System.out.println("MERGECOLL: mergeColl has " + mergeColl.getCount() + " entries in " + (mergeBuildTime - mergeStartTime) / 1000 + "us");
            doc = mergeColl.getFirstDocument();
            while (doc != null) {
                nextDoc = mergeColl.getNextDocument(doc);
                int n = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            long mergeWalkTime = System.nanoTime();
            System.out.println("MERGECOLL: mergeColl walked " + mergeColl.getCount() + " entries in " + (mergeWalkTime - mergeBuildTime) / 1000 + "us");
            System.out.println("MERGECOLL: mergeColl total time " + mergeColl.getCount() + " entries in " + (mergeWalkTime - ncStartTime) / 1000 + "us");
            walkStartTime = System.nanoTime();
            doc = allDocs.getFirstDocument();
            i = 0;
            while (doc != null) {
                nextDoc = allDocs.getNextDocument(doc);
                nids[i++] = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            walkEndTime = System.nanoTime();
            System.out.println("DOCWALK: noteid array has " + allDocs.getCount() + " entries in " + (walkEndTime - walkStartTime) / 1000 + "us");
            ncStartTime = System.nanoTime();
            nc = db.createNoteCollection(false);
            nc.add(allDocs);
            nids = nc.getNoteIDs();
            ncBuildTime = System.nanoTime();
            System.out.println("NOTECOLL: noteid array has " + nids.length + " entries in " + (ncBuildTime - ncStartTime) / 1000 + "us");
            // for (int j = 0; j < nids.length; j++) {
            // doc = db.getDocumentByID(Integer.toString(nids[j], 16));
            // }
            // long ncWalkTime = System.nanoTime();
            // System.out.println("NOTECOLL: noteid array walked " + nids.length + " entries in " + (ncWalkTime - ncBuildTime) / 1000
            // + "us");
            mergeStartTime = System.nanoTime();
            mergeColl = db.search("@False", db.getLastModified(), 1);
            for (int j = 0; j < nids.length; j++) {
                mergeColl.merge(nids[j]);
            }
            mergeBuildTime = System.nanoTime();
            System.out.println("MERGECOLL: mergeColl has " + mergeColl.getCount() + " entries in " + (mergeBuildTime - mergeStartTime) / 1000 + "us");
            doc = mergeColl.getFirstDocument();
            while (doc != null) {
                nextDoc = mergeColl.getNextDocument(doc);
                int n = Integer.valueOf(doc.getNoteID(), 16);
                doc.recycle();
                doc = nextDoc;
            }
            mergeWalkTime = System.nanoTime();
            System.out.println("MERGECOLL: mergeColl walked " + mergeColl.getCount() + " entries in " + (mergeWalkTime - mergeBuildTime) / 1000 + "us");
            System.out.println("MERGECOLL: mergeColl total time " + mergeColl.getCount() + " entries in " + (mergeWalkTime - ncStartTime) / 1000 + "us");
            nc.recycle();
            allDocs.recycle();
            mergeColl.recycle();
        } catch (Throwable t) {
            t.printStackTrace();
        }
        session.recycle();
    } catch (Throwable t) {
        t.printStackTrace();
    }
    System.out.println("FINI!");
}
Also used : DocumentCollection(lotus.domino.DocumentCollection) NoteCollection(lotus.domino.NoteCollection) Database(lotus.domino.Database) DocumentCollection(lotus.domino.DocumentCollection) Session(lotus.domino.Session)

Example 18 with Database

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

the class OpenntfDominoDocumentData method createDocument.

/**
 * creates a new document and wraps it in an OpenntfDominoDocument
 *
 * @return
 * @throws NotesException
 */
protected OpenntfDominoDocument createDocument() throws NotesException {
    Database db = openDatabase();
    String server = com.ibm.xsp.model.domino.DominoUtils.getCurrentDatabase().getServer();
    if (!(StringUtil.isEmpty(server))) {
        String currentUser = com.ibm.xsp.model.domino.DominoUtils.getCurrentSession().getEffectiveUserName();
        int i = db.queryAccessPrivileges(currentUser);
        if (((i & Database.DBACL_CREATE_DOCS) == 0) && ((i & Database.DBACL_WRITE_PUBLIC_DOCS) == 0)) {
            throw new NoAccessSignal("User " + currentUser + " is has not enough privileges to create documents in " + getDatabaseName());
        }
    }
    DominoDocument dominoDoc = DominoDocument.wrap(getDatabaseName(), db, getParentId(), getFormName(), getComputeWithForm(), getConcurrencyMode(), isAllowDeletedDocs(), getSaveLinksAs(), getWebQuerySaveAgent());
    OpenntfDominoDocument ntfDoc = wrap(dominoDoc, true);
    ntfDoc.setEditable(true);
    return ntfDoc;
}
Also used : Database(lotus.domino.Database) NoAccessSignal(com.ibm.xsp.acl.NoAccessSignal) DominoDocument(com.ibm.xsp.model.domino.wrapped.DominoDocument)

Example 19 with Database

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

the class OpenntfDominoDocumentData method openDocument.

/**
 * Opens the document with the given noteId
 *
 * @param noteId
 * @return
 * @throws NotesException
 */
protected OpenntfDominoDocument openDocument(final String noteId) throws NotesException {
    Database db = openDatabase();
    boolean allowDelted = isAllowDeletedDocs();
    Document backendDoc = com.ibm.xsp.model.domino.DominoUtils.getDocumentById(db, noteId, allowDelted);
    if (backendDoc != null) {
    // BackendBridge.setNoRecycle(backendDoc.getParentDatabase().getParent(), backendDoc, true);
    }
    DominoDocument dominoDoc = DominoDocument.wrap(getDatabaseName(), backendDoc, getComputeWithForm(), getConcurrencyMode(), allowDelted, getSaveLinksAs(), getWebQuerySaveAgent());
    OpenntfDominoDocument ntfDoc = wrap(dominoDoc, false);
    boolean editMode = "editDocument".equals(getEffectiveAction());
    ntfDoc.setEditable(editMode);
    return ntfDoc;
}
Also used : Database(lotus.domino.Database) DominoDocument(com.ibm.xsp.model.domino.wrapped.DominoDocument) Document(lotus.domino.Document) DominoDocument(com.ibm.xsp.model.domino.wrapped.DominoDocument)

Example 20 with Database

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

the class DefaultDominoDocumentCollectionManager method delete.

@Override
public void delete(DocumentDeleteQuery query) {
    try {
        Database database = supplier.get();
        List<String> unids = query.getDocuments();
        if (unids != null && !unids.isEmpty()) {
            for (String unid : unids) {
                if (unid != null && !unid.isEmpty()) {
                    lotus.domino.Document doc = database.getDocumentByUNID(unid);
                    doc.remove(true);
                }
            }
        } else if (query.getCondition().isPresent()) {
            // Then do it via DQL
            DQLTerm dql = QueryConverter.getCondition(query.getCondition().get());
            DominoQuery dominoQuery = database.createDominoQuery();
            DocumentCollection docs = dominoQuery.execute(dql.toString());
            docs.removeAll(true);
        }
    } catch (NotesException e) {
        throw new RuntimeException(e);
    }
}
Also used : NotesException(lotus.domino.NotesException) Database(lotus.domino.Database) DominoQuery(lotus.domino.DominoQuery) DocumentCollection(lotus.domino.DocumentCollection) DQLTerm(org.openntf.xsp.nosql.communication.driver.DQL.DQLTerm)

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