public void GetHostsBySpeciesFactSearchCriteria() { List <WebTaxon> hosts; WebSpeciesFactSearchCriteria searchCriteria; searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IncludeNotValidHosts = true; searchCriteria.IncludeNotValidTaxa = true; searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(1222); // Värddjur hosts = WebServiceProxy.AnalysisService.GetHostsBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(hosts.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IncludeNotValidHosts = true; searchCriteria.IncludeNotValidTaxa = true; searchCriteria.HostIds = new List <Int32>(); searchCriteria.HostIds.Add((Int32)(TaxonId.Insects)); hosts = WebServiceProxy.AnalysisService.GetHostsBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(hosts.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IncludeNotValidHosts = true; searchCriteria.IncludeNotValidTaxa = true; searchCriteria.TaxonIds = new List <Int32>(); searchCriteria.TaxonIds.Add(100011); // Kungsörn hosts = WebServiceProxy.AnalysisService.GetHostsBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(hosts.IsNotEmpty()); }
/// <summary> /// Get taxon count of the taxa that matches fact search criteria. /// </summary> /// <param name="context">Web service request context.</param> /// <param name="searchCriteria">Species fact search criteria.</param> /// <returns>Taxon count of the taxa that matches fact search criteria.</returns> public static Int32 GetTaxaCountBySearchCriteria(WebServiceContext context, WebSpeciesFactSearchCriteria searchCriteria) { Int32 taxonCount = 0; // Check arguments. searchCriteria.CheckNotNull("searchCriteria"); searchCriteria.CheckData(); // Get data from database. using (DataReader dataReader = context.GetTaxonAttributeDatabase().GetSpeciesFactsBySearchCriteria(searchCriteria.GetQuery(WebSpeciesFactSearchCriteriaExtension.QuerySelectPart.QueryTaxonCount), searchCriteria.FactorDataTypeIds, searchCriteria.FactorIds, searchCriteria.HostIds, searchCriteria.TaxonIds)) { while (dataReader.Read()) { taxonCount = dataReader.GetInt32(SpeciesFactData.TAXON_COUNT); if (taxonCount > Settings.Default.MaxSpeciesFacts) { // Exceeding max numbers of taxa that // can be retrieved in one request. throw new ArgumentException("Max " + Settings.Default.MaxSpeciesFacts + " taxa can be retrieved in one call."); } } } return(taxonCount); }
/// <summary> /// Get information about species facts that matches search criteria. /// </summary> /// <param name="context">Web service request context.</param> /// <param name="searchCriteria">Species fact search criteria.</param> /// <returns>Species facts that matches search criteria.</returns> public static List <WebSpeciesFact> GetSpeciesFactsBySearchCriteria(WebServiceContext context, WebSpeciesFactSearchCriteria searchCriteria) { List <WebSpeciesFact> speciesFacts; WebSpeciesFact speciesFact; // Check arguments. searchCriteria.CheckNotNull("searchCriteria"); searchCriteria.CheckData(); // Get data from database. speciesFacts = new List <WebSpeciesFact>(); using (DataReader dataReader = context.GetTaxonAttributeDatabase().GetSpeciesFactsBySearchCriteria(searchCriteria.GetQuery(WebSpeciesFactSearchCriteriaExtension.QuerySelectPart.QueryDefault), searchCriteria.FactorDataTypeIds, searchCriteria.FactorIds, searchCriteria.HostIds, searchCriteria.TaxonIds)) { while (dataReader.Read()) { speciesFact = new WebSpeciesFact(); speciesFact.LoadData(dataReader); speciesFacts.Add(speciesFact); if (speciesFacts.Count > Settings.Default.MaxSpeciesFacts) { // Exceeding max numbers of species facts that // can be retrieved in one request. throw new ArgumentException("Max " + Settings.Default.MaxSpeciesFacts + " species facts can be retrieved in one call."); } } } return(speciesFacts); }
/// <summary> /// Get information about taxa that matches search criteria. /// </summary> /// <param name="clientInformation">Information about the client that makes this web service call.</param> /// <param name="searchCriteria">Species fact search criteria.</param> /// <returns>List of Taxa ids that matches search criteria.</returns> public List <WebTaxon> GetTaxaBySearchCriteria(WebClientInformation clientInformation, WebSpeciesFactSearchCriteria searchCriteria) { using (ClientProxy client = new ClientProxy(this, 2)) { return(client.Client.GetTaxaBySearchCriteria(clientInformation, searchCriteria)); } }
/// <summary> /// The get species facts. /// </summary> /// <returns> /// The <see cref="IEnumerable"/>. /// </returns> private static IEnumerable <ArtDatabanken.WebService.Data.WebSpeciesFact> GetSpeciesFacts(WebServiceContext webContext) { WebSpeciesFactSearchCriteria webUserParameterSelection = new WebSpeciesFactSearchCriteria(); webUserParameterSelection.IncludeNotValidHosts = true; webUserParameterSelection.IncludeNotValidTaxa = true; webUserParameterSelection.FactorIds = new List <Int32>(); // ActionPlan webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.ActionPlan); // Redlist webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.RedlistCategory); // Natura 2000 webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.Natura2000BirdsDirective); webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.Natura2000HabitatsDirectiveArticle2); webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.Natura2000HabitatsDirectiveArticle4); webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.Natura2000HabitatsDirectiveArticle5); // ProtectionLevel webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.ProtectionLevel); // ProtectedByLaw webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.ProtectedByLaw); // SwedishHistory webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.SwedishHistory); // SwedishOccurrence webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.SwedishOccurrence); // Redlist_OrganismLabel1 webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.Redlist_OrganismLabel1); // DisturbanceRadius webUserParameterSelection.FactorIds.Add((Int32)ArtDatabanken.Data.FactorId.DisturbanceRadius); webUserParameterSelection.IndividualCategoryIds = new List <Int32>(); WebIndividualCategory individualcategory = WebServiceData.FactorManager.GetDefaultIndividualCategory(webContext); webUserParameterSelection.IndividualCategoryIds.Add(individualcategory.Id); webUserParameterSelection.PeriodIds = new List <Int32>(); // webUserParameterSelection.PeriodIds.Add(WebServiceData.FactorManager.GetCurrentPublicPeriod(webContext).Id); webUserParameterSelection.PeriodIds.Add((Int32)(PeriodId.Year2015)); // Get data from web service. List <ArtDatabanken.WebService.Data.WebSpeciesFact> webSpeciesFacts = WebServiceData.SpeciesFactManager.GetSpeciesFactsBySearchCriteria(webContext, webUserParameterSelection); return(webSpeciesFacts); }
/// <summary> /// Get unique taxa for all species facts /// that matches search criteria. /// </summary> /// <param name="clientInformation">Information about the client that makes this web service call.</param> /// <param name="searchCriteria">Species fact search criteria.</param> /// <returns>Taxa for all species facts that matches search criteria.</returns> public List <WebTaxon> GetTaxaBySpeciesFactSearchCriteria(WebClientInformation clientInformation, WebSpeciesFactSearchCriteria searchCriteria) { using (WebServiceContext context = GetWebServiceContext(clientInformation)) { try { return(AnalysisManager.GetTaxaBySpeciesFactSearchCriteria(context, searchCriteria)); } catch (Exception exception) { WebServiceData.LogManager.LogError(context, exception); throw; } } }
public void GetSpeciesFactsBySearchCriteriaFactFieldSearchCriteria() { // Test String species fact field condition in combination with Enum String. List <WebSpeciesFact> speciesFacts1; WebSpeciesFactSearchCriteria searchCriteria; searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(1001); searchCriteria.FieldLogicalOperator = LogicalOperator.Or; // Test List of Enums as String species fact field condition. searchCriteria.FieldSearchCriteria = new List <WebSpeciesFactFieldSearchCriteria>(); searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[0].FactorField = GetFactorField(52, "tal1"); Assert.IsTrue(searchCriteria.FieldSearchCriteria[0].FactorField.IsEnumField, "Choose other factor field that has enum fields. I.e. tal1."); searchCriteria.FieldSearchCriteria[0].IsEnumAsString = false; searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Equal; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("1"); searchCriteria.FieldSearchCriteria[0].Values.Add("2"); // Test String species fact field condition. searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[1].FactorField = GetFactorField(52, "text2"); searchCriteria.FieldSearchCriteria[1].Operator = CompareOperator.Like; searchCriteria.FieldSearchCriteria[1].Values = new List <String>(); searchCriteria.FieldSearchCriteria[1].Values.Add("bedömd för adulter"); // Test Double species fact field condition. searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[2].FactorField = GetFactorField(52, "tal2"); searchCriteria.FieldSearchCriteria[2].Operator = CompareOperator.GreaterOrEqual; searchCriteria.FieldSearchCriteria[2].Values = new List <String>(); searchCriteria.FieldSearchCriteria[2].Values.Add("11"); // Test Double species fact field condition. searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[3].FactorField = GetFactorField(52, "tal3"); searchCriteria.FieldSearchCriteria[3].Operator = CompareOperator.LessOrEqual; searchCriteria.FieldSearchCriteria[3].Values = new List <String>(); searchCriteria.FieldSearchCriteria[3].Values.Add("22"); speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); }
/// <summary> /// Convert a ISpeciesFactSearchCriteria instance /// to a WebSpeciesFactSearchCriteria instance. /// </summary> /// <param name="searchCriteria">An ISpeciesFactSearchCriteria object.</param> /// <returns>A WebSpeciesFactSearchCriteria object.</returns> protected WebSpeciesFactSearchCriteria GetSpeciesFactSearchCriteria(ISpeciesFactSearchCriteria searchCriteria) { WebSpeciesFactSearchCriteria webSearchCriteria; webSearchCriteria = new WebSpeciesFactSearchCriteria(); if (searchCriteria.IsNotNull()) { if (searchCriteria.FactorDataTypes.IsNotEmpty()) { webSearchCriteria.FactorDataTypeIds = searchCriteria.FactorDataTypes.GetIds(); } if (searchCriteria.Factors.IsNotEmpty()) { webSearchCriteria.FactorIds = searchCriteria.Factors.GetIds(); } webSearchCriteria.FieldLogicalOperator = searchCriteria.FieldLogicalOperator; webSearchCriteria.FieldSearchCriteria = GetSpeciesFactFieldSearchCriteria(searchCriteria.FieldSearchCriteria); if (searchCriteria.Hosts.IsNotEmpty()) { webSearchCriteria.HostIds = searchCriteria.Hosts.GetIds(); } webSearchCriteria.IncludeNotValidHosts = searchCriteria.IncludeNotValidHosts; webSearchCriteria.IncludeNotValidTaxa = searchCriteria.IncludeNotValidTaxa; if (searchCriteria.IndividualCategories.IsNotEmpty()) { webSearchCriteria.IndividualCategoryIds = searchCriteria.IndividualCategories.GetIds(); } if (searchCriteria.Periods.IsNotEmpty()) { webSearchCriteria.PeriodIds = searchCriteria.Periods.GetIds(); } if (searchCriteria.Taxa.IsNotEmpty()) { webSearchCriteria.TaxonIds = searchCriteria.Taxa.GetIds(); } } return(webSearchCriteria); }
public void GetTaxaBySearchCriteriaFactFieldSearchCriteria() { List <WebTaxon> taxa; WebSpeciesFactSearchCriteria searchCriteria; searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(1001); searchCriteria.FieldLogicalOperator = LogicalOperator.Or; searchCriteria.FieldSearchCriteria = new List <WebSpeciesFactFieldSearchCriteria>(); // Test Double species fact field condition. searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[0].FactorField = GetFactorField(52, "tal2"); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.GreaterOrEqual; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("11"); taxa = SpeciesFactManager.GetTaxaBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(taxa.Count > 0); // Test String species fact field condition. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.FieldSearchCriteria = new List <WebSpeciesFactFieldSearchCriteria>(); searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[0].FactorField = GetFactorField(30, "text1"); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Equal; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("VU"); taxa = SpeciesFactManager.GetTaxaBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Like; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("%VU%"); taxa = SpeciesFactManager.GetTaxaBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Equal; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("V'U"); taxa = SpeciesFactManager.GetTaxaBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(taxa.IsEmpty()); }
public void GetTaxaBySpeciesFactSearchCriteria() { List <WebTaxon> taxa; WebSpeciesFactSearchCriteria searchCriteria; searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IncludeNotValidHosts = true; searchCriteria.IncludeNotValidTaxa = true; searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.PeriodIds = new List <Int32>(); searchCriteria.PeriodIds.Add(4); // 2015 taxa = WebServiceProxy.AnalysisService.GetTaxaBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IncludeNotValidHosts = true; searchCriteria.IncludeNotValidTaxa = true; searchCriteria.HostIds = new List <Int32>(); searchCriteria.HostIds.Add(102656); // Hedsidenbi. taxa = WebServiceProxy.AnalysisService.GetTaxaBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IndividualCategoryIds = new List <Int32>(); searchCriteria.IndividualCategoryIds.Add(9); // Ungar (juveniler) taxa = WebServiceProxy.AnalysisService.GetTaxaBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); searchCriteria.IndividualCategoryIds.Add(10); // Vuxna (imago). taxa = WebServiceProxy.AnalysisService.GetTaxaBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IncludeNotValidHosts = true; searchCriteria.IncludeNotValidTaxa = true; searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.PeriodIds = new List <Int32>(); searchCriteria.PeriodIds.Add(4); // 2015 taxa = WebServiceProxy.AnalysisService.GetTaxaBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); searchCriteria.PeriodIds.Add(5); // 2013 HELCOM taxa = WebServiceProxy.AnalysisService.GetTaxaBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IncludeNotValidHosts = true; searchCriteria.IncludeNotValidTaxa = true; searchCriteria.PeriodIds = new List <Int32>(); searchCriteria.PeriodIds.Add(4); // 2015 searchCriteria.IndividualCategoryIds = new List <Int32>(); searchCriteria.IndividualCategoryIds.Add(10); // Vuxna (imago). taxa = WebServiceProxy.AnalysisService.GetTaxaBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IncludeNotValidHosts = true; searchCriteria.IncludeNotValidTaxa = true; searchCriteria.TaxonIds = new List <Int32>(); searchCriteria.TaxonIds.Add((Int32)(TaxonId.DrumGrasshopper)); taxa = WebServiceProxy.AnalysisService.GetTaxaBySpeciesFactSearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(taxa.IsNotEmpty()); }
/// <summary> /// Get taxa that matches fact search criteria. /// </summary> /// <param name="context">Web service request context.</param> /// <param name="searchCriteria">Species fact search criteria.</param> /// <returns>Taxa that matches fact search criteria.</returns> public static List <WebTaxon> GetTaxaBySearchCriteria(WebServiceContext context, WebSpeciesFactSearchCriteria searchCriteria) { List <Int32> taxonIds = new List <int>(); // Check arguments. searchCriteria.CheckNotNull("searchCriteria"); searchCriteria.CheckData(); // Get list of taxon ids from database. using (DataReader dataReader = context.GetTaxonAttributeDatabase().GetSpeciesFactsBySearchCriteria(searchCriteria.GetQuery(WebSpeciesFactSearchCriteriaExtension.QuerySelectPart.QueryTaxonIds), searchCriteria.FactorDataTypeIds, searchCriteria.FactorIds, searchCriteria.HostIds, searchCriteria.TaxonIds)) { while (dataReader.Read()) { // Gather distinct list of taxon ids if (!taxonIds.Contains(dataReader.GetInt32(SpeciesFactData.TAXON_ID))) { taxonIds.Add(dataReader.GetInt32(SpeciesFactData.TAXON_ID)); } if (taxonIds.Count > Settings.Default.MaxSpeciesFacts) { // Exceeding max numbers of taxa that // can be retrieved in one request. throw new ArgumentException("Max " + Settings.Default.MaxSpeciesFacts + " taxa can be retrieved in one call."); } } } // Get list of taxa by list of taxon ids return(WebServiceData.TaxonManager.GetTaxaByIds(context, taxonIds)); }
/// <summary> /// Get taxon count of the taxa that matches fact search criteria. /// </summary> /// <param name="clientInformation">Information about the client that makes this web service call.</param> /// <param name="searchCriteria">Species fact search criteria.</param> /// <returns>Taxon count of the taxa that matches fact search criteria.</returns> public Int32 GetTaxaCountBySearchCriteria(WebClientInformation clientInformation, WebSpeciesFactSearchCriteria searchCriteria) { using (WebServiceContext context = GetWebServiceContext(clientInformation)) { try { return(SpeciesFactManager.GetTaxaCountBySearchCriteria(context, searchCriteria)); } catch (Exception exception) { WebServiceData.LogManager.LogError(context, exception); throw; } } }
public void GetSpeciesFactsBySearchCriteria() { List <WebSpeciesFact> speciesFacts1, speciesFacts2; WebSpeciesFactSearchCriteria searchCriteria; // Test factor data types. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorDataTypeIds = new List <Int32>(); searchCriteria.FactorDataTypeIds.Add(106); // SA_KvalitativaKaraktärer. speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(2547); // 2:e gångbenparet lång relativt kroppslängden, ben/kroppslängd kvot = 2-8 speciesFacts2 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts2.IsNotEmpty()); Assert.IsTrue(speciesFacts1.Count > speciesFacts2.Count); // Test factors. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.PeriodIds = new List <Int32>(); searchCriteria.PeriodIds.Add(2); // 2010 speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.HostIds = new List <Int32>(); searchCriteria.HostIds.Add(102656); // Hedsidenbi. speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IndividualCategoryIds = new List <Int32>(); searchCriteria.IndividualCategoryIds.Add(9); // Ungar (juveniler) speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria.IndividualCategoryIds.Add(10); // Vuxna (imago). speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.PeriodIds = new List <Int32>(); searchCriteria.PeriodIds.Add(1); // 2000 speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria.PeriodIds.Add(2); // 2005 speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); // Test include not valid hosts. // Hard to test since there are no host values // in database that belongs to not valid taxa. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(5); searchCriteria.IncludeNotValidHosts = false; speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(5); searchCriteria.IncludeNotValidHosts = true; speciesFacts2 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts2.IsNotEmpty()); Assert.IsTrue(speciesFacts2.Count >= speciesFacts1.Count); // Test include not valid taxa. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(5); searchCriteria.IncludeNotValidTaxa = false; speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(5); searchCriteria.IncludeNotValidTaxa = true; speciesFacts2 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts2.IsNotEmpty()); Assert.IsTrue(speciesFacts2.Count > speciesFacts1.Count); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.PeriodIds = new List <Int32>(); searchCriteria.PeriodIds.Add(3); // 2010 searchCriteria.IndividualCategoryIds = new List <Int32>(); searchCriteria.IndividualCategoryIds.Add(10); // Vuxna (imago). speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.TaxonIds = new List <Int32>(); searchCriteria.TaxonIds.Add((Int32)(TaxonId.DrumGrasshopper)); speciesFacts1 = WebServiceProxy.TaxonAttributeService.GetSpeciesFactsBySearchCriteria(GetClientInformation(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); }
public void GetSpeciesFactsBySearchCriteria() { List <WebSpeciesFact> speciesFacts1, speciesFacts2; WebSpeciesFactSearchCriteria searchCriteria; // Test factor data types. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorDataTypeIds = new List <Int32>(); searchCriteria.FactorDataTypeIds.Add(106); // SA_KvalitativaKaraktärer. speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(2547); // 2:e gångbenparet lång relativt kroppslängden, ben/kroppslängd kvot = 2-8 speciesFacts2 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts2.IsNotEmpty()); Assert.IsTrue(speciesFacts1.Count > speciesFacts2.Count); // Test factors. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.PeriodIds = new List <Int32>(); searchCriteria.PeriodIds.Add(2); // 2010 speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); // Test hosts. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.HostIds = new List <Int32>(); searchCriteria.HostIds.Add(102656); // Hedsidenbi. speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); // Test include not valid hosts. // Hard to test since there are no host values // in database that belongs to not valid taxa. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(5); searchCriteria.IncludeNotValidHosts = false; speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(5); searchCriteria.IncludeNotValidHosts = true; speciesFacts2 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts2.IsNotEmpty()); Assert.IsTrue(speciesFacts2.Count >= speciesFacts1.Count); // Test include not valid taxa. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(5); searchCriteria.IncludeNotValidTaxa = false; speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(5); searchCriteria.IncludeNotValidTaxa = true; speciesFacts2 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts2.IsNotEmpty()); Assert.IsTrue(speciesFacts2.Count > speciesFacts1.Count); // Test individual categories. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.IndividualCategoryIds = new List <Int32>(); searchCriteria.IndividualCategoryIds.Add(9); // Ungar (juveniler) speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria.IndividualCategoryIds.Add(10); // Vuxna (imago). speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); // Test periods. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.PeriodIds = new List <Int32>(); searchCriteria.PeriodIds.Add(1); // 2000 speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria.PeriodIds.Add(2); // 2005 speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); // Test periods and individual categories. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.PeriodIds = new List <Int32>(); searchCriteria.PeriodIds.Add(3); // 2010 searchCriteria.IndividualCategoryIds = new List <Int32>(); searchCriteria.IndividualCategoryIds.Add(10); // Vuxna (imago). speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); // Test taxa. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.TaxonIds = new List <Int32>(); searchCriteria.TaxonIds.Add((Int32)(TaxonId.DrumGrasshopper)); speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); // Test Boolean species fact field condition. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.FieldSearchCriteria = new List <WebSpeciesFactFieldSearchCriteria>(); searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[0].FactorField = GetFactorField(30, "tal2"); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Equal; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add(Boolean.TrueString); speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); // Test Float64 species fact field condition. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add(2547); // 2:e gångbenparet lång relativt kroppslängden, ben/kroppslängd kvot = 2-8 searchCriteria.FieldSearchCriteria = new List <WebSpeciesFactFieldSearchCriteria>(); searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[0].FactorField = GetFactorField(106, "tal1"); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Greater; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("0"); speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Greater; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("2"); speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsEmpty()); // Test Int32 species fact field condition. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.FieldSearchCriteria = new List <WebSpeciesFactFieldSearchCriteria>(); searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[0].FactorField = GetFactorField(30, "tal1"); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Equal; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add(2.WebToString()); // CR searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[1].FactorField = GetFactorField(30, "tal1"); searchCriteria.FieldSearchCriteria[1].Operator = CompareOperator.Equal; searchCriteria.FieldSearchCriteria[1].Values = new List <String>(); searchCriteria.FieldSearchCriteria[1].Values.Add(3.WebToString()); // EN searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[2].FactorField = GetFactorField(30, "tal1"); searchCriteria.FieldSearchCriteria[2].Operator = CompareOperator.Equal; searchCriteria.FieldSearchCriteria[2].Values = new List <String>(); searchCriteria.FieldSearchCriteria[2].Values.Add(4.WebToString()); // VU searchCriteria.FieldLogicalOperator = LogicalOperator.Or; speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); // Test String species fact field condition. searchCriteria = new WebSpeciesFactSearchCriteria(); searchCriteria.FactorIds = new List <Int32>(); searchCriteria.FactorIds.Add((Int32)(FactorId.RedlistCategory)); searchCriteria.FieldSearchCriteria = new List <WebSpeciesFactFieldSearchCriteria>(); searchCriteria.FieldSearchCriteria.Add(new WebSpeciesFactFieldSearchCriteria()); searchCriteria.FieldSearchCriteria[0].FactorField = GetFactorField(30, "text1"); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Equal; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("VU"); speciesFacts1 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts1.IsNotEmpty()); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Like; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("%VU%"); speciesFacts2 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts2.IsNotEmpty()); Assert.IsTrue(speciesFacts1.Count < speciesFacts2.Count); searchCriteria.FieldSearchCriteria[0].Operator = CompareOperator.Equal; searchCriteria.FieldSearchCriteria[0].Values = new List <String>(); searchCriteria.FieldSearchCriteria[0].Values.Add("V'U"); speciesFacts2 = SpeciesFactManager.GetSpeciesFactsBySearchCriteria(GetContext(), searchCriteria); Assert.IsTrue(speciesFacts2.IsEmpty()); }