Search in sources :

Example 11 with Document

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

the class IndexDatabase method restoreTokenLocationMap.

/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#restoreTokenLocationMap(java.lang.CharSequence, java.lang.Object)
	 */
@Override
public Map<CharSequence, Set<CharSequence>> restoreTokenLocationMap(final CharSequence token, final Object mapKey) {
    Map result = null;
    Document doc = getTermDocument(token.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 12 with Document

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

the class IndexDatabase method getTermUnidInItems.

/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#getTermUnidInItems(java.lang.CharSequence, java.util.Collection)
	 */
@Override
public Set<CharSequence> getTermUnidInItems(final CharSequence term, final Collection<String> itemNames) {
    Set<CharSequence> unids = new HashSet<CharSequence>();
    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());
            Map termMap = doc.getItemValue(itemName, Map.class);
            for (String key : itemNames) {
                CaseInsensitiveString ciskey = new CaseInsensitiveString(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 : Item(org.openntf.domino.Item) 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 13 with Document

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

the class IndexDatabase method getTermUnidMap.

/*public static List<String> dbidCollToTitle(final Session session, final String serverName, final Collection<String> dbids) {
		List<String> result = new ArrayList<String>();
		for (String dbid : dbids) {
			Database db = session.getDatabase(serverName, dbid);
			if (db != null) {
				result.add(db.getTitle() + "|" + dbid);
			}
		}
		return result;
	}

	public static List<String> dbMapToCheckbox(final Session session, final String serverName, final Map<String, AtomicInteger> dbMap) {
		List<String> result = new ArrayList<String>();
		for (String dbid : dbMap.keySet()) {
			Database db = session.getDatabase(serverName, dbid);
			if (db != null) {
				result.add(db.getTitle() + " (" + dbMap.get(dbid) + ")|" + dbid);
			}
		}
		return result;
	}

	public static List<String> itemMapToCheckbox(final Map<String, AtomicInteger> itemMap) {
		List<String> result = new ArrayList<String>();
		for (String item : itemMap.keySet()) {
			result.add(item.substring(16) + " (" + itemMap.get(item) + ")|" + item.substring(16));
		}
		return result;
	}

	public static List<String> formMapToCheckbox(final Map<String, AtomicInteger> formMap) {
		List<String> result = new ArrayList<String>();
		for (String form : formMap.keySet()) {
			result.add(form.substring(16) + " (" + formMap.get(form) + ")|" + form.substring(16));
		}
		return result;
	}*/
/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#getTermUnidMap(java.lang.CharSequence)
	 */
@Override
public Map<CharSequence, Set<CharSequence>> getTermUnidMap(final CharSequence term) {
    Map<CharSequence, Set<CharSequence>> result = new LinkedHashMap<CharSequence, Set<CharSequence>>();
    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());
            Set<CharSequence> unids = new HashSet<CharSequence>();
            Map termMap = doc.getItemValue(itemName, Map.class);
            for (Object key : termMap.keySet()) {
                Object termObj = termMap.get(key);
                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));
                    }
                }
            }
            result.put(dbid, unids);
        }
    }
    return result;
}
Also used : Item(org.openntf.domino.Item) HashSet(java.util.HashSet) Set(java.util.Set) 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) LinkedHashMap(java.util.LinkedHashMap) HashSet(java.util.HashSet)

Example 14 with Document

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

the class IndexDatabase method getValueDocument.

@Override
public Document getValueDocument(final CharSequence value) {
    String key = caseSensitive_ ? value.toString() : value.toString().toLowerCase();
    Document result = getIndexDb().getDocumentWithKey(key, true);
    if (result != null && result.isNewNote()) {
        result.replaceItemValue("Form", VALUE_FORM_NAME);
        result.replaceItemValue(VALUE_KEY_NAME, value);
        result.save();
    }
    return result;
}
Also used : CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Document(org.openntf.domino.Document)

Example 15 with Document

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

the class IndexDatabase method restoreValueLocationMap.

@Override
public Map<CharSequence, Set<CharSequence>> restoreValueLocationMap(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)

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