Beispiel #1
0
        public static MvcHtmlString RenderTaxonLink(this HtmlHelper htmlHelper, string scientificName, string commonName, int sortOrder, string action, string controller, object routeValues)
        {
            UrlHelper  urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);
            TagBuilder linkTag   = new TagBuilder("a");
            string     url       = urlHelper.Action(action, controller, routeValues);

            linkTag.MergeAttribute("href", url);
            ITaxonCategory genusTaxonCategory = CoreData.TaxonManager.GetTaxonCategory(
                CoreData.UserManager.GetCurrentUser(),
                TaxonCategoryId.Genus);

            if (sortOrder >= genusTaxonCategory.SortOrder)
            {
                TagBuilder tag = new TagBuilder("em");
                tag.SetInnerText(scientificName);
                linkTag.InnerHtml = tag.ToString(TagRenderMode.Normal);
            }
            else
            {
                linkTag.SetInnerText(scientificName);
            }

            if (!string.IsNullOrEmpty(commonName))
            {
                linkTag.InnerHtml += string.Format(" ({0})", commonName);
            }

            return(MvcHtmlString.Create(linkTag.ToString(TagRenderMode.Normal)));
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportTaxonListExcelFile"/> class.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <param name="exportTaxonItems">The export taxon items.</param>
        /// <param name="fileFormat">The file format.</param>
        public ExportTaxonListExcelFile(
            ExportViewModel options,
            List <ExportTaxonItem> exportTaxonItems,
            ExcelFileFormat fileFormat)
        {
            HttpRequest request;

            _options                 = options;
            _columnCount             = 0;
            _exportTaxonItems        = exportTaxonItems;
            _fileFormat              = fileFormat;
            _genusTaxonCategory      = options.TaxonCategories.Get((Int32)TaxonCategoryId.Genus);
            _parentTaxaCategoryNames = new List <String>();
            _rowCount                = exportTaxonItems.Count + 1;
            _taxonBaseUrl            = "";
            _utf7Encoding            = new UTF7Encoding();
            if (options.OutputTaxonUrl && HttpContext.Current.IsNotNull())
            {
                request       = HttpContext.Current.Request;
                _taxonBaseUrl = request.Url.GetLeftPart(UriPartial.Authority).ToLower() + request.ApplicationPath.ToLower();
                if (!_taxonBaseUrl.EndsWith("/"))
                {
                    _taxonBaseUrl += "/";
                }

                _taxonBaseUrl += @"taxon/info/";
            }
        }
 public CategoryTaxaViewModel(ITaxonCategory category)
 {
     CategoryName      = category.Name;
     CategoryId        = category.Id;
     CategorySortOrder = category.SortOrder;
     Taxa = new List <TaxonViewModel>();
 }
        public static MvcHtmlString RenderScientificName(this HtmlHelper htmlHelper, string name, string author, int sortOrder, bool isOriginal = false)
        {
            var result = new StringBuilder();

            ITaxonCategory genusTaxonCategory = CoreData.TaxonManager.GetTaxonCategory(CoreData.UserManager.GetCurrentUser(),
                                                                                       TaxonCategoryId.Genus);

            if (sortOrder >= genusTaxonCategory.SortOrder)
            {
                var tag = new TagBuilder("em");
                tag.SetInnerText(name);
                result.Append(tag.ToString());
            }
            else
            {
                result.Append(htmlHelper.Encode(name));
            }

            if (!string.IsNullOrEmpty(author))
            {
                result.Append(" ");
                result.Append(htmlHelper.Encode(author));
            }
            if (isOriginal)
            {
                result.Append("*");
            }
            return(MvcHtmlString.Create(result.ToString()));
        }
        /// <summary>
        /// Indicates whether or not the taxon is ranked after genus.
        /// </summary>
        /// <param name="taxon">The taxon.</param>
        /// <param name="userContext">The user context.</param>
        /// <returns>True if taxon is ranked after genus.</returns>
        public static Boolean IsBelowGenus(this ITaxon taxon, IUserContext userContext)
        {
            if (_genusTaxonCategory.IsNull())
            {
                _genusTaxonCategory = CoreData.TaxonManager.GetTaxonCategory(userContext, TaxonCategoryId.Genus);
            }

            return(taxon.Category.SortOrder > _genusTaxonCategory.SortOrder);
        }
 public RelatedTaxonViewModel(ITaxon taxon, ITaxonCategory taxonCategory, DateTime?endDate)
 {
     this.CommonName     = taxon.CommonName.IsNotEmpty() ? taxon.CommonName : "";
     this.EndDate        = endDate;
     this.ScientificName = taxon.ScientificName.IsEmpty() ? string.Format("({0})", Resource.ErrorNameIsMissing) : taxon.ScientificName;
     this.SortOrder      = taxonCategory.SortOrder;
     this.Category       = taxonCategory.Name;
     this.TaxonId        = taxon.Id;
 }
Beispiel #7
0
        public static ExportTaxonCategory Create(ITaxonCategory taxonCategory, bool isChecked)
        {
            var model = new ExportTaxonCategory();

            model.IsChecked    = isChecked;
            model.CategoryName = taxonCategory.Name;
            model.CategoryId   = taxonCategory.Id;
            //model.Id = taxonCategory.Id;
            model.SortOrder = taxonCategory.SortOrder;
            return(model);
        }
        /// <summary>
        /// Indicates whether or not the taxon is ranked after genus.
        /// </summary>
        /// <param name="taxon">The taxon.</param>
        /// <returns>True if taxon is ranked after genus.</returns>
        public static Boolean IsBelowGenus(this ITaxon taxon)
        {
            if (_genusTaxonCategory.IsNull())
            {
                _genusTaxonCategory = CoreData.TaxonManager.GetTaxonCategory(
                    CoreData.UserManager.GetCurrentUser(),
                    TaxonCategoryId.Genus);
            }

            return(taxon.Category.SortOrder > _genusTaxonCategory.SortOrder);
        }
Beispiel #9
0
        public TaxonPropertiesList GetTaxonProperties(IUserContext userContext, ITaxon taxon)
        {
            TaxonPropertiesList properties      = new TaxonPropertiesList();
            ITaxonCategory      taxonCategory   = GetReferenceTaxonCategory(userContext, 1);
            ITaxonProperties    taxonProperties = new TaxonProperties()
            {
                DataContext = new DataContext(userContext), IsValid = true, TaxonCategory = taxonCategory, ValidToDate = new DateTime(2111, 12, 31)
            };

            taxon.SetTaxonProperties(new List <ITaxonProperties>()
            {
                taxonProperties
            });
            properties.Add(taxonProperties);
            return(properties);
        }
        public List <ITaxon> GetAllSpecies(int taxonId)
        {
            ITaxonCategory speciesTaxonCategory = CoreData.TaxonManager.GetTaxonCategory(UserContext, TaxonCategoryId.Species);

            List <ITaxon> taxonAndAllChildren = GetTaxonAndAllChildren(taxonId);
            List <ITaxon> speciesTaxa         = new List <ITaxon>();

            foreach (ITaxon taxon in taxonAndAllChildren)
            {
                if (taxon.Category.SortOrder >= speciesTaxonCategory.SortOrder)
                {
                    speciesTaxa.Add(taxon);
                }
            }
            return(speciesTaxa);
        }
        // Called "LIVE"
        public TaxonInfoViewModel(ITaxon taxon, IUserContext user, ITaxonRevision taxonRevision, int?revisionTaxonCategorySortOrder)
        {
            this._user          = user;
            this._taxon         = taxon;
            this._taxonRevision = taxonRevision;
            this._revisionTaxonCategorySortOrder = revisionTaxonCategorySortOrder;
            _taxonCategory = taxon.Category;
            bool isInRevision      = IsInRevision;
            bool isUserTaxonEditor = user.IsTaxonEditor();

            //AcceptedNames = GetAcceptedNames(isInRevision, isUserTaxonEditor);
            Synonyms = _taxon.GetSynonymsViewModel(isInRevision, isUserTaxonEditor, false);
            //NewSynonyms = GetNewSynonyms(isInRevision, isUserTaxonEditor);
            ProParteSynonyms = _taxon.GetProParteSynonymsViewModel(isInRevision, isUserTaxonEditor);
            MisappliedNames  = _taxon.GetMisappliedNamesViewModel(isInRevision, isUserTaxonEditor);
            Identifiers      = _taxon.GetIdentfiersViewModel(isInRevision, isUserTaxonEditor);
        }
Beispiel #12
0
        /// <summary>
        /// Creates a taxon for test
        /// </summary>
        /// <returns></returns>
        public ITaxon GetReferenceParentTaxon(IUserContext userContext, int taxonId)
        {
            ITaxon refTaxon = new Taxon();

            string   conceptDefinitionPartString = "";
            DateTime createdDate   = new DateTime(2004, 01, 20);
            Int32    createdBy     = userContext.User.Id;
            string   personName    = @"Hölje Soderås";
            DateTime validFromDate = new DateTime(1763, 02, 08);
            DateTime validToDate   = new DateTime(2447, 08, 01);

            // refTaxon.ConceptDefinitionFullGeneratedString = conceptDefinitionFullGeneratedString;
            refTaxon.PartOfConceptDefinition = conceptDefinitionPartString;
            refTaxon.CreatedBy        = createdBy;
            refTaxon.CreatedDate      = createdDate;
            refTaxon.DataContext      = new DataContext(userContext);
            refTaxon.ModifiedByPerson = personName;
            refTaxon.ValidFromDate    = validFromDate;
            refTaxon.ValidToDate      = validToDate;
            refTaxon.Id = taxonId;
            int taxonNameId = DyntaxaTestSettings.Default.TestParentTaxonNameId;
            // ITaxonName refTaxonName = GetReferenceTaxonName(userContext, taxonId, taxonNameId);
            ITaxonCategory   taxonCategory   = GetReferenceTaxonCategory(userContext, 1);
            ITaxonProperties taxonProperties = new TaxonProperties()
            {
                IsValid = true, DataContext = new DataContext(userContext), TaxonCategory = taxonCategory, ValidToDate = new DateTime(2111, 12, 31)
            };

            refTaxon.SetTaxonProperties(new List <ITaxonProperties>()
            {
                taxonProperties
            });
            refTaxon.Category = taxonCategory;
            // ITaxonName recName = new TaxonName(userContext);
            refTaxon.Author         = "ReferenceParentAuthor";        //GetReferenceTaxonName(userContext, taxonId, taxonNameId).Author;
            refTaxon.ScientificName = "ReferenceParentScentificName"; //GetReferenceTaxonName(userContext, taxonId, taxonNameId).Name;
            refTaxon.CommonName     = "ReferenceParentCommonName";    //GetReferenceTaxonName(userContext, taxonId, taxonNameId + 1).Name;
            //ITaxon grandParentTaxon = GetReferenceGrandParentTaxon(userContext, DyntaxaTestSettings.Default.TestParentTaxonId +10);
            //refTaxon.GetParentTaxa(userContext).Add(new TaxonRelation() { RelatedTaxon = grandParentTaxon, ValidFromDate = DateTime.Now, ValidToDate = new DateTime(2022, 1, 30) });
            //List<ITaxonRelation> grandParentsList = new List<ITaxonRelation>();
            //grandParentsList.Add(new TaxonRelation() { RelatedTaxon = grandParentTaxon, ValidFromDate = DateTime.Now, ValidToDate = new DateTime(2022, 1, 30) });

            //refTaxon.ParentTaxa = grandParentsList;
            return(refTaxon);
        }
        //public static MvcHtmlString RenderTaxonName(this HtmlHelper htmlHelper, TaxonNameViewModel model)
        //{
        //    return htmlHelper.RenderScientificName(model.Name, model.Author, model.IsScientificName ? model.TaxonCategorySortOrder : -1, model.IsOriginal);
        //}

        public static MvcHtmlString RenderScientificLink(this HtmlHelper htmlHelper, string name, int sortOrder, string action, string controller, object routeValues)
        {
            StringBuilder result = new StringBuilder();
            MvcHtmlString link   = htmlHelper.ActionLink(name, action, controller, routeValues, null);

            ITaxonCategory genusTaxonCategory = CoreData.TaxonManager.GetTaxonCategory(CoreData.UserManager.GetCurrentUser(),
                                                                                       TaxonCategoryId.Genus);

            if (sortOrder >= genusTaxonCategory.SortOrder)
            {
                TagBuilder tag = new TagBuilder("em");
                tag.InnerHtml = link.ToHtmlString();
                result.Append(tag.ToString());
            }
            else
            {
                result.Append(link.ToHtmlString());
            }

            return(MvcHtmlString.Create(result.ToString()));
        }
Beispiel #14
0
        /// <summary>
        /// Creates a taxon for test
        /// </summary>
        /// <returns></returns>
        public ITaxon GetReferenceGrandParentTaxon(IUserContext userContext, int taxonId)
        {
            ITaxon refTaxon = new Taxon();

            string   conceptDefinitionPartString = "";
            DateTime createdDate   = new DateTime(2004, 01, 20);
            Int32    createdBy     = userContext.User.Id;
            string   personName    = @"Hölje KAos";
            DateTime validFromDate = new DateTime(1763, 02, 08);
            DateTime validToDate   = new DateTime(2447, 08, 01);

            // refTaxon.ConceptDefinitionFullGeneratedString = conceptDefinitionFullGeneratedString;
            refTaxon.PartOfConceptDefinition = conceptDefinitionPartString;
            refTaxon.CreatedBy        = createdBy;
            refTaxon.CreatedDate      = createdDate;
            refTaxon.DataContext      = new DataContext(userContext);
            refTaxon.ModifiedByPerson = personName;
            refTaxon.ValidFromDate    = validFromDate;
            refTaxon.ValidToDate      = validToDate;
            refTaxon.Id = taxonId;
            // ITaxonName refTaxonName = GetReferenceTaxonName(userContext, taxonId, taxonNameId);
            ITaxonCategory   taxonCategory   = GetReferenceTaxonCategory(userContext, 1);
            ITaxonProperties taxonProperties = new TaxonProperties()
            {
                IsValid = true, TaxonCategory = taxonCategory, ValidToDate = new DateTime(2111, 12, 31)
            };

            refTaxon.SetTaxonProperties(new List <ITaxonProperties>()
            {
                taxonProperties
            });
            refTaxon.Category = taxonCategory;
            // ITaxonName recName = new TaxonName(userContext);
            refTaxon.Author         = "ReferenceGrandParentAuthor";        //GetReferenceTaxonName(userContext, taxonId, taxonNameId).Author;
            refTaxon.ScientificName = "ReferenceGrandParentScentificName"; //GetReferenceTaxonName(userContext, taxonId, taxonNameId).Name;
            refTaxon.CommonName     = "ReferenceGrandParentCommonName";    //GetReferenceTaxonName(userContext, taxonId, taxonNameId + 1).Name;

            return(refTaxon);
        }
Beispiel #15
0
 public static ExportTaxonCategory Create(ITaxonCategory taxonCategory)
 {
     return(Create(taxonCategory, false));
 }
 /// <summary>
 /// Get parent taxon of specified taxon category.
 /// Returns null if there is no parent of specified taxon category.
 /// </summary>
 /// <param name="parentTaxonCategory">Parent taxon category.</param>
 /// <returns>Parent taxon of specified taxon category.</returns>
 public ITaxon GetParentTaxon(ITaxonCategory parentTaxonCategory)
 {
     return((ITaxon)_parentTaxa[parentTaxonCategory.Id]);
 }
Beispiel #17
0
        public static MvcHtmlString RenderTaxonNameWithStatus(this HtmlHelper htmlHelper, TaxonNameViewModel taxonName)
        {
            string name       = taxonName.Name;
            string author     = taxonName.Author;
            int    sortOrder  = taxonName.IsScientificName ? taxonName.TaxonCategorySortOrder : -1;
            bool   isOriginal = taxonName.IsOriginal;

            var result = new StringBuilder();

            ITaxonCategory genusTaxonCategory = CoreData.TaxonManager.GetTaxonCategory(
                CoreData.UserManager.GetCurrentUser(),
                TaxonCategoryId.Genus);

            if (sortOrder >= genusTaxonCategory.SortOrder)
            {
                var tag = new TagBuilder("em");
                tag.SetInnerText(name);
                result.Append(tag.ToString());
            }
            else
            {
                result.Append(htmlHelper.Encode(name));
            }

            if (!string.IsNullOrEmpty(author))
            {
                result.Append(" ");
                result.Append(htmlHelper.Encode(author));
            }
            if (isOriginal)
            {
                result.Append("*");
            }

            List <string> extraInfo = new List <string>();

            // Spelling variant
            if (taxonName.NameUsageId == (int)TaxonNameUsageId.Accepted &&
                taxonName.IsScientificName && !taxonName.IsRecommended)
            {
                extraInfo.Add(Resources.DyntaxaResource.TaxonNameSharedSpellingVariant);
            }

            // Heterotypic or Homotypic
            if (taxonName.NameUsageId == (int)TaxonNameUsageId.Heterotypic ||
                taxonName.NameUsageId == (int)TaxonNameUsageId.Homotypic)
            {
                extraInfo.Add(taxonName.NameUsage);
            }

            // Name status isn't Correct.
            if (taxonName.NameStatusId != (int)TaxonNameStatusId.ApprovedNaming)
            {
                extraInfo.Add(taxonName.NameStatus);
            }
            else if (taxonName.CategoryTypeId == (int)TaxonNameCategoryTypeId.Identifier &&
                     !(taxonName.NameStatusId == (int)TaxonNameStatusId.ApprovedNaming || taxonName.NameStatusId == (int)TaxonNameStatusId.Informal))
            { // Identifier status isn't correct.
                extraInfo.Add(taxonName.NameStatus);
            }

            if (extraInfo.IsNotEmpty())
            {
                result.Append(" [");
                result.Append(string.Join(", ", extraInfo));
                result.Append("]");
            }

            //// Add information inside [] if name status isn't Correct,
            //// or name usage is Heterotypic or homotypic.
            //if (taxonName.NameStatusId != (int)TaxonNameStatusId.ApprovedNaming || taxonName.NameUsageId == (int)TaxonNameUsageId.Heterotypic || taxonName.NameUsageId == (int)TaxonNameUsageId.Homotypic)
            //{
            //    bool itemHasBeenAdded = false;
            //    result.Append(" [");
            //    if (taxonName.NameUsageId == (int)TaxonNameUsageId.Accepted &&
            //        taxonName.IsScientificName && !taxonName.IsRecommended)
            //    {
            //        result.Append(Resources.DyntaxaResource.TaxonNameSharedSpellingVariant);
            //        itemHasBeenAdded = true;
            //    }

            //    if (taxonName.NameUsageId == (int)TaxonNameUsageId.Heterotypic ||
            //        taxonName.NameUsageId == (int)TaxonNameUsageId.Homotypic)
            //    {
            //        if (itemHasBeenAdded)
            //        {
            //            result.Append(", ");
            //        }

            //        result.Append(taxonName.NameUsage);
            //        itemHasBeenAdded = true;
            //    }

            //    if (taxonName.NameStatusId != (int)TaxonNameStatusId.ApprovedNaming)
            //    {
            //        if (itemHasBeenAdded)
            //        {
            //            result.Append(", ");
            //        }

            //        result.Append(taxonName.NameStatus);
            //    }

            //    result.Append("]");
            //}

            return(MvcHtmlString.Create(result.ToString()));
        }
Beispiel #18
0
        /// <summary>
        /// Creates a taxon for test
        /// </summary>
        /// <returns></returns>
        public ITaxon GetReferenceTaxon(IUserContext userContext, int taxonId)
        {
            ITaxon refTaxon = new Taxon();

            string   conceptDefinitionPartString = "ConceptDefinitionPartString Text";
            DateTime createdDate   = new DateTime(2004, 01, 20);
            Int32    createdBy     = userContext.User.Id;
            string   personName    = @"Hölje Soderås";
            DateTime validFromDate = new DateTime(1763, 02, 08);
            DateTime validToDate   = new DateTime(2447, 08, 01);

            // refTaxon.ConceptDefinitionFullGeneratedString = conceptDefinitionFullGeneratedString;
            refTaxon.PartOfConceptDefinition = conceptDefinitionPartString;
            refTaxon.CreatedBy        = createdBy;
            refTaxon.CreatedDate      = createdDate;
            refTaxon.DataContext      = new DataContext(userContext);
            refTaxon.ModifiedByPerson = personName;
            refTaxon.ValidFromDate    = validFromDate;
            refTaxon.ValidToDate      = validToDate;
            refTaxon.Id = taxonId;
            int taxonNameId = DyntaxaTestSettings.Default.TestTaxonNameId;
            //ITaxonName refTaxonName = GetReferenceTaxonName(userContext, taxonId, taxonNameId);
            //ITaxonName refTaxonName2 = GetReferenceTaxonName(userContext, taxonId, taxonNameId +1);
            //refTaxonName2.IsRecommended = false;
            ITaxonCategory   taxonCategory   = GetReferenceTaxonCategory(userContext, 0);
            ITaxonProperties taxonProperties = new TaxonProperties()
            {
                DataContext = new DataContext(userContext), IsValid = true, TaxonCategory = taxonCategory, ValidToDate = new DateTime(2111, 12, 31)
            };

            refTaxon.SetTaxonProperties(new List <ITaxonProperties>()
            {
                taxonProperties
            });
            refTaxon.Category = taxonCategory;
            //ITaxonName recName = new TaxonName(userContext);
            refTaxon.Author         = "ReferenceAuthor";        //GetReferenceTaxonName(userContext, taxonId, taxonNameId).Author;
            refTaxon.ScientificName = "ReferenceScentificName"; //GetReferenceTaxonName(userContext, taxonId, taxonNameId).Name;
            refTaxon.CommonName     = "ReferenceCommonName";    //GetReferenceTaxonName(userContext, taxonId, taxonNameId + 1).Name;

            ITaxon parentTaxon = GetReferenceParentTaxon(userContext, DyntaxaTestSettings.Default.TestParentTaxonId);

            //TaxonRelationList relationList = refTaxon.GetNearestParentTaxonRelations(userContext);
            //ITaxonRelation taxonRel = new TaxonRelation() { ParentTaxon = parentTaxon, ValidFromDate = DateTime.Now, ValidToDate = new DateTime(2022, 1, 30), IsMainRelation = true, ReplacedInTaxonRevisionEventId = null };
            //relationList.Add(taxonRel);
            refTaxon.GetNearestParentTaxonRelations(userContext).Add(new TaxonRelation()
            {
                ParentTaxon = parentTaxon, ValidFromDate = DateTime.Now, ValidToDate = new DateTime(2022, 1, 30), IsMainRelation = true, ReplacedInTaxonRevisionEventId = null
            });
            ITaxon taxon = new Taxon();

            taxon.Id        = 3897845;
            taxon.SortOrder = 4;
            taxon.Category  = new TaxonCategory()
            {
                Id = 2
            };
            TaxonRelationList parentsList = new TaxonRelationList();

            parentsList.Add(new TaxonRelation()
            {
                ParentTaxon = parentTaxon, ValidFromDate = DateTime.Now, ValidToDate = new DateTime(2022, 1, 30), IsMainRelation = true, ReplacedInTaxonRevisionEventId = null, ChildTaxon = taxon
            });
            refTaxon.IsInRevision = true;
            refTaxon.SetParentTaxa(parentsList);

            return(refTaxon);
        }