Package lotus.domino

Examples of lotus.domino.Document


  }

  public void dateTimeEqualsTest() {
    StringBuilder sb = new StringBuilder();
    View threads = null;
    Document firstDoc = null;
    Document secondDoc = null;
    DateTime firstDate = null;
    DateTime secondDate = null;
    try {
      Session s = ExtLibUtil.getCurrentSession();
      Database currDb = s.getCurrentDatabase();
      threads = currDb.getView("AllThreads");
      Random randomGenerator = new Random();
      int randomInt = randomGenerator.nextInt(100);
      firstDoc = threads.getNthDocument(randomInt);
      randomInt = randomGenerator.nextInt(100);
      secondDoc = threads.getNthDocument(randomInt);
      String firstDt = firstDoc.getFirstItem("Date").getText();
      String secondDt = secondDoc.getFirstItem("Date").getText();
      firstDate = s.createDateTime(firstDt);
      secondDate = s.createDateTime(secondDt);
      Date firstDateJ = firstDate.toJavaDate();
      Date secondDateJ = secondDate.toJavaDate();
      sb.append("Comparing " + firstDt + " (" + firstDoc.getUniversalID() + ") with " + secondDt + " ("
          + secondDoc.getUniversalID() + ")...");
      if (firstDateJ.equals(secondDateJ)) {
        sb.append("first is the same date/time as second");
      } else {
        sb.append("first is NOT the same date/time as second");
      }
    } catch (NotesException e) {
      // doSomething
    } finally {
      try {
        threads.recycle();
        firstDoc.recycle();
        secondDoc.recycle();
        firstDate.recycle();
        secondDate.recycle();
      } catch (NotesException e) {
        // doSomething
      }
View Full Code Here


  }

  public void dateTimeEqualsIgnoreDateTest() {
    StringBuilder sb = new StringBuilder();
    View threads = null;
    Document firstDoc = null;
    Document secondDoc = null;
    DateTime firstDate = null;
    DateTime secondDate = null;
    try {
      Session s = ExtLibUtil.getCurrentSession();
      Database currDb = s.getCurrentDatabase();
      threads = currDb.getView("AllThreads");
      Random randomGenerator = new Random();
      int randomInt = randomGenerator.nextInt(100);
      firstDoc = threads.getNthDocument(randomInt);
      randomInt = randomGenerator.nextInt(100);
      secondDoc = threads.getNthDocument(randomInt);
      String firstDt = firstDoc.getFirstItem("Date").getText();
      String secondDt = secondDoc.getFirstItem("Date").getText();
      firstDate = s.createDateTime(firstDt);
      secondDate = s.createDateTime(secondDt);
      Calendar c1 = GregorianCalendar.getInstance();
      Calendar c2 = GregorianCalendar.getInstance();
      c1.setTime(firstDate.toJavaDate());
      c1.set(Calendar.DAY_OF_MONTH, 1);
      c1.set(Calendar.MONTH, 0);
      c1.set(Calendar.YEAR, 2000);
      c2.setTime(secondDate.toJavaDate());
      c2.set(Calendar.DAY_OF_MONTH, 1);
      c2.set(Calendar.MONTH, 0);
      c2.set(Calendar.YEAR, 2000);
      sb.append("Comparing " + firstDt + " (" + firstDoc.getUniversalID() + ") with " + secondDt + " ("
          + secondDoc.getUniversalID() + ")...");
      if (c1.equals(c2)) {
        sb.append("first is the same time as second");
      } else {
        sb.append("first is NOT the same time as second");
      }
    } catch (NotesException e) {
      // doSomething
    } finally {
      try {
        threads.recycle();
        firstDoc.recycle();
        secondDoc.recycle();
        firstDate.recycle();
        secondDate.recycle();
      } catch (NotesException e) {
        // doSomething
      }
View Full Code Here

  }

  public void dateTimeEqualsIgnoreTimeTest() {
    StringBuilder sb = new StringBuilder();
    View threads = null;
    Document firstDoc = null;
    Document secondDoc = null;
    DateTime firstDate = null;
    DateTime secondDate = null;
    try {
      Session s = ExtLibUtil.getCurrentSession();
      Database currDb = s.getCurrentDatabase();
      threads = currDb.getView("AllThreads");
      Random randomGenerator = new Random();
      int randomInt = randomGenerator.nextInt(100);
      firstDoc = threads.getNthDocument(randomInt);
      randomInt = randomGenerator.nextInt(100);
      secondDoc = threads.getNthDocument(randomInt);
      String firstDt = firstDoc.getFirstItem("Date").getText();
      String secondDt = secondDoc.getFirstItem("Date").getText();
      firstDate = s.createDateTime(firstDt);
      secondDate = s.createDateTime(secondDt);
      Calendar c1 = GregorianCalendar.getInstance();
      Calendar c2 = GregorianCalendar.getInstance();
      c1.setTime(firstDate.toJavaDate());
      c1.set(Calendar.HOUR_OF_DAY, 0);
      c1.set(Calendar.MINUTE, 0);
      c1.set(Calendar.SECOND, 0);
      c1.set(Calendar.MILLISECOND, 0);
      c2.setTime(secondDate.toJavaDate());
      c2.set(Calendar.HOUR_OF_DAY, 0);
      c2.set(Calendar.MINUTE, 0);
      c2.set(Calendar.SECOND, 0);
      c2.set(Calendar.MILLISECOND, 0);
      sb.append("Comparing " + firstDt + " (" + firstDoc.getUniversalID() + ") with " + secondDt + " ("
          + secondDoc.getUniversalID() + ")...");
      if (c1.equals(c2)) {
        sb.append("first is the same date as second");
      } else {
        sb.append("first is NOT the same date as second");
      }
    } catch (NotesException e) {
      // doSomething
    } finally {
      try {
        threads.recycle();
        firstDoc.recycle();
        secondDoc.recycle();
        firstDate.recycle();
        secondDate.recycle();
      } catch (NotesException e) {
        // doSomething
      }
View Full Code Here

    View threads = null;
    try {
      Session s = ExtLibUtil.getCurrentSession();
      Database currDb = s.getCurrentDatabase();
      threads = currDb.getView("AllContacts");
      Document doc = threads.getFirstDocument();
      DateTime dt = s.createDateTime(new Date());
      doc.replaceItemValue("testDate", dt);
      doc.save(true, false);
      if (doc.hasItem("testDate")) {
        java.util.Vector<?> vector = doc.getItemValue("testDate");
        if (vector != null && !vector.isEmpty()) {
          Object o = vector.get(0);
          if (o != null) {
            if (o instanceof lotus.domino.DateTime) {
              lotus.domino.DateTime datetime = (lotus.domino.DateTime) o;
              try {
                ExtLibUtil.getViewScope().put("oldJavaTest", datetime.toJavaDate());
              } catch (lotus.domino.NotesException ne1) {
                ne1.printStackTrace();
              } finally {
                datetime.recycle(); // You still have to recycle even if the conversion to java date failed!
              }
            } else {
              // Deal with having gotten something besides a Date, like a DateRange or a Number or a String
            }
          } else {
            // Deal with the vector having null entries
          }
        } else {
          // Deal with having gotten an empty vector (yes, it's possible)
        }
      } else {
        // Deal with the absence of a processDate field
        ExtLibUtil.getViewScope().put("oldJavaTest", doc.getItemValue("testDate")); // This will return a Vector with a String of "" if the item isn't present.
      }
    } catch (lotus.domino.NotesException ne) {
      ne.printStackTrace(); // Again, probably not what you actually want to do
    }
  }
View Full Code Here

        getLotusId(dt);
        DateTime end = session.createDateTime(new Date());
        getLotusId(end);
        DateRange dr = session.createDateRange(dt, end);
        getLotusId(dr);
        Document doc = db.createDocument();
        getLotusId(doc);
        Item i1 = doc.replaceItemValue("Foo", dr);
        getLotusId(i1);
        Item i2 = doc.replaceItemValue("Bar", dr.getText());
        getLotusId(i2);
        Item i3 = doc.replaceItemValue("Blah", dr.getStartDateTime().getLocalTime());
        getLotusId(i3);
        lotus.domino.ColorObject color = session.createColorObject();
        getLotusId(color);
        color.setRGB(128, 128, 128);
        Item i4 = doc.replaceItemValue("color", color.getNotesColor());
        getLotusId(i4);
        i1.recycle();
        i2.recycle();
        i3.recycle();
        i4.recycle();
        DateTime create = doc.getCreated();
        getLotusId(create);
        @SuppressWarnings("unused")
        String lc = create.getLocalTime();
        //          if (i % 10000 == 0) {
        //            System.out.println(Thread.currentThread().getName() + " Name " + i + " is " + name.getCommon() + " "
        //                + "Local time is " + lc + "  " + dr.getText());
        //          }
        dr.recycle();
        doc.recycle();
        dt.recycle();
        end.recycle();
        create.recycle();
        color.recycle();
        name.recycle();
View Full Code Here

    }
  }

  public void run2(final Session session) throws NotesException {
    Database db = session.getDatabase("", "log.nsf");
    Document doc = db.createDocument();
    Item names = doc.replaceItemValue("Names", "CN=Nathan T Freeman/O=REDPILL");
    names.setAuthors(true);
    doc.replaceItemValue("form", "test");
    doc.save(true);
    String nid = doc.getNoteID();
    doc.recycle();
    doc = db.getDocumentByID(nid);
    Vector<Double> numbers = new Vector<Double>();
    numbers.add(new Double(1));
    numbers.add(new Double(2));

    doc.replaceItemValue("Names", numbers);
    doc.save(true);
    doc.recycle();
    doc = db.getDocumentByID(nid);
    names = doc.getFirstItem("Names");
    System.out.println("Names is " + names.getType() + " with " + names.isNames() + " and " + names.isAuthors() + " and value "
        + names.getText());
    doc.recycle();
    db.recycle();
  }
View Full Code Here

    NoteCollection cacheNC = db.createNoteCollection(false);
    cacheNC.setSelectDocuments(true);
    cacheNC.buildCollection();
    cacheNC.recycle();
    DocumentCollection cacheDc = db.getAllDocuments();
    Document cacheDoc = cacheDc.getFirstDocument();
    cacheDoc.recycle();
    cacheDc.recycle();
    db.recycle();

    db = session.getDatabase("", "events4.nsf");
    DocumentCollection dc = db.getAllDocuments();
    Document doc = dc.getFirstDocument();
    Document nextDoc = null;
    int dcCount = dc.getCount();
    int j = 0;
    String[] dcUnids = new String[dcCount];
    long dcStart = System.nanoTime();
    while (doc != null) {
      nextDoc = dc.getNextDocument(doc);
      dcUnids[j++] = doc.getUniversalID();
      doc.recycle();
      doc = nextDoc;
    }
    System.out.println("DocumentCollection strategy got UNIDs for " + dcCount + " docs in " + (System.nanoTime() - dcStart) / 1000
        + "us");
    dc.recycle();
    db.recycle();

    db = session.getDatabase("", "events4.nsf");
    NoteCollection nc3 = db.createNoteCollection(false);
    nc3.setSelectDocuments(true);
    nc3.buildCollection();
    int nc3Count = nc3.getCount();
    String[] nc3Unids = new String[nc3Count];
    int[] nids = nc3.getNoteIDs();
    int k = 0;
    long nc3Start = System.nanoTime();
    for (int id : nids) {
      nc3Unids[k++] = nc3.getUNID(Integer.toHexString(id));
    }
    System.out.println("NoteCollection strategy ints got UNIDs for " + nc3Count + " notes in " + (System.nanoTime() - nc3Start) / 1000
        + "us");
    nc3.recycle();
    db.recycle();

    db = session.getDatabase("", "events4.nsf");
    NoteCollection nc = db.createNoteCollection(false);
    nc.setSelectDocuments(true);
    nc.buildCollection();
    int ncCount = nc.getCount();
    String[] ncUnids = new String[ncCount];
    String nid = nc.getFirstNoteID();
    long ncStart = System.nanoTime();
    for (int i = 0; i < ncCount; i++) {
      ncUnids[i] = nc.getUNID(nid);
      nid = nc.getNextNoteID(nid);
    }
    System.out.println("NoteCollection strategy first/next got UNIDs for " + ncCount + " notes in " + (System.nanoTime() - ncStart)
        / 1000 + "us");
    nc.recycle();
    db.recycle();

    db = session.getDatabase("", "events4.nsf");
    NoteCollection nc2 = db.createNoteCollection(false);
    nc2.setSelectDocuments(true);
    nc2.buildCollection();
    int nc2Count = nc2.getCount();
    String[] nc2Unids = new String[nc2Count];
    nid = nc2.getFirstNoteID();
    long nc2Start = System.nanoTime();
    for (int i = 0; i < nc2Count; i++) {
      Document nc2doc = db.getDocumentByID(nid);
      nc2Unids[i] = nc2doc.getUniversalID();
      nc2doc.recycle();
      nid = nc2.getNextNoteID(nid);
    }
    System.out.println("NoteCollection strategy doc got UNIDs for " + nc2Count + " notes in " + (System.nanoTime() - nc2Start) / 1000
        + "us");
    nc2.recycle();
View Full Code Here

  static class DocCreator implements Runnable {

    @Override
    public void run() {
      try {
        Document doc = null;
        System.out.println("START Creation of Documents:" + new Date().toString());
        Session s = NotesFactory.createSession();
        Set<Document> docset = new HashSet<Document>();
        Database db = s.getDatabase("", "OneMillionLotus.nsf", true);
        if (!db.isOpen()) {
          Database db2 = s.getDatabase("", "billing.ntf", true);
          db = db2.createCopy("", "OneMillionLotus.nsf");
          if (!db.isOpen())
            db.open();
        }

        for (int i = 1; i < 200000; i++) {
          doc = db.createDocument();
          doc.replaceItemValue("form", "doc");
          doc.replaceItemValue("Subject", String.valueOf(System.nanoTime()));
          doc.save();
          doc.recycle();
          if (i % 5000 == 0) {
            System.out.println("Created " + i + " documents so far. Still going...");
          }
        }
        System.out.println("ENDING Creation of Documents: " + new Date().toString());
View Full Code Here

  public void getAllDocumentsByKey() {
    Database db = null;
    View view = null;
    DocumentCollection dc = null;
    Document doc = null;
    Document nextDoc = null;
    StringBuilder sb = new StringBuilder();
    try {
      db = ExtLibUtil.getCurrentDatabase();
      view = db.getView("allContactsByState");
      view.setAutoUpdate(false);
View Full Code Here

  public void getAllDocumentsByKeyNoMatch() {
    Database db = null;
    View view = null;
    DocumentCollection dc = null;
    Document doc = null;
    Document nextDoc = null;
    StringBuilder sb = new StringBuilder();
    try {
      db = ExtLibUtil.getCurrentDatabase();
      view = db.getView("allContactsByState");
      view.setAutoUpdate(false);
View Full Code Here

TOP

Related Classes of lotus.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.