示例#1
0
 /// <summary>
 /// Get ids for taxa that matches search criteria.
 /// </summary>
 /// <param name="analysisManager">Analysis manager.</param>
 /// <param name="searchCriteria">Analysis search critera.</param>
 /// <param name="taxonIds">
 /// Limit search to these taxa.
 /// This parameter is ignored if value is null.
 /// </param>
 /// <returns>Ids for taxa that matches search criteria.</returns>
 public static TaxonIdList GetTaxonIds(
     this IAnalysisManager analysisManager,
     AnalysisSearchCriteria searchCriteria,
     TaxonIdList taxonIds)
 {
     return(mCache.GetTaxonIds(searchCriteria, taxonIds));
 }
示例#2
0
        ///// <summary>
        ///// Init Biotopes information.
        ///// </summary>
        ///// <param name="searchCriteria">The search criteria.</param>
        ///// <param name="model">The view model stored in session.</param>
        //public static void InitBiotopeInformation(this AnalysisSearchCriteria searchCriteria, SearchViewModel model)
        //{
        //    if (model.IsBiotopeEnabled && model.Biotopes.Any(r => r.Selected))
        //    {
        //        searchCriteria.Biotopes = new BiotopeSearchCriteria
        //        {
        //            ImportantOnly = model.IsBiotopeImportant,
        //            Operator = model.BiotopeOperator,
        //            BiotopeIds = new List<int>()
        //        };
        //        foreach (var biotope in model.Biotopes)
        //        {
        //            if (biotope.Selected)
        //            {
        //                searchCriteria.Biotopes.BiotopeIds.Add(biotope.Id);
        //            }
        //        }
        //    }
        //}

        ///// <summary>
        ///// Init SwedishOccurrence information
        ///// </summary>
        ///// <param name="searchCriteria"></param>
        ///// <param name="model"></param>
        //public static void InitSwedishOccurrenceInformation(this AnalysisSearchCriteria searchCriteria, SearchViewModel model)
        //{
        //    if (model.IsSwedishOccurrenceEnabled && model.SwedishOccurrences.Any(r => r.Selected))
        //    {
        //        searchCriteria.SwedishOccurrence = new List<int>();
        //        foreach (var swedishOccurrence in model.SwedishOccurrences)
        //        {
        //            if (swedishOccurrence.Selected)
        //            {
        //                searchCriteria.SwedishOccurrence.Add(swedishOccurrence.Id);
        //            }
        //        }
        //    }
        //}

        ///// <summary>
        ///// Init CountyOccurrence information.
        ///// </summary>
        ///// <param name="searchCriteria">The search criteria.</param>
        ///// <param name="model">The view model stored in session.</param>
        //public static void InitCountyOccurrencesInformation(this AnalysisSearchCriteria searchCriteria, SearchViewModel model)
        //{
        //    if (model.IsCountyOccurrenceEnabled && model.CountyOccurrences.Any(r => r.Selected))
        //    {
        //        searchCriteria.CountyOccurrence = new List<int>();
        //        foreach (var countyOccurrence in model.CountyOccurrences)
        //        {
        //            if (countyOccurrence.Selected)
        //            {
        //                searchCriteria.CountyOccurrence.Add(countyOccurrence.Id);
        //            }
        //        }
        //    }
        //}

        ///// <summary>
        ///// Init thematic list information.
        ///// </summary>
        ///// <param name="searchCriteria">The search criteria.</param>
        ///// <param name="model">The view model stored in session.</param>
        //public static void InitThematicListInformation(this AnalysisSearchCriteria searchCriteria, SearchViewModel model)
        //{
        //    if (model.IsThematicListEnabled && model.ThematicLists.Any(r => r.Selected))
        //    {
        //        searchCriteria.ThematicLists = new ThematicListSearchCriteria
        //        {
        //            Operator = model.ThematicListOperator,
        //            ThematicListIds = new List<int>()
        //        };
        //        foreach (var thematicList in model.ThematicLists)
        //        {
        //            if (thematicList.Selected)
        //            {
        //                searchCriteria.ThematicLists.ThematicListIds.Add(thematicList.Id);
        //            }
        //        }
        //    }
        //}

        /// <summary>
        /// Init RedListCategories information.
        /// </summary>
        /// <param name="searchCriteria">The search criteria.</param>
        /// <param name="model">The view model stored in session.</param>
        public static void InitRedListCategories(this AnalysisSearchCriteria searchCriteria, SearchViewModel model)
        {
            if (model.IsRedListCategoriesEnabled && model.RedListCategories.Any(r => r.Selected))
            {
                searchCriteria.RedListCategories = new List <int>();
                foreach (var redListCategory in model.RedListCategories)
                {
                    if (redListCategory.Selected)
                    {
                        searchCriteria.RedListCategories.Add(redListCategory.OrderNumber);
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Get ids for taxa that matches search criteria.
        /// </summary>
        /// <param name="analysisManager">Analysis manager.</param>
        /// <param name="searchCriteria">Analysis search critera.</param>
        /// <param name="taxa">
        /// Limit search to these taxa.
        /// This parameter is ignored if value is null.
        /// </param>
        /// <returns>Ids for taxa that matches search criteria.</returns>
        public static TaxonIdList GetTaxonIds(
            this IAnalysisManager analysisManager,
            AnalysisSearchCriteria searchCriteria,
            TaxonList taxa)
        {
            TaxonIdList taxonIds = null;

            if (taxa.IsNotNull())
            {
                taxonIds = new TaxonIdList();
                taxonIds.Merge(taxa);
            }

            return(mCache.GetTaxonIds(searchCriteria, taxonIds));
        }
示例#4
0
        /// <summary>
        /// Get ids for taxa that matches search criteria.
        /// </summary>
        /// <param name="searchCriteria">Analysis search criteria.</param>
        /// <param name="taxonIds">
        /// Limit search to these taxon ids.
        /// This parameter is ignored if value is null.
        /// </param>
        /// <returns>Ids for taxa that matches search criteria.</returns>
        public TaxonIdList GetTaxonIds(AnalysisSearchCriteria searchCriteria, TaxonIdList taxonIds = null)
        {
            TaxonIdList tempTaxonIds;

            tempTaxonIds = null;
            if (taxonIds.IsNotNull())
            {
                tempTaxonIds = new TaxonIdList();
                tempTaxonIds.AddRange(taxonIds);
            }

            //if (searchCriteria.Biotopes.IsNotNull())
            //{
            //    tempTaxonIds = Biotope.GetTaxonIds(searchCriteria.Biotopes,
            //                                       tempTaxonIds);
            //}

            //if (searchCriteria.SwedishOccurrence.IsNotNull())
            //{
            //    tempTaxonIds = SwedishOccurrence.GetTaxonIds(searchCriteria.SwedishOccurrence,
            //                                                 tempTaxonIds);
            //}

            //if (searchCriteria.CountyOccurrence.IsNotNull())
            //{
            //    tempTaxonIds = CountyOccurrence.GetTaxonIds(searchCriteria.CountyOccurrence,
            //                                                tempTaxonIds);
            //}

            //if (searchCriteria.Host.IsNotNull())
            //{
            //    tempTaxonIds = Host.GetTaxonIds(searchCriteria.Host,
            //                                    tempTaxonIds);
            //}

            //if (searchCriteria.Impact.IsNotNull())
            //{
            //    tempTaxonIds = Impact.GetTaxonIds(searchCriteria.Impact,
            //                                      tempTaxonIds);
            //}

            //if (searchCriteria.LandscapeTypes.IsNotNull())
            //{
            //    tempTaxonIds = LandscapeType.GetTaxonIds(searchCriteria.LandscapeTypes,
            //                                             tempTaxonIds);
            //}

            //if (searchCriteria.LifeForms.IsNotNull())
            //{
            //    tempTaxonIds = LifeForm.GetTaxonIds(searchCriteria.LifeForms,
            //                                        tempTaxonIds);
            //}

            //if (searchCriteria.OrganismGroups.IsNotNull())
            //{
            //    tempTaxonIds = OrganismGroup.GetTaxonIds(searchCriteria.OrganismGroups,
            //                                             tempTaxonIds);
            //}

            if (searchCriteria.RedListCategories.IsNotNull())
            {
                tempTaxonIds = RedListCategory.GetTaxonIds(searchCriteria.RedListCategories, tempTaxonIds);
            }

            //if (searchCriteria.TaxonCategories.IsNotEmpty())
            //{
            //    tempTaxonIds = TaxonScope.GetTaxonIds(searchCriteria.TaxonCategories,
            //                                                    tempTaxonIds);
            //}
            //else if (searchCriteria.TaxonScope.IsNotNull())
            //{
            //    tempTaxonIds = TaxonScope.GetTaxonIds(searchCriteria.TaxonScope,
            //                                                    tempTaxonIds);
            //}

            //if (searchCriteria.Substrate.IsNotNull())
            //{
            //    tempTaxonIds = Substrate.GetTaxonIds(searchCriteria.Substrate,
            //                                         tempTaxonIds);
            //}

            //if (searchCriteria.ThematicLists.IsNotNull())
            //{
            //    tempTaxonIds = ThematicLists.GetTaxonIds(searchCriteria.ThematicLists,
            //                                             tempTaxonIds);
            //}

            return(tempTaxonIds);
        }
        ///// <summary>
        ///// Check dataselection and if only red listed is selected then check if taxa has factor 743/red listed.
        ///// Remove other taxa then from result depending on data selection LC/NE/NA taxa could be included or excluded.
        ///// </summary>
        ///// <param name="result">
        ///// Result taxa list from taxa selection search.
        ///// </param>
        //private void RemoveTaxaNotRedlistedOrRedlistedEnsuredFromList(List<TaxonListInformation> result)
        //{
        //    // Make a copy of the list
        //    var tempResult = new List<TaxonListInformation>();
        //    if (result.IsNotEmpty())
        //    {
        //        tempResult.AddRange(result);
        //    }

        //    // Check dataselection and if only redlisted is selected then check if taxa has factor 743/redlisted and is not of type
        //    // LC/NE/NA. Remove other taxa then from result.
        //    if (SessionHandler.UseOnlyRedlistedData)
        //    {
        //        foreach (TaxonListInformation taxonListInformation in tempResult.Where(taxonListInformation => !taxonListInformation.IsRedListed))
        //        {
        //            result.RemoveAll(x => x.Id == taxonListInformation.Id);
        //        }
        //    }
        //}

        /// <summary>
        /// Get taxa by user selections.
        /// </summary>
        /// <param name="model">
        /// Search view model.
        /// </param>
        /// <param name="useNonCategorizedTaxaIdOnly">
        /// Indicates if only taxa without category red listed (743) set.
        /// </param>
        /// <param name="selectedCategories"> returns selected categories to filter on if selection of non categorized data is choosen to be viewed.</param>
        /// <returns>
        /// List of taxon ids.
        /// </returns>
        private TaxonIdList GetTaxaBySearchCriteria(SearchViewModel model, out bool useNonCategorizedTaxaIdOnly, out IList <RedListCategoryItemViewModel> selectedCategories)
        {
            var searchCriteria = new AnalysisSearchCriteria();

            bool onlyNonCategorizedTaxaIdUsed = false;

            useNonCategorizedTaxaIdOnly = false;
            selectedCategories          = null;

            if (model.RedListCategories.IsNotEmpty())
            {
                // Get number of selected
                selectedCategories = model.RedListCategories.Where(item => item.Selected).ToList();
                const int NonCategorizedTaxaId = 1000;

                // Check if non categorizedtaxa is the selected then we have to get all taxa.
                if (model.RedListCategories.Any(redListCategory =>
                                                (redListCategory.Id == NonCategorizedTaxaId) && redListCategory.Selected))
                {
                    onlyNonCategorizedTaxaIdUsed = true;
                    useNonCategorizedTaxaIdOnly  = true;
                }
            }

            if (!onlyNonCategorizedTaxaIdUsed)
            {
                searchCriteria.InitRedListCategories(model);
            }
            else
            {
                // Getting alla taxa for all categories; must filter below on data not categorized.
                searchCriteria.RedListCategories = null;
            }

            //// Red list taxon categories / (Arter/Småarter/Underarter)
            //searchCriteria.InitRedListTaxonCategories(model);

            //// Scope
            //searchCriteria.InitTaxonScope(model);

            //// Swedish occurrence
            //searchCriteria.InitSwedishOccurrenceInformation(model);

            //// Organism / Organismgrupp
            //searchCriteria.InitOrganismGroups(model);

            //// Landscape / Landskapstyp
            //searchCriteria.InitLandscapeTypes(model);

            //// County / Län
            //searchCriteria.InitCountyOccurrencesInformation(model);

            //// Biotope / Biotop
            //searchCriteria.InitBiotopeInformation(model);

            //// Substrate / Substrat
            //searchCriteria.InitSubstrate(model);

            //// Impact / Påverkan
            //searchCriteria.InitImpact(model);

            //// Lifeforms / Livsform
            //searchCriteria.InitLifeForms(model);

            //// Host / Värd
            //searchCriteria.InitHost(model);

            //// Thematic listing / Tematisk lista
            //searchCriteria.InitThematicListInformation(model);

            // Fetch the taxonids
            TaxonIdList taxonIds = CoreData.AnalysisManager.GetTaxonIds(searchCriteria);

            return(taxonIds);
        }