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();
}
}
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!");
}
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;
}
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;
}
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);
}
}
Aggregations