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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations