/// <summary> /// Return an expression tree with the structure of the target paths and leaves corresponding to the source paths. /// </summary> public ExprNode BuildExpression(ActionType action) { // Two algorithms: // - for all matches: add all target paths to the expression root and for each of them generate a continuation from the source path by attaching to the leaf // - generate separately a target tree in a separate method. for each leaf, generate a continuation path and attach it to the leaf // Methods: // - ExprNode = CreateCall(ColumnPath path). generate a sequential access expression from a path (optionally with 'this' formatted for the initial table in the leaf) // - take into account Oledb by instantiating correct epxr node type // - alternativey, add the path to a tree node // - Expr::AddToTuple(ColumnPath path). add a path to an existing tree. here we have to know // - criterion of equality of path segment and tree node, // - a method for creating a node from a path segment // - the semantics of adding from the point of view of tree operation (expr node has to be parameterized accordingly) // - Mapping::BuildTupleTree() Expr::CreateTuple(Mapping) build a source/target tree from a mapping (or from a list of paths) // - add all paths sequentially to the expression tree // - returning leaves of an expression tree (in order to attach continuation paths) // Create root tuple expression corresponding to the table ExprNode tupleExpr = new ExprNode(); tupleExpr.Operation = OperationType.TUPLE; tupleExpr.Action = action; tupleExpr.Name = ""; // This tuple is not a member in any other tuple tupleExpr.OutputVariable.SchemaName = TargetTab.Schema.Name; tupleExpr.OutputVariable.TypeName = TargetTab.Name; tupleExpr.OutputVariable.TypeSchema = TargetTab.Schema; tupleExpr.OutputVariable.TypeTable = TargetTab; // This tuple is a member in the table // For each match, add a tuple branch and then an access call foreach (PathMatch match in Matches) { // Add a branch into the tuple tree ExprNode leafNode = tupleExpr.AddToTuple(match.TargetPath, false); // Add an access expression to this branch ExprNode accessNode = ExprNode.CreateReader(match.SourcePath, true); leafNode.AddChild((ExprNode)accessNode.Root); // TODO: Old question: what is in the tuple leaves: VALUE, CALL, or whatever } return(tupleExpr); }
private void AddOperand_Click(object sender, RoutedEventArgs e) { // // Determine parent expression // ExprNode parentExpr; parentExpr = (ExprNode)expressionModel.ExprTreeView.SelectedItem; if (parentExpr == null && ExpressionModel.Count != 0) { return; // Nothing is selected } // // Determine dimension (function) and create child expression // DimPath path = (DimPath)operands.SelectedItem; if (path == null) { return; } var expr = ExprNode.CreateReader(path, false); expr = (ExprNode)expr.Root; // // Insert new child expression // if (parentExpr == null) // First exprssion node { ExpressionModel.Add(expr); } else { parentExpr.AddChild(expr); } RefreshAll(); }