private WebTaxonTreeSearchCriteria GetSearchCriteria(Boolean refresh) { if (_searchCriteria.IsNull() || refresh) { _searchCriteria = new WebTaxonTreeSearchCriteria(); } return(_searchCriteria); }
public void GetTaxonTreesBySearchCriteria() { List <Int32> taxonIds; List <WebTaxonTreeNode> taxonTrees; TaxonInformationType taxonInformationType; WebTaxonTreeSearchCriteria searchCriteria; taxonIds = new List <Int32>(); taxonIds.Add(HAWK_BIRDS_TAXON_ID); taxonIds.Add((Int32)(TaxonId.Bears)); taxonInformationType = TaxonInformationType.Basic; searchCriteria = new WebTaxonTreeSearchCriteria(); searchCriteria.TaxonInformationType = taxonInformationType; taxonTrees = TaxonManager.GetTaxonTreesBySearchCriteria(GetContext(), searchCriteria); Assert.IsNotNull(taxonTrees); Assert.IsTrue(taxonTrees.IsNotEmpty()); searchCriteria.RestrictSearchToTaxonTypeIds = GetTaxonTypeIds(); taxonTrees = TaxonManager.GetTaxonTreesBySearchCriteria(GetContext(), searchCriteria); Assert.IsNotNull(taxonTrees); Assert.IsTrue(taxonTrees.IsNotEmpty()); searchCriteria.RestrictSearchToTaxonTypeIds = null; searchCriteria.RestrictSearchToTaxonIds = taxonIds; taxonTrees = TaxonManager.GetTaxonTreesBySearchCriteria(GetContext(), searchCriteria); Assert.IsNotNull(taxonTrees); Assert.AreEqual(taxonTrees.Count, taxonIds.Count); searchCriteria.RestrictSearchToTaxonTypeIds = GetTaxonTypeIds(); taxonTrees = TaxonManager.GetTaxonTreesBySearchCriteria(GetContext(), searchCriteria); Assert.IsNotNull(taxonTrees); Assert.IsTrue(taxonTrees.IsNotEmpty()); // Test with root taxon. searchCriteria = new WebTaxonTreeSearchCriteria(); searchCriteria.TaxonInformationType = TaxonInformationType.Basic; taxonIds = new List <Int32>(); taxonIds.Add(ROOT_TAXON_ID); searchCriteria.RestrictSearchToTaxonIds = taxonIds; taxonTrees = TaxonManager.GetTaxonTreesBySearchCriteria(GetContext(), searchCriteria); Assert.IsNotNull(taxonTrees); // Test with more than one root taxon. taxonIds = new List <Int32>(); taxonIds.Add(HAWK_BIRDS_TAXON_ID); taxonIds.Add((Int32)(ArtDatabanken.Data.TaxonId.Mammals)); taxonInformationType = TaxonInformationType.Basic; searchCriteria = new WebTaxonTreeSearchCriteria(); searchCriteria.RestrictSearchToTaxonIds = taxonIds; searchCriteria.TaxonInformationType = taxonInformationType; taxonTrees = TaxonManager.GetTaxonTreesBySearchCriteria(GetContext(), searchCriteria); Assert.IsNotNull(taxonTrees); Assert.AreEqual(taxonIds.Count, taxonTrees.Count); }
public static WebTaxonTreeNode GetBearTaxonTreeNode(WebServiceContext context) { List <Int32> taxonIds; List <WebTaxonTreeNode> taxonTrees; WebTaxonTreeSearchCriteria searchCriteria; searchCriteria = new WebTaxonTreeSearchCriteria(); taxonIds = new List <Int32>(); taxonIds.Add(BEAR_TAXON_ID); searchCriteria.RestrictSearchToTaxonIds = taxonIds; taxonTrees = TaxonManager.GetTaxonTreesBySearchCriteria(context, searchCriteria); return(taxonTrees[0]); }
/// <summary> /// Convert TaxonTreeSearchCriteria to WebTaxonTreeSearchCriteria. /// </summary> /// <param name="searchCriteria">A TaxonTreeSearchCriteria instance.</param> /// <returns>A WebTaxonTreeSearchCriteria instance.</returns> private static WebTaxonTreeSearchCriteria GetTaxonTreeSearchCriteria(TaxonTreeSearchCriteria searchCriteria) { WebTaxonTreeSearchCriteria webSearchCriteria; webSearchCriteria = new WebTaxonTreeSearchCriteria(); if (searchCriteria.RestrictSearchToTaxonIds.IsNotNull()) { webSearchCriteria.RestrictSearchToTaxonIds = searchCriteria.RestrictSearchToTaxonIds; } if (searchCriteria.RestrictSearchToTaxonTypeIds.IsNotNull()) { webSearchCriteria.RestrictSearchToTaxonTypeIds = searchCriteria.RestrictSearchToTaxonTypeIds; } webSearchCriteria.TaxonInformationType = searchCriteria.TaxonInformationType; #if DATA_SPECIFIED_EXISTS webSearchCriteria.TaxonInformationTypeSpecified = true; #endif return(webSearchCriteria); }
public void GetTaxonTreesBySearchCriteria() { List <WebTaxonTreeNode> taxonTrees; WebTaxonTreeSearchCriteria searchCriteria; // Get a part of the taxon tree. foreach (TaxonTreeSearchScope scope in Enum.GetValues(typeof(TaxonTreeSearchScope))) { searchCriteria = new WebTaxonTreeSearchCriteria(); searchCriteria.IsMainRelationRequired = false; searchCriteria.IsValidRequired = true; searchCriteria.Scope = scope; searchCriteria.TaxonIds = new List <Int32>(); searchCriteria.TaxonIds.Add((Int32)(TaxonId.Mammals)); taxonTrees = WebServiceProxy.TaxonService.GetTaxonTreesBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxonTrees.IsNotEmpty()); if ((searchCriteria.Scope == TaxonTreeSearchScope.AllChildTaxa) || (searchCriteria.Scope == TaxonTreeSearchScope.NearestChildTaxa)) { Assert.AreEqual(1, taxonTrees.Count); Assert.AreEqual((Int32)(TaxonId.Mammals), taxonTrees[0].Taxon.Id); } } // Get the entire taxon tree (valid taxa and relations). searchCriteria = new WebTaxonTreeSearchCriteria(); searchCriteria.IsMainRelationRequired = false; searchCriteria.IsValidRequired = true; taxonTrees = WebServiceProxy.TaxonService.GetTaxonTreesBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxonTrees.IsNotEmpty()); // Get the entire taxon tree (include not valid taxa and relations). searchCriteria = new WebTaxonTreeSearchCriteria(); searchCriteria.IsMainRelationRequired = false; searchCriteria.IsValidRequired = false; taxonTrees = WebServiceProxy.TaxonService.GetTaxonTreesBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxonTrees.IsNotEmpty()); }
public WebTaxonTreeSearchCriteriaTest() { _searchCriteria = null; }