Package org.openntf.domino

Examples of org.openntf.domino.DateTime


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

  void createDiscussionDocument(Database db, Document parent, ArrayList<String> users, int[] pos, int nDoc)
      throws 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();
      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);
      }
    }
  }
View Full Code Here


      Session currSess = Factory.getSession();
      Database currDb = currSess.getCurrentDatabase();
      Utils.addAllListeners(currDb);
      View contactsView = currDb.getView("AllContacts");
      for (ViewEntry ent : contactsView.getAllEntries()) {
        DateTime dt = currSess.createDateTime(new Date());
        Document doc = ent.getDocument();
        doc.replaceItemValue("testDate", dt);
        doc.save(true, false);
      }
      date = new Date();
View Full Code Here

        }
        if (docCount % 2000 == 0) {
          thirdReference.add(doc);
        }

        DateTime toxic = doc.getLastModified();
        String busyWork = toxic.getGMTTime();
        DateTime toxic2 = doc.getLastModified();
        String busyWork2 = toxic2.getDateOnly();
        // System.out.println("LastMod: " + toxic.getGMTTime());
        dateCount++;
      }
      System.out.println("REPEATING ITERATION of Documents");
      for (Document doc : dc) {
        docCount++;
        Vector v = doc.getItemValue("$UpdatedBy");
        for (Object o : v) {
          if (o instanceof String) {
            Name n = s.createName((String) o);
            String cn = n.getCommon();
            nameCount++;
          }
        }
        if (docCount % 1000 == 0) {
          secondReference.add(db.getDocumentByID(doc.getNoteID()));
        }
        if (docCount % 2000 == 0) {
          thirdReference.add(doc);
        }

        DateTime toxic = doc.getLastModified();
        String busyWork = toxic.getGMTTime();
        DateTime toxic2 = doc.getLastModified();
        String busyWork2 = toxic2.getDateOnly();
        // System.out.println("LastMod: " + toxic.getGMTTime());
        dateCount++;
      }

      System.out.println("ENDING ITERATION of Documents");
View Full Code Here

     *            the second reference
     */
    private void iterateSecondReferences(final Set<Document> secondReference) {
      System.out.println("ITERATING Second reference set");
      for (Document doc : secondReference) {
        DateTime created = doc.getCreated();
        dateCount++;
        String busyWork3 = created.getDateOnly();
      }
    }
View Full Code Here

     * Iterate third references.
     */
    private void iterateThirdReferences() {
      System.out.println("ITERATING Third reference set");
      for (Document doc : thirdReference) {
        DateTime initMod = doc.getInitiallyModified();
        dateCount++;
        String busyWork4 = initMod.getDateOnly();
      }
    }
View Full Code Here

  public void getCreatedOld() {
    Session s = Factory.getSession();
    Database currDb = s.getCurrentDatabase();
    View contacts = currDb.getView("AllContacts");
    Document doc = contacts.getFirstDocument();
    DateTime created = doc.getCreated();
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm");
    String formatted = format.format(created.toJavaDate());
    ExtLibUtil.getViewScope().put("javaTest", formatted);
  }
View Full Code Here

        if (database != null) {
          if (!database.isOpen()) {
            database.open();
          }

          DateTime toxic = database.getCreated();
          dateCount++;

          for (ACLEntry entry : database.getACL()) {
            Name entryName = entry.getNameObject();
            nameCount++;
View Full Code Here

    private void iterateSecondReferences(final Set<Document> secondReference) {
      System.out.println("ITERATING Second reference set");
      org.openntf.domino.transactions.DatabaseTransaction txn = db.startTransaction();
      for (Document doc : secondReference) {
        DateTime created = doc.getCreated();
        if (created != null) {
          dateCount++;
          @SuppressWarnings("unused")
          String busyWork3 = created.getDateOnly();
        } else {
          System.out.println("Created was null from document " + doc.getUniversalID());
        }
        doc.replaceItemValue("TxnTest2", new Date());
      }
View Full Code Here

    }

    private void iterateThirdReferences() {
      System.out.println("ITERATING Third reference set");
      for (Document doc : thirdReference) {
        DateTime initMod = doc.getInitiallyModified();
        dateCount++;
        @SuppressWarnings("unused")
        String busyWork4 = initMod.getDateOnly();
      }
    }
View Full Code Here

        }
        if (docCount % 2000 == 0) {
          thirdReference.add(doc);
        }

        DateTime toxic = doc.getLastModified();
        String busyWork = toxic.getGMTTime();
        DateTime toxic2 = doc.getLastModified();
        String busyWork2 = toxic2.getDateOnly();
        // System.out.println("LastMod: " + toxic.getGMTTime());
        dateCount++;
      }
      System.out.println("ENDING ITERATION of Documents");
    }
View Full Code Here

TOP

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