use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class ViewCheckUniqueTest method NotesMain.
@SuppressWarnings("unused")
public void NotesMain() {
Session session;
Database database;
try {
Session s;
Database db;
if (this.session != null) {
s = this.session;
db = this.database;
try {
StringBuilder sb = new StringBuilder();
Document doc = db.createDocument();
doc.put("FirstName", "Aaron");
doc.put("LastName", "Monroe");
View view = db.getView("AllContacts");
ArrayList<String> key = new ArrayList<String>();
key.add(doc.getItemValueString("FirstName"));
key.add(doc.getItemValueString("LastName"));
if (view.checkUnique(key, doc)) {
sb.append("No document yet exists with name Aaron Monroe");
} else {
sb.append("Document already exists with name Aaron Monroe");
}
System.out.println(sb.toString());
} catch (Throwable t) {
System.err.println(t);
}
}
} catch (Throwable t) {
}
}
use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class DbHandleTest method run.
@Override
public void run() {
Factory.enableCounters(true, false);
try {
Session sess = Factory.getSession(SessionType.CURRENT);
lotus.domino.Session s = sess.getFactory().toLotus(sess);
lotus.domino.Database d1 = s.getDatabase("", "");
lotus.domino.Database d2 = s.getDatabase("", "");
// System.out.println("d1.cppId: " + Base.getLotusId(d1));
// System.out.println("d2.cppId: " + Base.getLotusId(d2));
d1.openWithFailover("", "names.nsf");
d2.openWithFailover("", "names.nsf");
// System.out.println("d1.cppId: " + Base.getLotusId(d1));
// System.out.println("d2.cppId: " + Base.getLotusId(d2));
System.out.println("D1:" + d1.getFilePath());
d1.recycle();
System.out.println("D2:" + d2.getFilePath());
d2.recycle();
} catch (NotesException e) {
e.printStackTrace();
}
}
use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class DesignClassTest method testDesignFactory.
// @Test
public void testDesignFactory() throws IOException {
Session sess = Factory.getSession(SessionType.CURRENT);
DbDirectory dir = sess.getDbDirectory("");
for (Database db : dir) {
try {
db.open();
} catch (OpenNTFNotesException e) {
e.printStackTrace();
}
if (db.isOpen()) {
System.out.println("DB under test" + db);
testDb(db);
}
}
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/proglib4work2.nsf");
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/empty.ns9");
}
use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class DesignClassTest method testDesignClass.
// @Test
public void testDesignClass() throws IOException {
Session sess = Factory.getSession(SessionType.CURRENT);
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/empty.ns9");
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/empty2.nsf");
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/proglib4work2.nsf");
Database db = sess.getDatabase("srv-01-ndev2!!entwicklung/alex/proglib4work22.nsf");
testDb(db);
DatabaseDesign design = db.getDesign();
// -X = no AgentData
DesignCollection<DesignBase> elems = design.getDesignElements(//
"!@Contains($Flags;{X}) & !($TITLE={WEB-INF/classes/plugin/Activator.class}:{$BEProfileR7}) " + "");
// + "& @IsAvailable($ACLDigest) ");
// + "& @contains($TITLE;{gadproxy}) ");
System.out.println("Count: " + elems.getCount());
Path root = Paths.get("D:/daten/temp/ods3");
OnDiskProject odp = new OnDiskProject(root);
// PrintWriter pw = new PrintWriter(oFile);
for (DesignBase elem : elems) {
// + elem.getDocument().getItemValueString("$FLAGS"));
try {
odp.export(elem);
// //elem.getDxlString(null)
// String odp = elem.getOnDiskPath();
// if (StringUtil.isEmpty(odp)) {
// odp = elem.getNoteID() + ".note";
// }
// File odsFile = new File(root, odp);
// System.out.println(elem.getClass().getName() + "\t\t\t" + odsFile);
// odsFile.getParentFile().mkdirs(); // ensure the path exists
// elem.writeOnDiskFile(odsFile);
// if (elem instanceof HasMetadata) {
// File meta = new File(odsFile.getAbsolutePath() + ".metadata");
// ((HasMetadata) elem).writeOnDiskMeta(meta);
// }
} catch (Exception ne) {
ne.printStackTrace();
}
// String path = "./" + elem.getOnDiskPath();
// String ext = elem.getOnDiskExtension();
// if (path != null && ext != null && !path.endsWith(ext))
// path = path + ext;
// pw.println(path + "\t'" + elem.getClass().getSimpleName() + "\t" + elem.getNoteID() + "\t" + elem.getName() + "\t"
// + elem.getDocument().getItemValueString("$FLAGS"));
// if (elem instanceof HasMetadata) {
// pw.println(path + ".metadata");
// }
// if (elem instanceof CustomControl) {
// pw.println(path + "-config");
// }
}
}
use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class NoteListTest method run1.
public void run1() {
long testStartTime = System.nanoTime();
Session session = this.getSession();
Database log = session.getDatabase("", "log.nsf");
Document storeTest = log.createDocument();
storeTest.replaceItemValue("form", "BinaryTest");
Database db = session.getDatabase("", "imdb/movies.nsf");
try {
marktime = System.nanoTime();
NoteSet noteset = new NoteSet();
timelog("Beginning first noteset...");
NoteCollection notecoll2 = db.createNoteCollection(false);
notecoll2.setSelectDocuments(true);
notecoll2.setSelectionFormula("@Begins(Title; \"B\")");
notecoll2.buildCollection();
// DocumentCollection coll = db.search("@Begins(Title; \"B\")");
timelog("Starting note coordinates of " + notecoll2.getCount() + " documents");
// for (Document doc : notecoll) {
for (String nid : notecoll2) {
NoteCoordinate nc = new NoteCoordinate(notecoll2, nid);
noteset.add(nc);
}
timelog("Done note coordinates of " + noteset.size() + " documents. Doing again...");
int i = 0;
for (String nid : notecoll2) {
if (i++ < 10000) {
NoteCoordinate nc = new NoteCoordinate(notecoll2, nid);
noteset.add(nc);
} else {
break;
}
}
timelog("Complete note coordinates of " + noteset.size() + " documents.");
NoteList notelist = new NoteList();
timelog("Beginning first notelist...");
NoteCollection notecoll = db.createNoteCollection(false);
notecoll.setSelectDocuments(true);
notecoll.setSelectionFormula("@Begins(Title; \"B\")");
notecoll.buildCollection();
// DocumentCollection coll = db.search("@Begins(Title; \"B\")");
timelog("Starting note coordinates of " + notecoll.getCount() + " documents");
// for (Document doc : notecoll) {
for (String nid : notecoll) {
NoteCoordinate nc = new NoteCoordinate(notecoll, nid);
notelist.add(nc);
}
timelog("Done note coordinates of " + notelist.size() + " documents. Doing again...");
i = 0;
for (String nid : notecoll) {
if (i++ < 10000) {
NoteCoordinate nc = new NoteCoordinate(notecoll, nid);
notelist.add(nc);
} else {
break;
}
}
timelog("Complete note coordinates of " + notelist.size() + " documents.");
// Database eventDb = session.getDatabase("", "events4.nsf");
// NoteCollection eventNotecoll = eventDb.createNoteCollection(false);
// eventNotecoll.setSelectDocuments(true);
// eventNotecoll.buildCollection();
// timelog("Continuing note coordinates of " + eventNotecoll.getCount() + " documents");
// for (String nid : eventNotecoll) {
// NoteCoordinate nc = new NoteCoordinate(eventNotecoll, nid);
// notelist.add(nc);
// }
// Database xspextDb = session.getDatabase("", "openntf/xpagesext.nsf");
// NoteCollection xspextNotecoll = xspextDb.createNoteCollection(false);
// xspextNotecoll.setSelectDocuments(true);
// xspextNotecoll.buildCollection();
// timelog("Continuing note coordinates of " + xspextNotecoll.getCount() + " documents");
// for (String nid : xspextNotecoll) {
// NoteCoordinate nc = new NoteCoordinate(xspextNotecoll, nid);
// notelist.add(nc);
// }
byte[] bytes = notelist.toByteArray();
int byteSize = bytes.length;
timelog("Resulting bytearray is " + bytes.length + " so we expect " + (bytes.length / (2500 * 24)) + " items");
// File file = File.createTempFile("foo", "bar");
// FileOutputStream fos = new FileOutputStream(file);
// fos.write(bytes);
// fos.close();
storeTest.writeBinary("imdbNoteList", bytes, 2500 * 24);
storeTest.save();
String storeId = storeTest.getUniversalID();
storeTest.recycle();
storeTest = null;
// coll.recycle();
// coll = null;
notecoll.recycle();
notecoll = null;
// eventNotecoll.recycle();
// eventNotecoll = null;
// eventDb.recycle();
// eventDb = null;
// xspextNotecoll.recycle();
// xspextNotecoll = null;
// xspextDb.recycle();
// xspextDb = null;
notelist = null;
// timelog("Binary data serialized out. Reloading...");
db.recycle();
db = null;
System.gc();
storeTest = log.getDocumentByUNID(storeId);
// FileInputStream fis = new FileInputStream(file);
// DbCache cache = new DbCache();
// NoteCoordinate.setDbCache(cache);
// NoteList notelist2 = new NoteList(cache, NoteList.getComparator("Title"));
// byte[] loaded = storeTest.readBinary("imdbNoteList");
// byte[] loaded = new byte[byteSize];
// fis.read(loaded);
// notelist2.loadByteArray(loaded);
// timelog("Done reloading " + notelist2.size() + " sorted notes. Iterating...");
// int notecount = 0;
// try {
// for (NoteCoordinate nc : notelist2) {
// Document doc = nc.getDocument();
// notecount++;
// // System.out.println("doc " + doc.getNoteID() + " " + doc.getItemValue("$UpdatedBy", String.class));
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// timelog("iterated over " + notecount + " notes out of " + notelist2.size());
long endTime = System.nanoTime();
} catch (Throwable t) {
t.printStackTrace();
}
long testEndTime = System.nanoTime();
System.out.println("Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms");
}
Aggregations