/// <summary>
 /// Get red list category as descriptive string.
 /// </summary>
 /// <param name="speciesFact">The red list species fact (FactorId.RedlistCategory).</param>
 /// <returns>Red list category as descriptive string.</returns>
 private String GetRedListCategory(ArtDatabanken.Data.SpeciesFact speciesFact)
 {
     if (speciesFact.IsNotNull() && speciesFact.HasField1)
     {
         return(speciesFact.Field1.EnumValue.OriginalLabel);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Get an empty (only default data) SpeciesFact instance.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="taxon">Taxon object of the species fact</param>
        /// <param name="individualCategory">Individual category object of the species fact</param>
        /// <param name="factor">Factor object of the species fact</param>
        /// <param name="host">Host taxon object of the species fact</param>
        /// <param name="period">Period object of the species fact</param>
        /// <returns>A SpeciesFact instance.</returns>
        public virtual ISpeciesFact GetSpeciesFact(IUserContext userContext,
                                                   ITaxon taxon,
                                                   IIndividualCategory individualCategory,
                                                   IFactor factor,
                                                   ITaxon host,
                                                   IPeriod period)
        {
            ISpeciesFact speciesFact;

            switch (factor.Id)
            {
            case (Int32)(FactorId.RedListCategoryAutomatic):
                speciesFact = new SpeciesFactRedListCategory(userContext,
                                                             taxon,
                                                             individualCategory,
                                                             factor,
                                                             host,
                                                             period);
                break;

            case (Int32)(FactorId.RedListCriteriaAutomatic):
                speciesFact = new SpeciesFactRedListCriteria(userContext,
                                                             taxon,
                                                             individualCategory,
                                                             factor,
                                                             host,
                                                             period);
                break;

            case (Int32)(FactorId.RedListCriteriaDocumentationAutomatic):
                speciesFact = new SpeciesFactRedListCriteriaDocumentation(userContext,
                                                                          taxon,
                                                                          individualCategory,
                                                                          factor,
                                                                          host,
                                                                          period);
                break;

            default:
                speciesFact = new SpeciesFact(userContext,
                                              taxon,
                                              individualCategory,
                                              factor,
                                              host,
                                              period);
                break;
            }

            return(speciesFact);
        }
        private int?GetRedListCategoryValue(ArtDatabanken.Data.SpeciesFact speciesFact)
        {
            if (speciesFact == null)
            {
                return(null);
            }

            int?redlistCategoryValue = null;

            if (speciesFact.HasField1)
            {
                redlistCategoryValue = speciesFact.Field1.EnumValue.KeyInt;
            }

            return(redlistCategoryValue);
        }
        /// <summary>
        /// Set species fact field value as a result of
        /// an automatic calculation.
        /// </summary>
        /// <param name='value'>New value for species fact field.</param>
        public void SetValueAutomatic(Object value)
        {
            SpeciesFact.CheckAutomaticUpdate();

            if (value.IsNull())
            {
                HasValue     = false;
                _stringValue = null;
            }
            else
            {
                switch (Type.DataType)
                {
                case FactorFieldDataTypeId.Boolean:
                    SetBooleanValue((Boolean)value);
                    break;

                case FactorFieldDataTypeId.Double:
                    SetDoubleValue((Double)value);
                    break;

                case FactorFieldDataTypeId.Enum:
                    SetEnumValue((FactorFieldEnumValue)value);
                    break;

                case FactorFieldDataTypeId.Int32:
                    SetInt32Value((Int32)value);
                    break;

                case FactorFieldDataTypeId.String:
                    SetStringValue((String)value);
                    break;

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

            SpeciesFact.FireUpdateEvent();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a species fact instance with data from data source.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="id">Id of the species fact.</param>
        /// <param name="taxon">Taxon of the species fact.</param>
        /// <param name="individualCategory">Individual Category of the species fact.</param>
        /// <param name="factor">Factor of the species fact.</param>
        /// <param name="host">Host taxon associated with the species fact.</param>
        /// <param name="period">Period of the species fact.</param>
        /// <param name="fieldValue1">Field value of field 1 for the species fact.</param>
        /// <param name="hasFieldValue1">Indicates if field 1 has a value.</param>
        /// <param name="fieldValue2">Field value of field 2 for the species fact.</param>
        /// <param name="hasFieldValue2">Indicates if field 2 has a value.</param>
        /// <param name="fieldValue3">Field value of field 3 for the species fact.</param>
        /// <param name="hasFieldValue3">Indicates if field 3 has a value.</param>
        /// <param name="fieldValue4">Field value of field 4 for the species fact.</param>
        /// <param name="hasFieldValue4">Indicates if field 4 has a value.</param>
        /// <param name="fieldValue5">Field value of field 5 for the species fact.</param>
        /// <param name="hasFieldValue5">Indicates if field 5 has a value.</param>
        /// <param name="quality">Quality of the species fact.</param>
        /// <param name="reference">Reference of the species fact.</param>
        /// <param name="modifiedBy">Full name of the update user of the species fact.</param>
        /// <param name="modifiedDate">Update date of the species fact.</param>
        public virtual ISpeciesFact GetSpeciesFact(IUserContext userContext,
                                                   Int32 id,
                                                   ITaxon taxon,
                                                   IIndividualCategory individualCategory,
                                                   IFactor factor,
                                                   ITaxon host,
                                                   IPeriod period,
                                                   Double fieldValue1,
                                                   Boolean hasFieldValue1,
                                                   Double fieldValue2,
                                                   Boolean hasFieldValue2,
                                                   Double fieldValue3,
                                                   Boolean hasFieldValue3,
                                                   String fieldValue4,
                                                   Boolean hasFieldValue4,
                                                   String fieldValue5,
                                                   Boolean hasFieldValue5,
                                                   ISpeciesFactQuality quality,
                                                   IReference reference,
                                                   String modifiedBy,
                                                   DateTime modifiedDate)
        {
            ISpeciesFact speciesFact;

            switch (factor.Id)
            {
            case (Int32)(FactorId.RedListCategoryAutomatic):
                speciesFact = new SpeciesFactRedListCategory(userContext,
                                                             id,
                                                             taxon,
                                                             individualCategory,
                                                             factor,
                                                             host,
                                                             period,
                                                             fieldValue1,
                                                             hasFieldValue1,
                                                             fieldValue2,
                                                             hasFieldValue2,
                                                             fieldValue3,
                                                             hasFieldValue3,
                                                             fieldValue4,
                                                             hasFieldValue4,
                                                             fieldValue5,
                                                             hasFieldValue5,
                                                             quality,
                                                             reference,
                                                             modifiedBy,
                                                             modifiedDate);
                break;

            case (Int32)(FactorId.RedListCriteriaAutomatic):
                speciesFact = new SpeciesFactRedListCriteria(userContext,
                                                             id,
                                                             taxon,
                                                             individualCategory,
                                                             factor,
                                                             host,
                                                             period,
                                                             fieldValue1,
                                                             hasFieldValue1,
                                                             fieldValue2,
                                                             hasFieldValue2,
                                                             fieldValue3,
                                                             hasFieldValue3,
                                                             fieldValue4,
                                                             hasFieldValue4,
                                                             fieldValue5,
                                                             hasFieldValue5,
                                                             quality,
                                                             reference,
                                                             modifiedBy,
                                                             modifiedDate);
                break;

            case (Int32)(FactorId.RedListCriteriaDocumentationAutomatic):
                speciesFact = new SpeciesFactRedListCriteriaDocumentation(userContext,
                                                                          id,
                                                                          taxon,
                                                                          individualCategory,
                                                                          factor,
                                                                          host,
                                                                          period,
                                                                          fieldValue1,
                                                                          hasFieldValue1,
                                                                          fieldValue2,
                                                                          hasFieldValue2,
                                                                          fieldValue3,
                                                                          hasFieldValue3,
                                                                          fieldValue4,
                                                                          hasFieldValue4,
                                                                          fieldValue5,
                                                                          hasFieldValue5,
                                                                          quality,
                                                                          reference,
                                                                          modifiedBy,
                                                                          modifiedDate);
                break;

            default:
                speciesFact = new SpeciesFact(id,
                                              taxon,
                                              individualCategory,
                                              factor,
                                              host,
                                              period,
                                              fieldValue1,
                                              hasFieldValue1,
                                              fieldValue2,
                                              hasFieldValue2,
                                              fieldValue3,
                                              hasFieldValue3,
                                              fieldValue4,
                                              hasFieldValue4,
                                              fieldValue5,
                                              hasFieldValue5,
                                              quality,
                                              reference,
                                              modifiedBy,
                                              modifiedDate);
                break;
            }

            return(speciesFact);
        }