Package org.openntf.domino

Examples of org.openntf.domino.Database


  }

  public void dateTimeEqualsIgnoreTimeTest() {
    StringBuilder sb = new StringBuilder();
    Session s = Factory.getSession();
    Database currDb = s.getCurrentDatabase();
    View threads = currDb.getView("AllThreads");
    Random randomGenerator = new Random();
    int randomInt = randomGenerator.nextInt(100);
    Document firstDoc = threads.getNthDocument(randomInt);
    randomInt = randomGenerator.nextInt(100);
    Document secondDoc = threads.getNthDocument(randomInt);
View Full Code Here


    ExtLibUtil.getViewScope().put("javaTest", sb.toString());
  }

  public void getProcessedDate() {
    Session s = Factory.getSession();
    Database currDb = s.getCurrentDatabase();
    Utils.addAllListeners(currDb);
    View threads = currDb.getView("AllContacts");
    Document doc = threads.getFirstDocument();
    DateTime dt = s.createDateTime(new Date());
    doc.put("testDate", dt);
    doc.save(true, false);
    ExtLibUtil.getViewScope().put("javaTest", doc.get("testDate").toString());
View Full Code Here

    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()) {
View Full Code Here

  }

  @Override
  public void run() {
    Session s = Factory.getSession();
    Database d = s.getDatabase("", "names.nsf");
    List<String> ids = new ArrayList<String>();

    Collection<Document> documents = d.getAllDocuments();

    for (Document doc : documents) {
      ids.add(doc.getNoteID());
    }
    //System.out.println("IDS.size " + ids.size());
    for (int i = 1; i < 100; i++) {
      System.out.println(i + ": " + Factory.dumpCounters(false));
      Document doc1 = null;
      Document doc2 = null;
      Document doc3 = null;
      for (String id : ids) {
        d = s.getDatabase("", "names.nsf");
        doc1 = d.getDocumentByID(id);
        doc1 = null;
        doc2 = d.getDocumentByID(id);
        doc2 = null;
        doc3 = d.getDocumentByID(id);
        doc3 = null;
        int rndIdx = (int) Math.floor(Math.random() * ids.size());

        //        if (i % 20 == 0 && false) {
        //          System.gc();
        //          try {
        //            Thread.sleep(10);
        //          } catch (InterruptedException e) {
        //            // TODO Auto-generated catch block
        //            e.printStackTrace();
        //          }
        //        }

        doc2 = d.getDocumentByID(ids.get(rndIdx));
        doc2 = null;
        d = null;
      }
      //System.out.println(doc1 + "" + doc2 + "" + doc3);
    }
View Full Code Here

  private static final long serialVersionUID = 1L;
  private String apiPath;
  private Map<String, Object> applicationScope;

  public XotsBasic() {
    Database db = Factory.getSession().getCurrentDatabase();
    setApiPath(db.getApiPath());

    ExtLibUtil.getApplicationScope().put("MessageFromXots",
        "Please refresh page to see message (set from constructor)");
    ExtLibUtil.getApplicationScope().put("MessageFromXotsConstructor", "Nothing yet (set from constructor)");
    setApplicationScope(ExtLibUtil.getApplicationScope());
View Full Code Here

  @Override
  public void run() {
    try {
      Session sess = this.getSession();
      Database db = sess.getDatabase(getApiPath());

      String msg = "User is " + sess.getEffectiveUserName();
      msg = msg + " access is " + Integer.toString(db.getCurrentAccessLevel());
      System.out.println(msg);
      getApplicationScope().put("MessageFromXots", msg + "(set from Xots method)");
    } catch (Throwable t) {
      t.printStackTrace();
    }
View Full Code Here

    try {
      Session sess = getSession();
      Date now = new Date();
      String msg = "Running Xots " + now.toString();
      msg = msg + "\n " + sess.getEffectiveUserName() + " is on server " + String.valueOf(sess.isOnServer());
      Database db = sess.getDatabase("log.nsf");
      msg = msg + "\n" + "Log at " + db.getApiPath() + " is " + db.getSize();
      System.out.println(msg);
      ExtLibUtil.getApplicationScope().put("MessageFromXotsSchedule", msg);
      XspOpenLogUtil.logEvent(new Throwable(msg), msg, Level.FINE, null);
    } catch (Throwable t) {
      t.printStackTrace();
View Full Code Here

        doc.replaceItemValue("Form", "Round" + i);
        doc.replaceItemValue("i", i);
        doc.replaceItemValue("j", j);
        doc.save();
        Document savedDoc = doc.getDoc();
        Database savedDB = savedDoc.getParentDatabase();

        System.out.println("Stored doc in " + savedDB.getServer() + "!!" + savedDB.getFilePath());
      }
    }
  }
View Full Code Here

        doc.replaceItemValue("Form", "Round" + i);
        doc.replaceItemValue("i", i);
        doc.replaceItemValue("j", j);
        doc.save();
        Document savedDoc = doc.getDoc();
        Database savedDB = savedDoc.getParentDatabase();

        System.out.println("Stored doc in " + savedDB.getServer() + "!!" + savedDB.getFilePath());
      }
    }
  }
View Full Code Here

   *
   * @see org.openntf.domino.View#getAllDocuments()
   */
  @Override
  public DocumentCollection getAllDocuments() {
    Database db = getAncestorDatabase();
    DocumentCollection result = db.createDocumentCollection();

    // When it's a folder, there's no selection formula, so do it the "dumb" way for now
    if (isFolder()) {
      // TODO See if there's a better way
      for (ViewEntry entry : getAllEntries()) {
        if (entry.isDocument()) {
          result.add(entry.getDocument());
        }
      }
    } else {
      // According to Tommy Valand's research, the fastest method is to build a NoteCollection with a matching selection formula
      // http://dontpanic82.blogspot.com/2013/06/benchmark-fetching-noteids-and.html
      NoteCollection nc = getNoteCollection();

      int[] nids = nc.getNoteIDs();

      // Arrays.sort(nids);
      // for (org.openntf.domino.Document doc : result) {
      // int nid = Integer.valueOf(doc.getNoteID(), 16);
      // if (!(Arrays.binarySearch(nids, nid) >= 0)) {
      // result.subtract(nid);
      // }
      // }

      // for (int nid : nids) {
      // result.intersect(nid);
      // }

      // TODO due to a bug in 9.0, this is being reverted to highly inefficient behavior...
      for (int nid : nids) {
        Document doc = db.getDocumentByID(Integer.toHexString(nid));
        result.add(doc);
      }
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of org.openntf.domino.Database

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.