internal bool TryGetMeasureDimensionNodesForRole(string currentLanguage, string currentLabelRole, string roleId, Taxonomy tax, out DimensionNode topLevelNode) { topLevelNode = null; DefinitionLink dl = definitionLinks[roleId] as DefinitionLink; if (dl != null) { string label = dl.Title; topLevelNode = new DimensionNode(label); topLevelNode.MyDefinitionLink = dl; if (dl.HypercubeLocatorsHrefs.Count > 0) { foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs) { List <DimensionNode> dns; dl.BuildMeasureElementTreeForHypercubeId(tax, hypercubeHref, false, out dns); if (dns != null) { foreach (DimensionNode dn in dns) { topLevelNode.AddChild(dn); } } } } } return(topLevelNode != null); }
private void CreateChildNodes(string lang, string role, DimensionNode parentNode, DefinitionLink dLink, Hashtable definisionLinks, HybridDictionary ChildDefinitionLocatorsHD, bool buildHypercubeChildren, bool isScenarioMarkup) { if (ChildDefinitionLocatorsHD == null) { return; } if (!buildHypercubeChildren) { if (parentNode.NodeDimensionInfo != null && parentNode.NodeDimensionInfo.NodeType == DimensionNode.NodeType.Hypercube) { //no need to build the children... return; } } foreach (ChildDefinitionLocator cdl in ChildDefinitionLocatorsHD.Values) { DefinitionLocator childLocator; if (!dLink.TryGetLocator(cdl.HRef, out childLocator)) { continue; } bool recursive = true; if (parentNode != null && parentNode.GetParent(childLocator.HRef) != null) { recursive = false; //we have a recursion.. //this might be ok if one of the links is a prohibitted link... } //organize locators by non xlink attributes //we should have only one valid LocatorRelationshipInfo for each order... DefinitionLocatorRelationshipInfo currentRelationShip = null; for (int i = cdl.LocatorRelationshipInfos.Count - 1; i >= 0; i--) { DefinitionLocatorRelationshipInfo lri = cdl.LocatorRelationshipInfos[i] as DefinitionLocatorRelationshipInfo; if (currentRelationShip != null && lri.IsNonXlinkEquivalentRelationship(currentRelationShip)) { continue; } currentRelationShip = lri; //if (lri.IsDefault) continue; //this is just the default definition...no need to include it when we build the tree.. if (lri.IsProhibited) { continue; } childLocator.CreateDimensionNode(lang, role, parentNode, parentNode.Id, dLink, recursive, definisionLinks, lri, null, buildHypercubeChildren, isScenarioMarkup); } } }
public async Task <ActionResult> DeleteConfirmed(int id) { DefinitionLink definitionLink = await db.DefinitionLinks.FindAsync(id); int defID = definitionLink.Definition_ID; db.DefinitionLinks.Remove(definitionLink); await db.SaveChangesAsync(); return(RedirectToAction("Index", new { id = defID })); }
internal bool TryGetDimensionNodeForRole(string currentLanguage, string currentLabelRole, string roleId, out DimensionNode topLevelNode) { topLevelNode = null; DefinitionLink dl = definitionLinks[roleId] as DefinitionLink; if (dl != null) { string label = dl.Title; topLevelNode = new DimensionNode(label); topLevelNode.MyDefinitionLink = dl; if (dl.HypercubeLocatorsHrefs.Count > 0) { foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs) { DimensionNode hyperCubeNode; if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks, hypercubeHref, false, out hyperCubeNode)) { topLevelNode.AddChild(hyperCubeNode); } } } else { //we might have to build the dimension nodes by itself... if (dl.DimensionLocatorsHrefs.Count > 0) { foreach (string dimHref in dl.DimensionLocatorsHrefs) { DefinitionLocator dloc; if (!dl.TryGetLocator(dimHref, out dloc)) { return(false); } DimensionNode dn = dloc.CreateDimensionNode(currentLanguage, currentLabelRole, null, dimHref, dl, true, definitionLinks, null, null, true, false); if (dn != null) { topLevelNode.AddChild(dn); } } } } } return(topLevelNode != null); }
public async Task <ActionResult> Edit([Bind(Include = "ID,Descriptor_ID,Start_char,Length,Definition_ID")] DefinitionLink definitionLink) { if (ModelState.IsValid) { db.Entry(definitionLink).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index", new { id = definitionLink.Definition_ID })); } ViewBag.Definition_ID = new SelectList(db.Definitions, "ID", "Definition_content", definitionLink.Definition_ID); ViewBag.Descriptor_ID = new SelectList(db.Descriptors, "ID", "Descriptor_content", definitionLink.Descriptor_ID); return(View(definitionLink)); }
// GET: DefinitionLinks/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DefinitionLink definitionLink = await db.DefinitionLinks.FindAsync(id); if (definitionLink == null) { return(HttpNotFound()); } return(View(definitionLink)); }
internal Dimension CreateCopyForMerging() { Dimension copy = new Dimension(); copy.BaseSchema = this.BaseSchema; copy.MyHref = this.MyHref; foreach (DictionaryEntry de in this.definitionLinks) { DefinitionLink dl = de.Value as DefinitionLink; copy.definitionLinks[de.Key] = dl.CreateCopyForMerging(); } return(copy); }
// GET: DefinitionLinks/Create public async Task <ActionResult> Create(int id) { if (User.Identity.IsAuthenticated) { ViewBag.Definition_ID = new SelectList(db.Definitions, "ID", "Definition_content"); ViewBag.Descriptor_ID = new SelectList(db.Descriptors, "ID", "Descriptor_content"); Definition def = await db.Definitions.FindAsync(id); DefinitionLink dl = new DefinitionLink { Definition = def, Definition_ID = id }; return(View(dl)); } else { return(RedirectToAction("Login", "Authentification")); } }
//------------------------------------------------------------------------------- //------------------------------------------------------------------------------- private void ValidateFactsReferencedInDefinitionArcRoles(DefinitionLink CurrentDefinitionLink) { foreach (DefinitionArc CurrentDefinitionArc in CurrentDefinitionLink.DefinitionArcs) { switch (CurrentDefinitionArc.Role) { case DefinitionArc.RoleEnum.EssenceAlias: ValidateEssenceAliasedFacts(CurrentDefinitionArc); break; case DefinitionArc.RoleEnum.RequiresElement: ValidateRequiresElementFacts(CurrentDefinitionArc); break; default: break; } } }
// GET: DefinitionLinks/Delete/5 public async Task <ActionResult> Delete(int?id) { if (!User.Identity.IsAuthenticated) { ViewBag.ShowModal = true; } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DefinitionLink definitionLink = await db.DefinitionLinks.FindAsync(id); if (definitionLink == null) { return(HttpNotFound()); } return(View(definitionLink)); }
internal bool TryGetHypercubeNode(string currentLanguage, string currentLabelRole, string role, string hypercubeId, bool buildnew, out DimensionNode hypercubeNode) { hypercubeNode = null; DefinitionLink dl = definitionLinks[role] as DefinitionLink; if (dl != null) { if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks, hypercubeId, buildnew, out hypercubeNode)) { return(true); } return(false); } return(false); }
private void ProcessDimensionLinks(XmlNode dlNode, string role, string title, ref int errorsEncountered, Dictionary <string, string> discoveredSchemas) { DefinitionLink dl = definitionLinks[role] as DefinitionLink; if (dl == null) { // create the object dl = new DefinitionLink(title, role, BaseSchema, errorList); // put it in the hashtable definitionLinks[role] = dl; } // and load up the links int linkErrors = 0; dl.LoadChildren(dlNode, theManager, discoveredSchemas, this.schemaPath, out linkErrors); errorsEncountered += linkErrors; }
// GET: DefinitionLinks/Edit/5 public async Task <ActionResult> Edit(int?id) { if (User.Identity.IsAuthenticated) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DefinitionLink definitionLink = await db.DefinitionLinks.FindAsync(id); if (definitionLink == null) { return(HttpNotFound()); } ViewBag.Definition_ID = new SelectList(db.Definitions, "ID", "Definition_content", definitionLink.Definition_ID); ViewBag.Descriptor_ID = new SelectList(db.Descriptors, "ID", "Descriptor_content", definitionLink.Descriptor_ID); return(View(definitionLink)); } else { return(RedirectToAction("Login", "Authentification")); } }
internal DimensionNode CreateDimensionNode(string lang, string role, Node parentNode, string parentId, DefinitionLink dLink, bool recursive, Hashtable definisionLinks, DefinitionLocatorRelationshipInfo lri, DimensionNode newNode, bool buildHypercubeChildren, bool isScenarioMarkup) { if (e == null) { return(null); } if (newNode == null) { newNode = new DimensionNode(e); newNode.IsSegmentMarkup = !isScenarioMarkup; newNode.SetLabel(lang, role); newNode.NodeDimensionInfo = lri; newNode.IsDraggable = false; if (lri != null && lri.NodeType == DimensionNode.NodeType.Item && lri.Usable) { if (!e.IsAbstract) { newNode.IsDraggable = true; } } newNode.MyDefinitionLink = dLink; } if (lri != null) { newNode.SetOrder(lri.Order); if (PresentationLocator.preferredLabelRole.Equals(role)) { if (lri.PrefLabel != null) { newNode.UpdatePreferredLabel(lang, lri.PrefLabel); } } } if (parentNode != null) { // and add it parentNode.AddChild(newNode); parentId = parentNode.Id; } if (recursive) { if (lri != null && lri.TargetRole != null && dLink.Role != lri.TargetRole) { if (definisionLinks != null) { DefinitionLink targetDLink = definisionLinks[lri.TargetRole] as DefinitionLink; if (targetDLink != null) { DefinitionLocator targetLocator; if (targetDLink.TryGetLocator(newNode.Id, out targetLocator)) { CreateChildNodes(lang, role, newNode, targetDLink, definisionLinks, targetLocator.childLocatorsByHRef, buildHypercubeChildren, isScenarioMarkup); } } } if (newNode.Children != null) { newNode.Children.Sort(new NodeOrderSorter()); } return(newNode); } CreateChildNodes(lang, role, newNode, dLink, definisionLinks, childLocatorsByHRef, buildHypercubeChildren, isScenarioMarkup); //need to sort the nodes if (newNode.Children != null) { newNode.Children.Sort(new NodeOrderSorter()); } } return(newNode); }
private Linkbase CreateDefinitionLinkbase(Taxonomy taxonomy, DiscoverableTaxonomySet dts) { var linkbase = new Linkbase(GetLinkbaseFileName(taxonomy, "def")); var memberItems = ExtensionItems.OfType <ExtensionMember>().ToList(); var groupedByHypercube = memberItems.SelectMany(i => i.Locations.Select(l => new { l.HypercubeName, Location = l, Item = i })) .GroupBy(d => d.HypercubeName) .ToList(); foreach (var groupByHypercube in groupedByHypercube) { var hypercubeNode = dts.GetAllLinks() .Where(l => l.ElementName == LinkbaseXNames.Definition) .SelectMany(l => l.NodesMap.Values) .OfType <LocatorNode>() .SingleOrDefault(ln => ln.Item.Name == groupByHypercube.Key); if (hypercubeNode == null) { throw new InvalidOperationException($"Could not find a hypercube (aka table) {groupByHypercube.Key} in the DTS."); } var definitionLink = new DefinitionLink(LinkbaseXNames.Definition, hypercubeNode.Link.Role); linkbase.AddLink(definitionLink, dts); var locCount = 0; foreach (var locationAndItem in groupByHypercube) { var dimensionLocationNode = hypercubeNode.FromArcs .OfType <DefinitionArc>() .Select(da => da.ToLocator) .SingleOrDefault(ln => ln.Item.Name == locationAndItem.Location.DimensionName); if (dimensionLocationNode == null) { throw new InvalidOperationException($"Could not find a dimension (aka axis) {locationAndItem.Location.DimensionName} in the hypercube (aka table) {groupByHypercube.Key}."); } var parentNodeInBaseTaxonomy = FindParentNode(dimensionLocationNode, locationAndItem.Location.ParentName); if (parentNodeInBaseTaxonomy == null) { throw new InvalidOperationException($"There is no member {locationAndItem.Location.ParentName} in the dimension {groupByHypercube.Key}."); } var siblingArcs = parentNodeInBaseTaxonomy.GetOrderedOutgoingHierarchicalArcs <DefinitionArc>(); double newOrder; try { newOrder = DetermineOrder(locationAndItem.Location.PrecedingSiblingName, siblingArcs); } catch (InvalidOperationException ex) { throw new InvalidOperationException($"The sibling {locationAndItem.Location.PrecedingSiblingName} was not found as a child of {locationAndItem.Location.ParentName} in the dimension {groupByHypercube.Key}.", ex); } var parentLocLabel = $"loc_{locCount}"; locCount += 1; var parentNode = new LocatorNode(parentLocLabel, parentNodeInBaseTaxonomy.Item); definitionLink.AddNode(parentNode); var locLabel = $"loc_{locCount}"; locCount += 1; var locNode = CreateLocatorNode(locLabel, locationAndItem.Item, dts); definitionLink.AddNode(locNode); var arc = new DefinitionArc(parentNode, locNode, newOrder); definitionLink.AddArc(arc); } } return(linkbase); }