public string GetScientificSynonyms(ITaxon taxon) { if (taxon == null || taxon.GetSynonyms(CoreData.UserManager.GetCurrentUser(), true) == null) { return(""); } var names = new StringBuilder(); foreach (var taxonName in taxon.GetSynonyms(CoreData.UserManager.GetCurrentUser(), true)) { if (names.Length > 0) { names.Append("; "); } names.Append(taxonName.Name); if (!string.IsNullOrEmpty(taxonName.Author)) { names.Append(" "); names.Append(taxonName.Author); } } //IList<ITaxonName> list = taxon.GetTaxonNamesBySearchCriteria(null, null, null, false, true, false); return(names.ToString()); }
/// <summary> /// Gets a string with taxons all synonyms separated by ;. /// </summary> /// <param name="taxon">The taxon.</param> /// <returns>a string with taxons all synonyms separated by ;.</returns> public static string GetScientificSynonymsString(this ITaxon taxon) { if (taxon == null || taxon.GetSynonyms(CoreData.UserManager.GetCurrentUser(), true) == null) { return(""); } var names = new StringBuilder(); foreach (var taxonName in taxon.GetSynonyms(CoreData.UserManager.GetCurrentUser(), true)) { if (names.Length > 0) { names.Append("; "); } names.Append(taxonName.Name); if (!string.IsNullOrEmpty(taxonName.Author)) { names.Append(" "); names.Append(taxonName.Author); } } return(names.ToString()); }
/// <summary> /// Creates a ChangeNameItem /// </summary> /// <remarks> /// Example: /// Here we choose to move the taxon A2 and all its children to Parent B /// In this step we create the taxon A221 => the following references is used: /// /// Parent A (oldParentTaxon) Parent B (newParentTaxon) /// |-A1 /// |-A2 (movedTaxonParent) /// |-A21 /// |-A22 /// |A221 (taxon) /// </remarks> public static ChangeNameItem CreateChangeNameItem(ITaxon taxon, ITaxon movedTaxonParent, ITaxon oldParentTaxon, ITaxon newParentTaxon, IUserContext user) { ChangeNameItem model = new ChangeNameItem(); model.TaxonId = taxon.Id; model.Category = taxon.Category.Name; model.OldName = taxon.ScientificName.IsNotEmpty() ? taxon.ScientificName : string.Format("({0})", DyntaxaResource.ErrorNameIsMissing); model.OldAuthor = taxon.Author.IsNotEmpty() ? taxon.Author : ""; model.Name = GetNewRecommendedName(taxon, oldParentTaxon, newParentTaxon); model.Author = model.OldAuthor; model.NameId = -1; // Synonyms model.Synonyms = new List <SynonymName>(); List <ITaxonName> synonyms = taxon.GetSynonyms(CoreData.UserManager.GetCurrentUser(), true); if (synonyms != null) { foreach (var taxonName in synonyms) { model.Synonyms.Add(new SynonymName(taxonName, taxon)); } } //foreach (var taxonName in taxon.TaxonNames) //{ // if (taxonName.NameCategory.Id == TaxonNameCategoryIds.SCIENTIFIC_NAME && taxonName.NameUsage.Id == (int)TaxonNameUsageId.ApprovedNaming) // { // model.Synonyms.Add(new SynonymeName(taxonName, taxon)); // } //} return(model); }
private List <TaxonNameViewModel> GetSynonyms(ITaxon taxon) { var synonymsList = new List <TaxonNameViewModel>(); var synonyms = taxon.GetSynonyms(_userContext, false); foreach (ITaxonName taxonName in synonyms) { synonymsList.Add(new TaxonNameViewModel(taxonName, taxon)); } return(synonymsList); }
/// <summary> /// All taxon synonyms /// </summary> public static List <TaxonNameViewModel> GetSynonymsViewModel(this ITaxon taxon, bool isInRevision, bool isEditorUser, bool includeProParteSynonyms) { List <ITaxonName> synonyms = taxon.GetSynonyms(CoreData.UserManager.GetCurrentUser(), includeProParteSynonyms); synonyms = synonyms.OrderBy(t => t.Category.Id).ThenBy(t => t.Status.SortOrder()).ToList(); List <TaxonNameViewModel> resultList = new List <TaxonNameViewModel>(); foreach (ITaxonName taxonName in synonyms) { if (IsNameOkToShow(taxonName, isInRevision, isEditorUser)) { resultList.Add(new TaxonNameViewModel(taxonName, taxon)); } } return(resultList); }