private void iterateAllDocuments(Database db, Set<Document> secondReference) {
      System.out.println(
          "Thread " + Thread.currentThread().getName() + " BEGINNING ITERATION of Documents");
      Session s = db.getParent();
      DocumentCollection dc = db.getAllDocuments();
      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");
    }
 private void iterateThirdReferences() {
   System.out.println("ITERATING Third reference set");
   for (Document doc : thirdReference) {
     DateTime initMod = doc.getInitiallyModified();
     dateCount++;
     String busyWork4 = initMod.getDateOnly();
   }
 }
 private void iterateSecondReferences(Set<Document> secondReference) {
   System.out.println("ITERATING Second reference set");
   for (Document doc : secondReference) {
     DateTime created = doc.getCreated();
     dateCount++;
     String busyWork3 = created.getDateOnly();
   }
 }
Exemplo n.º 4
0
  @SuppressWarnings("unused")
  @Override
  public Document createDocument(final Database db, final String doctype) {
    IDocumentDefinition def = getDocumentDefinitions().get(doctype);
    if (def == null) return null;
    Document result = db.createDocument();
    result.replaceItemValue("$$SchemaType", doctype);
    result.replaceItemValue("form", def.getName());
    Map<String, IItemDefinition> itemDefs = def.getItemDefinitions();
    for (String key : itemDefs.keySet()) {
      IItemDefinition itemDef = itemDefs.get(key);
      Item item = itemDef.createDefaultItem(result, def);
    }

    return result;
  }
    private void iterateForms(Database db) {
      System.out.println(
          "Thread " + Thread.currentThread().getName() + " BEGINNING ITERATION of Forms");
      Vector<Form> forms = db.getForms();
      for (Form form : forms) {
        // System.out.println("Form : " + form.getName() + " (" +
        // DominoUtils.getUnidFromNotesUrl(form.getNotesURL()) + ")");
        Document d = form.getDocument();
        Vector v = d.getItemValue("$UpdatedBy");

        Name n = db.getParent().createName((String) v.get(0));
        String cn = n.getCommon();
        nameCount++;
        docCount++;
        // System.out.println("Last Editor: " + n);
      }
      System.out.println("ENDING ITERATION of Forms");
    }
 public int compare(final Document doc1, final Document doc2) {
   // loop all sortFields
   for (String key : sortKeys) {
     Object obj1 = doc1.get(key);
     Object obj2 = doc2.get(key);
     if (obj1 instanceof List && obj2 instanceof List) {
       List l1 = (List) obj1;
       List l2 = (List) obj2;
       int min = l1.size() < l2.size() ? l1.size() : l2.size();
       int fallback =
           Integer.valueOf(l1.size())
               .compareTo(l2.size()); // if all values are the same up to the end of the smaller
       // list, the smaller list wins
       for (int i = 0; i < min; i++) {
         int result = compareObj(l1.get(i), l2.get(i));
         if (result != 0) return result;
       }
       return fallback;
     } else {
       return compareObj(obj1, obj2);
     }
   }
   return 0;
 }
Exemplo n.º 7
0
  @Override
  public boolean validateDocument(final Document doc) {
    String doctype = doc.getItemValueString("$$SchemaType");
    IDocumentDefinition def = getDocumentDefinitions().get(doctype);
    if (def == null) return true;

    boolean result = true;
    Map<String, IItemDefinition> itemDefs = def.getItemDefinitions();
    for (String key : itemDefs.keySet()) {
      @SuppressWarnings("unused")
      IItemDefinition itemDef = itemDefs.get(key);
      // TODO NTF
    }

    return result;
  }
  @Override
  public void run() {
    Session session = this.getSession();
    session.setConvertMIME(false);
    session.setFixEnable(Fixes.APPEND_ITEM_VALUE, true);
    session.setFixEnable(Fixes.FORCE_JAVA_DATES, true);
    session.setFixEnable(Fixes.CREATE_DB, true);
    Database db = session.getDatabase("", "log.nsf");
    Document doc = db.createDocument();
    doc.replaceItemValue("form", "Events");
    doc.replaceItemValue("Server", "Test");
    Map<String, String> map = new HashMap<String, String>();
    map.put("me", "us");
    map.put("myself", "ourselves");
    map.put("I", "we");
    doc.replaceItemValue("map", map);
    doc.save();
    String unid = doc.getUniversalID();
    doc = null;
    Document docJunk = db.createDocument();
    doc = db.getDocumentByUNID(unid);
    System.out.println(doc.getNoteID());
    Object o = doc.getItemValue("map", Map.class);
    System.out.println(o.getClass().getName());
    Map<String, String> remap = (Map<String, String>) o;

    for (String key : remap.keySet()) {
      System.out.println(key + ":" + remap.get(key));
    }
    session.setConvertMIME(true);
    doc = null;
    docJunk = db.createDocument();
    doc = db.getDocumentByUNID(unid);
    Vector<Item> items = doc.getItems();
    for (Item item : items) {
      if (item.getName().equalsIgnoreCase("map")) {
        System.out.println("map: " + item.getType());
        System.out.println("map value: " + item.getText());
      }
    }
    doc.replaceItemValue("foo", "bar");
    doc.save();
    session.setConvertMIME(false);
    o = null;
    doc = null;
    docJunk = db.createDocument();
    doc = db.getDocumentByUNID(unid);
    o = doc.getItemValue("map", Map.class);
    System.out.println(o.getClass().getName());
    remap = (Map<String, String>) o;

    for (String key : remap.keySet()) {
      System.out.println(key + ":" + remap.get(key));
    }

    System.out.println("Complete");
  }