Package org.openntf.domino

Examples of org.openntf.domino.Document


    Session s = Factory.getSession();
    Database currDb = s.getCurrentDatabase();
    View contacts = currDb.getView("AllContacts");
    View contactsByState = currDb.getView("AllContactsByState");
    Utils.addAllListeners(currDb);
    Document doc = contacts.getFirstDocument();
    DocumentCollection dc = contactsByState.getAllDocumentsByKey("CA", true);
    doc.put("javaDCField", dc);
    doc.save(true, false);
    DocumentCollection srcDc = doc.getItemValue("javaDCField", DocumentCollection.class);
    StringBuilder sb = new StringBuilder();
    for (Document savedDoc : srcDc) {
      sb.append(savedDoc.getNoteID());
      sb.append(", ");
    }
View Full Code Here


                curActor = curLine.substring(0, tabPos).trim();
                if (actorCount % 1000 == 0) {
                  System.out.println("Processing actor " + actorCount + ": " + curActor + " (" + lineCount + " lines)");
                }
                Database db = null; //TODO obviously not...
                @SuppressWarnings("null")
                Document doc = db.getDocumentWithKey(curActor, false);
                if (doc != null) {
                  doc.replaceItemValue("Genres", genres);
                  doc.save();
                } else {
                  exceptionCount++;
                }
                lastActor = curActor;
                genres = new ArrayList<String>();
View Full Code Here

  public void setMapField() {
    Session s = Factory.getSession();
    Database currDb = s.getCurrentDatabase();
    View contacts = currDb.getView("AllContacts");
    Utils.addAllListeners(currDb);
    Document doc = contacts.getFirstDocument();
    TreeMap<String, String> testMap = new TreeMap<String, String>();
    testMap.put("Per", "Denmark");
    testMap.put("John", "South Africa");
    testMap.put("Mark", "Netherlands");
    testMap.put("Paul", "UK");
    doc.put("javaMapField", testMap);
    doc.save(true, false);
  }
View Full Code Here

  public void breakNames() {
    try {
      Session s = Factory.getSession();
      Database currDb = s.getCurrentDatabase();
      View contacts = currDb.getView("AllContacts");
      Document doc = contacts.getFirstDocument();
      Item testItem = doc.replaceItemValue("muppetField", 1);
      testItem.setNames(true);
      doc.save(true, false);
    } catch (Throwable t) {
      ExtLibUtil.getViewScope().put("javaTest", t.getClass().getName() + ": " + t.getLocalizedMessage());
    }
  }
View Full Code Here

    try {
      StringBuilder sb = new StringBuilder();
      Session s = Factory.getSession();
      Database currDb = s.getCurrentDatabase();
      View contacts = currDb.getView("AllContacts");
      Document doc = contacts.getFirstDocument();
      Item testItem = doc.replaceItemValue("readersAuthorsNamesField", s.getEffectiveUserName());
      sb.append("Checking if Item is Readers, Names or Authors...");
      sb.append(testItem.isReadersNamesAuthors());
      testItem.setNames(true);
      testItem.setAuthors(true);
      testItem.setReaders(true);
      sb.append("<br/>Checking if Item is Readers, Names or Authors...");
      sb.append(testItem.isReadersNamesAuthors());
      doc.save(true, false);
      sb.append("<br/>Success!!");
      ExtLibUtil.getViewScope().put("javaTest", sb.toString());
    } catch (Throwable t) {

    }
View Full Code Here

  public void getDocAsJson() {
    try {
      Session s = Factory.getSession();
      Database currDb = s.getCurrentDatabase();
      View contacts = currDb.getView("AllContacts");
      Document doc = contacts.getFirstDocument();
      ExtLibUtil.getViewScope().put("javaTest", doc.toJson(true));
    } catch (Throwable t) {

    }
  }
View Full Code Here

        db = db2.createCopy("", TARGET);
        if (!db.isOpen())
          db.open();
      }

      Document doc = null;
      System.out.println("-- START --");
      long start = System.nanoTime();
      for (int i = 1; i < NUMBER_OF_DOCS + 1; i++) {

        doc = db.createDocument();
        doc.replaceItemValue("form", FORM);
        doc.replaceItemValue(ITEM, String.valueOf(System.nanoTime()));
        doc.computeWithForm(false, false);
        doc.save();
        /*
         * if (i % 5000 == 0) { System.out.println("Created " + i + " documents so far. Still going..."); }
         */
      }
      long elapsed = System.nanoTime() - start;
View Full Code Here

  public void checkIsUnique() {
    try {
      StringBuilder sb = new StringBuilder();
      Database db = Factory.getSession().getCurrentDatabase();
      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");
      }
View Full Code Here

  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 {
      NoteList notelist = new NoteList();
      marktime = System.nanoTime();
      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);
      }

      //      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;
      db.recycle();
      db = null;
      notelist = null;
      System.gc();

      timelog("Binary data serialized out. Reloading...");
      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();
View Full Code Here

      Database currentDB = doc_.getParentDatabase();
      if (!(currentDB.getFilePath().equalsIgnoreCase(destDB.getFilePath()) && currentDB.getServer().equalsIgnoreCase(
          destDB.getServer()))) {

        Document destDoc = destDB.createDocument();
        doc_.copyAllItems(destDoc, true);
        destDoc.replaceItemValue("$Created", doc_.getCreated());
        destDoc.setUniversalID(doc_.getUniversalID());
        doc_ = destDoc;
      }

      return doc_.save();
    }
View Full Code Here

TOP

Related Classes of org.openntf.domino.Document

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.