Search in sources :

Example 96 with Document

use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.

the class IndexDatabase method restoreRichTextLocationMap.

@Override
public Map<CharSequence, CharSequence> restoreRichTextLocationMap(final CharSequence token, final Object mapKey) {
    Map result = null;
    Document doc = getValueDocument(token.toString());
    String itemName = VALUE_MAP_PREFIX + String.valueOf(mapKey);
    if (doc.hasItem(itemName)) {
        result = doc.getItemValue(itemName, Map.class);
    } else {
        result = new ConcurrentHashMap<CaseInsensitiveString, Set<String>>(8, 0.9f, 1);
    }
    return result;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Document(org.openntf.domino.Document) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString)

Example 97 with Document

use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.

the class IndexDatabase method getTermDbids.

// public void writeResults(final CharSequence dbid, final DocumentScanner scanner) {
// Map<CharSequence, Map<CharSequence, Set<CharSequence>>> tlMap = scanner.getTokenLocationMap();
// saveTokenLocationMap(dbid, tlMap, scanner);
// }
/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#getTermDbids(java.lang.CharSequence)
	 */
@Override
public List<String> getTermDbids(final CharSequence term) {
    List<String> result = new ArrayList<String>();
    Document doc = getTermDocument(term);
    for (Item item : doc.getItems()) {
        String itemName = item.getName();
        if (itemName.startsWith(TERM_MAP_PREFIX)) {
            String dbid = itemName.substring(TERM_MAP_PREFIX.length());
            result.add(dbid);
        }
    }
    return result;
}
Also used : Item(org.openntf.domino.Item) ArrayList(java.util.ArrayList) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Document(org.openntf.domino.Document)

Example 98 with Document

use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.

the class IndexDatabase method getTermUnidInDbsItems.

/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#getTermUnidInDbsItems(java.lang.String, java.util.Collection, java.util.Collection)
	 */
@Override
public Set<CharSequence> getTermUnidInDbsItems(final String term, final Collection<String> dbids, final Collection<?> itemNames) {
    Set<CharSequence> unids = new HashSet<CharSequence>();
    Document doc = getTermDocument(term);
    for (String dbid : dbids) {
        String itemName = TERM_MAP_PREFIX + dbid;
        if (doc.hasItem(itemName)) {
            Map termMap = doc.getItemValue(itemName, Map.class);
            for (Object key : itemNames) {
                CaseInsensitiveString ciskey = null;
                if (key instanceof CaseInsensitiveString) {
                    ciskey = (CaseInsensitiveString) key;
                } else if (key instanceof String) {
                    ciskey = new CaseInsensitiveString((String) key);
                } else {
                    ciskey = new CaseInsensitiveString(String.valueOf(key));
                }
                Object termObj = termMap.get(ciskey);
                if (termObj != null) {
                    if (termObj instanceof Collection) {
                        unids.addAll((Collection) termObj);
                    } else if (termObj instanceof CharSequence) {
                        unids.add(((CharSequence) termObj).toString());
                    } else {
                        unids.add(String.valueOf(termObj));
                    }
                }
            }
        }
    }
    return unids;
}
Also used : Collection(java.util.Collection) DocumentCollection(org.openntf.domino.DocumentCollection) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Document(org.openntf.domino.Document) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) HashSet(java.util.HashSet)

Example 99 with Document

use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.

the class IndexDatabase method restoreNameLocationMap.

/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#restoreNameLocationMap(java.lang.CharSequence, java.lang.Object)
	 */
@Override
public Map<CharSequence, Set<CharSequence>> restoreNameLocationMap(final CharSequence name, final Object mapKey) {
    Map result = null;
    Document doc = getNameDocument(name.toString());
    String itemName = TERM_MAP_PREFIX + String.valueOf(mapKey);
    if (doc.hasItem(itemName)) {
        result = doc.getItemValue(itemName, Map.class);
    } else {
        result = new ConcurrentHashMap<CaseInsensitiveString, Set<String>>(8, 0.9f, 1);
    }
    return result;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Document(org.openntf.domino.Document) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString)

Example 100 with Document

use of org.openntf.domino.Document in project org.openntf.domino by OpenNTF.

the class IndexDatabase method getTermLinksInDbsItems.

/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#getTermLinksInDbsItems(org.openntf.domino.Session, java.lang.String, java.lang.String, java.util.Collection, java.util.Collection)
	 */
@Override
public Set<String> getTermLinksInDbsItems(final Session session, final String serverName, final String term, final Collection<CharSequence> dbids, final Collection<?> itemNames) {
    Set<String> unids = new HashSet<String>();
    Document doc = getTermDocument(term);
    for (CharSequence dbid : dbids) {
        String itemName = TERM_MAP_PREFIX + dbid;
        if (doc.hasItem(itemName)) {
            Map termMap = doc.getItemValue(itemName, Map.class);
            // if (db != null) {
            for (Object key : itemNames) {
                CaseInsensitiveString ciskey = null;
                if (key instanceof CaseInsensitiveString) {
                    ciskey = (CaseInsensitiveString) key;
                } else if (key instanceof String) {
                    ciskey = new CaseInsensitiveString((String) key);
                } else {
                    ciskey = new CaseInsensitiveString(String.valueOf(key));
                }
                Object termObj = termMap.get(ciskey);
                if (termObj != null) {
                    if (termObj instanceof Collection) {
                        for (Object unid : (Collection) termObj) {
                            // Document curDoc = db.getDocumentByUNID((String) unid);
                            unids.add("http://localhost/__" + dbid + ".nsf/0/" + unid);
                        }
                    // unids.addAll((Collection) termObj);
                    } else if (termObj instanceof CharSequence) {
                        // Document curDoc = db.getDocumentByUNID((String) ((CharSequence) termObj).toString());
                        unids.add("http://localhost/__" + dbid + ".nsf/0/" + ((CharSequence) termObj).toString());
                    // unids.add(((CharSequence) termObj).toString());
                    } else {
                        unids.add(String.valueOf(termObj));
                    }
                }
            }
        // }
        }
    }
    return unids;
}
Also used : Collection(java.util.Collection) DocumentCollection(org.openntf.domino.DocumentCollection) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Document(org.openntf.domino.Document) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) HashSet(java.util.HashSet)

Aggregations

Document (org.openntf.domino.Document)112 Database (org.openntf.domino.Database)48 CaseInsensitiveString (org.openntf.domino.types.CaseInsensitiveString)31 Session (org.openntf.domino.Session)28 Map (java.util.Map)20 HashSet (java.util.HashSet)15 LinkedHashMap (java.util.LinkedHashMap)15 DocumentCollection (org.openntf.domino.DocumentCollection)15 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)13 Item (org.openntf.domino.Item)13 Set (java.util.Set)12 ArrayList (java.util.ArrayList)11 Date (java.util.Date)9 HashMap (java.util.HashMap)9 View (org.openntf.domino.View)9 Collection (java.util.Collection)8 UserAccessException (org.openntf.domino.exceptions.UserAccessException)8 Serializable (java.io.Serializable)7 Test (org.junit.Test)7 NotesException (lotus.domino.NotesException)6