public void Visit(UnionNode node) { var right = Nodes.Pop(); var left = Nodes.Pop(); Nodes.Push(new UnionNode(node.ResultTableName, node.Keys, left, right, node.IsNested, node.IsTheLastOne)); }
private ITreeData getPersonFromUnion(UnionNode un, int x0, int y0) { float x = x0 / _zoom; // 'undo' impact of zoom: box bounds are un-zoomed float y = y0 / _zoom; var box = _boxen.getNodeBounds()[un]; //drawBounds(un); var box1 = new Rect(box.X, box.Y, un.P1.Wide, un.P1.High); if (box1.Contains(x, y)) { return(un.P1); } Rect box2; if (un.Vertical) { box2 = new Rect(box.X, box.Y + un.P1.High + UNION_BAR_WIDE, un.P2.Wide, un.P2.High); } else { box2 = new Rect(box.X + un.P1.Wide + UNION_BAR_WIDE, box.Y, un.P2.Wide, un.P2.High); } if (box2.Contains(x, y)) { return(un.P2); } return(null); }
public BaseNode AddUnion(string id, string name, string file, string sz) { UnionNode unionn = new UnionNode(id, name, file, sz); nodemap.Add(id, unionn); return(unionn); }
private UnionNode FindNode(UnionNode initialNode) { if (initialNode.parent == null) { return(initialNode); } UnionNode currentNode = initialNode.parent; while (currentNode.parent != null) { currentNode = currentNode.parent; } UnionNode representative = currentNode; currentNode = initialNode; while (currentNode.parent != representative) { UnionNode temp = currentNode; currentNode = currentNode.parent; temp.parent = representative; } return(representative); }
private void paintUnionEdgesH(UnionNode parent) { // Draw edge connectors associated with a Union. This is the horizontal // (root at top) variant. var b1 = drawBounds(parent); // connector between spouse boxes int y = b1.Top + (b1.Height / 2); int x = b1.Left + parent.P1.Wide; _g.DrawLine(_spousePen, x, y, x + UNION_BAR_WIDE, y); // if this is a duplicate, or there are no children, we're done if (DrawDuplicateNode(parent) || !hasChildren(parent)) { return; } // Top point - vertical line from connector to child line int vertLx = x + UNION_BAR_WIDE / 2; int vertLy = y; DrawChildrenEdgesH(parent, vertLx, vertLy); }
private static DashboardFederationDataSource CreateFederatedDataSource(DashboardSqlDataSource sqlDS, DashboardExcelDataSource excelDS, DashboardObjectDataSource objDS, DashboardJsonDataSource jsonDS) { DashboardFederationDataSource federationDataSource = new DashboardFederationDataSource("Federated Data Source"); Source sqlSource = new Source("sqlSource", sqlDS, "SQL Orders"); Source excelSource = new Source("excelSource", excelDS, ""); Source objectSource = new Source("objectSource", objDS, ""); SourceNode jsonSourceNode = new SourceNode(new Source("json", jsonDS, "")); // Join SelectNode joinQuery = sqlSource.From() .Select("OrderDate", "ShipCity", "ShipCountry") .Join(excelSource, "[excelSource.OrderID] = [sqlSource.OrderID]") .Select("CategoryName", "ProductName", "Extended Price") .Join(objectSource, "[objectSource.Country] = [excelSource.Country]") .Select("Country", "UnitPrice") .Build("Join query"); federationDataSource.Queries.Add(joinQuery); // Union and UnionAll UnionNode queryUnionAll = sqlSource.From().Select("OrderID", "OrderDate").Build("OrdersSqlite") .UnionAll(excelSource.From().Select("OrderID", "OrderDate").Build("OrdersExcel")) .Build("OrdersUnionAll"); queryUnionAll.Alias = "Union query"; UnionNode queryUnion = sqlSource.From().Select("OrderID", "OrderDate").Build("OrdersSqlite") .Union(excelSource.From().Select("OrderID", "OrderDate").Build("OrdersExcel")) .Build("OrdersUnion"); queryUnion.Alias = "UnionAll query"; federationDataSource.Queries.Add(queryUnionAll); federationDataSource.Queries.Add(queryUnion); // Transformation TransformationNode unfoldNode = new TransformationNode(jsonSourceNode) { Alias = "Unfold", Rules = { new TransformationRule { ColumnName = "Products", Alias = "Product", Unfold = true, Flatten = false } } }; TransformationNode unfoldFlattenNode = new TransformationNode(jsonSourceNode) { Alias = "Unfold and Flatten", Rules = { new TransformationRule { ColumnName = "Products", Unfold = true, Flatten = true } } }; federationDataSource.Queries.Add(unfoldNode); federationDataSource.Queries.Add(unfoldFlattenNode); return(federationDataSource); }
private UnionNode Find(UnionNode node) { if (node.Parent != node) { node.Parent = Find(node.Parent); } return(node.Parent); }
protected QueryBase VisitUnion(UnionNode node, ElasticQueryMapperState state) { var query1 = Visit(node.InnerQuery, state); var query2 = Visit(node.OuterQuery, state); // TODO: Need to check if this is correct, but it should be: https://www.elastic.co/guide/en/elasticsearch/guide/current/bool-query.html return(query1 || query2); }
private UnionNode GetNode(T element) { UnionNode node; if (!elementToNodeMap.TryGetValue(element, out node)) { node = new UnionNode(element); elementToNodeMap.Add(element, node); } return(node); }
// TODO should be in tree classes? private ITreeData findPersonFromPoint(int X, int Y) { ITreeData node = findNodeByPoint(X - 8, Y - 8); // TODO WHY is this delta necessary? UnionNode un = node as UnionNode; if (un != null) { node = getPersonFromUnion(un, X - 8, Y - 8); } return(node); }
/// <summary> /// Makes a new set containing only the specified value. /// </summary> /// <param name="value">The value to store in the new set.</param> public void Make(T value) { if (nodes.ContainsKey(value)) { throw new ArgumentException("That value has already been added.", "value"); } UnionNode node = new UnionNode(value, 0); nodes[value] = node; }
/// <summary> /// Draw a connection between two, duplicated union nodes /// </summary> /// <param name="union"></param> /// <returns></returns> private bool DrawDuplicateNode(UnionNode union) { // This is not a duplicate, nothing to do if (union.DupNode == null) { return(false); } var thisRect = drawBounds(union); var destRect = drawBounds(union.DupNode); thisRect.Inflate(1, 1); // TODO need to use the pen thickness destRect.Inflate(1, 1); // TODO need to use the pen thickness int midXDest = destRect.Left + (destRect.Right - destRect.Left) / 2; int midXthis = thisRect.Left + (thisRect.Right - thisRect.Left) / 2; int yThis = thisRect.Bottom; int yDest = destRect.Bottom; int midmidX = midXDest + (midXthis - midXDest) / 2; int midY = Math.Max(thisRect.Bottom, destRect.Bottom) + (gapBetweenLevels / 2) - 5; // TODO tweak/make constant if (union.Vertical) { midXthis = thisRect.Right; midXDest = destRect.Right; yThis = thisRect.Top + thisRect.Height / 2; yDest = destRect.Top + destRect.Height / 2; midmidX = Math.Max(midXthis, midXDest) + (gapBetweenLevels / 2) - 5; // TODO tweak/make constant midY = Math.Min(yThis, yDest) + Math.Abs(yThis - yDest) / 2; } // Curve points from middle of two boxes to a point half-way between; said point below/right of boxes Point p1 = new Point(midXthis, yThis); Point p2 = new Point(midmidX, midY); Point p3 = new Point(midXDest, yDest); _g.DrawRectangle(_duplPen, thisRect); _g.DrawRectangle(_duplPen, destRect); // TODO p2 might be below the bottom of the panel. // TODO consider drawing from left edge of 'this' to right edge of 'dest' _g.DrawCurve(_duplPen, new[] { p1, p2, p3 }); return(true); }
public void Dump(BaseNode root) { if (root == null) { root = rootNode; } foreach (BaseNode node in root.childnodes) { if (node.Type() == typeof(EnumNode)) { EnumNode enode = node as EnumNode; Console.WriteLine("Enum: " + enode.name); } else if (node.Type() == typeof(StructNode)) { StructNode snode = node as StructNode; Console.WriteLine("Struct: " + snode.name); } else if (node.Type() == typeof(UnionNode)) { UnionNode unode = node as UnionNode; Console.WriteLine("Union: " + unode.name); } else if (node.Type() == typeof(ClassNode)) { ClassNode cnode = node as ClassNode; Console.WriteLine("Class: " + cnode.name); } else if (node.Type() == typeof(FieldNode)) { FieldNode fnode = node as FieldNode; BaseNode n; Console.WriteLine("Field: " + fnode.name + " type: " + ResolveType(fnode.type, out n, false) + " (" + fnode.type + ")"); } else if (node.Type() == typeof(MethodNode)) { MethodNode mnode = node as MethodNode; BaseNode n; Console.WriteLine("Method: " + mnode.name + " virtual: " + mnode.virt + " returns: " + ResolveType(mnode.ret, out n, true) + " (" + mnode.ret + ")"); } Dump(node); } }
/// <summary> /// 取得出货指示 /// </summary> /// <param name="program_job_no">作业编号</param> /// <param name="status">A.新增 S.过帐</param> /// <param name="doc_no">单据编号</param> /// <param name="site_no">工厂</param> /// <param name="warehouse_no">库位编号</param> /// <returns></returns> public Hashtable GetInstructions(string program_job_no, string status, DependencyObjectCollection param_master, string site_no, string warehouse_no) { #region 参数检查 if (Maths.IsEmpty(program_job_no)) { throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "program_job_no" })); } if (Maths.IsEmpty(status)) { throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "status" })); } if (Maths.IsEmpty(param_master) || param_master.Count <= 0) { throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "doc_no" })); } if (Maths.IsEmpty(site_no)) { throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "site_no" })); } #endregion QueryNode node = QueryData(program_job_no, status, param_master, site_no, warehouse_no, "1"); node = new UnionNode(node, QueryData(program_job_no, status, param_master, site_no, warehouse_no, "2"), true); node = new UnionNode(node, QueryData(program_job_no, status, param_master, site_no, warehouse_no, "3"), true); node = new UnionNode(node, QueryData(program_job_no, status, param_master, site_no, warehouse_no, "4"), true); node = new UnionNode(node, QueryData(program_job_no, status, param_master, site_no, warehouse_no, "5"), true); node = new UnionNode(node, QueryData(program_job_no, status, param_master, site_no, warehouse_no, "6"), true); node = new UnionNode(node, QueryData(program_job_no, status, param_master, site_no, warehouse_no, "7"), true); DependencyObjectCollection result = this.GetService <IQueryService>().ExecuteDependencyObject(node); //20170328 add by wangyq for P001-170327001 数据库中加入无效果,继续更新一次=============begin============= if (result.Count > 0 && result.ItemDependencyObjectType.Properties.Contains("inventory_management_features")) { foreach (DependencyObject barCode in result) { barCode["inventory_management_features"] = UtilsClass.SpaceValue; } } //20170328 add by wangyq for P001-170327001 数据库中加入无效果,继续更新一次=============end============= Hashtable hashTable = new Hashtable(); hashTable.Add("inventory_detail", result); return(hashTable); }
public void Visit(UnionNode node) { var key = CreateSetOperatorPositionKey(); _currentScope[MetaAttributes.SetOperatorName] = key; SetOperatorFieldPositions.Add(key, CreateSetOperatorPositionIndexes((QueryNode)node.Left, node.Keys)); var right = Nodes.Pop(); var left = Nodes.Pop(); var rightMethodName = Methods.Pop(); var leftMethodName = Methods.Pop(); var methodName = $"{leftMethodName}_Union_{rightMethodName}"; Methods.Push(methodName); _currentScope.ScopeSymbolTable.AddSymbol(methodName, _currentScope.Child[0].ScopeSymbolTable.GetSymbol(((QueryNode)left).From.Alias)); Nodes.Push(new UnionNode(node.ResultTableName, node.Keys, left, right, node.IsNested, node.IsTheLastOne)); }
private void Union(UnionNode node1, UnionNode node2) { UnionNode root1 = Find(node1), root2 = Find(node2); if (root1 == root2) { return; } if (root1.Rank > root2.Rank) { root2.Parent = root1; } else if (root2.Rank > root1.Rank) { root1.Parent = root2; } else { root2.Parent = root1; root1.Rank++; } }
public void Union(T firstElement, T secondElement) { UnionNode firstNodeRep = FindNode(GetNode(firstElement)); UnionNode secondNodeRep = FindNode(GetNode(secondElement)); if (firstNodeRep == secondNodeRep) { return; } if (firstNodeRep.rank < secondNodeRep.rank) { firstNodeRep.parent = secondNodeRep; } else if (firstNodeRep.rank > secondNodeRep.rank) { secondNodeRep.parent = firstNodeRep; } else { secondNodeRep.parent = firstNodeRep; firstNodeRep.rank++; } }
public UnionNode(T element) { this.element = element; this.parent = null; this.rank = 0; }
public void Visit(UnionNode node) { LoadScope("Union"); TraverseSetOperator(node); }
public virtual void Visit(UnionNode node) { TraverseSetOperator(node); }
// TODO: Sitecore 8.2 only (UnionNode/UnionMethod)? protected virtual void StripUnion(UnionNode node, ElasticQueryMapperState state) { state.AdditionalQueryMethods.Add(new UnionMethod(node.GetOuterQueryable(), node.GetInnerQueryable())); }
public UnionTable(UnionNode node, Program program) : base(node, program) { }
private void paintNode(ITreeData node) { int currDepth = 0; int genLineY = 0; bool drawVert = false; Rectangle box = drawBounds(node); PersonNode foo = node as PersonNode; if (foo != null) { // Don't draw the fake for multi-marriage at root if (foo.Text != " " || foo.Who != null) { paintABox(foo, box); } currDepth = foo.Depth; genLineY = foo.Vertical ? box.Right : box.Bottom; drawVert = foo.Vertical; } else { // Drawing a union node. Said node consists of two Person boxes. // (Spouse connector drawn in PaintEdges). UnionNode bar = node as UnionNode; if (bar != null) { Rectangle box1 = new Rectangle(box.X, box.Y, bar.P1.Wide, bar.P1.High); Rectangle box2; if (bar.Vertical) { box2 = new Rectangle(box.X, box.Y + bar.P1.High + UNION_BAR_WIDE, bar.P2.Wide, bar.P2.High); } else { box2 = new Rectangle(box.X + bar.P1.Wide + UNION_BAR_WIDE, box.Y, bar.P2.Wide, bar.P2.High); } paintABox(bar.P1, box1); paintABox(bar.P2, box2); currDepth = bar.P1.Depth; genLineY = bar.Vertical ? Math.Max(box1.Right, box2.Right) : Math.Max(box1.Bottom, box2.Bottom); drawVert = bar.Vertical; } // debugging //using (var pen = new Pen(Color.Magenta)) // _g.DrawRectangle(pen, box); } if (currDepth == _nextLevel && _config.GenLines) { _nextLevel += 1; genLineY += 8; if (drawVert) { _g.DrawLine(Pens.Blue, new Point(genLineY, 0), new Point(genLineY, Height)); } else { _g.DrawLine(Pens.Blue, new Point(0, genLineY), new Point(Width, genLineY)); } } }
public void ProcessType(FieldNode fieldbase, string ntype) { BaseNode n; string type = ResolveType(ntype, out n, false); string dtype; if (typeDict.TryGetValue(type, out dtype)) { type = dtype; } if (prefix != null) { sb.AppendLine(new String('\t', level) + prefix); } if (n.Type() == typeof(UnionNode)) { UnionNode unode = n as UnionNode; if (files[unode.file].StartsWith(@"G:\dev\C++\Open Steamworks")) { string name = unode.name; if (name.Contains("$")) { name = fieldbase.name; } if (name.Length == 0) { name = "value"; } Console.WriteLine("Union"); sb.AppendLine(); sb.AppendLine(new String('\t', level) + "[StructLayout(LayoutKind.Explicit,CharSet=CharSet.Ansi,Pack=1,Size=" + unode.size + ")]"); sb.AppendLine(new String('\t', level) + "public struct Union" + name); sb.AppendLine(new String('\t', level) + "{"); prefix = "[FieldOffset(0)]"; level++; WriteToFile(unode); level--; prefix = null; sb.AppendLine(new String('\t', level) + "}"); sb.AppendLine(new String('\t', level) + "public Union" + name + " " + name + ";"); sb.AppendLine(); } } else if (n.Type() == typeof(ArrayTypeNode)) { ArrayTypeNode an = n as ArrayTypeNode; sb.AppendLine(new String('\t', level) + "[MarshalAs(UnmanagedType.ByValArray, SizeConst = " + (an.size / an.align) + ")]"); sb.AppendLine(new String('\t', level) + "public " + type + "[] " + fieldbase.name + ";"); } else { if (type == "bool") { sb.AppendLine(new String('\t', level) + "[MarshalAs(UnmanagedType.I1)]"); } sb.AppendLine(new String('\t', level) + "public " + type + " " + fieldbase.name + ";"); } }
public void Visit(UnionNode node) { }
public BaseNode AddUnion(string id, string name, string file, string sz) { UnionNode unionn = new UnionNode(id, name, file, sz); nodemap.Add(id, unionn); return unionn; }
private void paintUnionEdgesV(UnionNode parent) { Rectangle b1 = drawBounds(parent); // spouse connector between boxes int x = b1.Left + Math.Min(parent.P1.Wide, parent.P2.Wide) / 2; int y = b1.Top + parent.P1.High; _g.DrawLine(_spousePen, x, y, x, y + UNION_BAR_WIDE); // nothing further to do if this is a "duplicate" or there are no children if (DrawDuplicateNode(parent) || !hasChildren(parent)) { return; } // Draw the connector from the spouse-line to the children-line int horzLx = x; int horzLy = y + UNION_BAR_WIDE / 2; int targetX = -1; // Need to calculate the child-line loc relative to the children // NOTE: requires align==towardsroot! // determine top/bottom of children line int minChildY = int.MaxValue; int maxChildY = int.MinValue; foreach (var child in getChildren(parent)) { // Do not draw 'I'm a child' line for spouses if (child is PersonNode && !((PersonNode)child).DrawVert) { continue; } var b2 = drawBounds(child); int childX = b2.Left; int childY = b2.Top + child.ParentConnectLoc; if (targetX == -1) { targetX = childX - gapBetweenLevels / 2; } minChildY = Math.Min(minChildY, childY); maxChildY = Math.Max(maxChildY, childY); // connector from child to child-line _g.DrawLine(_childPen, childX, childY, targetX, childY); } // Union has a single child. Connector from child unlikely to // match to connector from union. Draw an extra connector. if (minChildY == maxChildY) { _g.DrawLine(_childPen, targetX, minChildY, targetX, horzLy); } else { _g.DrawLine(_childPen, targetX, minChildY, targetX, maxChildY); // the child-line proper } // union-link to child line _g.DrawLine(_childPen, horzLx, horzLy, targetX, horzLy); }