Example #1
0
        /// <summary>
        /// Dictionary search that will return a list of dictionary terms based on the dictionary type passed in
        /// and what kind of search is desired
        /// </summary>
        /// <param name="searchText">the text that has been typed into the search box</param>
        /// <param name="searchType">the type of search being executed</param>
        /// <param name="offset">how many to offset the first return result</param>
        /// <param name="maxResults">the max results to return<remarks>int.maxvalue should be used for retrieving all unless we have more</remarks></param>
        /// <param name="dictionary">the dictionary type (cancert term, drug, genetic)</param>
        /// <param name="language">English/Spanish</param>
        /// <returns>returns a list of dictioanry terms and related metadata</returns>
        public DictionarySearchResultCollection Search(String searchText, SearchType searchType, int offset, int maxResults, DictionaryType dictionary, String language)
        {
            // Translate from types the AppManager exposes to types the Dictionary Service exposes.
            svcDictionaryType svcDictionary = TypeTranslator.Translate(dictionary);
            svcSearchType     svcSearchType = TypeTranslator.Translate(searchType);
            svcLanguage       svcLanguage   = TypeTranslator.TranslateLocaleString(language);

            DictionaryService service = new DictionaryService();

            //sets up SearchReturn from Web Service
            NCI.Services.Dictionary.BusinessObjects.SearchReturn searchRet = null;

            //tries the dictionary service to get the strings back
            try
            {
                searchRet = service.Search(searchText, svcSearchType, offset, maxResults, svcDictionary, svcLanguage);
            }
            catch (Exception ex)
            {
                log.Error("There is an error in the Search Method of the Dictionary Service.", ex);
            }

            List <DictionarySearchResult>    resultList = DeserializeList(searchRet.Result, svcDictionary);
            DictionarySearchResultCollection collection = new DictionarySearchResultCollection(resultList.AsEnumerable());

            collection.ResultsCount = searchRet.Meta.ResultCount;
            return(collection);
        }
Example #2
0
        /// <summary>
        /// Term suggestions from what is being typed into the search box.  Used for autosuggest
        /// </summary>
        /// <param name="searchText">the string being typed</param>
        /// <param name="searchType">Type of search being done (contains, starts with, etc.)</param>
        /// <param name="dictionary">Which dictionary is being searched</param>
        /// <param name="language">Language</param>
        /// <returns>returns list of suggestions</returns>
        public DictionarySuggestionCollection SearchSuggest(String searchText, SearchType searchType, DictionaryType dictionary, String language)
        {
            // Translate from types the AppManager exposes to types the Dictionary Service exposes.
            svcDictionaryType svcDictionary = TypeTranslator.Translate(dictionary);
            svcSearchType     svcSearchType = TypeTranslator.Translate(searchType);
            svcLanguage       svcLanguage   = TypeTranslator.TranslateLocaleString(language);

            //Set up variables we will use
            List <DictionarySuggestion> list    = new List <DictionarySuggestion>();
            DictionaryService           service = new DictionaryService();
            SuggestReturnMeta           meta    = new SuggestReturnMeta();

            NCI.Services.Dictionary.BusinessObjects.SuggestReturn suggestRet = null;

            try
            {
                service.SearchSuggest(searchText, svcSearchType, svcDictionary, svcLanguage);
            }
            catch (Exception ex)
            {
                log.Error("Error in search suggest method in Dictionary Web Service.", ex);
            }

            //sets up the suggest so the list of suggestions
            DictionarySuggestion suggest = new DictionarySuggestion();

            foreach (NCI.Services.Dictionary.BusinessObjects.DictionarySuggestion m in suggestRet.Result)
            {
                //get properties and set them then add to list
                suggest.ID   = m.ID;
                suggest.Term = m.Term;
                list.Add(suggest);
            }
            //create return variable based on list
            DictionarySuggestionCollection result = new DictionarySuggestionCollection(list.AsEnumerable());

            result.ResultsCount = suggestRet.Meta.ResultCount;
            return(result);
        }