Package org.openntf.domino.helpers

Examples of org.openntf.domino.helpers.DocumentScanner


      ExtLibUtil.getViewScope().put("javaTest", sb.toString());
    }
  }

  public static void contactScannerMap() {
    DocumentScanner scanner = new DocumentScanner();
    scanner.setIgnoreDollar(true);

    Database db = Factory.getSession().getCurrentDatabase();
    View contacts = db.getView("AllContacts");
    for (ViewEntry ent : contacts.getAllEntries()) {
      scanner.processDocument(ent.getDocument());
    }

    ExtLibUtil.getViewScope().put("scannerFieldTokenMap", scanner.getFieldTokenMap());
    ExtLibUtil.getViewScope().put("scannerFieldValueMap", scanner.getFieldValueMap());
    ExtLibUtil.getViewScope().put("scannerFieldTypeMap", scanner.getFieldTypeMap());
    ExtLibUtil.getViewScope().put("scannerTokenFreqMap", scanner.getTokenFreqMap());
  }
View Full Code Here


      long start = System.nanoTime();
      @SuppressWarnings("unused")
      DateFormat df = new SimpleDateFormat("yyyyMMddhhmmss");
      int docCount = 0;

      DocumentScanner scanner = new DocumentScanner();
      scanner.setTrackTokenLocation(true);
      scanner.setTrackFieldTokens(true);
      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()
          + " items, and " + scanner.getTokenCount() + " tokens.");
      System.out.println("Built field token map of " + scanner.getFieldTokenMap().size() + " entries");
      Map<?, ?> tfmap = scanner.getTokenLocationMap();
      System.out.println("Built token location map of " + tfmap.size() + " entries");
      CaseInsensitiveString dom = new CaseInsensitiveString("domino");
      if (tfmap.get(dom) != null) {
        int hitCount = 0;
        Map<?, ?> tlvalue = (Map<?, ?>) tfmap.get(dom);
View Full Code Here

    System.out.println("Completed scan of server " + serverName);
  }

  public DocumentScanner scanDatabase(final Database db) {
    Document dbDoc = getDbDocument(db.getReplicaID());
    DocumentScanner scanner = new DocumentScanner();
    scanner.setTrackFieldTokens(false);
    scanner.setTrackFieldTypes(false);
    scanner.setTrackFieldValues(false);
    scanner.setTrackTokenFreq(false);
    scanner.setTrackTokenLocation(true);
    scanner.setTrackNameLocation(true);
    scanner.setStopTokenList(getStopList());
    scanner.setIgnoreDollar(true);
    scanner.setStateManager(this, db.getReplicaID());
    scanner.setCaseSensitive(getCaseSensitive());
    dbDoc.replaceItemValue(IndexDatabase.DB_TITLE_NAME, db.getTitle());
    if (dbDoc.hasItem(DB_LAST_INDEX_NAME)) {
      scanner.setLastScanDate((Date) dbDoc.getItemValue(DB_LAST_INDEX_NAME, Date.class));
      //      scanner.setStopTokenList(getStopList());
      //      scanner.setIgnoreDollar(true);
      //      Object tokenLocationObject = dbDoc.getItemValue(DB_TOKEN_LOCATION_NAME, Map.class);
      //      if (tokenLocationObject != null && !((Map) tokenLocationObject).isEmpty()) {
      //        scanner.setTokenLocationMap(tokenLocationObject);
      //      }
    }
    if (dbDoc.hasItem(IndexDatabase.DB_DOC_LIST_NAME)) {
      scanner.setCollection((org.openntf.domino.DocumentCollection) dbDoc.getItemValue(IndexDatabase.DB_DOC_LIST_NAME,
          org.openntf.domino.DocumentCollection.class));
    }
    Date scanDate = new Date();
    scanDatabase(db, scanner);
    String dbid = db.getReplicaID();
View Full Code Here

    try {
      IScannerStateManager.ScanStatus status = null;
      if (arg instanceof IScannerStateManager.ScanStatus) {
        status = (IScannerStateManager.ScanStatus) arg;
      }
      DocumentScanner scanner = null;
      if (o instanceof DocumentScanner) {
        scanner = (DocumentScanner) o;
      } else {
        System.out
            .println("Observable object was not a DocumentScanner. It was a " + (o == null ? "null" : o.getClass().getName()));
      }
      if (status != null) {
        //        System.out.println("DEBUG: Received update with status " + status.name());
        switch (status) {
        case NEW:
          break;
        case RUNNING:
          //        System.out.println("DEBUG: branched to running status...");
          if (scanner != null) {
            if (scanner.isTrackTokenLocation()) {
              Map tokenLocationMap = scanner.getTokenLocationMap();
              int tlsize = tokenLocationMap.size();
              if (tlsize >= 1024) {
                //                System.out.println("Processed " + scanner.getDocCount() + " documents so far, " + scanner.getItemCount()
                //                    + " items and " + scanner.getTokenCount());
                synchronized (tokenLocationMap) {
                  saveTokenLocationMap(scanner.getStateManagerKey(), tokenLocationMap, scanner);
                  tokenLocationMap.clear();
                }
              }
            } else {
              //              System.out.println("TokenLocation not being tracked by scanner");
            }
            if (scanner.isTrackNameLocation()) {
              Map nameLocationMap = scanner.getNameLocationMap();
              int nlsize = nameLocationMap.size();
              if (nlsize >= 128) {
                synchronized (nameLocationMap) {
                  saveTokenLocationMap(scanner.getStateManagerKey(), nameLocationMap, scanner);
                  nameLocationMap.clear();
                }
              }
            }
          } else {
            System.out.println("Scanner is null from notifications");
          }
          break;
        case COMPLETE:
          //          System.out.println("DEBUG: branched to complete status...");

          if (scanner != null) {
            if (scanner.isTrackTokenLocation()) {
              Map tokenLocationMap = scanner.getTokenLocationMap();
              synchronized (tokenLocationMap) {
                saveTokenLocationMap(scanner.getStateManagerKey(), tokenLocationMap, scanner);
                tokenLocationMap.clear();
              }
              //              System.out.println("Completed " + scanner.getDocCount() + " documents at completion, " + scanner.getItemCount()
              //                  + " items and " + scanner.getTokenCount());
            } else {
              //              System.out.println("TokenLocation not being tracked by scanner");
            }
            if (scanner.isTrackNameLocation()) {
              Map nameLocationMap = scanner.getNameLocationMap();
              synchronized (nameLocationMap) {
                saveNameLocationMap(scanner.getStateManagerKey(), nameLocationMap, scanner);
                nameLocationMap.clear();
              }
            }
          } else {
            System.out.println("ALERT! Scanner was null??");
View Full Code Here

    doc.get("@Adjust(@Modified; 1; 0; 0; 0; 0; 0)");
  }

  public Map<?, ?> scanDatabase(final org.openntf.domino.Database db) {
    // DocumentScanner looks at values of all string-based items in a document
    DocumentScanner scanner = new DocumentScanner();
    for (org.openntf.domino.Document doc : db.getAllDocuments()) {
      scanner.processDocument(doc);
    }
    // The FieldTokenMap returns a Map with a key of the item name, and a sorted set of the unique strings in each of those items
    // Sample uses: Predictive typeahead, custom indexing, external term matching
    return scanner.getFieldTokenMap();
  }
View Full Code Here

TOP

Related Classes of org.openntf.domino.helpers.DocumentScanner

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.