コード例 #1
0
        /// <summary>
        /// Convert a WebTaxonName array to a TaxonNameList.
        /// </summary>
        /// <param name="webTaxonNames">Web taxon names.</param>
        /// <returns>Taxon names.</returns>
        private static TaxonNameList GetTaxonNames(List <WebTaxonName> webTaxonNames)
        {
            DataFieldList dataFields;
            TaxonName     taxonName;
            TaxonNameList taxonNames = null;

            if (webTaxonNames.IsNotEmpty())
            {
                taxonNames = new TaxonNameList();
                foreach (WebTaxonName webTaxonName in webTaxonNames)
                {
                    dataFields = new DataFieldList(webTaxonName.Taxon.DataFields);
                    taxonName  = new TaxonName(webTaxonName.Id,
                                               webTaxonName.Taxon.Id,
                                               webTaxonName.TaxonNameTypeId,
                                               webTaxonName.TaxonNameUseTypeId,
                                               webTaxonName.Name,
                                               webTaxonName.Author,
                                               webTaxonName.IsRecommended);
                    taxonName.Taxon = new TaxonPrintObs(webTaxonName.Taxon.Id,
                                                        webTaxonName.Taxon.TaxonTypeId,
                                                        webTaxonName.Taxon.SortOrder,
                                                        webTaxonName.Taxon.TaxonInformationType,
                                                        webTaxonName.Taxon.ScientificName,
                                                        webTaxonName.Taxon.Author,
                                                        webTaxonName.Taxon.CommonName,
                                                        dataFields.GetString(TaxonPrintObs.PHYLUM_DATA_FIELD),
                                                        dataFields.GetString(TaxonPrintObs.CLASS_DATA_FIELD),
                                                        dataFields.GetString(TaxonPrintObs.ORDER_DATA_FIELD),
                                                        dataFields.GetString(TaxonPrintObs.FAMILY_DATA_FIELD));
                    taxonNames.Add(taxonName);
                }
            }
            return(taxonNames);
        }
コード例 #2
0
 private ArtDatabanken.Data.ArtDatabankenService.TaxonNameList GetTaxonNames()
 {
     if (_taxonNames.IsNull())
     {
         _taxonNames = TaxonManagerTest.GetSomeTaxonNames();
     }
     return(_taxonNames);
 }
コード例 #3
0
 /// <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
        public void SquareBracketOperator()
        {
            Int32 taxonNameIndex;

            ArtDatabanken.Data.ArtDatabankenService.TaxonNameList newTaxonNameList, oldTaxonNameList;

            oldTaxonNameList = GetTaxonNames();
            newTaxonNameList = new ArtDatabanken.Data.ArtDatabankenService.TaxonNameList();
            for (taxonNameIndex = 0; taxonNameIndex < oldTaxonNameList.Count; taxonNameIndex++)
            {
                newTaxonNameList.Add(oldTaxonNameList[oldTaxonNameList.Count - taxonNameIndex - 1]);
            }
            for (taxonNameIndex = 0; taxonNameIndex < oldTaxonNameList.Count; taxonNameIndex++)
            {
                Assert.AreEqual(newTaxonNameList[taxonNameIndex], oldTaxonNameList[oldTaxonNameList.Count - taxonNameIndex - 1]);
            }
        }
コード例 #5
0
 public TaxonNameListTest()
 {
     _taxonNames = null;
 }
コード例 #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>
        /// Update species fact fields from Dyntaxa.
        /// </summary>
        public void SetTaxonNameValues()
        {
            if (AllowAutomaticUpdate)
            {
                StringBuilder summary = new StringBuilder();
                summary.Append(this.Taxon.ScientificNameAndAuthor);
                summary.Append(".");
                TaxonNameList scientificNames = new TaxonNameList();
                TaxonNameList swedishNames    = new TaxonNameList();
                //TaxonName originalName;
                foreach (TaxonName name in this.Taxon.TaxonNames)
                {
                    if (name.TaxonNameType.Id == 0 &&
                        name.TaxonNameUseType.Id == 0 &&
                        !name.IsRecommended)
                    {
                        scientificNames.Add(name);
                    }

                    if (name.TaxonNameType.Id == 1 &&
                        name.TaxonNameUseType.Id == 0 &&
                        !name.IsRecommended)
                    {
                        swedishNames.Add(name);
                    }
                }

                if (scientificNames.IsNotEmpty())
                {
                    if (scientificNames.Count == 1)
                    {
                        summary.Append(" Synonym: ");
                        summary.Append(scientificNames[0].Name);
                        if (scientificNames[0].Author.IsNotEmpty())
                        {
                            summary.Append(" ");
                            summary.Append(scientificNames[0].Author);
                            summary.Append(".");
                        }
                    }
                    else
                    {
                        summary.Append(" Synonymer: ");
                        for (int i = 0; i < scientificNames.Count - 1; i++)
                        {
                            summary.Append(scientificNames[i].Name);
                            if (scientificNames[i].Author.IsNotEmpty())
                            {
                                summary.Append(" ");
                                summary.Append(scientificNames[i].Author);
                            }
                            if (i < (scientificNames.Count - 2))
                            {
                                summary.Append(", ");
                            }
                        }
                        summary.Append(" och ");
                        summary.Append(scientificNames[scientificNames.Count - 1].Name);
                        if (scientificNames[scientificNames.Count - 1].Author.IsNotEmpty())
                        {
                            summary.Append(" ");
                            summary.Append(scientificNames[scientificNames.Count - 1].Author);
                        }
                        summary.Append(".");
                    }
                }

                if (swedishNames.IsNotEmpty())
                {
                    if (swedishNames.Count == 1)
                    {
                        summary.Append(" Svensk synonym: ");
                        summary.Append(swedishNames[0].Name);
                        summary.Append(".");
                    }
                    else
                    {
                        summary.Append(" Svenska synonymer: ");
                        for (int i = 0; i < swedishNames.Count - 1; i++)
                        {
                            summary.Append(scientificNames[i].Name);
                            if (i < (swedishNames.Count - 2))
                            {
                                summary.Append(", ");
                            }
                        }
                        summary.Append(" och ");
                        summary.Append(swedishNames[swedishNames.Count - 1].Name);
                        summary.Append(".");
                    }
                }

                Field5.SetValueAutomatic(summary.ToString());
            }
        }