private void iterateAllDocuments(Database db, Set<Document> secondReference) { System.out.println( "Thread " + Thread.currentThread().getName() + " BEGINNING ITERATION of Documents"); Session s = db.getParent(); DocumentCollection dc = db.getAllDocuments(); for (Document doc : dc) { docCount++; Vector v = doc.getItemValue("$UpdatedBy"); for (Object o : v) { if (o instanceof String) { Name n = s.createName((String) o); String cn = n.getCommon(); nameCount++; } } if (docCount % 1000 == 0) { secondReference.add(db.getDocumentByID(doc.getNoteID())); } if (docCount % 2000 == 0) { thirdReference.add(doc); } DateTime toxic = doc.getLastModified(); String busyWork = toxic.getGMTTime(); DateTime toxic2 = doc.getLastModified(); String busyWork2 = toxic2.getDateOnly(); // System.out.println("LastMod: " + toxic.getGMTTime()); dateCount++; } System.out.println("ENDING ITERATION of Documents"); }
public View getView() { Database database = FrameworkUtils.getDatabase(server_, filePath_); View view = database.getView(viewName_); view.setAutoUpdate(false); view.setEnableNoteIDsForCategories(true); if (category_ == null) { if (getResortColumn() != null) { view.resortView(getResortColumn(), isAscending()); } else { view.resortView(); } } return view; }
public void resetDbs() { System.out.println("Resetting Star Wars test databases"); Session session = Factory.getSession(SessionType.NATIVE); Database crewDb = session.getDatabase(crewPath); if (crewDb != null) { crewDb.getAllDocuments().removeAll(true); } else { Factory.println("crewDb was null"); } Database movieDb = session.getDatabase(moviePath); if (movieDb != null) { movieDb.getAllDocuments().removeAll(true); } Database characterDb = session.getDatabase(charactersPath); if (characterDb != null) { characterDb.getAllDocuments().removeAll(true); } Database edgeDb = session.getDatabase(edgePath); if (edgeDb != null) { edgeDb.getAllDocuments().removeAll(true); } // Database nabDb = session.getDatabase("", "names.nsf"); // Document ntfDoc = nabDb.getDocumentByUNID(ntfUnid); // ntfDoc.removeItem("_COUNT_OPEN_OUT_rates"); // ntfDoc.removeItem("_OPEN_OUT_rates"); // ntfDoc.removeItem("_ODA_GRAPHTYPE"); // ntfDoc.save(); session.recycle(); System.gc(); }
public DominoModelList( final Database database, final String viewName, final String category, final Class<E> clazz) { super(clazz); server_ = database.getServer(); filePath_ = database.getFilePath(); viewName_ = viewName; category_ = category; // Gather the view info now View view = database.getView(viewName_); invalid_ = view == null; columnInfo_ = invalid_ ? null : DominoColumnInfo.fromView(view); }
@Override public void run() { Session session = this.getSession(); session.setConvertMIME(false); session.setFixEnable(Fixes.APPEND_ITEM_VALUE, true); session.setFixEnable(Fixes.FORCE_JAVA_DATES, true); session.setFixEnable(Fixes.CREATE_DB, true); Database db = session.getDatabase("", "log.nsf"); Document doc = db.createDocument(); doc.replaceItemValue("form", "Events"); doc.replaceItemValue("Server", "Test"); Map<String, String> map = new HashMap<String, String>(); map.put("me", "us"); map.put("myself", "ourselves"); map.put("I", "we"); doc.replaceItemValue("map", map); doc.save(); String unid = doc.getUniversalID(); doc = null; Document docJunk = db.createDocument(); doc = db.getDocumentByUNID(unid); System.out.println(doc.getNoteID()); Object o = doc.getItemValue("map", Map.class); System.out.println(o.getClass().getName()); Map<String, String> remap = (Map<String, String>) o; for (String key : remap.keySet()) { System.out.println(key + ":" + remap.get(key)); } session.setConvertMIME(true); doc = null; docJunk = db.createDocument(); doc = db.getDocumentByUNID(unid); Vector<Item> items = doc.getItems(); for (Item item : items) { if (item.getName().equalsIgnoreCase("map")) { System.out.println("map: " + item.getType()); System.out.println("map value: " + item.getText()); } } doc.replaceItemValue("foo", "bar"); doc.save(); session.setConvertMIME(false); o = null; doc = null; docJunk = db.createDocument(); doc = db.getDocumentByUNID(unid); o = doc.getItemValue("map", Map.class); System.out.println(o.getClass().getName()); remap = (Map<String, String>) o; for (String key : remap.keySet()) { System.out.println(key + ":" + remap.get(key)); } System.out.println("Complete"); }
private void iterateForms(Database db) { System.out.println( "Thread " + Thread.currentThread().getName() + " BEGINNING ITERATION of Forms"); Vector<Form> forms = db.getForms(); for (Form form : forms) { // System.out.println("Form : " + form.getName() + " (" + // DominoUtils.getUnidFromNotesUrl(form.getNotesURL()) + ")"); Document d = form.getDocument(); Vector v = d.getItemValue("$UpdatedBy"); Name n = db.getParent().createName((String) v.get(0)); String cn = n.getCommon(); nameCount++; docCount++; // System.out.println("Last Editor: " + n); } System.out.println("ENDING ITERATION of Forms"); }
@Override public void run() { long start = System.nanoTime(); org.openntf.domino.Session s = null; if (Thread.currentThread() instanceof DominoChildThread) { s = (org.openntf.domino.Session) ((DominoChildThread) Thread.currentThread()).getContextVar("session"); } Database db = null; if (Thread.currentThread() instanceof DominoChildThread) { db = (org.openntf.domino.Database) ((DominoChildThread) Thread.currentThread()).getContextVar("database"); } // Database db = s.getDatabase("", "events4.nsf"); RunContext rc = s.getRunContext(); System.out.println("RunContext: " + rc.toString()); Name sname = s.getUserNameObject(); DateFormat df = new SimpleDateFormat("yyyyMMddhhmmss"); System.out.println(df.format(new Date()) + " Name: " + sname.getCanonical()); if (INCLUDE_FORMS) { iterateForms(db); } Set<Document> secondReference = new HashSet<Document>(); iterateAllDocuments(db, secondReference); System.gc(); NoteCollection nc = db.createNoteCollection(false); nc.buildCollection(); iterateSecondReferences(secondReference); iterateThirdReferences(); long elapsed = System.nanoTime() - start; StringBuilder sb = new StringBuilder(); sb.append("Thread " + Thread.currentThread().getName()); sb.append(" *** ALL OPERATIONS COMPLETE elapsed time: "); sb.append(elapsed / 1000000 + "ms: processed "); sb.append(nameCount + " names, "); sb.append(docCount + " docs, and "); sb.append(dateCount + " datetimes without recycling."); System.out.println(sb.toString()); }
private Document createDocument() { if (db == null) db = Factory.getSession().getDatabase("", "log.nsf"); try { Document doc = db.createDocument(); return doc; } catch (NullPointerException npe) { System.err.println("Cannot create demo doc. Is your server running?"); return null; } }
@SuppressWarnings("unused") @Override public Document createDocument(final Database db, final String doctype) { IDocumentDefinition def = getDocumentDefinitions().get(doctype); if (def == null) return null; Document result = db.createDocument(); result.replaceItemValue("$$SchemaType", doctype); result.replaceItemValue("form", def.getName()); Map<String, IItemDefinition> itemDefs = def.getItemDefinitions(); for (String key : itemDefs.keySet()) { IItemDefinition itemDef = itemDefs.get(key); Item item = itemDef.createDefaultItem(result, def); } return result; }