public JsonNetResult GetGraphVizJson(ExportGraphVizViewModel model) { IUserContext userContext = GetCurrentUser(); if (!(userContext.IsTaxonRevisionAdministrator() || userContext.IsTaxonEditor())) { return(new JsonNetResult("Access is not allowed")); } if (TaxonRelationsTreeCacheManager.CachedTaxonRelationTree == null) { return(new JsonNetResult("Dyntaxa Tree not yet created. Please try again in 1 minute.")); } if (ModelState.IsValid) { var tree = TaxonRelationsTreeCacheManager.CachedTaxonRelationTree; string graphviz = GraphvizManager.CreateGraphvizFormatRepresentation( userContext, tree, tree.GetTreeNodes(model.GetTaxonIdsFromString()), model.TreeIterationMode, model.RelationTypeMode == TaxonRelationsTreeRelationTypeMode.OnlyValidRelations, new GraphVizFormat() { ShowRelationId = model.ShowRelationId, ShowLumpsAndSplits = model.IncludeLumpSplits }); return(new JsonNetResult(graphviz)); } return(new JsonNetResult("Unexpected error")); }
public ActionResult Graphviz(ExportGraphVizViewModel model, string downloadTokenValue) { IUserContext userContext = GetCurrentUser(); if (!(userContext.IsTaxonRevisionAdministrator() || userContext.IsTaxonEditor())) { return(RedirectToAction("AccessIsNotAllowed", "Account", new { url = this.Request.Url })); } if (TaxonRelationsTreeCacheManager.CachedTaxonRelationTree == null) { ModelState.AddModelError("TreeError", "Dyntaxa Tree not yet created. Please try again in 1 minute."); } if (ModelState.IsValid) { var tree = TaxonRelationsTreeCacheManager.CachedTaxonRelationTree; string graphviz = GraphvizManager.CreateGraphvizFormatRepresentation( userContext, tree, tree.GetTreeNodes(model.GetTaxonIdsFromString()), model.TreeIterationMode, model.RelationTypeMode == TaxonRelationsTreeRelationTypeMode.OnlyValidRelations, new GraphVizFormat() { ShowRelationId = model.ShowRelationId, ShowLumpsAndSplits = model.IncludeLumpSplits }); return(Content(graphviz)); } // RowDelimiter Dropbox var rowDelimiters = from MatchTaxonRowDelimiter rd in Enum.GetValues(typeof(MatchTaxonRowDelimiter)) select new { value = (int)rd, text = rd.GetLocalizedDescription() }; ViewData["RowDelimiter"] = new SelectList(rowDelimiters, "value", "text", model.RowDelimiter.ToString()); if (userContext.IsTaxonRevisionAdministrator() || userContext.IsTaxonEditor()) { ViewBag.ShowRefreshDyntaxaTaxonTreeButton = true; } else { ViewBag.ShowRefreshDyntaxaTaxonTreeButton = false; } ViewBag.TreeLastUpdatedTime = TaxonRelationsTreeCacheManager.CacheLastUpdatedTime; return(View(model)); }
public void CreateCompleteTaxonRelationsTree() { using (ShimsContext.Create()) { LoginApplicationUserAndSetSessionVariables(); SetSwedishLanguage(); IUserContext userContext = ApplicationUserContextSV; ITaxonSearchCriteria taxonSearchCriteria = new TaxonSearchCriteria(); var allTaxa = CoreData.TaxonManager.GetTaxa(userContext, taxonSearchCriteria); TaxonRelationSearchCriteria searchCriteria = new TaxonRelationSearchCriteria(); var allRelations = CoreData.TaxonManager.GetTaxonRelations(userContext, searchCriteria); var tree = TaxonRelationsTreeManager.CreateTaxonRelationsTree(userContext, allRelations, allTaxa, false); //1012265 //1011617 //6001191 ensam var edges = tree.GetAllChildAndParentEdges(266838); string graphviz = GraphvizManager.CreateGraphvizFormatRepresentation(edges); // find suspicious hybrids List <ITaxonRelationsTreeNode> invalidHybrids; // find root nodes tree.RootNodes = new HashSet <ITaxonRelationsTreeNode>(); tree.ValidRootNodes = new HashSet <ITaxonRelationsTreeNode>(); foreach (var node in tree.AllTreeNodes) { tree.RootNodes.Add(node.RootNode); if (node.RootNode.Taxon.IsValid) { tree.ValidRootNodes.Add(node.RootNode); } } } }
public void SplitGraphTest() { using (ShimsContext.Create()) { //Arrange LoginApplicationUserAndSetSessionVariables(); SetSwedishLanguage(); IUserContext userContext = ApplicationUserContextSV; const int lumpSplitTaxonId = 2755; //TaxonIdBefore: 233285 //TaxonIdAfter: 2755 ITaxonSearchCriteria taxonSearchCriteria = new TaxonSearchCriteria(); TaxonList allTaxa = CoreData.TaxonManager.GetTaxa(userContext, taxonSearchCriteria); TaxonRelationSearchCriteria searchCriteria = new TaxonRelationSearchCriteria(); TaxonRelationList allRelations = CoreData.TaxonManager.GetTaxonRelations(userContext, searchCriteria); TaxonRelationsTree tree = TaxonRelationsTreeManager.CreateTaxonRelationsTree(userContext, allRelations, allTaxa, false); var edges = tree.GetAllChildAndParentEdges(lumpSplitTaxonId); var edges2 = tree.GetAllValidChildAndParentEdges(lumpSplitTaxonId); List <ITaxonRelationsTreeNode> sourceNodes = new List <ITaxonRelationsTreeNode> { tree.GetTreeNode(lumpSplitTaxonId) }; GraphVizFormat graphVizFormat = new GraphVizFormat() { ShowLumpsAndSplits = true, ShowRelationId = false }; string graphRepresentation2 = GraphvizManager.CreateGraphvizFormatRepresentation( userContext, tree, edges2, sourceNodes, graphVizFormat); int x = 8; } }