/// <summary> /// Get taxon list information about specified taxa. /// Returned list has the same order as the input taxon list. /// </summary> /// <param name="taxonIds">Taxon ids.</param> /// <param name="useNonCategorizedTaxaIdOnly">Indicates if filtering on only data without category 743 is to be returned.</param> /// <param name="selectedCategories">Selected categories.</param> /// <returns>Taxon list information about specified taxa.</returns> public List <TaxonListInformation> GetTaxonListInformation( TaxonIdList taxonIds, bool useNonCategorizedTaxaIdOnly, IList <RedListCategoryItemViewModel> selectedCategories) { if (!mIsInitialized) { throw new Exception("TaxonListInformation cache is not initialized"); } var taxonListInformation = new List <TaxonListInformation>(); if (taxonIds.IsNotEmpty()) { CheckCachedInformation(taxonIds); foreach (ITaxonId taxonId in taxonIds) { TaxonListInformation taxonInfo = TaxonInformationCache.TaxonInformation[taxonId.Id]; // Check if only non categorized taxa are to be shown. if (useNonCategorizedTaxaIdOnly) { bool taxonFound = selectedCategories.Any(category => category.OrderNumber == taxonInfo.RedListCategoryId); // First we check if taxon is beloning to a selected category if so add this taxon. if (taxonFound) { taxonListInformation.Add(taxonInfo); } else if (!taxonInfo.IsRedListed && !taxonInfo.IsRedListedEnsured) { // Not add taxon since it is ensured or redlisted and selected catgories is not choosen // This option is needed to select taxon which is not redlisted or ensured. These taxa should not be added. // This selcetion is keept for debugging purposes. // Only non categorized species are used here taxonListInformation.Add(taxonInfo); } } else { taxonListInformation.Add(taxonInfo); } } } return(taxonListInformation); }
/// <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); } }