/// <summary>
 /// Extract min, probable and max value from a species fact.
 /// </summary>
 /// <param name="speciesFact">Species facts with red list information.</param>
 /// <param name="hasMin">Indicates if min value is available.</param>
 /// <param name="valueMin">Min value.</param>
 /// <param name="hasProbable">Indicates if probable value is available.</param>
 /// <param name="valueProbable">Probable value.</param>
 /// <param name="hasMax">Indicates if max value is available.</param>
 /// <param name="valueMax">Max value.</param>
 protected void GetValues(SpeciesFact speciesFact,
                          ref Boolean hasMin,
                          ref Int64 valueMin,
                          ref Boolean hasProbable,
                          ref Int64 valueProbable,
                          ref Boolean hasMax,
                          ref Int64 valueMax)
 {
     valueMin      = 0;
     valueProbable = 0;
     valueMax      = 0;
     hasMin        = speciesFact.Field2.HasValue;
     if (hasMin)
     {
         valueMin = speciesFact.Field2.GetInt64();
     }
     hasProbable = speciesFact.Field1.HasValue;
     if (hasProbable)
     {
         valueProbable = speciesFact.Field1.GetInt64();
     }
     hasMax = speciesFact.Field3.HasValue;
     if (hasMax)
     {
         valueMax = speciesFact.Field3.GetInt64();
     }
 }
コード例 #2
0
        /// <summary>
        /// Create a SpeciesFactField instance with default data.
        /// </summary>
        /// <param name="speciesFact">The SpeciesFact that this SpeciesFactField belongs to.</param>
        /// <param name="factorField">Factor field for the species fact field</param>
        public SpeciesFactField(SpeciesFact speciesFact,
                                FactorField factorField)
            : base(factorField.Id, factorField.Id)
        {
            _speciesFact = speciesFact;
            _factorField = factorField;

            UpdateData(false, null);
        }
コード例 #3
0
 /// <summary>
 /// Add SpeciesFact to list.
 /// </summary>
 /// <param name='speciesFact'>SpeciesFact to add</param>
 public void Add(SpeciesFact speciesFact)
 {
     if (speciesFact.IsNotNull())
     {
         if (_optimize)
         {
             _identifierHashTable.Add(speciesFact.Identifier, speciesFact);
         }
         base.Add(speciesFact);
     }
 }
コード例 #4
0
        /// <summary>
        /// Create a SpeciesFactField instance with data from database.
        /// </summary>
        /// <param name="speciesFact">The SpeciesFact that this SpeciesFactField belongs to.</param>
        /// <param name="factorField">Factor field for the species fact field</param>
        /// <param name="hasValue">Indication whether or not a value is initially specified</param>
        /// <param name="value">The value of the species fact field</param>
        public SpeciesFactField(
            SpeciesFact speciesFact,
            FactorField factorField,
            Boolean hasValue,
            Object value)
            : base(factorField.Id, factorField.Id)
        {
            _speciesFact = speciesFact;
            _factorField = factorField;

            UpdateData(hasValue, value);
        }
        /// <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();
                }
            }
        }
        /// <summary>
        /// Update red list calculation with information from species fact.
        /// </summary>
        /// <param name="speciesFact">Species facts with red list information.</param>
        protected override void SetSpeciesFact(SpeciesFact speciesFact)
        {
            Boolean hasMax = false, hasMin = false, hasProbable = false;
            Double  doubleMax = 0, doubleMin = 0, doubleProbable = 0;
            String  oldCriteriaDocumentation = null;

            // Test if the species fact is criteria documentation specific.
            switch (speciesFact.Factor.Id)
            {
            case ((Int32)FactorId.RedListCriteriaDocumentationIntroduction):
            case ((Int32)FactorId.GlobalRedlistCategory):
            case ((Int32)FactorId.GenerationTime):
            case ((Int32)FactorId.LastEncounter):
            case ((Int32)FactorId.ImmigrationOccurs):
                // Criteria documentation specific.
                break;

            default:
                // Not criteria documentation specific.
                // Handle in base class.
                base.SetSpeciesFact(speciesFact);
                return;
            }

            if (!IsInInit)
            {
                oldCriteriaDocumentation = GetRedListCalculator().CriteriaDocumentation;
            }

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

            case ((Int32)FactorId.GlobalRedlistCategory):
                if (speciesFact.Field4.HasValue)
                {
                    GetRedListCalculator().SetGlobalRedlistCategory(speciesFact.Field4.GetStringValue());
                }
                else
                {
                    GetRedListCalculator().SetGlobalRedlistCategory(null);
                }
                break;

            case ((Int32)FactorId.ImmigrationOccurs):
                if (speciesFact.Field1.HasValue)
                {
                    GetRedListCalculator().SetImmigrationOccurs(speciesFact.Field1.GetBoolean());
                }
                else
                {
                    GetRedListCalculator().SetImmigrationOccurs(false);
                }
                break;

            case ((Int32)FactorId.LastEncounter):
                if (speciesFact.Field1.HasValue)
                {
                    GetRedListCalculator().SetLastEncounter(true,
                                                            speciesFact.Field1.GetInt32());
                }
                else
                {
                    GetRedListCalculator().SetLastEncounter(false, 0);
                }
                break;

            case ((Int32)FactorId.RedListCriteriaDocumentationIntroduction):
                if (speciesFact.Field5.HasValue)
                {
                    GetRedListCalculator().SetIntroduction(speciesFact.Field5.GetStringValue());
                }
                else
                {
                    GetRedListCalculator().SetIntroduction(null);
                }
                break;

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

            if (!IsInInit)
            {
                if (oldCriteriaDocumentation != GetRedListCalculator().CriteriaDocumentation)
                {
                    SetReadListValues();
                }
            }
        }
コード例 #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;
            }
        }