/// <summary>
        /// Get all taxa for the species observations
        /// that matches the search criteria.
        /// </summary>
        /// <param name="searchCriteria">The search criteria for the species observations.</param>
        /// <returns>Taxa information.</returns>
        public static TaxonList GetTaxaBySpeciesObservations(SpeciesObservationSearchCriteria searchCriteria)
        {
            WebSpeciesObservationSearchCriteria webSearchCriteria;
            List <WebTaxon> webTaxa;

            // Check arguments.
            searchCriteria.CheckNotNull("searchCriteria");

            // Get data from web service.
            webSearchCriteria = GetSpeciesObservationSearchCriteria(searchCriteria);
            webTaxa           = WebServiceClient.GetTaxaBySpeciesObservations(webSearchCriteria);
            return(TaxonManager.GetTaxa(webTaxa));
        }
        /// <summary>
        /// Reades one row from the xml format.
        /// </summary>
        /// <param name='xmlDoc'>The xml document that the row node will be read from.</param>
        /// <param name="nsmgr">Namespacemanager containing all namespaces used by the excel compatible xml format</param>
        protected override void ReadXmlRows(XmlDocument xmlDoc, XmlNamespaceManager nsmgr)
        {
            List <int> taxonIDs = new List <int>();

            XmlNodeList rowNodes = xmlDoc.SelectNodes("/ss:Workbook/ss:Worksheet/ss:Table/ss:Row", nsmgr);

            foreach (XmlNode rowNode in rowNodes)
            {
                XmlNode dataNode = rowNode.SelectSingleNode("ss:Cell/ss:Data", nsmgr);
                int     taxonId  = Convert.ToInt32(dataNode.InnerText);
                taxonIDs.Add(taxonId);
            }

            this.AddRange(TaxonManager.GetTaxa(taxonIDs, ArtDatabanken.Data.WebService.TaxonInformationType.Basic));
        }
 /// <summary>
 /// Create a Taxon instance.
 /// </summary>
 /// <param name='id'>Id for taxon type.</param>
 /// <param name='taxonTypeId'>Id for type of taxon.</param>
 /// <param name='sortOrder'>Sort order among taxa.</param>
 /// <param name="taxonInformationType">Type of taxon information in this object.</param>
 /// <param name="scientificName">Scientific name for this taxon.</param>
 /// <param name="author">Author of the scientific name for this taxon.</param>
 /// <param name="commonName">Common name for this taxon.</param>
 public Taxon(Int32 id,
              Int32 taxonTypeId,
              Int32 sortOrder,
              TaxonInformationType taxonInformationType,
              String scientificName,
              String author,
              String commonName)
     : base(id, sortOrder)
 {
     _taxonType            = TaxonManager.GetTaxonType(taxonTypeId);
     _taxonInformationType = taxonInformationType;
     _scientificName       = scientificName;
     _author     = author;
     _commonName = commonName;
     _taxonNames = null;
 }
示例#4
0
 /// <summary>
 /// Create a TaxonName instance.
 /// </summary>
 /// <param name='id'>Id for taxon name.</param>
 /// <param name='taxonId'>Id for the taxon that this name belongs to.</param>
 /// <param name='taxonNameTypeId'>Id for type of name.</param>
 /// <param name='taxonNameUseTypeId'>Id for use of name.</param>
 /// <param name='name'>Name for taxon name.</param>
 /// <param name='author'>Author of this taxon name.</param>
 /// <param name='isRecommended'>Information about if this is the recommended name.</param>
 public TaxonName(Int32 id,
                  Int32 taxonId,
                  Int32 taxonNameTypeId,
                  Int32 taxonNameUseTypeId,
                  String name,
                  String author,
                  Boolean isRecommended)
     : base(id)
 {
     _taxonId          = taxonId;
     _taxonNameType    = TaxonManager.GetTaxonNameType(taxonNameTypeId);
     _taxonNameUseType = TaxonManager.GetTaxonNameUseType(taxonNameUseTypeId);
     _name             = name;
     _author           = author;
     _taxon            = null;
     _isRecommended    = isRecommended;
 }
        /// <summary>
        /// Creates a species fact instance with data from web service.
        /// </summary>
        /// <param name="id">Id of the species fact</param>
        /// <param name="sortOrder">Sort order 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">Foctor 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="updateUserFullName">Full Name of the pdate user of the species fact</param>
        /// <param name="updateDate">Update date of the species fact</param>
        public SpeciesFact(
            Int32 id,
            Int32 sortOrder,
            Taxon taxon,
            Int32 individualCategoryId,
            Int32 factorId,
            Taxon 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 updateUserFullName,
            DateTime updateDate)
            : base(id, sortOrder)
        {
            Int32 hostId;
            Int32 fieldIndex;

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

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

            _taxon = taxon;
            _individualCategory = IndividualCategoryManager.GetIndividualCategory(individualCategoryId);
            _factor             = FactorManager.GetFactor(factorId);

            if (hasHost)
            {
                _host    = host;
                _hasHost = hasHost;
            }
            else
            {
                if (_factor.IsTaxonomic)
                {
                    _host = TaxonManager.GetTaxon(0, TaxonInformationType.Basic);
                }
                else
                {
                    _host = null;
                }
                _hasHost = _host.IsNotNull();
            }



            if (hasPeriod)
            {
                _period = PeriodManager.GetPeriod(periodId);
            }
            else
            {
                _period = null;
            }
            _hasPeriod = hasPeriod;

            _quality            = SpeciesFactManager.GetSpeciesFactQuality(qualityId);
            _oldQuality         = _quality;
            _reference          = ReferenceManager.GetReference(referenceId);
            _oldReference       = _reference;
            _updateUserFullName = updateUserFullName;
            _updateDate         = updateDate;
            _hasUpdateDate      = true;

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

                foreach (FactorField factorField in _factor.FactorDataType.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;
                    }
                }
            }
            _shouldBeSaved = AllowUpdate;
        }
示例#6
0
        /// <summary>
        /// Get string with taxonomic information.
        /// </summary>
        /// <returns>String with taxonomic information.</returns>
        private String GetAutomaticTaxonomicString()
        {
            StringBuilder text;

            if (_taxonomicParagraphSpeciesFact.IsNotNull() &&
                (_taxonomicParagraphSpeciesFact.Quality.Id == (Int32)SpeciesFactQualityId.VerryGood) &&
                _taxonomicParagraphSpeciesFact.Field5.HasValue)
            {
                return(_taxonomicParagraphSpeciesFact.Field5.StringValue);
            }

            text = new StringBuilder();
            if (_taxon.IsNotNull())
            {
                _italicStringsInAutomaticTaxonomicParagraph.Clear();

                TaxonSearchCriteria criteria = new TaxonSearchCriteria();
                List <Int32>        taxonIds = new List <Int32>();
                taxonIds.Add(_taxon.Id);
                criteria.RestrictSearchToTaxonIds = taxonIds;
                criteria.RestrictReturnToScope    = WebService.TaxonSearchScope.AllParentTaxa;
                TaxonList parentTaxa      = TaxonManager.GetTaxaBySearchCriteria(criteria);
                TaxonList suitableParents = new TaxonList();
                foreach (Taxon parent in parentTaxa)
                {
                    if ((parent.TaxonType.Id == (Int32)(TaxonTypeId.Kingdom)) ||
                        (parent.TaxonType.Id == (Int32)(TaxonTypeId.Phylum)) ||
                        (parent.TaxonType.Id == (Int32)(TaxonTypeId.Class)) ||
                        (parent.TaxonType.Id == (Int32)(TaxonTypeId.Order)) ||
                        (parent.TaxonType.Id == (Int32)(TaxonTypeId.Family)))
                    {
                        if (!(parent.Id == (Int32)TaxonId.Dummy))
                        {
                            suitableParents.Add(parent);
                        }
                    }
                }
                Int32 startFromIndex = suitableParents.Count - 3;
                if (startFromIndex < 0)
                {
                    startFromIndex = 0;
                }
                for (Int32 index = startFromIndex; index < suitableParents.Count; index++)
                {
                    if (text.ToString() != String.Empty)
                    {
                        text.Append(", ");
                    }
                    text.Append(suitableParents[index].TaxonType.Label + " ");
                    text.Append(suitableParents[index].ScientificName);

                    //Eventuellt ska denna kodrad tas bort (förslag från Tomas Hallingbäck): Överordnade taxa bör ej vara kursiverade
                    //Enligt artexperternas diskussion 2010-03-04 ska överordnade vetenskapliga taxonnamn ej kursiveras!
                    //_italicStringsInAutomaticTaxonomicParagraph.Add(suitableParents[index].ScientificName);

                    if (suitableParents[index].CommonName.IsNotEmpty())
                    {
                        text.Append(" (" + suitableParents[index].CommonName + ")");
                    }
                }

                if (text.ToString() != String.Empty)
                {
                    text.Append(", ");
                }

                text.Append(_taxon.ScientificNameAndAuthor);
                _italicStringsInAutomaticTaxonomicParagraph.Add(_taxon.ScientificName);

                TaxonNameList Synonyms = new TaxonNameList();
                foreach (TaxonName name in _taxon.TaxonNames)
                {
                    if ((name.TaxonNameType.Id == 0) &&
                        (name.TaxonNameUseType.Id == 0) &&
                        (!name.IsRecommended) &&
                        (name.Name != _taxon.ScientificName))
                    {
                        _italicStringsInAutomaticTaxonomicParagraph.Add(name.Name);
                        Synonyms.Add(name);
                    }
                }

                if (Synonyms.Count > 0)
                {
                    text.Append(". Syn. ");
                    for (Int32 itemIndex = 0; itemIndex < Synonyms.Count; itemIndex++)
                    {
                        if (itemIndex > 0)
                        {
                            if (itemIndex == Synonyms.Count - 1)
                            {
                                text.Append(" och ");
                            }
                            else
                            {
                                text.Append(", ");
                            }
                        }

                        text.Append(Synonyms[itemIndex].Name);
                        if (Synonyms[itemIndex].Author.IsNotEmpty())
                        {
                            text.Append(" " + Synonyms[itemIndex].Author);
                        }
                    }
                }
                if (text.ToString() != String.Empty)
                {
                    text.Append(". ");
                }
            }
            String cleanText = text.ToString().Replace("..", ".");

            return(cleanText);
        }
示例#7
0
 /// <summary>
 /// Creates a instance of a Species Information Document object based on TaxonId.
 /// </summary>
 /// <param name="taxonId">Id of the taxon</param>
 public SpeciesEncyclopediaArticle(Int32 taxonId)
     : this(TaxonManager.GetTaxon(taxonId, TaxonInformationType.Basic))
 {
 }
 /// <summary>
 /// Creates a instance of a Species Information Document object based on TaxonId.
 /// </summary>
 /// <param name="taxonId">Id of the taxon</param>
 public SpeciesInformationDocument(Int32 taxonId)
     : this(TaxonManager.GetTaxon(taxonId, TaxonInformationType.Basic))
 {
 }