/// <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 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);
        }
예제 #3
0
 /// <summary>
 /// Init calculation automatic species fact field values.
 /// </summary>
 /// <param name="speciesFacts">Species facts to get data from.</param>
 public void Init(SpeciesFactList speciesFacts)
 {
     if (AllowAutomaticUpdate)
     {
         SetTaxonNameValues();
     }
 }
        /// <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>
 /// Init calculation of red list criteria.
 /// </summary>
 /// <param name="speciesFacts">Species facts to get data from.</param>
 public override void Init(SpeciesFactList speciesFacts)
 {
     if (AllowAutomaticUpdate)
     {
         RedListCalculator = new RedListCalculator(Taxon.TaxonType.Name, Taxon.TaxonType.NameDefinite);
         RedListCalculator.IsCriteriaCalculated = false;
         base.Init(speciesFacts);
         SetReadListValues();
     }
 }
        /// <summary>
        /// Get a subset of this species fact list based on parameters
        /// </summary>
        /// <param name="individualCategory">The individual category for the requested species facts.</param>
        /// <returns>A species fact list</returns>
        public SpeciesFactList GetSpeciesFactsByParameters(IndividualCategory individualCategory)
        {
            SpeciesFactList speciesFacts = new SpeciesFactList();
            var             subset       = from SpeciesFact speciesFact in this
                                           where speciesFact.IndividualCategory.Id == individualCategory.Id
                                           select speciesFact;

            speciesFacts.AddRange(subset.ToArray());
            return(speciesFacts);
        }
        /// <summary>
        /// Get a subset of this species fact list based on parameters
        /// </summary>
        /// <param name="period">The period for the requested species facts.</param>
        /// <returns>A species fact list</returns>
        public SpeciesFactList GetSpeciesFactsByParameters(Period period)
        {
            SpeciesFactList speciesFacts = new SpeciesFactList();
            var             subset       = from SpeciesFact speciesFact in this
                                           where speciesFact.Period == period
                                           select speciesFact;

            speciesFacts.AddRange(subset.ToArray());
            return(speciesFacts);
        }
        /// <summary>
        /// Get a subset of this species fact list by quality
        /// </summary>
        /// <param name="quality">The quality for the requested species facts.</param>
        /// <returns>A species fact list</returns>
        public SpeciesFactList GetSpeciesFactsByQuality(SpeciesFactQuality quality)
        {
            SpeciesFactList speciesFacts = new SpeciesFactList();
            var             subset       = from SpeciesFact speciesFact in this
                                           where speciesFact.Quality == quality
                                           select speciesFact;

            speciesFacts.AddRange(subset.ToArray());
            return(speciesFacts);
        }
        /// <summary>
        /// Get a subset of this species fact list based on parameters
        /// </summary>
        /// <param name="factor">The factor for the requested species facts.</param>
        /// <returns>A species fact list</returns>
        public SpeciesFactList GetSpeciesFactsByParameters(Factor factor)
        {
            SpeciesFactList speciesFacts = new SpeciesFactList();
            var             subset       = from SpeciesFact speciesFact in this
                                           where speciesFact.Factor.Id == factor.Id
                                           orderby speciesFact.Taxon.SortOrder ascending
                                           select speciesFact;

            speciesFacts.AddRange(subset.ToArray());
            return(speciesFacts);
        }
        /// <summary>
        /// Get a subset of this species fact list based on parameters
        /// </summary>
        /// <param name="taxon">The taxon for the requested species facts.</param>
        /// <returns>A species fact list</returns>
        public SpeciesFactList GetSpeciesFactsByParameters(Taxon taxon)
        {
            SpeciesFactList speciesFacts = new SpeciesFactList();
            var             subset       = from SpeciesFact speciesFact in this
                                           where speciesFact.Taxon.Id == taxon.Id
                                           //where speciesFact.Taxon == taxon //denna kod fungera lika bra som rad ovan
                                           orderby speciesFact.Factor.SortOrder ascending
                                           select speciesFact;

            speciesFacts.AddRange(subset.ToArray());
            return(speciesFacts);
        }
예제 #11
0
 /// <summary>
 /// Creates a instance of a Species Information Document
 /// object based on a list of species facts.
 /// </summary>
 /// <param name="speciesFacts">The species facts related to species information document factors and a single taxon</param>
 /// <param name="period">Period for red list information.</param>
 public SpeciesEncyclopediaArticle(SpeciesFactList speciesFacts,
                                   Period period)
 {
     _period       = period;
     _speciesFacts = speciesFacts;
     if (_speciesFacts.IsEmpty())
     {
         _taxon = null;
     }
     else
     {
         _taxon = _speciesFacts[0].Taxon;
     }
     SetParagraphSpeciesFacts();
 }
 /// <summary>
 /// Creates a instance of a Species Information Document
 /// object based on a list of species facts.
 /// </summary>
 /// <param name="speciesFacts">The species facts related to species information document factors and a single taxon</param>
 /// <param name="period">Period for red list information.</param>
 public SpeciesInformationDocument(SpeciesFactList speciesFacts,
                                   Period period)
 {
     _period       = period;
     _speciesFacts = speciesFacts;
     if (_speciesFacts.IsEmpty())
     {
         _taxon = null;
     }
     else
     {
         _taxon = _speciesFacts[0].Taxon;
     }
     SetParagraphSpeciesFacts();
 }
예제 #13
0
        /// <summary>
        /// Get species facts with species document information.
        /// </summary>
        private void GetSpeciesFacts()
        {
            UserParameterSelection parameters = new UserParameterSelection();
            TaxonList taxa = new TaxonList();

            taxa.Add(_taxon);
            parameters.Taxa = taxa;
            FactorSearchCriteria criteria  = new FactorSearchCriteria();
            List <Int32>         factorIds = new List <Int32>();

            factorIds.Add((Int32)FactorId.SpeciesInformationDocumentGroup);
            criteria.RestrictSearchToFactorIds = factorIds;
            criteria.RestrictReturnToScope     = ArtDatabanken.Data.WebService.FactorSearchScope.LeafFactors;
            parameters.Factors = FactorManager.GetFactorsBySearchCriteria(criteria);
            _speciesFacts      = SpeciesFactManager.GetSpeciesFactsByUserParameterSelection(parameters);
        }
        /// <summary>
        /// Get a subset of this species fact list based on parameters
        /// </summary>
        /// <param name="taxon">The taxon for the requested species facts.</param>
        /// <param name="individualCategory">The individidual category for the requested species facts.</param>
        /// <param name="factor">The factor for the requested species facts.</param>
        /// <param name="period">The period for the requested species facts.</param>
        /// <returns></returns>
        public SpeciesFactList GetSpeciesFactsByParameters(
            Taxon taxon,
            IndividualCategory individualCategory,
            Factor factor,
            Period period)
        {
            SpeciesFactList speciesFacts = new SpeciesFactList();
            var             subset       = from SpeciesFact speciesFact in this
                                           where speciesFact.Taxon.Id == taxon.Id &&
                                           speciesFact.IndividualCategory.Id == individualCategory.Id &&
                                           speciesFact.Factor.Id == factor.Id &&
                                           ((speciesFact.Period == period) || (speciesFact.Period == null))
                                           select speciesFact;

            speciesFacts.AddRange(subset.ToArray());
            return(speciesFacts);
        }
        /// <summary>
        /// Init calculation of red list criteria.
        /// </summary>
        /// <param name="speciesFacts">Species facts to get data from.</param>
        public virtual void Init(SpeciesFactList speciesFacts)
        {
            SpeciesFact speciesFact;

            if (AllowAutomaticUpdate)
            {
                IsInInit = true;
                RedListCalculator.InitBegin();
                foreach (Factor factor in this.Factor.GetDependentFactors())
                {
                    speciesFact = GetSpeciesFact(speciesFacts, factor);
                    SetSpeciesFact(speciesFact);
                    speciesFact.UpdateEvent += new SpeciesFactUpdateEventHandler(SetSpeciesFact);
                }
                RedListCalculator.InitEnd();
                IsInInit = false;
            }
        }
        /// <summary>
        /// Get species fact with the same, Taxon, IndividualCategory,
        /// Host and Period as this species fact but with
        /// another factor.
        /// </summary>
        /// <param name="speciesFacts">
        /// List of species facts from where the requested
        /// species are fetched.
        /// </param>
        /// <param name="factor">Factor to use in species fact identifier.</param>
        /// <returns>Requested species fact.</returns>
        protected SpeciesFact GetSpeciesFact(SpeciesFactList speciesFacts,
                                             Factor factor)
        {
            Int32  hostId = 0, periodId = 0;
            String speciesFactIdentifier;

            if (HasHost)
            {
                hostId = Host.Id;
            }
            if (HasPeriod)
            {
                periodId = Period.Id;
            }
            speciesFactIdentifier = SpeciesFactManager.GetSpeciesFactIdentifier(Taxon.Id,
                                                                                IndividualCategory.Id,
                                                                                factor.Id,
                                                                                HasHost,
                                                                                hostId,
                                                                                HasPeriod && factor.IsPeriodic,
                                                                                periodId);
            return(speciesFacts.Get(speciesFactIdentifier));
        }
        /// <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>
 /// Creates a instance of a Species Information Document
 /// object based on a list of species facts.
 /// </summary>
 /// <param name="speciesFacts">The species facts related to species information document factors and a single taxon</param>
 public SpeciesInformationDocument(SpeciesFactList speciesFacts)
     : this(speciesFacts, PeriodManager.GetCurrentPublicPeriod())
 {
 }
예제 #19
0
 /// <summary>
 /// Creates a instance of a Species Information Document
 /// object based on a list of species facts.
 /// </summary>
 /// <param name="speciesFacts">The species facts related to species information document factors and a single taxon</param>
 public SpeciesEncyclopediaArticle(SpeciesFactList speciesFacts)
     : this(speciesFacts, PeriodManager.GetCurrentPublicPeriod())
 {
 }
        /// <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);
        }
예제 #21
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;
            }
        }
 /// <summary>
 /// Create a user data set instance.
 /// </summary>
 public UserDataSet()
 {
     _parameters   = new UserParameterSelection();
     _speciesFacts = new SpeciesFactList();
 }