/// <summary>
        /// Method that returns a filtered version of this species fact list. The filtering is done on factors
        /// </summary>
        /// <param name="factors"></param>
        /// <returns>A filtered SpeciesFactList</returns>
        public SpeciesFactList FilterSpeciesFacts(FactorList factors)
        {
            if (factors == null)
            {
                throw new ArgumentException("FactorList is null", "factors");
            }

            SpeciesFactList filteredList = new SpeciesFactList();

            //if (originalList.Count > factors.Count)
            {
                foreach (SpeciesFact fact in this)
                {
                    foreach (Factor factor in factors)
                    {
                        if (fact.Factor.Id == factor.Id)
                        {
                            filteredList.Add(fact);
                            break;
                        }
                    }
                }
            }

            return(filteredList);
        }
        /// <summary>
        /// Method that returns a filtered version of this species fact list. The filtering is done on hosts
        /// </summary>
        /// <param name="hosts"></param>
        /// <returns>A filtered SpeciesFactList</returns>
        public SpeciesFactList FilterSpeciesFactsHosts(TaxonList hosts)
        {
            if (hosts == null)
            {
                throw new ArgumentException("TaxonList is null", "hosts");
            }

            SpeciesFactList filteredList = new SpeciesFactList();

            //if (originalList.Count > hosts.Count)
            {
                foreach (SpeciesFact fact in this)
                {
                    foreach (Taxon host in hosts)
                    {
                        if (fact.Host.Id == host.Id)
                        {
                            filteredList.Add(fact);
                            break;
                        }
                    }
                }
            }

            return(filteredList);
        }
        /// <summary>
        /// Method that returns a filtered version of this species fact list. The filtering is done on Periods
        /// </summary>
        /// <param name="periods"></param>
        /// <returns>A filtered SpeciesFactList</returns>
        public SpeciesFactList FilterSpeciesFacts(PeriodList periods)
        {
            if (periods == null)
            {
                throw new ArgumentException("PeriodList is null", "periods");
            }

            SpeciesFactList filteredList = new SpeciesFactList();

            //if (originalList.Count > periods.Count)
            {
                foreach (SpeciesFact fact in this)
                {
                    foreach (Period period in periods)
                    {
                        if (fact.Period.Id == period.Id)
                        {
                            filteredList.Add(fact);
                            break;
                        }
                    }
                }
            }

            return(filteredList);
        }
        /// <summary>
        /// Method that returns a filtered version of this species fact list. The filtering is done on Taxa
        /// </summary>
        /// <param name="taxa"></param>
        /// <returns>A filtered SpeciesFactList</returns>
        public SpeciesFactList FilterSpeciesFacts(TaxonList taxa)
        {
            if (taxa == null)
            {
                throw new ArgumentException("TaxonList is null", "taxa");
            }

            SpeciesFactList filteredList = new SpeciesFactList();

            //if (originalList.Count > taxa.Count)
            {
                foreach (SpeciesFact fact in this)
                {
                    foreach (Taxon taxon in taxa)
                    {
                        if (fact.Taxon.Id == taxon.Id)
                        {
                            filteredList.Add(fact);
                            break;
                        }
                    }
                }
            }
            return(filteredList);
        }
        /// <summary>
        /// Method that returns a filtered version of this species fact list. The filtering is done on Individual Categories
        /// </summary>
        /// <param name="individualCategories"></param>
        /// <returns>A filtered SpeciesFactList</returns>
        public SpeciesFactList FilterSpeciesFacts(IndividualCategoryList individualCategories)
        {
            if (individualCategories == null)
            {
                throw new ArgumentException("CategoryList is null", "individualCategories");
            }

            SpeciesFactList filteredList = new SpeciesFactList();

            {
                foreach (SpeciesFact fact in this)
                {
                    foreach (IndividualCategory category in individualCategories)
                    {
                        if (fact.IndividualCategory.Id == category.Id)
                        {
                            filteredList.Add(fact);
                            break;
                        }
                    }
                }
            }
            return(filteredList);
        }
        /// <summary>
        /// Method that returns a filtered version of this species fact list. The filtering is done on several parameters.
        /// </summary>
        /// <param name="individualCategories"></param>
        /// <param name="periods"></param>
        /// <param name="hosts"></param>
        /// <param name="taxa"></param>
        /// <param name="factors"></param>
        /// <returns>A filtered SpeciesFactList</returns>
        public SpeciesFactList FilterSpeciesFacts(
            IndividualCategoryList individualCategories,
            PeriodList periods,
            TaxonList hosts,
            TaxonList taxa,
            FactorList factors)
        {
            SpeciesFactList filteredList = new SpeciesFactList();

            foreach (SpeciesFact fact in this)
            {
                bool go = true;

                if (fact.IndividualCategory != null)
                {
                    if ((individualCategories != null) && (individualCategories.Count > 0))
                    {
                        if (!individualCategories.Exists(fact.IndividualCategory))
                        {
                            go = false;
                        }
                    }
                }

                if (go)
                {
                    if (fact.Period != null)
                    {
                        if ((periods != null) && (periods.Count > 0))
                        {
                            if (!periods.Exists(fact.Period))
                            {
                                go = false;
                            }
                        }
                    }
                }
                if (go)
                {
                    if (fact.Host != null)
                    {
                        // For the time being we only accept species facts that dont have a host.

                        go = false;

                        //if ((hosts != null) && (hosts.Count > 0))
                        //{
                        //    if (!hosts.Exists(fact.Host))
                        //        go = false;
                        //}
                    }
                }
                if (go)
                {
                    if (fact.Taxon != null)
                    {
                        if ((taxa != null) && (taxa.Count > 0))
                        {
                            if (!taxa.Exists(fact.Taxon))
                            {
                                go = false;
                            }
                        }
                    }
                }
                if (go)
                {
                    if (fact.Factor != null)
                    {
                        if ((factors != null) && (factors.Count > 0))
                        {
                            if (!factors.Exists(fact.Factor))
                            {
                                go = false;
                            }
                        }
                    }
                }

                if (go)
                {
                    filteredList.Add(fact);
                }
            }

            return(filteredList);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Bind species fact to related member.
        /// </summary>
        private void SetParagraphSpeciesFacts()
        {
            SpeciesFactList speciesFacts;

            _italicStringsInAutomaticTaxonomicParagraph = new List <String>();
            if (_speciesFacts.IsNotEmpty())
            {
                speciesFacts = new SpeciesFactList();
                foreach (SpeciesFact speciesFact in _speciesFacts)
                {
                    switch (speciesFact.Factor.Id)
                    {
                    case (Int32)FactorId.SpeciesInformationDocumentTaxonomicInformation:
                        speciesFacts.Add(speciesFact);
                        _taxonomicParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentDescription:
                        speciesFacts.Add(speciesFact);
                        _descriptionParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentDistribution:
                        speciesFacts.Add(speciesFact);
                        _distributionParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentEcology:
                        speciesFacts.Add(speciesFact);
                        _ecologyParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentThreats:
                        speciesFacts.Add(speciesFact);
                        _threatsParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentMeasures:
                        speciesFacts.Add(speciesFact);
                        _measuresParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentExtra:
                        speciesFacts.Add(speciesFact);
                        _extraParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentReferences:
                        speciesFacts.Add(speciesFact);
                        _referencesParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentAuthorAndYear:
                        speciesFacts.Add(speciesFact);
                        _authorParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentItalicsInReferences:
                        speciesFacts.Add(speciesFact);
                        _italicsInReferencesParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentItalicsInText:
                        speciesFacts.Add(speciesFact);
                        _italicsInTextParagraphSpeciesFact = speciesFact;
                        break;

                    case (Int32)FactorId.SpeciesInformationDocumentIsPublishable:
                        speciesFacts.Add(speciesFact);
                        _isPublishable = speciesFact;
                        break;
                    }
                }

                // Make sure that only species facts that belong
                // to this SpeciesInformationDocument is handled.
                _speciesFacts = speciesFacts;
            }
        }