Package org.openntf.domino

Examples of org.openntf.domino.Database


  }

  public void syncDatabases() {
    Session s = Factory.getSession();
    Database currDb = s.getCurrentDatabase();
    Utils.addAllListeners(currDb);
    java.util.Map<Object, String> syncMap = new java.util.HashMap<Object, String>();
    syncMap.put("Key", "State");
    syncMap.put("Name", "StateName");
    syncMap.put("@Now", "LastSync");
    DocumentSyncHelper helper = new DocumentSyncHelper(DocumentSyncHelper.Strategy.CREATE_AND_REPLACE, syncMap,
        currDb.getServer(), currDb.getFilePath(), "AllContactsByState", "Key");
    View states = currDb.getView("AllStates");
    DocumentCollection sourceCollection = states.getAllDocuments();
    helper.process(sourceCollection);
    ExtLibUtil.getViewScope().put("javaTest", "Done");
  }
View Full Code Here


    long documentBuildNS = 0l;
    long documentPageNS = 0l;
    int collectionSize = 0;
    int dbDocs = 0;
    try {
      Database db = session.getDatabase("", "imdb/movies.bak");
      dbDocs = db.getAllDocuments().getCount();
      long testStartTime = System.nanoTime();
      NoteCollection nc = db.createNoteCollection(false);
      nc.selectAllDataNotes(true);
      nc.setSelectionFormula("@Begins(Title; \"B\")"); //NTF comment or uncomment this to toggle testing selection formula impact
      nc.buildCollection();
      int[] nids = nc.getNoteIDs();
      long collectionTime = System.nanoTime();
      collectionBuildNS = collectionTime - testStartTime;
      collectionSize = nids.length;
      Document[] documents = new Document[collectionSize];
      for (int i = 0; i < collectionSize; i++) {
        documents[i] = db.getDocumentByID(nids[i], true/*false would mean full load of the Document*/);
      }
      long documentTime = System.nanoTime();
      documentBuildNS = documentTime - collectionTime;
      int pageSize = 1000;
      int pageStart = 2014;
View Full Code Here

  public void run2() {
    long testStartTime = System.nanoTime();
    Session session = this.getSession();
    try {
      Database db = session.getDatabase("", "imdb/movies.nsf");
      //      db.setDelayUpdates(true);
      marktime = System.nanoTime();
      timelog("Beginning view build...");
      View byLength = db.getView("byLength");
      View btitles = db.createView("BTitles", "@Begins(Title; \"B\")", byLength);
      //      View btitles = db.createView("BTitles", "@Begins(Title; \"B\")");
      ViewColumn length = btitles.createColumn(1, "Title", "Title");
      length.setSorted(true);
      timelog("View defined.");
      btitles.refresh();
      timelog("Completed view build.");
      ViewEntryCollection vec = btitles.getAllEntries();
      int count = vec.getCount();
      timelog("Found " + count + " documents in the view");
      btitles.remove();
      timelog("Removed view.");
      btitles.recycle();
      db.recycle();
    } catch (Throwable t) {
      t.printStackTrace();
    } finally {
      long testEndTime = System.nanoTime();
      System.out.println("Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms");
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...");
View Full Code Here

  public NewDatabaseBean() {

  }

  public void getApiPath() {
    Database db = Factory.getSession().getCurrentDatabase();
    ExtLibUtil.getViewScope().put("javaTest", db.getApiPath());
  }
View Full Code Here

    Database db = Factory.getSession().getCurrentDatabase();
    ExtLibUtil.getViewScope().put("javaTest", db.getApiPath());
  }

  public void getByApiPath() {
    Database db = Factory.getSession().getCurrentDatabase();
    String apiPath = db.getApiPath();
    Database currDb = Factory.getSession().getDatabase(apiPath);
    if (null != currDb) {
      ExtLibUtil.getViewScope().put("javaTest", "Database found at " + db.getApiPath());
    }
  }
View Full Code Here

      ExtLibUtil.getViewScope().put("javaTest", "Database found at " + db.getApiPath());
    }
  }

  public void getMetaReplicaID() {
    Database db = Factory.getSession().getCurrentDatabase();
    ExtLibUtil.getViewScope().put("javaTest", db.getMetaReplicaID());
  }
View Full Code Here

    Database db = Factory.getSession().getCurrentDatabase();
    ExtLibUtil.getViewScope().put("javaTest", db.getMetaReplicaID());
  }

  public void getByMetaReplicaID() {
    Database db = Factory.getSession().getCurrentDatabase();
    String metaReplicaID = db.getMetaReplicaID();
    Database currDb = Factory.getSession().getDatabase(metaReplicaID);
    if (null != currDb) {
      ExtLibUtil.getViewScope().put("javaTest", "Database found at " + db.getMetaReplicaID());
    }
  }
View Full Code Here

      scanner.setTrackFieldTypes(false);
      scanner.setTrackFieldValues(false);
      scanner.setTrackTokenFreq(false);

      Session s = Factory.getSession();
      Database db = s.getDatabase("", "help/help9_admin.nsf");
      System.out.println("Beginning scan of " + db.getApiPath());
      for (Document doc : db.getAllDocuments()) {
        scanner.processDocument(doc);
        docCount++;
      }

      System.out.println("Scanner reports processing " + scanner.getDocCount() + " documents, " + scanner.getItemCount()
View Full Code Here

        while (hashChunk.length() < places_)
          hashChunk = "0" + hashChunk;
        String server = serverStrategy_ == null ? server_ : serverStrategy_.getServerForHashChunk(hashChunk);
        DbDirectory dbdir = getDbDirectoryForHashChunk(hashChunk);
        String dbName = baseName_ + "-" + hashChunk + ".nsf";
        Database database = session_.getDatabase(server, dbName, true);
        if (!database.isOpen()) {
          database = createDatabase(dbdir, dbName);
        }
        dbCache_.put(dbName, database);
      }
    } else {
      Database database = session_.getDatabase(server_, baseName_ + ".nsf");
      if (!database.isOpen()) {
        database = createDatabase(getDbDirectoryForHashChunk(null), baseName_ + ".nsf");
      }
      dbCache_.put(baseName_ + ".nsf", database);
    }
  }
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.