public ResultSet <LexEntry> GetEntriesWithMissingFieldSortedByLexicalUnit(MissingFieldQuery query, IWritingSystemDefinition lexicalUnitWritingSystem) { Guard.AgainstNull(lexicalUnitWritingSystem, "lexicalUnitWritingSystem"); Guard.AgainstNull(query.Field, "field"); Guard.AgainstNull(query, "query"); string cacheName = String.Format("missingFieldsSortedByLexicalForm_{0}_{1}_{2}", query.Field, lexicalUnitWritingSystem.Id, query.UniqueCacheId); //cacheName = MakeSafeForFileName(cacheName); if (_caches[cacheName] == null) { DelegateQuery <LexEntry> lexicalFormQuery = new DelegateQuery <LexEntry>( delegate(LexEntry entryToQuery) { IDictionary <string, object> tokenFieldsAndValues = new Dictionary <string, object>(); if (query.FilteringPredicate(entryToQuery)) { string lexicalForm = null; if (!String.IsNullOrEmpty(entryToQuery.LexicalForm[lexicalUnitWritingSystem.Id])) { lexicalForm = entryToQuery.LexicalForm[lexicalUnitWritingSystem.Id]; } tokenFieldsAndValues.Add("Form", lexicalForm); return(new IDictionary <string, object>[] { tokenFieldsAndValues }); } return(new IDictionary <string, object> [0]); }); ResultSet <LexEntry> itemsMatching = _decoratedDataMapper.GetItemsMatching(lexicalFormQuery); SortDefinition[] sortOrder = new SortDefinition[1]; sortOrder[0] = new SortDefinition("Form", lexicalUnitWritingSystem.Collator); _caches.Add(cacheName, new ResultSetCache <LexEntry>(this, sortOrder, itemsMatching, lexicalFormQuery)); } ResultSet <LexEntry> resultsFromCache = _caches[cacheName].GetResultSet(); return(resultsFromCache); }
/// <summary> /// Gets a ResultSet containing entries that are missing the field matching field /// sorted by the lexical form in the given writing system. /// Use "Form" to access the lexical form in a RecordToken. /// </summary> /// <returns></returns> public ResultSet <LexEntry> GetEntriesWithMissingFieldSortedByLexicalUnit(Field field, string[] searchWritingSystemIds, IWritingSystemDefinition lexicalUnitWritingSystem) { var query = new MissingFieldQuery(field, searchWritingSystemIds, null); return(GetEntriesWithMissingFieldSortedByLexicalUnit(query, lexicalUnitWritingSystem)); }