Exemplo n.º 1
0
        public void GetField5MaxLength()
        {
            Int32 maxStringLength;

            maxStringLength = WebSpeciesFact.GetField5MaxLength(GetContext());
            Assert.IsTrue(0 < maxStringLength);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get all species facts.
        /// </summary>
        /// <param name="context">Web service request context.</param>
        /// <param name="speciesFactIds">Ids for speciesFacts to get information about.</param>
        /// <returns>SpeciesFacts information.</returns>
        public static List <WebSpeciesFact> GetSpeciesFactsByIds(WebServiceContext context, List <int> speciesFactIds)
        {
            List <WebSpeciesFact> speciesFacts;
            WebSpeciesFact        speciesFact;

            // Check arguments.
            speciesFactIds.CheckNotEmpty("speciesFactIds");
            if (speciesFactIds.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.");
            }

            // Get data from database.
            speciesFacts = new List <WebSpeciesFact>();
            using (DataReader dataReader = context.GetTaxonAttributeDatabase().GetSpeciesFactsByIds(speciesFactIds))
            {
                while (dataReader.Read())
                {
                    speciesFact = new WebSpeciesFact();
                    speciesFact.LoadData(dataReader);
                    speciesFacts.Add(speciesFact);
                }
            }

            if (speciesFacts.Count != speciesFactIds.Count)
            {
                // Probably invalid speciesFact ids.
                throw new ArgumentException("Invalid speciesFact ids!");
            }

            return(speciesFacts);
        }
 /// <summary>
 /// Load data into the WebSpeciesFact instance.
 /// </summary>
 /// <param name="speciesFact">The species fact instance.</param>
 /// <param name='dataReader'>An open data reader.</param>
 public static void LoadData(this WebSpeciesFact speciesFact,
                             DataReader dataReader)
 {
     speciesFact.FactorId               = dataReader.GetInt32(SpeciesFactData.FACTOR_ID);
     speciesFact.FieldValue1            = dataReader.GetDouble(SpeciesFactData.FIELD_VALUE_1, -99);
     speciesFact.FieldValue2            = dataReader.GetDouble(SpeciesFactData.FIELD_VALUE_2, -99);
     speciesFact.FieldValue3            = dataReader.GetDouble(SpeciesFactData.FIELD_VALUE_3, -99);
     speciesFact.FieldValue4            = dataReader.GetString(SpeciesFactData.FIELD_VALUE_4);
     speciesFact.FieldValue5            = dataReader.GetString(SpeciesFactData.FIELD_VALUE_5);
     speciesFact.HostId                 = dataReader.GetInt32(SpeciesFactData.HOST_ID, -1);
     speciesFact.Id                     = dataReader.GetInt32(SpeciesFactData.ID);
     speciesFact.IndividualCategoryId   = dataReader.GetInt32(SpeciesFactData.INDIVIDUAL_CATEGORY_ID);
     speciesFact.IsFieldValue1Specified = dataReader.IsNotDbNull(SpeciesFactData.FIELD_VALUE_1);
     speciesFact.IsFieldValue2Specified = dataReader.IsNotDbNull(SpeciesFactData.FIELD_VALUE_2);
     speciesFact.IsFieldValue3Specified = dataReader.IsNotDbNull(SpeciesFactData.FIELD_VALUE_3);
     speciesFact.IsFieldValue4Specified = dataReader.IsNotDbNull(SpeciesFactData.FIELD_VALUE_4);
     speciesFact.IsFieldValue5Specified = dataReader.IsNotDbNull(SpeciesFactData.FIELD_VALUE_5);
     speciesFact.IsHostSpecified        = speciesFact.HostId > 0;
     speciesFact.IsPeriodSpecified      = dataReader.IsNotDbNull(SpeciesFactData.PERIOD_ID);
     speciesFact.ModifiedBy             = dataReader.GetString(SpeciesFactData.UPDATE_PERSON);
     speciesFact.ModifiedDate           = dataReader.GetDateTime(SpeciesFactData.UPDATE_DATE, new DateTime(2000, 1, 1));
     speciesFact.PeriodId               = dataReader.GetInt32(SpeciesFactData.PERIOD_ID, -1);
     speciesFact.QualityId              = dataReader.GetInt32(SpeciesFactData.QUALITY_ID, -1);
     speciesFact.ReferenceId            = dataReader.GetInt32(SpeciesFactData.REFERENCE_ID, -1);
     speciesFact.TaxonId                = dataReader.GetInt32(SpeciesFactData.TAXON_ID);
 }
Exemplo n.º 4
0
        public void CreateSpeciesFacts()
        {
            List <int> speciesFactIds = new List <int> {
                1
            };
            WebSpeciesFact speciesFact = SpeciesFactManager.GetSpeciesFactsByIds(GetContext(), speciesFactIds)[0], newSpeciesFact;
            DataTable      speciesFactsTable;
            int            newSpeciesFactId;

            speciesFact.FactorId               = 10;
            speciesFact.FieldValue1            = 10;
            speciesFact.IsFieldValue1Specified = true;
            speciesFact.IndividualCategoryId   = 2;
            speciesFact.TaxonId = 209210;
            speciesFactsTable   = SpeciesFactManager.GetSpeciesFactCreateTable(GetContext(),
                                                                               new List <WebSpeciesFact> {
                speciesFact
            },
                                                                               DateTime.Now,
                                                                               string.Empty);
            newSpeciesFactId = (int)speciesFactsTable.Rows[0]["idnr"];
            GetDatabase(true).CreateSpeciesFacts(speciesFactsTable);
            newSpeciesFact = SpeciesFactManager.GetSpeciesFactsByIds(GetContext(), new List <int> {
                newSpeciesFactId
            })[0];
            Assert.AreEqual(newSpeciesFact.Id, newSpeciesFactId);
        }
Exemplo n.º 5
0
        public void GetUpdateUserFullNameMaxLength()
        {
            Int32 maxStringLength;

            maxStringLength = WebSpeciesFact.GetUpdateUserFullNameMaxLength(GetContext());
            Assert.IsTrue(0 < maxStringLength);
        }
Exemplo n.º 6
0
        /// <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 species fact as string.
 /// </summary>
 /// <param name='speciesFact'>Species fact.</param>
 /// <returns>Information about species fact as string.</returns>
 public static String GetString(this WebSpeciesFact speciesFact)
 {
     return("FactorId = " + speciesFact.FactorId.WebToString() +
            ": FieldValue1 = " + speciesFact.FieldValue1.WebToString() +
            ": FieldValue2 = " + speciesFact.FieldValue2.WebToString() +
            ": FieldValue3 = " + speciesFact.FieldValue3.WebToString() +
            ": FieldValue4 = " + speciesFact.FieldValue4 +
            ": FieldValue5 = " + speciesFact.FieldValue5 +
            ": HostId = " + speciesFact.HostId.WebToString() +
            ": Id = " + speciesFact.Id.WebToString() +
            ": IndividualCategoryId = " + speciesFact.IndividualCategoryId.WebToString() +
            ": IsFieldValue1Specified = " + speciesFact.IsFieldValue1Specified.WebToString() +
            ": IsFieldValue2Specified = " + speciesFact.IsFieldValue2Specified.WebToString() +
            ": IsFieldValue3Specified = " + speciesFact.IsFieldValue3Specified.WebToString() +
            ": IsFieldValue4Specified = " + speciesFact.IsFieldValue4Specified.WebToString() +
            ": IsFieldValue5Specified = " + speciesFact.IsFieldValue5Specified.WebToString() +
            ": IsHostSpecified = " + speciesFact.IsHostSpecified.WebToString() +
            ": IsPeriodSpecified = " + speciesFact.IsPeriodSpecified.WebToString() +
            ": ModifiedBy = " + speciesFact.ModifiedBy +
            ": ModifiedDate = " + speciesFact.ModifiedDate.WebToString() +
            ": PeriodId = " + speciesFact.PeriodId.WebToString() +
            ": QualityId = " + speciesFact.QualityId.WebToString() +
            ": ReferenceId = " + speciesFact.ReferenceId.WebToString() +
            ": TaxonId = " + speciesFact.TaxonId.WebToString());
 }
Exemplo n.º 8
0
 private WebSpeciesFact GetSpeciesFact(Boolean refresh)
 {
     if (_speciesFact.IsNull() || refresh)
     {
         _speciesFact = SpeciesFactManagerTest.GetOneSpeciesFact(GetContext());
     }
     return(_speciesFact);
 }
        private void UpdateDyntaxaSpeciesFacts(WebSpeciesFact speciesFact)
        {
            List <WebSpeciesFact> speciesFacts;

            speciesFacts = new List <WebSpeciesFact>();
            speciesFacts.Add(speciesFact);
            SpeciesFactManager.UpdateDyntaxaSpeciesFacts(GetContext(), null, null, speciesFacts, "Dyntaxa Kindvall");
        }
        private void UpdateSpeciesFacts(WebSpeciesFact speciesFact)
        {
            List <WebSpeciesFact> speciesFacts;

            speciesFacts = new List <WebSpeciesFact>();
            speciesFacts.Add(speciesFact);
            SpeciesFactManager.UpdateSpeciesFacts(GetContext(), null, null, speciesFacts);
        }
        private WebSpeciesFact GetSpeciesFact(WebSpeciesFact speciesFact)
        {
            List <Int32> speciesFactIds;

            speciesFactIds = new List <Int32>();
            speciesFactIds.Add(speciesFact.Id);
            return(SpeciesFactManager.GetSpeciesFactsById(GetContext(), speciesFactIds)[0]);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Get species facts with specified identifiers.
        /// Only existing species facts are returned,
        /// e.g. species fact identifiers that does not
        /// match existing species fact does not affect
        /// the returned species facts.
        /// </summary>
        /// <param name="context">Web service request context.</param>
        /// <param name="speciesFactIdentifiers">
        /// Species facts identifiers. E.g. WebSpeciesFacts
        /// instances where id for requested combination of
        /// factor, host, individual category, period and taxon
        /// has been set.
        /// Host id is only used together with taxonomic factors.
        /// Period id is only used together with periodic factors.
        /// </param>
        /// <returns>
        /// Existing species facts among the
        /// requested species facts.
        /// </returns>
        public static List <WebSpeciesFact> GetSpeciesFactsByIdentifiers(WebServiceContext context,
                                                                         List <WebSpeciesFact> speciesFactIdentifiers)
        {
            DataTable             speciesFactIdentifiersTable;
            List <WebSpeciesFact> speciesFacts;
            Object         host, period;
            WebSpeciesFact speciesFact;

            // Check arguments.
            speciesFactIdentifiers.CheckNotEmpty("speciesFacts");
            if (speciesFactIdentifiers.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.");
            }

            // Get data from database.
            speciesFactIdentifiersTable = GetSpeciesFactIdentifiersTable();
            foreach (WebSpeciesFact webSpeciesFact in speciesFactIdentifiers)
            {
                if (webSpeciesFact.IsHostSpecified)
                {
                    host = webSpeciesFact.HostId;
                }
                else
                {
                    host = DBNull.Value;
                }

                if (webSpeciesFact.IsPeriodSpecified)
                {
                    period = webSpeciesFact.PeriodId;
                }
                else
                {
                    period = DBNull.Value;
                }

                speciesFactIdentifiersTable.Rows.Add(webSpeciesFact.TaxonId, webSpeciesFact.FactorId, webSpeciesFact.IndividualCategoryId, host, period);
            }

            speciesFacts = new List <WebSpeciesFact>();
            using (DataReader dataReader = context.GetTaxonAttributeDatabase().GetSpeciesFactsByIdentifiers(speciesFactIdentifiersTable))
            {
                while (dataReader.Read())
                {
                    speciesFact = new WebSpeciesFact();
                    speciesFact.LoadData(dataReader);
                    speciesFacts.Add(speciesFact);
                }
            }

            return(speciesFacts);
        }
Exemplo n.º 13
0
        public void UpdateSpeciesFacts()
        {
            List <int> speciesFactIds = new List <int> {
                1
            };
            WebSpeciesFact speciesFact = SpeciesFactManager.GetSpeciesFactsByIds(GetContext(), speciesFactIds)[0], updatedSpeciesFact;
            DataTable      speciesFactTable = SpeciesFactManager.GetSpeciesFactUpdateTable(GetContext(),
                                                                                           new List <WebSpeciesFact> {
                speciesFact
            });

            GetDatabase(true).UpdateSpeciesFacts(speciesFactTable);
            updatedSpeciesFact = SpeciesFactManager.GetSpeciesFactsByIds(GetContext(), speciesFactIds)[0];
            Assert.AreEqual(updatedSpeciesFact.ModifiedBy, "TestFirstName TestLastName");
        }
        public void GetSpeciesFactsByIdentifiers()
        {
            List <WebSpeciesFact> inSpeciesFacts, outSpeciesFacts;
            List <Int32>          speciesFactIds = new List <Int32> {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            WebSpeciesFact speciesFact;

            UseTransaction  = true;
            inSpeciesFacts  = SpeciesFactManager.GetSpeciesFactsByIds(GetContext(), speciesFactIds);
            outSpeciesFacts = SpeciesFactManager.GetSpeciesFactsByIdentifiers(GetContext(), inSpeciesFacts);
            Assert.AreEqual(inSpeciesFacts.Count, outSpeciesFacts.Count);

            UseTransaction  = false;
            inSpeciesFacts  = SpeciesFactManager.GetSpeciesFactsByIds(GetContext(), speciesFactIds);
            outSpeciesFacts = SpeciesFactManager.GetSpeciesFactsByIdentifiers(GetContext(), inSpeciesFacts);
            Assert.AreEqual(inSpeciesFacts.Count, outSpeciesFacts.Count);

            speciesFact                        = new WebSpeciesFact();
            speciesFact.FactorId               = 655;
            speciesFact.FieldValue1            = 0;
            speciesFact.FieldValue2            = 0;
            speciesFact.FieldValue3            = 0;
            speciesFact.FieldValue4            = "A";
            speciesFact.FieldValue5            = null;
            speciesFact.HostId                 = -1;
            speciesFact.Id                     = 2167795;
            speciesFact.IndividualCategoryId   = 0;
            speciesFact.IsFieldValue1Specified = false;
            speciesFact.IsFieldValue2Specified = false;
            speciesFact.IsFieldValue3Specified = false;
            speciesFact.IsFieldValue4Specified = true;
            speciesFact.IsFieldValue5Specified = false;
            speciesFact.IsHostSpecified        = false;
            speciesFact.IsPeriodSpecified      = true;
            speciesFact.ModifiedBy             = "";
            speciesFact.ModifiedDate           = DateTime.Now;
            speciesFact.PeriodId               = 4;
            speciesFact.QualityId              = 8;
            speciesFact.ReferenceId            = 524;
            speciesFact.TaxonId                = 700;
            inSpeciesFacts                     = new List <WebSpeciesFact>();
            inSpeciesFacts.Add(speciesFact);
            outSpeciesFacts = SpeciesFactManager.GetSpeciesFactsByIdentifiers(GetContext(), inSpeciesFacts);
            Assert.AreEqual(inSpeciesFacts.Count, outSpeciesFacts.Count);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Convert a WebSpeciesFact instance into
        /// an ISpeciesFact instance.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="webSpeciesFact">A WebSpeciesFact instance.</param>
        /// <param name="factors">List of factors.</param>
        /// <param name="individualCategories">List of individual categories.</param>
        /// <param name="periods">List of periods.</param>
        /// <param name="references">List of references.</param>
        /// <param name="speciesFactQualities">List of species fact qualities.</param>
        /// <param name="taxa">Taxa that are used in the species facts.</param>
        /// <returns>An ISpeciesFact instance.</returns>
        private ISpeciesFact GetSpeciesFact(IUserContext userContext,
                                            WebSpeciesFact webSpeciesFact,
                                            FactorList factors,
                                            IndividualCategoryList individualCategories,
                                            PeriodList periods,
                                            ReferenceList references,
                                            SpeciesFactQualityList speciesFactQualities,
                                            TaxonList taxa)
        {
            IFactor      factor;
            IPeriod      period;
            ISpeciesFact speciesFact;
            ITaxon       host, taxon;

            factor = factors.Get(webSpeciesFact.FactorId);
            if (webSpeciesFact.IsHostSpecified)
            {
#if EXAMINE_PROBLEM
                if (!(taxa.Contains(webSpeciesFact.HostId)))
                {
                    throw new Exception("Host with id = " + webSpeciesFact.HostId + " is not in taxon list." + webSpeciesFact.GetString());
                }
#endif

                host = taxa.Get(webSpeciesFact.HostId);
            }
            else
            {
                if (factor.IsTaxonomic)
                {
                    host = CoreData.TaxonManager.GetTaxon(userContext, 0);
                }
                else
                {
                    host = null;
                }
            }

            if (webSpeciesFact.IsPeriodSpecified)
            {
#if EXAMINE_PROBLEM
                if (!(periods.Contains(webSpeciesFact.PeriodId)))
                {
                    throw new Exception("Period with id = " + webSpeciesFact.PeriodId + " is not in period list." + webSpeciesFact.GetString());
                }
#endif

                period = periods.Get(webSpeciesFact.PeriodId);
            }
            else
            {
                period = null;
            }

#if EXAMINE_PROBLEM
            if (!(taxa.Contains(webSpeciesFact.TaxonId)))
            {
                throw new Exception("Taxon with id = " + webSpeciesFact.TaxonId + " is not in taxon list." + webSpeciesFact.GetString());
            }
#endif

            taxon = taxa.Get(webSpeciesFact.TaxonId);
#if EXAMINE_PROBLEM
            if (!(individualCategories.Contains(webSpeciesFact.IndividualCategoryId)))
            {
                throw new Exception("Individual category with id = " + webSpeciesFact.IndividualCategoryId + " is not in individual category list." + webSpeciesFact.GetString());
            }

            if (!(speciesFactQualities.Contains(webSpeciesFact.QualityId)))
            {
                throw new Exception("Quality with id = " + webSpeciesFact.QualityId + " is not in quality list." + webSpeciesFact.GetString());
            }

            if (!(references.Contains(webSpeciesFact.ReferenceId)))
            {
                throw new Exception("Reference with id = " + webSpeciesFact.ReferenceId + " is not in reference list." + webSpeciesFact.GetString());
            }
#endif

            speciesFact = CoreData.SpeciesFactManager.GetSpeciesFact(userContext,
                                                                     webSpeciesFact.Id,
                                                                     taxon,
                                                                     individualCategories.Get(webSpeciesFact.IndividualCategoryId),
                                                                     factor,
                                                                     host,
                                                                     period,
                                                                     webSpeciesFact.FieldValue1,
                                                                     webSpeciesFact.IsFieldValue1Specified,
                                                                     webSpeciesFact.FieldValue2,
                                                                     webSpeciesFact.IsFieldValue2Specified,
                                                                     webSpeciesFact.FieldValue3,
                                                                     webSpeciesFact.IsFieldValue3Specified,
                                                                     webSpeciesFact.FieldValue4,
                                                                     webSpeciesFact.IsFieldValue4Specified,
                                                                     webSpeciesFact.FieldValue5,
                                                                     webSpeciesFact.IsFieldValue5Specified,
                                                                     speciesFactQualities.Get(webSpeciesFact.QualityId),
                                                                     references.Get(webSpeciesFact.ReferenceId),
                                                                     webSpeciesFact.ModifiedBy,
                                                                     webSpeciesFact.ModifiedDate);

            return(speciesFact);
        }
Exemplo n.º 16
0
 public WebSpeciesFactTest()
 {
     _speciesFact = null;
 }
Exemplo n.º 17
0
        /// <summary>
        /// Converts an ISpeciesFact instance to a WebSpeciesFact instance.
        /// </summary>
        /// <param name="speciesFact">An ISpeciesFact instance.</param>
        /// <param name="defaultReference">Reference used if no reference is specified.</param>
        /// <returns>A WebSpeciesFact instance.</returns>
        private WebSpeciesFact GetWebSpeciesFact(ISpeciesFact speciesFact,
                                                 IReference defaultReference)
        {
            WebSpeciesFact webSpeciesFact = new WebSpeciesFact
            {
                FactorId             = speciesFact.Factor.Id,
                HostId               = speciesFact.HasHost ? speciesFact.Host.Id : -1,
                Id                   = speciesFact.Id,
                IndividualCategoryId = speciesFact.IndividualCategory.Id,
                IsHostSpecified      = speciesFact.HasHost,
                IsPeriodSpecified    = speciesFact.HasPeriod,
                ModifiedBy           = speciesFact.ModifiedBy,
                ModifiedDate         = speciesFact.ModifiedDate,
                PeriodId             = speciesFact.HasPeriod ? speciesFact.Period.Id : -1,
                QualityId            = speciesFact.Quality.Id,
                ReferenceId          = speciesFact.HasReference ? speciesFact.Reference.Id : defaultReference.Id,
                TaxonId              = speciesFact.Taxon.Id
            };

            foreach (ISpeciesFactField field in speciesFact.Fields)
            {
                switch (field.Index)
                {
                case 0:
                    webSpeciesFact.IsFieldValue1Specified = field.HasValue;
                    if (field.HasValue)
                    {
                        webSpeciesFact.FieldValue1 = field.GetDoubleValue();
                    }

                    break;

                case 1:
                    webSpeciesFact.IsFieldValue2Specified = field.HasValue;
                    if (field.HasValue)
                    {
                        webSpeciesFact.FieldValue2 = field.GetDoubleValue();
                    }

                    break;

                case 2:
                    webSpeciesFact.IsFieldValue3Specified = field.HasValue;
                    if (field.HasValue)
                    {
                        webSpeciesFact.FieldValue3 = field.GetDoubleValue();
                    }

                    break;

                case 3:
                    webSpeciesFact.IsFieldValue4Specified = field.HasValue;
                    if (field.HasValue)
                    {
                        webSpeciesFact.FieldValue4 = field.GetStringValue().Trim();
                    }

                    break;

                case 4:
                    webSpeciesFact.IsFieldValue5Specified = field.HasValue;
                    if (field.HasValue)
                    {
                        webSpeciesFact.FieldValue5 = field.GetStringValue().Trim();
                    }

                    break;

                default:
                    throw new Exception("Unknown data field!");
                }
            }

            return(webSpeciesFact);
        }
        /// <summary>
        /// Convert a WebSpeciesFact instance into
        /// an ISpeciesFact instance.
        /// </summary>
        /// <param name="webSpeciesFact">A WebSpeciesFact instance.</param>
        /// <param name="factors">List of factors.</param>
        /// <param name="individualCategories">List of individual categories.</param>
        /// <param name="periods">List of periods.</param>
        /// <returns>An ISpeciesFact instance.</returns>
        private ISpeciesFact GetSpeciesFact(
            WebSpeciesFact webSpeciesFact,
            FactorList factors,
            IndividualCategoryList individualCategories,
            PeriodList periods)
        {
            IFactor      factor;
            IPeriod      period;
            ISpeciesFact speciesFact;
            ITaxon       host, taxon;

            factor = factors.Get(webSpeciesFact.FactorId);
            if (webSpeciesFact.IsHostSpecified)
            {
                host    = new Data.Taxon();
                host.Id = webSpeciesFact.HostId;
            }
            else
            {
                if (factor.IsTaxonomic)
                {
                    host = new Data.Taxon {
                        Id = (int)TaxonId.Life
                    };
                }
                else
                {
                    host = null;
                }
            }

            if (webSpeciesFact.IsPeriodSpecified)
            {
                period = periods.Get(webSpeciesFact.PeriodId);
            }
            else
            {
                period = null;
            }

            taxon       = new Data.Taxon();
            taxon.Id    = webSpeciesFact.TaxonId;
            speciesFact = new SpeciesFact(
                webSpeciesFact.Id,
                taxon,
                individualCategories.Get(webSpeciesFact.IndividualCategoryId),
                factor,
                host,
                period,
                webSpeciesFact.FieldValue1,
                webSpeciesFact.IsFieldValue1Specified,
                webSpeciesFact.FieldValue2,
                webSpeciesFact.IsFieldValue2Specified,
                webSpeciesFact.FieldValue3,
                webSpeciesFact.IsFieldValue3Specified,
                webSpeciesFact.FieldValue4,
                webSpeciesFact.IsFieldValue4Specified,
                webSpeciesFact.FieldValue5,
                webSpeciesFact.IsFieldValue5Specified,
                null,
                null,
                webSpeciesFact.ModifiedBy,
                webSpeciesFact.ModifiedDate);

            return(speciesFact);
        }