/// <summary>
 /// Expands a Species Fact List with empty species facts so that every combination from the user parameter selection is represented.
 /// Factor Headers are excluded.
 /// Periodic factors are not expanded to individual categories other than the default.
 /// </summary>
 /// <param name="userContext">The user context.</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>
 /// <param name="speciesFacts">Species fact list to be expanded.</param>
 private static void ExpandSpeciesFactListWithEmptySpeciesFact(
     IUserContext userContext,
     ITaxon taxon,
     IIndividualCategory individualCategory,
     IFactor factor,
     ITaxon host,
     IPeriod period,
     SpeciesFactList speciesFacts)
 {
     if (!speciesFacts.Exists(CoreData.SpeciesFactManager.GetSpeciesFactIdentifier(
                                  taxon,
                                  individualCategory,
                                  factor,
                                  host,
                                  period)))
     {
         speciesFacts.Add(CoreData.SpeciesFactManager.GetSpeciesFact(
                              userContext,
                              taxon,
                              individualCategory,
                              factor,
                              host,
                              period));
     }
 }
        /// <summary>
        /// Add individual category to search criteria.
        /// </summary>
        /// <param name="individualCategory">The individual category.</param>
        public void Add(IIndividualCategory individualCategory)
        {
            if (IndividualCategories.IsNull())
            {
                IndividualCategories = new IndividualCategoryList();
            }

            IndividualCategories.Add(individualCategory);
        }
 /// <summary>
 /// Creates a species fact instance with no data from web service.
 /// </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>
 public SpeciesFactRedListCriteriaDocumentation(IUserContext userContext,
                                                ITaxon taxon,
                                                IIndividualCategory individualCategory,
                                                IFactor factor,
                                                ITaxon host,
                                                IPeriod period)
     : base(userContext, taxon, individualCategory, factor, host, period)
 {
 }
        /// <summary>
        /// Remove individual category from current species fact data set scope.
        /// The species facts in the data set are updated
        /// to the new species fact data set scope.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="selection">Changed scope of the data set.</param>
        public virtual void RemoveSelection(IUserContext userContext,
                                            IIndividualCategory selection)
        {
            ISpeciesFactDataSetSelection newSelection;

            newSelection = new SpeciesFactDataSetSelection();
            newSelection.IndividualCategories.Merge(selection);
            RemoveSelection(userContext, newSelection);
        }
 /// <summary>
 /// Creates a species fact instance with no data from web service.
 /// </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>
 public SpeciesFactRedListCategory(IUserContext userContext,
                                   ITaxon taxon,
                                   IIndividualCategory individualCategory,
                                   IFactor factor,
                                   ITaxon host,
                                   IPeriod period)
     : base(userContext, taxon, individualCategory, factor, host, period)
 {
     _redListCategoryAutomaticFactor = CoreData.FactorManager.GetFactor(userContext, FactorId.RedListCategoryAutomatic);
 }
コード例 #6
0
        /// <summary>
        /// Get a subset of this species fact list based on parameters.
        /// </summary>
        /// <param name="individualCategory">The individual category for the requested species facts.</param>
        /// <returns>A species fact list.</returns>
        public SpeciesFactList GetSpeciesFacts(IIndividualCategory individualCategory)
        {
            SpeciesFactList speciesFacts = new SpeciesFactList();
            var             subset       = from SpeciesFact speciesFact in this
                                           where speciesFact.IndividualCategory.Id == individualCategory.Id
                                           select speciesFact;

            if (subset.IsNotNull() && subset.Any())
            {
                speciesFacts.AddRange(subset.ToArray());
            }

            return(speciesFacts);
        }
コード例 #7
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);
        }
コード例 #8
0
        /// <summary>
        /// Get species fact with a unique combination of parameters.
        /// </summary>
        /// <param name="taxon">Taxon for requested species fact.</param>
        /// <param name="individualCategory">Individual Category for requested species fact.</param>
        /// <param name="factor">Factor for requested species fact.</param>
        /// <param name="host">Host for the requested species fact.</param>
        /// <param name="period">Period for the requested species fact.</param>
        /// <returns>Requested species fact.</returns>
        public ISpeciesFact Get(ITaxon taxon,
                                IIndividualCategory individualCategory,
                                IFactor factor,
                                ITaxon host,
                                IPeriod period)
        {
            String identifier;

            identifier = CoreData.SpeciesFactManager.GetSpeciesFactIdentifier(taxon,
                                                                              individualCategory,
                                                                              factor,
                                                                              host,
                                                                              period);
            return(Get(identifier));
        }
 /// <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 SpeciesFactRedListCategory(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)
     : base(userContext,
            id,
            taxon,
            individualCategory,
            factor,
            host,
            period,
            fieldValue1,
            hasFieldValue1,
            fieldValue2,
            hasFieldValue2,
            fieldValue3,
            hasFieldValue3,
            fieldValue4,
            hasFieldValue4,
            fieldValue5,
            hasFieldValue5,
            quality,
            reference,
            modifiedBy,
            modifiedDate)
 {
     _redListCategoryAutomaticFactor = CoreData.FactorManager.GetFactor(userContext, FactorId.RedListCategoryAutomatic);
 }
 /// <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 SpeciesFactRedListCriteriaDocumentation(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)
     : base(userContext,
            id,
            taxon,
            individualCategory,
            factor,
            host,
            period,
            fieldValue1,
            hasFieldValue1,
            fieldValue2,
            hasFieldValue2,
            fieldValue3,
            hasFieldValue3,
            fieldValue4,
            hasFieldValue4,
            fieldValue5,
            hasFieldValue5,
            quality,
            reference,
            modifiedBy,
            modifiedDate)
 {
 }
コード例 #11
0
        /// <summary>
        /// Get a subset of this species fact list based on parameters.
        /// </summary>
        /// <param name="taxon">The taxon for the requested species facts.</param>
        /// <param name="individualCategory">The individual category for the requested species facts.</param>
        /// <param name="factor">The factor for the requested species facts.</param>
        /// <param name="period">The period for the requested species facts.</param>
        /// <returns>A species fact list.</returns>
        public SpeciesFactList GetSpeciesFacts(ITaxon taxon,
                                               IIndividualCategory individualCategory,
                                               IFactor factor,
                                               IPeriod period)
        {
            SpeciesFactList speciesFacts = new SpeciesFactList();
            var             subset       = from SpeciesFact speciesFact in this
                                           where speciesFact.Taxon.Id == taxon.Id &&
                                           speciesFact.IndividualCategory.Id == individualCategory.Id &&
                                           speciesFact.Factor.Id == factor.Id &&
                                           (speciesFact.Period.IsNull() || (speciesFact.Period.Id == period.Id))
                                           select speciesFact;

            if (subset.IsNotNull() && subset.Any())
            {
                speciesFacts.AddRange(subset.ToArray());
            }

            return(speciesFacts);
        }
コード例 #12
0
        /// <summary>
        /// Method that generates an unique identifier for a species fact.
        /// </summary>
        /// <param name="taxon">Taxon that is related to the species fact.</param>
        /// <param name="individualCategory">Individual category that is related to the species fact.</param>
        /// <param name="factor">Factor that is related to the species fact.</param>
        /// <param name="host">Host taxon that is related to the species fact.</param>
        /// <param name="period">Period that is related to the species fact.</param>
        /// <returns>Identifier for a species fact.</returns>
        public virtual String GetSpeciesFactIdentifier(ITaxon taxon,
                                                       IIndividualCategory individualCategory,
                                                       IFactor factor,
                                                       ITaxon host,
                                                       IPeriod period)
        {
            Int32 hostId = 0, periodId = 0;

            if ((host.IsNotNull()) && (factor.IsTaxonomic))
            {
                hostId = host.Id;
            }

            if ((period.IsNotNull()) && (factor.IsPeriodic))
            {
                periodId = period.Id;
            }

            return(GetSpeciesFactIdentifier(taxon.Id,
                                            individualCategory.Id,
                                            factor.Id,
                                            hostId,
                                            periodId));
        }
コード例 #13
0
        /// <summary>
        /// Merge empty species fact into this species fact list.
        /// The empty species fact is defined by the specified
        /// combination of factor, host, individual category,
        /// period and taxon.
        /// </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>
        public void Merge(IUserContext userContext,
                          ITaxon taxon,
                          IIndividualCategory individualCategory,
                          IFactor factor,
                          ITaxon host,
                          IPeriod period)
        {
            String speciesFactIdentifier;

            speciesFactIdentifier = CoreData.SpeciesFactManager.GetSpeciesFactIdentifier(taxon,
                                                                                         individualCategory,
                                                                                         factor,
                                                                                         host,
                                                                                         period);
            if (!Exists(speciesFactIdentifier))
            {
                Add(CoreData.SpeciesFactManager.GetSpeciesFact(userContext,
                                                               taxon,
                                                               individualCategory,
                                                               factor,
                                                               host,
                                                               period));
            }
        }
コード例 #14
0
        /// <summary>
        /// Creates a species fact instance with data from data source.
        /// </summary>
        /// <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 SpeciesFact(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)
        {
            Int32 fieldIndex;

            Id                 = id;
            _fields            = null;
            _substantialFields = null;
            _mainField         = null;
            _hasId             = true;
            _identifier        = CoreData.SpeciesFactManager.GetSpeciesFactIdentifier(taxon,
                                                                                      individualCategory,
                                                                                      factor,
                                                                                      host,
                                                                                      period);

            _taxon = taxon;
            _individualCategory = individualCategory;
            _factor             = factor;
            _host            = host;
            _hasHost         = host.IsNotNull();
            _period          = period;
            _hasPeriod       = period.IsNotNull();
            _quality         = quality;
            _oldQuality      = quality;
            _reference       = reference;
            _oldReference    = reference;
            _modifiedBy      = modifiedBy;
            _modifiedDate    = modifiedDate;
            _hasModifiedDate = true;

            if (!_factor.UpdateMode.IsHeader)
            {
                _fields            = new SpeciesFactFieldList();
                _substantialFields = new SpeciesFactFieldList();
                _fieldArray        = new ISpeciesFactField[CoreData.FactorManager.GetFactorFieldMaxCount()];
                for (fieldIndex = 0; fieldIndex < CoreData.FactorManager.GetFactorFieldMaxCount(); fieldIndex++)
                {
                    _fieldArray[fieldIndex] = null;
                }

                foreach (FactorField factorField in _factor.DataType.Fields)
                {
                    Boolean          hasFieldValue;
                    SpeciesFactField field;
                    Object           fieldValue;

                    switch (factorField.Index)
                    {
                    case 0:
                        fieldValue    = fieldValue1;
                        hasFieldValue = hasFieldValue1;
                        break;

                    case 1:
                        fieldValue    = fieldValue2;
                        hasFieldValue = hasFieldValue2;
                        break;

                    case 2:
                        fieldValue    = fieldValue3;
                        hasFieldValue = hasFieldValue3;
                        break;

                    case 3:
                        fieldValue    = fieldValue4;
                        hasFieldValue = hasFieldValue4;
                        break;

                    case 4:
                        fieldValue    = fieldValue5;
                        hasFieldValue = hasFieldValue5;
                        break;

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

                    field = new SpeciesFactField(this, factorField, hasFieldValue, fieldValue);
                    _fields.Add(field);
                    _fieldArray[field.Index] = field;

                    if (factorField.IsSubstantial)
                    {
                        _substantialFields.Add(field);
                    }

                    if (factorField.IsMain)
                    {
                        _mainField = field;
                    }
                }
            }

            Fields.Sort();
            _shouldBeSaved = AllowUpdate;
        }
コード例 #15
0
        /// <summary>
        /// Creates a species fact instance with no data from web service.
        /// </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>
        public SpeciesFact(IUserContext userContext,
                           ITaxon taxon,
                           IIndividualCategory individualCategory,
                           IFactor factor,
                           ITaxon host,
                           IPeriod period)
        {
            Int32 fieldIndex;

            Id                 = -1;
            _fields            = null;
            _substantialFields = null;
            _mainField         = null;
            _hasId             = false;

            _identifier = CoreData.SpeciesFactManager.GetSpeciesFactIdentifier(taxon,
                                                                               individualCategory,
                                                                               factor,
                                                                               host,
                                                                               period);
            _taxon = taxon;
            _individualCategory = individualCategory;
            _factor             = factor;
            _host            = host;
            _hasHost         = _host.IsNotNull();
            _period          = period;
            _hasPeriod       = _period.IsNotNull();
            _quality         = CoreData.SpeciesFactManager.GetDefaultSpeciesFactQuality(userContext);
            _oldQuality      = _quality;
            _reference       = null;
            _oldReference    = null;
            _modifiedBy      = null;
            _modifiedDate    = DateTime.MinValue;
            _hasModifiedDate = false;

            if (!_factor.UpdateMode.IsHeader)
            {
                _fields            = new SpeciesFactFieldList();
                _substantialFields = new SpeciesFactFieldList();
                _fieldArray        = new ISpeciesFactField[CoreData.FactorManager.GetFactorFieldMaxCount()];
                for (fieldIndex = 0; fieldIndex < CoreData.FactorManager.GetFactorFieldMaxCount(); fieldIndex++)
                {
                    _fieldArray[fieldIndex] = null;
                }

                foreach (FactorField factorField in _factor.DataType.Fields)
                {
                    ISpeciesFactField field;

                    field = new SpeciesFactField(this, factorField, false, null);
                    _fields.Add(field);
                    _fieldArray[field.Index] = field;

                    if (factorField.IsSubstantial)
                    {
                        _substantialFields.Add(field);
                    }

                    if (factorField.IsMain)
                    {
                        _mainField = field;
                    }
                }
            }

            Fields.Sort();
            _shouldBeSaved = AllowUpdate;
        }
コード例 #16
0
        /// <summary>
        /// Creates a species fact instance with data from web service.
        /// </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="individualCategoryId">Individual Category Id of the species fact.</param>
        /// <param name="factorId">Factor id of the species fact.</param>
        /// <param name="host">Host taxon associated with the species fact.</param>
        /// <param name="hasHost">Indicates if this species fact has a host.</param>
        /// <param name="periodId">Period Id of the species fact.</param>
        /// <param name="hasPeriod">Indicates if this species fact has a period.</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="qualityId">Quality Id of the species fact.</param>
        /// <param name="referenceId">Reference id 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 SpeciesFact(IUserContext userContext,
                           Int32 id,
                           ITaxon taxon,
                           Int32 individualCategoryId,
                           Int32 factorId,
                           ITaxon host,
                           Boolean hasHost,
                           Int32 periodId,
                           Boolean hasPeriod,
                           Double fieldValue1,
                           Boolean hasFieldValue1,
                           Double fieldValue2,
                           Boolean hasFieldValue2,
                           Double fieldValue3,
                           Boolean hasFieldValue3,
                           String fieldValue4,
                           Boolean hasFieldValue4,
                           String fieldValue5,
                           Boolean hasFieldValue5,
                           Int32 qualityId,
                           Int32 referenceId,
                           String modifiedBy,
                           DateTime modifiedDate)
        {
            Int32 hostId;
            Int32 fieldIndex;

            Id                 = id;
            _fields            = null;
            _substantialFields = null;
            _mainField         = null;
            _hasId             = true;
            hostId             = 0;
            if (hasHost)
            {
                hostId = host.Id;
            }

            _identifier = CoreData.SpeciesFactManager.GetSpeciesFactIdentifier(taxon.Id,
                                                                               individualCategoryId,
                                                                               factorId,
                                                                               hasHost,
                                                                               hostId,
                                                                               hasPeriod,
                                                                               periodId);

            _taxon = taxon;
            _individualCategory = CoreData.FactorManager.GetIndividualCategory(userContext, individualCategoryId);
            _factor             = CoreData.FactorManager.GetFactor(userContext, factorId);

            if (hasHost)
            {
                _host    = host;
                _hasHost = true;
            }
            else
            {
                if (_factor.IsTaxonomic)
                {
                    _host = CoreData.TaxonManager.GetTaxon(userContext, 0);
                }
                else
                {
                    _host = null;
                }

                _hasHost = _host.IsNotNull();
            }

            if (hasPeriod)
            {
                _period = CoreData.FactorManager.GetPeriod(userContext, periodId);
            }
            else
            {
                _period = null;
            }

            _hasPeriod = hasPeriod;

            _quality         = CoreData.SpeciesFactManager.GetSpeciesFactQuality(userContext, qualityId);
            _oldQuality      = _quality;
            _reference       = CoreData.ReferenceManager.GetReference(userContext, referenceId);
            _oldReference    = _reference;
            _modifiedBy      = modifiedBy;
            _modifiedDate    = modifiedDate;
            _hasModifiedDate = true;

            if (!_factor.UpdateMode.IsHeader)
            {
                _fields            = new SpeciesFactFieldList();
                _substantialFields = new SpeciesFactFieldList();
                _fieldArray        = new ISpeciesFactField[CoreData.FactorManager.GetFactorFieldMaxCount()];
                for (fieldIndex = 0; fieldIndex < CoreData.FactorManager.GetFactorFieldMaxCount(); fieldIndex++)
                {
                    _fieldArray[fieldIndex] = null;
                }

                foreach (FactorField factorField in _factor.DataType.Fields)
                {
                    Boolean          hasFieldValue;
                    SpeciesFactField field;
                    Object           fieldValue;

                    switch (factorField.Index)
                    {
                    case 0:
                        fieldValue    = fieldValue1;
                        hasFieldValue = hasFieldValue1;
                        break;

                    case 1:
                        fieldValue    = fieldValue2;
                        hasFieldValue = hasFieldValue2;
                        break;

                    case 2:
                        fieldValue    = fieldValue3;
                        hasFieldValue = hasFieldValue3;
                        break;

                    case 3:
                        fieldValue    = fieldValue4;
                        hasFieldValue = hasFieldValue4;
                        break;

                    case 4:
                        fieldValue    = fieldValue5;
                        hasFieldValue = hasFieldValue5;
                        break;

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

                    field = new SpeciesFactField(this, factorField, hasFieldValue, fieldValue);
                    _fields.Add(field);
                    _fieldArray[field.Index] = field;

                    if (factorField.IsSubstantial)
                    {
                        _substantialFields.Add(field);
                    }

                    if (factorField.IsMain)
                    {
                        _mainField = field;
                    }
                }
            }

            Fields.Sort();
            _shouldBeSaved = AllowUpdate;
        }
        /// <summary>
        /// Retrieves information about the specified taxon.
        /// </summary>
        /// <param name="taxonId">Id of the taxon.</param>
        /// <returns>Information about the specified taxon.</returns>
        public TaxonSpeciesFactViewModel GetTaxonSpeciesFact(int taxonId)
        {
            mTaxon            = CoreData.TaxonManager.GetTaxon(mUserContext, taxonId);
            mTaxonSpeciesFact = new TaxonSpeciesFactViewModel(mUserContext, mTaxon);

            IIndividualCategory individualCategory          = CoreData.FactorManager.GetDefaultIndividualCategory(mUserContext);
            IPeriod             period                      = CoreData.FactorManager.GetCurrentRedListPeriod(mUserContext);
            PeriodList          periods                     = CoreData.FactorManager.GetPublicPeriods(mUserContext);
            IFactor             categoryFactor              = CoreData.FactorManager.GetFactor(mUserContext, FactorId.RedlistCategory);
            IFactor             criteriaDocumentationFactor = CoreData.FactorManager.GetFactor(mUserContext, FactorId.RedlistCriteriaDocumentation);
            IFactor             criteriaFactor              = CoreData.FactorManager.GetFactor(mUserContext, FactorId.RedlistCriteriaString);
            IFactor             globalCategoryFactor        = CoreData.FactorManager.GetFactor(mUserContext, FactorId.GlobalRedlistCategory);
            //FactorList landscapeTypesFactors = LandscapeTypeCache.GetFactors(mUserContext);
            //FactorList lifeFormFactors = LifeFormCache.GetFactors(mUserContext);
            FactorList conventionFactors    = CoreData.FactorManager.GetFactorTree(mUserContext, FactorId.Conventions).GetAllLeafFactors();
            IFactor    organismGroup1Factor = CoreData.FactorManager.GetFactor(mUserContext, FactorId.Redlist_OrganismLabel1);
            IFactor    organismGroup2Factor = CoreData.FactorManager.GetFactor(mUserContext, FactorId.Redlist_OrganismLabel2);
            //FactorList countyOccurrenceFactors = CountyOccurrenceCache.GetFactors(mUserContext);
            //FactorList biotopeFactors = BiotopeCache.GetFactors(mUserContext);
            //FactorList substrateFactors = SubstrateCache.GetFactors(mUserContext);
            //FactorList impactFactors = ImpactCache.GetFactors(mUserContext);
            IFactor actionPlanFactor        = CoreData.FactorManager.GetFactor(mUserContext, FactorId.ActionPlan);
            IFactor protectedByLawFactor    = CoreData.FactorManager.GetFactor(mUserContext, FactorId.ProtectedByLaw);
            IFactor swedishOccurrenceFactor = CoreData.FactorManager.GetFactor(mUserContext, FactorId.SwedishOccurrence);
            //FactorList hostFactors = HostCache.GetFactors(mUserContext);

            // Get species facts.
            var          countyOccurrenceSpeciesFacts     = new SpeciesFactList();
            var          landscapeTypeSpeciesFacts        = new SpeciesFactList();
            var          biotopeSpeciesFacts              = new SpeciesFactList();
            var          lifeFormSpeciesFacts             = new SpeciesFactList();
            var          conventionSpeciesFacts           = new SpeciesFactList();
            var          previouslyCategorySpeciesFact    = new SpeciesFactList();
            ISpeciesFact categorySpeciesFact              = null;
            ISpeciesFact criteriaDocumentationSpeciesFact = null;
            ISpeciesFact criteriaSpeciesFact              = null;
            ISpeciesFact globalCategorySpeciesFact        = null;
            ISpeciesFact organismGroup1SpeciesFact        = null;
            ISpeciesFact organismGroup2SpeciesFact        = null;
            var          substrateSpeciesFacts            = new SpeciesFactList();
            var          impactSpeciesFacts           = new SpeciesFactList();
            ISpeciesFact actionPlanSpeciesFact        = null;
            ISpeciesFact protectedByLawSpeciesFact    = null;
            ISpeciesFact swedishOccurrenceSpeciesFact = null;
            var          hostSpeciesFacts             = new SpeciesFactList();
            ISpeciesFactSearchCriteria searchCriteria = new SpeciesFactSearchCriteria {
                Factors = new FactorList()
            };

            searchCriteria.AddTaxon(mTaxon);
            searchCriteria.Add(individualCategory);
            foreach (IPeriod tempPeriod in periods)
            {
                searchCriteria.Add(tempPeriod);
            }

            // Add current period if not exist.
            bool currentPeriodExist = periods.Any(tempPeriod => tempPeriod.Id == period.Id);

            if (!currentPeriodExist)
            {
                searchCriteria.Add(period);
            }

            searchCriteria.Add(categoryFactor);
            searchCriteria.Add(criteriaDocumentationFactor);
            searchCriteria.Add(criteriaFactor);
            searchCriteria.Add(globalCategoryFactor);
            //searchCriteria.Factors.AddRange(landscapeTypesFactors);
            //searchCriteria.Factors.AddRange(lifeFormFactors);
            searchCriteria.Factors.AddRange(conventionFactors);
            searchCriteria.Add(organismGroup1Factor);
            searchCriteria.Add(organismGroup2Factor);
            //searchCriteria.Factors.AddRange(countyOccurrenceFactors);
            //searchCriteria.Factors.AddRange(biotopeFactors);
            //searchCriteria.Factors.AddRange(substrateFactors);
            //searchCriteria.Factors.AddRange(impactFactors);
            searchCriteria.Add(actionPlanFactor);
            searchCriteria.Add(protectedByLawFactor);
            searchCriteria.Add(swedishOccurrenceFactor);
            //searchCriteria.Factors.AddRange(hostFactors);
            SpeciesFactList speciesFacts = CoreData.SpeciesFactManager.GetSpeciesFacts(mUserContext, searchCriteria);

            // Split species facts into information groups.
            if (speciesFacts.IsNotEmpty())
            {
                foreach (ISpeciesFact speciesFact in speciesFacts)
                {
                    //if (countyOccurrenceFactors.Exists(speciesFact.Factor))
                    //{
                    //    countyOccurrenceSpeciesFacts.Add(speciesFact);
                    //}
                    //else if (landscapeTypesFactors.Exists(speciesFact.Factor))
                    //{
                    //    landscapeTypeSpeciesFacts.Add(speciesFact);
                    //}
                    //else if (biotopeFactors.Exists(speciesFact.Factor))
                    //{
                    //    biotopeSpeciesFacts.Add(speciesFact);
                    //}
                    //else if (substrateFactors.Exists(speciesFact.Factor))
                    //{
                    //    substrateSpeciesFacts.Add(speciesFact);
                    //    if (hostFactors.Exists(speciesFact.Factor))
                    //    {
                    //        hostSpeciesFacts.Add(speciesFact);
                    //    }
                    //}
                    //else if (impactFactors.Exists(speciesFact.Factor))
                    //{
                    //    impactSpeciesFacts.Add(speciesFact);
                    //}
                    //else if (lifeFormFactors.Exists(speciesFact.Factor))
                    //{
                    //    lifeFormSpeciesFacts.Add(speciesFact);
                    //}
                    if (conventionFactors.Exists(speciesFact.Factor))
                    {
                        conventionSpeciesFacts.Add(speciesFact);
                    }
                    else if (speciesFact.Factor.Id == (int)FactorId.RedlistCategory && speciesFact.Period.Id != period.Id)
                    {
                        previouslyCategorySpeciesFact.Add(speciesFact);
                    }
                    else
                    {
                        switch (speciesFact.Factor.Id)
                        {
                        case (int)FactorId.ActionPlan:
                            actionPlanSpeciesFact = speciesFact;
                            break;

                        case (int)FactorId.GlobalRedlistCategory:
                            globalCategorySpeciesFact = speciesFact;
                            break;

                        case (int)FactorId.ProtectedByLaw:
                            protectedByLawSpeciesFact = speciesFact;
                            break;

                        case (int)FactorId.RedlistCategory:
                            categorySpeciesFact = speciesFact;
                            break;

                        case (int)FactorId.RedlistCriteriaDocumentation:
                            criteriaDocumentationSpeciesFact = speciesFact;
                            break;

                        case (int)FactorId.RedlistCriteriaString:
                            criteriaSpeciesFact = speciesFact;
                            break;

                        case (int)FactorId.Redlist_OrganismLabel1:
                            organismGroup1SpeciesFact = speciesFact;
                            break;

                        case (int)FactorId.Redlist_OrganismLabel2:
                            organismGroup2SpeciesFact = speciesFact;
                            break;

                        case (int)FactorId.SwedishOccurrence:
                            swedishOccurrenceSpeciesFact = speciesFact;
                            break;
                        }
                    }
                }
            }

            //mTaxonSpeciesFact.InitCountyOccurrenceInformation(countyOccurrenceSpeciesFacts);
            //mTaxonSpeciesFact.InitLandscapeTypeInformation(landscapeTypeSpeciesFacts);
            //mTaxonSpeciesFact.InitBiotopeInformation(biotopeSpeciesFacts);
            //mTaxonSpeciesFact.InitLifeFormInformation(lifeFormSpeciesFacts);
            //mTaxonSpeciesFact.InitConventionInformation(conventionSpeciesFacts);
            InitRedListInformation(
                mTaxonSpeciesFact,
                categorySpeciesFact,
                criteriaSpeciesFact,
                criteriaDocumentationSpeciesFact,
                globalCategorySpeciesFact,
                period);
            //mTaxonSpeciesFact.InitOrganismGroupInformation(organismGroup1SpeciesFact,
            //                                              organismGroup2SpeciesFact);
            //mTaxonSpeciesFact.InitSubstrateInformation(substrateSpeciesFacts);
            //mTaxonSpeciesFact.InitImpactInformation(impactSpeciesFacts);
            //mTaxonSpeciesFact.InitActionPlanInformation(actionPlanSpeciesFact);
            //mTaxonSpeciesFact.InitProtectedByLawInformation(protectedByLawSpeciesFact);
            //mTaxonSpeciesFact.InitHostInformation(hostSpeciesFacts, mUserContext);
            //mTaxonSpeciesFact.InitSwedishOccurrenceInformation(swedishOccurrenceSpeciesFact);
            //mTaxonSpeciesFact.InitPreviouslyRedListedCategories(previouslyCategorySpeciesFact);
            //GetSpeciesInformationDocument();
            //long pictureId;
            //mTaxonSpeciesFact.HasImage = !string.IsNullOrWhiteSpace(GetPictureByTaxon(mTaxon,
            //                                                       AppSettings.Default.PictureXtraLargeHeight,
            //                                                       AppSettings.Default.PictureXtraLargeWidth,
            //                                                       AppSettings.Default.PictureLargeSize,
            //                                                       true,
            //                                                       string.Empty,
            //                                                       out pictureId));
            //mTaxonSpeciesFact.ImageMetaData = GetPictureMetadataByPictureId(pictureId);
            //mTaxonSpeciesFact.HasCountyMap = GetCountyMap(mTaxon) != null;
            //mTaxonSpeciesFact.HasObservationMap = SpeciesFilter.IsTaxaSpeciesOrBelow(mTaxon) &&
            //    SpeciesFactCacheManager.Instance.GetObservationMap(mTaxon.Id.ToString(CultureInfo.InvariantCulture)) != null;

            mTaxonSpeciesFact.HasSpeciesFacts = HasSpeciesFacts(speciesFacts);
            mTaxonSpeciesFact.IsValid         = CheckIfTaxonValid();

            //mTaxonSpeciesFact.Synonyms = mTaxon.GetSynonymsViewModel(mUserContext);

            // Identify higher level taxa
            //mTaxonSpeciesFact.CategoryNameHighLevel = SpeciesFilter.IsTaxaSpeciesOrBelow(mTaxon) ? "" : mTaxon.Category.Name + " - ";

            //// Ignore if not higher taxa
            //if ((mTaxonSpeciesFact.IsHigherTaxa = !SpeciesFilter.IsTaxaSpeciesOrBelow(mTaxon)) == false)
            //{
            //    return mTaxonSpeciesFact;
            //}

            // Count all occurences for each category in underlying taxa
            //var taxonNameSearchInformation = TaxonNameSearchManager.Instance.GetInformation(this.mTaxon.Id);
            //foreach (var category in RedListedHelper.GetAllRedListCategories())
            //{
            //    mTaxonSpeciesFact.RedListCategoryTaxa[category] = new List<int>();
            //}

            //foreach (var taxonInfoType in taxonNameSearchInformation.AllChildTaxaIdsInScope)
            //{
            //    if (SpeciesFilter.IsTaxaSpeciesOrBelow(taxonInfoType.CategoryId, taxonInfoType.ParentCategoryId) && taxonInfoType.HasValidRedListCategory)
            //    {
            //        mTaxonSpeciesFact.RedListCategoryTaxa[taxonInfoType.RedListCategoryId].Add(taxonInfoType.TaxonId);
            //    }
            //}

            return(mTaxonSpeciesFact);
        }
コード例 #18
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);
        }