/// <summary> /// Check that taxon list information about specified taxa has been fetched in the cache. /// Cache the information if it is not cached. /// </summary> /// <param name="taxonIds">Taxon ids.</param> private void CheckCachedInformation(IEnumerable <ITaxonId> taxonIds) { var notCachedTaxa = new TaxonIdList(); foreach (ITaxonId taxonId in taxonIds) { if (!mTaxonInformationCache.TaxonInformation.ContainsKey(taxonId.Id)) { notCachedTaxa.Add(taxonId); } } if (notCachedTaxa.IsNotEmpty()) { LoadTaxonListInformation(notCachedTaxa); } }
///// <summary> ///// Get search criteria view model from database or cache. ///// </summary> ///// <returns>View model.</returns> //public SearchViewModel GetSearchViewModel() //{ // // If values are stored in session, update current values // SearchViewModel searchViewModelFromSession = GetSearchViewModelFromSession(); // if (searchViewModelFromSession.IsNull()) // { // searchViewModelFromSession = new SearchViewModel(); // } // var searchViewModel = new SearchViewModel(); // searchViewModel.InitSearchViewModel(mUserContext, searchViewModelFromSession); // searchViewModel.InitSwedishOccurrenceInformation(); // searchViewModel.InitBiotopeInformation(); // searchViewModel.InitCountyOccurrencesInformation(); // searchViewModel.InitThematicListInformation(); // searchViewModel.InitRedListCategories(); // searchViewModel.InitRedListTaxonCategories(); // searchViewModel.InitTaxonScope(); // searchViewModel.InitOrganismGroups(); // searchViewModel.InitLandscapeTypes(); // searchViewModel.InitSubstrate(); // searchViewModel.InitImpact(); // searchViewModel.InitLifeForms(); // searchViewModel.InitHost(); // return searchViewModel; //} /// <summary> /// Get list of taxon information by user selections. /// </summary> /// <param name="model">Search view model.</param> /// <param name="allTaxa"></param> /// <returns>List of taxon information.</returns> public List <TaxonListInformation> SearchTaxa(SearchViewModel model, List <int> allTaxa) { if (model == null) { return(null); } List <TaxonListInformation> taxonListInformations = null; if (allTaxa == null) { bool useNonCategorizedTaxaIdOnly; IList <RedListCategoryItemViewModel> selectedCategories; TaxonIdList taxonIds = GetTaxaBySearchCriteria( model, out useNonCategorizedTaxaIdOnly, out selectedCategories); taxonListInformations = TaxonListInformationManager.Instance.GetTaxonListInformation( taxonIds, useNonCategorizedTaxaIdOnly, selectedCategories); } else { var resList = new TaxonIdList(); foreach (var id in allTaxa) { resList.Add(new TaxonIdImplementation(id)); } taxonListInformations = TaxonListInformationManager.Instance.GetTaxonListInformation( resList, false, null); } return(taxonListInformations); }