Package lotus.domino

Examples of lotus.domino.DateTime


  /** {@inheritDoc} */
  @Override
  public NotesDocumentCollection search(String formula, NotesDateTime startDate,
      int maxDocs) throws NotesConnectorExceptionImpl {
    try {
      DateTime notesStartDate = null;
      if (startDate != null) {
        notesStartDate = ((NotesDateTimeImpl) startDate).getNotesObject();
      }

      return new NotesDocumentCollectionImpl(
View Full Code Here


    createDiscussionDocument(db, null, users, new int[] { 0 }, disc_rootDocs);
  }

  void createDiscussionDocument(Database db, Document parent, ArrayList<String> users, int[] pos, int nDoc)
      throws NotesException, IOException {
    DateTime date = db.getParent().createDateTime(new Date());
    String[] loremIpsum = SampleDataUtil.readLoremIpsum();
    for (int j = 0; j < nDoc; j++) {
      pos[pos.length - 1] = j + 1;

      Document doc = db.createDocument();
      try {
        doc.replaceItemValue("Form", "Discussion");
        StringBuilder b = new StringBuilder();
        for (int i = 0; i < pos.length; i++) {
          if (i > 0) {
            b.append("/");
          }
          b.append(pos[i]);
        }
        int idx = (int) (Math.random() * (loremIpsum.length - 1));
        String body = loremIpsum[idx];
        int dot = body.indexOf('.');
        if (dot < 0) {
          dot = body.length() - 1;
        }
        int coma = body.indexOf(',');
        if (coma < 0) {
          coma = body.length() - 1;
        }
        String title = body.substring(0, Math.min(dot, coma));

        // Get a random author
        int x = Math.min((int) (Math.random() * (users.size())), users.size());
        String author = users.get(x);

        doc.replaceItemValue("Title", title);
        doc.replaceItemValue("Body", body);
        doc.replaceItemValue("Author", author);
        doc.replaceItemValue("Date", date);
        if (parent != null) {
          doc.makeResponse(parent);
        }
        doc.computeWithForm(false, false);
        doc.save();

        if (pos.length < disc_maxDepth) {
          double r = Math.random();
          if (r <= (1.0 / pos.length)) {
            int[] newPos = new int[pos.length + 1];
            System.arraycopy(pos, 0, newPos, 0, pos.length);
            int n = (int) (Math.random() * 5);
            createDiscussionDocument(db, doc, users, newPos, n);
          }
        }
        // Move the date to the day before if requested
        boolean mvd = Math.random() <= 0.40;
        if (mvd) {
          // Previous day...
          date.adjustDay(-1);
        }
      } finally {
        doc.recycle();
      }
    }
View Full Code Here

      doc.recycle();
    }
  }

  protected DateTime createDate(Session session, int year, int month, int day) throws NotesException {
    DateTime d = session.createDateTime(new Date());
    d.setLocalDate(year, month, day);
    return d;
  }
View Full Code Here

    d.setLocalDate(year, month, day);
    return d;
  }

  protected DateTime createTime(Session session, int hour, int minute, int second) throws NotesException {
    DateTime d = session.createDateTime(new Date());
    d.setLocalTime(hour, minute, second, 0);
    return d;
  }
View Full Code Here

    return d;
  }

  protected DateTime createDateTime(Session session, int year, int month, int day, int hour, int minute, int second)
      throws NotesException {
    DateTime d = session.createDateTime(new Date());
    d.setLocalDate(year, month, day);
    d.setLocalTime(hour, minute, second, 0);
    return d;
  }
View Full Code Here

      int i = 0;
      try {
        for (i = 0; i <= 100000; i++) {
          name = session.createName(UUID.randomUUID().toString());
          getLotusId(name);
          DateTime dt = session.createDateTime(new Date());
          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);
          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();
          if (name != null)
            name.recycle();
        }
      } catch (Throwable t) {
View Full Code Here

  public void dateTimeIsBeforeTest() {
    StringBuilder sb = new StringBuilder();
    View threadsByDate = null;
    Document firstDoc = null;
    Document secondDoc = null;
    DateTime firstDate = null;
    DateTime secondDate = null;
    try {
      Session s = ExtLibUtil.getCurrentSession();
      Database currDb = s.getCurrentDatabase();
      threadsByDate = currDb.getView("AllThreadsByDate");
      threadsByDate.setAutoUpdate(false);
      ViewNavigator vNav = threadsByDate.createViewNav();
      vNav.setEntryOptions(lotus.domino.ViewNavigator.VN_ENTRYOPT_NOCOLUMNVALUES);
      Random randomGenerator = new Random();
      int randomInt = randomGenerator.nextInt(20);
      ViewEntry firstEnt = vNav.getNth(randomInt);
      while (!firstEnt.isDocument()) {
        ViewEntry tmpEnt = vNav.getNext();
        firstEnt.recycle();
        firstEnt = tmpEnt;
      }
      randomInt = randomGenerator.nextInt(20);
      ViewEntry secondEnt = vNav.getNth(randomInt);
      while (!secondEnt.isDocument()) {
        ViewEntry tmpEnt = vNav.getNext();
        secondEnt.recycle();
        secondEnt = tmpEnt;
      }
      firstDoc = firstEnt.getDocument();
      secondDoc = secondEnt.getDocument();
      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.before(secondDateJ)) {
        sb.append("first before second");
      } else {
        sb.append("first NOT before second");
      }
      sb.append("..........................................................................................");
      sb.append("Comparing " + secondDt + " (" + secondDoc.getUniversalID() + ") with " + firstDt + " ("
          + firstDoc.getUniversalID() + ")...");
      if (secondDateJ.before(firstDateJ)) {
        sb.append("second before first");
      } else {
        sb.append("second NOT before first");
      }
    } catch (NotesException e) {
      // doSomething
    } finally {
      try {
        threadsByDate.recycle();
        firstDoc.recycle();
        secondDoc.recycle();
        firstDate.recycle();
        secondDate.recycle();
      } catch (NotesException e) {
        // doSomething
      }
    }
    ExtLibUtil.getViewScope().put("oldJavaTest", sb.toString());
View Full Code Here

  public void dateTimeIsAfterTest() {
    StringBuilder sb = new StringBuilder();
    View threadsByDate = null;
    Document firstDoc = null;
    Document secondDoc = null;
    DateTime firstDate = null;
    DateTime secondDate = null;
    try {
      Session s = ExtLibUtil.getCurrentSession();
      Database currDb = s.getCurrentDatabase();
      threadsByDate = currDb.getView("AllThreadsByDate");
      threadsByDate.setAutoUpdate(false);
      ViewNavigator vNav = threadsByDate.createViewNav();
      vNav.setEntryOptions(lotus.domino.ViewNavigator.VN_ENTRYOPT_NOCOLUMNVALUES);
      Random randomGenerator = new Random();
      int randomInt = randomGenerator.nextInt(20);
      ViewEntry firstEnt = vNav.getNth(randomInt);
      while (!firstEnt.isDocument()) {
        ViewEntry tmpEnt = vNav.getNext();
        firstEnt.recycle();
        firstEnt = tmpEnt;
      }
      randomInt = randomGenerator.nextInt(20);
      ViewEntry secondEnt = vNav.getNth(randomInt);
      while (!secondEnt.isDocument()) {
        ViewEntry tmpEnt = vNav.getNext();
        secondEnt.recycle();
        secondEnt = tmpEnt;
      }
      firstDoc = firstEnt.getDocument();
      secondDoc = secondEnt.getDocument();
      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.after(secondDateJ)) {
        sb.append("first after second");
      } else {
        sb.append("first NOT after second");
      }
      sb.append("..........................................................................................");
      sb.append("Comparing " + secondDt + " (" + secondDoc.getUniversalID() + ") with " + firstDt + " ("
          + firstDoc.getUniversalID() + ")...");
      if (secondDateJ.after(firstDateJ)) {
        sb.append("second after first");
      } else {
        sb.append("second NOT after first");
      }
    } catch (NotesException e) {
      // doSomething
    } finally {
      try {
        threadsByDate.recycle();
        firstDoc.recycle();
        secondDoc.recycle();
        firstDate.recycle();
        secondDate.recycle();
      } catch (NotesException e) {
        // doSomething
      }
    }
    ExtLibUtil.getViewScope().put("oldJavaTest", sb.toString());
View Full Code Here

  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
      }
    }
    ExtLibUtil.getViewScope().put("oldJavaTest", sb.toString());
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
      }
    }
    ExtLibUtil.getViewScope().put("oldJavaTest", sb.toString());
View Full Code Here

TOP

Related Classes of lotus.domino.DateTime

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.