/// <summary>
        /// Gets the taxon redlistcategory
        /// </summary>
        /// <param name="taxonId"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        public bool GetRedListCategoryForTaxonId(int taxonId, out RedListCategory category)
        {
            if (mTaxonIdCategories.ContainsKey(taxonId))
            {
                category = mTaxonIdCategories[taxonId];
                return(true);
            }

            category = RedListCategory.NA;
            return(false);
        }
Exemple #2
0
        ///// <summary>
        ///// Get ids for taxa that matches scope criteria.
        ///// </summary>
        ///// <param name="searchCriteria">Analysis search criteria.</param>
        ///// <returns>Ids for taxa that matches selected scope/search criteria.</returns>
        //public TaxonIdList GetTaxonIdsByScope(AnalysisSearchCriteria searchCriteria)
        //{
        //    TaxonIdList tempTaxonIds = null;
        //    if (searchCriteria.TaxonScope.IsNotNull())
        //    {
        //        tempTaxonIds = TaxonScope.GetTaxonIds(searchCriteria.TaxonScope, null);
        //    }

        //    return tempTaxonIds;
        //}

        /// <summary>
        /// Gets the redlistcategory for a specific taxon
        /// </summary>
        /// <param name="taxonId"></param>
        /// <param name="redListCategory"></param>
        /// <returns></returns>
        public bool GetRedListCategoryForTaxonId(int taxonId, out RedListCategory redListCategory)
        {
            return(RedListCategory.GetRedListCategoryForTaxonId(taxonId, out redListCategory));
        }
Exemple #3
0
        /// <summary>
        /// Get ids for taxa that matches search criteria.
        /// </summary>
        /// <param name="searchCriteria">Analysis search criteria.</param>
        /// <param name="taxonIds">
        /// Limit search to these taxon ids.
        /// This parameter is ignored if value is null.
        /// </param>
        /// <returns>Ids for taxa that matches search criteria.</returns>
        public TaxonIdList GetTaxonIds(AnalysisSearchCriteria searchCriteria, TaxonIdList taxonIds = null)
        {
            TaxonIdList tempTaxonIds;

            tempTaxonIds = null;
            if (taxonIds.IsNotNull())
            {
                tempTaxonIds = new TaxonIdList();
                tempTaxonIds.AddRange(taxonIds);
            }

            //if (searchCriteria.Biotopes.IsNotNull())
            //{
            //    tempTaxonIds = Biotope.GetTaxonIds(searchCriteria.Biotopes,
            //                                       tempTaxonIds);
            //}

            //if (searchCriteria.SwedishOccurrence.IsNotNull())
            //{
            //    tempTaxonIds = SwedishOccurrence.GetTaxonIds(searchCriteria.SwedishOccurrence,
            //                                                 tempTaxonIds);
            //}

            //if (searchCriteria.CountyOccurrence.IsNotNull())
            //{
            //    tempTaxonIds = CountyOccurrence.GetTaxonIds(searchCriteria.CountyOccurrence,
            //                                                tempTaxonIds);
            //}

            //if (searchCriteria.Host.IsNotNull())
            //{
            //    tempTaxonIds = Host.GetTaxonIds(searchCriteria.Host,
            //                                    tempTaxonIds);
            //}

            //if (searchCriteria.Impact.IsNotNull())
            //{
            //    tempTaxonIds = Impact.GetTaxonIds(searchCriteria.Impact,
            //                                      tempTaxonIds);
            //}

            //if (searchCriteria.LandscapeTypes.IsNotNull())
            //{
            //    tempTaxonIds = LandscapeType.GetTaxonIds(searchCriteria.LandscapeTypes,
            //                                             tempTaxonIds);
            //}

            //if (searchCriteria.LifeForms.IsNotNull())
            //{
            //    tempTaxonIds = LifeForm.GetTaxonIds(searchCriteria.LifeForms,
            //                                        tempTaxonIds);
            //}

            //if (searchCriteria.OrganismGroups.IsNotNull())
            //{
            //    tempTaxonIds = OrganismGroup.GetTaxonIds(searchCriteria.OrganismGroups,
            //                                             tempTaxonIds);
            //}

            if (searchCriteria.RedListCategories.IsNotNull())
            {
                tempTaxonIds = RedListCategory.GetTaxonIds(searchCriteria.RedListCategories, tempTaxonIds);
            }

            //if (searchCriteria.TaxonCategories.IsNotEmpty())
            //{
            //    tempTaxonIds = TaxonScope.GetTaxonIds(searchCriteria.TaxonCategories,
            //                                                    tempTaxonIds);
            //}
            //else if (searchCriteria.TaxonScope.IsNotNull())
            //{
            //    tempTaxonIds = TaxonScope.GetTaxonIds(searchCriteria.TaxonScope,
            //                                                    tempTaxonIds);
            //}

            //if (searchCriteria.Substrate.IsNotNull())
            //{
            //    tempTaxonIds = Substrate.GetTaxonIds(searchCriteria.Substrate,
            //                                         tempTaxonIds);
            //}

            //if (searchCriteria.ThematicLists.IsNotNull())
            //{
            //    tempTaxonIds = ThematicLists.GetTaxonIds(searchCriteria.ThematicLists,
            //                                             tempTaxonIds);
            //}

            return(tempTaxonIds);
        }
        /// <summary>
        /// Update red list calculation with information from species fact.
        /// </summary>
        /// <param name="speciesFact">Species facts with red list information.</param>
        protected virtual void SetSpeciesFact(SpeciesFact speciesFact)
        {
            Boolean         hasMax = false, hasMin = false, hasProbable = false;
            Boolean         oldIsGraded = false;
            Double          doubleMax = 0, doubleMin = 0, doubleProbable = 0;
            Int32           oldGrading = 0;
            Int32           int32Max = 0, int32Min = 0, int32Probable = 0;
            Int64           int64Max = 0, int64Min = 0, int64Probable = 0;
            RedListCategory oldCategory = RedListCategory.LC,
                            oldCategoryBestCase = RedListCategory.LC,
                            oldCategoryProbable = RedListCategory.LC,
                            oldCategoryWorstCase = RedListCategory.LC;
            String oldCriteria = null, oldCriteriaBestCase = null,
                   oldCriteriaProbable = null, oldCriteriaWorstCase = null, oldCriteriaDocumentation = null;

            if (!IsInInit)
            {
                oldCategory              = RedListCalculator.Category;
                oldCategoryBestCase      = RedListCalculator.CategoryBestCaseNoGrading;
                oldCategoryProbable      = RedListCalculator.CategoryProbableNoGrading;
                oldCategoryWorstCase     = RedListCalculator.CategoryWorstCaseNoGrading;
                oldCriteria              = RedListCalculator.Criteria;
                oldCriteriaBestCase      = RedListCalculator.CriteriaBestCase;
                oldCriteriaProbable      = RedListCalculator.CriteriaProbable;
                oldCriteriaWorstCase     = RedListCalculator.CriteriaWorstCase;
                oldGrading               = RedListCalculator.Grading;
                oldIsGraded              = RedListCalculator.IsGraded;
                oldCriteriaDocumentation = RedListCalculator.CriteriaDocumentation;
            }

            switch (speciesFact.Factor.Id)
            {
            case ((Int32)FactorId.AreaOfOccupancy_B2Estimated):
                GetValues(speciesFact,
                          ref hasMin,
                          ref doubleMin,
                          ref hasProbable,
                          ref doubleProbable,
                          ref hasMax,
                          ref doubleMax);
                RedListCalculator.SetAreaOfOccupancy(hasMin,
                                                     doubleMin,
                                                     hasProbable,
                                                     doubleProbable,
                                                     hasMax,
                                                     doubleMax,
                                                     speciesFact.Field4.GetStringValue(),
                                                     speciesFact.Field1.UnitLabel);
                break;

            case ((Int32)FactorId.ConservationDependent):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsConservationDependent(speciesFact.Field1.GetBoolean(),
                                                                 speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsConservationDependent(false, null);
                }
                break;

            case ((Int32)FactorId.ContinuingDecline):
                hasProbable = speciesFact.Field1.HasValue;
                if (hasProbable)
                {
                    int32Probable = speciesFact.Field1.GetInt32();
                }
                RedListCalculator.SetContinuingDecline(hasMin,
                                                       int32Min,
                                                       hasProbable,
                                                       int32Probable,
                                                       hasMax,
                                                       int32Max,
                                                       speciesFact.Field4.GetStringValue());
                break;

            case ((Int32)FactorId.ContinuingDeclineBasedOn_Bbi):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaBB1Fulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaBB1Fulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ContinuingDeclineBasedOn_Bbii):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaBB2Fulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaBB2Fulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ContinuingDeclineBasedOn_Bbiii):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaBB3Fulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaBB3Fulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ContinuingDeclineBasedOn_Bbiv):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaBB4Fulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaBB4Fulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ContinuingDeclineBasedOn_Bbv):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaBB5Fulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaBB5Fulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ExtentOfOccurrence_B1Estimated):
                GetValues(speciesFact,
                          ref hasMin,
                          ref doubleMin,
                          ref hasProbable,
                          ref doubleProbable,
                          ref hasMax,
                          ref doubleMax);
                RedListCalculator.SetExtentOfOccurrence(hasMin,
                                                        doubleMin,
                                                        hasProbable,
                                                        doubleProbable,
                                                        hasMax,
                                                        doubleMax,
                                                        speciesFact.Field4.GetStringValue(),
                                                        speciesFact.Field1.UnitLabel);
                break;

            case ((Int32)FactorId.ExtremeFluctuations):
                hasProbable = speciesFact.Field1.HasValue;
                if (hasProbable)
                {
                    int32Probable = speciesFact.Field1.GetInt32();
                }
                RedListCalculator.SetExtremeFluctuations(hasMin,
                                                         int32Min,
                                                         hasProbable,
                                                         int32Probable,
                                                         hasMax,
                                                         int32Max);
                break;

            case ((Int32)FactorId.ExtremeFluctuationsIn_Bci):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaBC1Fulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaBC1Fulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ExtremeFluctuationsIn_Bcii):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaBC2Fulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaBC2Fulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ExtremeFluctuationsIn_Bciii):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaBC3Fulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaBC3Fulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ExtremeFluctuationsIn_Bciv):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaBC4Fulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaBC4Fulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.Grading):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetGrading(true,
                                                 speciesFact.Field1.GetInt32(),
                                                 speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetGrading(false, 0, null);
                }
                break;

            case ((Int32)FactorId.MaxProportionLocalPopulation):
                GetValues(speciesFact,
                          ref hasMin,
                          ref doubleMin,
                          ref hasProbable,
                          ref doubleProbable,
                          ref hasMax,
                          ref doubleMax);
                RedListCalculator.SetMaxProportionLocalPopulation(hasMin,
                                                                  doubleMin,
                                                                  hasProbable,
                                                                  doubleProbable,
                                                                  hasMax,
                                                                  doubleMax);
                break;

            case ((Int32)FactorId.MaxSizeLocalPopulation):
                GetValues(speciesFact,
                          ref hasMin,
                          ref int64Min,
                          ref hasProbable,
                          ref int64Probable,
                          ref hasMax,
                          ref int64Max);
                RedListCalculator.SetMaxSizeLocalPopulation(hasMin,
                                                            int64Min,
                                                            hasProbable,
                                                            int64Probable,
                                                            hasMax,
                                                            int64Max);
                break;

            case ((Int32)FactorId.NumberOfLocations):
                GetValues(speciesFact,
                          ref hasMin,
                          ref int64Min,
                          ref hasProbable,
                          ref int64Probable,
                          ref hasMax,
                          ref int64Max);
                RedListCalculator.SetNumberOfLocations(hasMin,
                                                       int64Min,
                                                       hasProbable,
                                                       int64Probable,
                                                       hasMax,
                                                       int64Max,
                                                       speciesFact.Field4.GetStringValue());
                break;

            case ((Int32)FactorId.PopulationSize_Total):
                GetValues(speciesFact,
                          ref hasMin,
                          ref int64Min,
                          ref hasProbable,
                          ref int64Probable,
                          ref hasMax,
                          ref int64Max);
                RedListCalculator.SetPopulationSize(hasMin,
                                                    int64Min,
                                                    hasProbable,
                                                    int64Probable,
                                                    hasMax,
                                                    int64Max,
                                                    speciesFact.Field4.GetStringValue());
                break;

            case ((Int32)FactorId.ProbabilityOfExtinction):
                GetValues(speciesFact,
                          ref hasMin,
                          ref int32Min,
                          ref hasProbable,
                          ref int32Probable,
                          ref hasMax,
                          ref int32Max);
                RedListCalculator.SetProbabilityOfExtinction(hasMin,
                                                             int32Min,
                                                             hasProbable,
                                                             int32Probable,
                                                             hasMax,
                                                             int32Max,
                                                             speciesFact.Field4.GetStringValue());
                break;

            case ((Int32)FactorId.RedlistEvaluationProgressionStatus):
                RedListCalculator.IsEvaluationStatusSet = speciesFact.Field1.HasValue;
                if (speciesFact.Field1.HasValue)
                {
                    switch (speciesFact.Field1.GetInt32())
                    {
                    case 0:
                        RedListCalculator.SetRedlistEvaluationStatus(RedListCategory.NE);
                        break;

                    case 1:
                        RedListCalculator.SetRedlistEvaluationStatus(RedListCategory.NA);
                        break;

                    case 4:
                        RedListCalculator.SetRedlistEvaluationStatus(RedListCategory.DD);
                        break;

                    default:
                        RedListCalculator.SetRedlistEvaluationStatus(RedListCategory.LC);
                        break;
                    }
                }
                else
                {
                    RedListCalculator.SetRedlistEvaluationStatus(RedListCategory.LC);
                }
                break;

            case ((Int32)FactorId.Reduction_A1):
                GetValues(speciesFact,
                          ref hasMin,
                          ref doubleMin,
                          ref hasProbable,
                          ref doubleProbable,
                          ref hasMax,
                          ref doubleMax);
                RedListCalculator.SetPopulationReductionA1(hasMin,
                                                           doubleMin,
                                                           hasProbable,
                                                           doubleProbable,
                                                           hasMax,
                                                           doubleMax,
                                                           speciesFact.Field4.GetStringValue());
                break;

            case ((Int32)FactorId.Reduction_A2):
                GetValues(speciesFact,
                          ref hasMin,
                          ref doubleMin,
                          ref hasProbable,
                          ref doubleProbable,
                          ref hasMax,
                          ref doubleMax);
                RedListCalculator.SetPopulationReductionA2(hasMin,
                                                           doubleMin,
                                                           hasProbable,
                                                           doubleProbable,
                                                           hasMax,
                                                           doubleMax,
                                                           speciesFact.Field4.GetStringValue());
                break;

            case ((Int32)FactorId.Reduction_A3):
                GetValues(speciesFact,
                          ref hasMin,
                          ref doubleMin,
                          ref hasProbable,
                          ref doubleProbable,
                          ref hasMax,
                          ref doubleMax);
                RedListCalculator.SetPopulationReductionA3(hasMin,
                                                           doubleMin,
                                                           hasProbable,
                                                           doubleProbable,
                                                           hasMax,
                                                           doubleMax,
                                                           speciesFact.Field4.GetStringValue());
                break;

            case ((Int32)FactorId.Reduction_A4):
                GetValues(speciesFact,
                          ref hasMin,
                          ref doubleMin,
                          ref hasProbable,
                          ref doubleProbable,
                          ref hasMax,
                          ref doubleMax);
                RedListCalculator.SetPopulationReductionA4(hasMin,
                                                           doubleMin,
                                                           hasProbable,
                                                           doubleProbable,
                                                           hasMax,
                                                           doubleMax,
                                                           speciesFact.Field4.GetStringValue());
                break;

            case ((Int32)FactorId.ReductionBasedOn_A1a):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA1AFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA1AFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A1b):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA1BFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA1BFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A1c):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA1CFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA1CFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A1d):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA1DFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA1DFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A1e):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA1EFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA1EFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A2a):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA2AFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA2AFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A2b):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA2BFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA2BFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A2c):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA2CFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA2CFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A2d):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA2DFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA2DFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A2e):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA2EFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA2EFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A3b):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA3BFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA3BFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A3c):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA3CFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA3CFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A3d):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA3DFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA3DFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A3e):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA3EFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA3EFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A4a):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA4AFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA4AFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A4b):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA4BFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA4BFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A4c):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA4CFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA4CFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A4d):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA4DFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA4DFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.ReductionBasedOn_A4e):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetIsCriteriaA4EFulfilled(speciesFact.Field1.GetBoolean(),
                                                                speciesFact.Field4.GetStringValue());
                }
                else
                {
                    RedListCalculator.SetIsCriteriaA4EFulfilled(false, null);
                }
                break;

            case ((Int32)FactorId.SeverelyFragmented):
                hasProbable = speciesFact.Field1.HasValue;
                if (hasProbable)
                {
                    int32Probable = speciesFact.Field1.GetInt32();
                }
                RedListCalculator.SetSeverlyFragmented(hasMin,
                                                       int32Min,
                                                       hasProbable,
                                                       int32Probable,
                                                       hasMax,
                                                       int32Max);
                break;

            case ((Int32)FactorId.SwedishOccurrence):
                if (speciesFact.Field1.HasValue)
                {
                    RedListCalculator.SetSwedishOccurrence(speciesFact.Field1.GetInt32());
                }
                else
                {
                    RedListCalculator.SetSwedishOccurrence(0);
                }
                break;

            case ((Int32)FactorId.VeryRestrictedArea_D2VU):
                hasProbable = (speciesFact.Field1.HasValue &&
                               speciesFact.Field1.BooleanValue &&
                               speciesFact.Field2.HasValue);
                if (hasProbable)
                {
                    int32Probable = speciesFact.Field2.EnumValue.KeyInt;
                }
                RedListCalculator.SetVeryRestrictedArea(hasMin,
                                                        int32Min,
                                                        hasProbable,
                                                        int32Probable,
                                                        hasMax,
                                                        int32Max,
                                                        speciesFact.Field4.GetStringValue());
                break;

            default:
                throw new ApplicationException("Not handled species fact. Factor id " + speciesFact.Id);
            }

            if (!IsInInit)
            {
                if ((oldCategory != RedListCalculator.Category) ||
                    (oldCriteria != RedListCalculator.Criteria) ||
                    (oldGrading != RedListCalculator.Grading) ||
                    (oldIsGraded != RedListCalculator.IsGraded) ||
                    (oldCriteriaDocumentation != RedListCalculator.CriteriaDocumentation) ||
                    (oldCategoryBestCase != RedListCalculator.CategoryBestCaseNoGrading) ||
                    (oldCategoryProbable != RedListCalculator.CategoryProbableNoGrading) ||
                    (oldCategoryWorstCase != RedListCalculator.CategoryWorstCaseNoGrading) ||
                    (oldCriteriaBestCase != RedListCalculator.CriteriaBestCase) ||
                    (oldCriteriaProbable != RedListCalculator.CriteriaProbable) ||
                    (oldCriteriaWorstCase != RedListCalculator.CriteriaWorstCase))
                {
                    SetReadListValues();
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Set species fact information about this taxon.
        /// </summary>
        /// <param name="speciesFact">Species fact with red list information.</param>
        public void SetSpeciesFact(ISpeciesFact speciesFact)
        {
            if (LandscapeTypeManager.LandscapeTypeFactors.IsNotNull() &&
                LandscapeTypeManager.LandscapeTypeFactors.Exists(speciesFact.Factor))
            {
                if (speciesFact.IsLandscapeTypeOccurrenceSpecified())
                {
                    string landscapeTypeOccurrence = speciesFact.Factor.Label;
                    landscapeTypeOccurrence = landscapeTypeOccurrence.Substring(landscapeTypeOccurrence.Length - 2, 1);
                    switch (speciesFact.MainField.EnumValue.KeyInt)
                    {
                    case (int)LandscapeTypeImportanceEnum.HasImportance:
                        LandscapeTypeOccurrence += landscapeTypeOccurrence.ToLower();
                        break;

                    case (int)LandscapeTypeImportanceEnum.VeryImportant:
                        LandscapeTypeOccurrence += landscapeTypeOccurrence.ToUpper();
                        break;
                    }
                }
            }
            else
            {
                switch (speciesFact.Factor.Id)
                {
                case (int)FactorId.RedlistCategory:
                    if (speciesFact.IsRedlistCategorySpecified())
                    {
                        RedListCategory = speciesFact.Field1.EnumValue.OriginalLabel.Substring(0, speciesFact.Field1.EnumValue.OriginalLabel.Length - 4) +
                                          "(" + speciesFact.MainField.StringValue + ")";
                        var category = (RedListCategory)Enum.Parse(typeof(RedListCategory), RedListCategory.Substring(RedListCategory.IndexOf("(", StringComparison.Ordinal) + 1, 2));
                        IsRedListed        = RedListedHelper.IsRedListedDdToNt((int)category);
                        IsRedListedEnsured = RedListedHelper.IsRedListedDdToNe((int)category);
                        RedListCategoryId  = Convert.ToInt32(speciesFact.Field1.EnumValue.KeyInt);
                    }

                    break;

                case (int)FactorId.RedlistCriteriaString:
                    if (speciesFact.IsRedlistCriteriaSpecified())
                    {
                        RedListCriteria = speciesFact.MainField.StringValue;
                    }

                    break;

                case (int)FactorId.Redlist_OrganismLabel1:
                    if (speciesFact.IsOrganismGroupSpecified())
                    {
                        if (OrganismGroup.IsEmpty())
                        {
                            OrganismGroup = speciesFact.MainField.EnumValue.OriginalLabel;
                        }
                        else
                        {
                            if (OrganismGroup != speciesFact.MainField.EnumValue.OriginalLabel)
                            {
                                OrganismGroup = speciesFact.MainField.EnumValue.OriginalLabel + ", " + OrganismGroup;
                            }
                        }
                    }

                    break;

                case (int)FactorId.SwedishOccurrence:
                    if (speciesFact.IsSwedishOccurrenceSpecified())
                    {
                        SwedishOccurrence   = speciesFact.MainField.EnumValue.OriginalLabel;
                        SwedishOccurrenceId = Convert.ToInt32(speciesFact.MainField.EnumValue.KeyInt);
                    }
                    break;
                }
            }
        }
 /// <summary>
 /// Get cache key for taxa that is red listed
 /// in specified red list category.
 /// </summary>
 /// <param name="redlistCategory">Cache key for taxa belonging to specified red list category should be returned.</param>
 /// <returns>Cache key for red listed taxa.</returns>
 private static String GetRedlistedTaxaCacheKey(RedListCategory redlistCategory)
 {
     return(Settings.Default.RedlistedTaxaCacheKey +
            WebService.Settings.Default.CacheKeyDelimiter +
            redlistCategory);
 }
Exemple #7
0
        ///// <summary>
        ///// The get taxon ids selected by scope.
        ///// </summary>
        ///// <param name="analysisManager"></param>
        ///// <param name="searchCriteria">
        ///// The search criteria.
        ///// </param>
        ///// <returns>
        ///// Ids for taxa that matches scope/search criteria.
        ///// </returns>
        //public static TaxonIdList GetTaxonIdsByScope(this IAnalysisManager analysisManager, AnalysisSearchCriteria searchCriteria)
        //{
        //    return mCache.GetTaxonIdsByScope(searchCriteria);
        //}

        /// <summary>
        /// Gets the redlist category for a specific taxon
        /// </summary>
        /// <param name="analysisManager"></param>
        /// <param name="taxonId"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        public static bool GetRedListCategoryForTaxonId(this IAnalysisManager analysisManager, int taxonId, out RedListCategory category)
        {
            return(mCache.GetRedListCategoryForTaxonId(taxonId, out category));
        }