//Create a column that merge the result of all sub nodes static public Column BuildColumnNodeMerge(ViewTable vTable, Database.MetaColumn metaColumn, Operation.ExpressionParsingContext expressionParsingContext) { var columnNode = (ViewColumnNode.IViewColumnNode)Operation.ColumnCreator.CreateColumn(typeof(ViewColumnNodeMergeTyped <>), metaColumn.Type); ViewColumnNode viewColumnNode = new ViewColumnNode(vTable, metaColumn, expressionParsingContext); columnNode.SetColumn(viewColumnNode); return(columnNode.GetColumn()); }
public Database.MetaColumn GetColumnByName(string name) { Database.MetaColumn o; if (name == kRowIndexColumnName) { o = new Database.MetaColumn(kRowIndexColumnName, "Row", typeof(long), false, null, null); return(o); } if (m_ColumnsByName.TryGetValue(name, out o)) { return(o); } return(null); }
public Database.MetaColumn GetColumnByName(string name) { Database.MetaColumn o; if (name == kRowIndexColumnName) { var metaType = new MetaType() { scriptingType = typeof(long), comparisonMethod = DataMatchMethod.AsNumber }; o = new Database.MetaColumn(kRowIndexColumnName, "Row", metaType, false, null, null); return(o); } if (m_ColumnsByName.TryGetValue(name, out o)) { return(o); } return(null); }
private Operation.Grouping.IMergeAlgorithm BuildOrGetMergeAlgo(ViewColumn vc, Type columnValueType, Database.MetaColumn metaColumn) { Operation.Grouping.IMergeAlgorithm mergeAlgo = null; if (mergeAlgoE != Operation.Grouping.MergeAlgo.none) { mergeAlgo = Operation.Grouping.GetMergeAlgo(mergeAlgoE, columnValueType); if (metaColumn != null) { metaColumn.DefaultMergeAlgorithm = mergeAlgo; } } else { if (metaColumn != null) { mergeAlgo = metaColumn.DefaultMergeAlgorithm; } } if (vc != null && mergeAlgo != null && mergeAlgo.IsDisplayMergedRowsOnly()) { vc.m_IsDisplayMergedOnly = true; } return(mergeAlgo); }
public IViewColumn Build(ViewTable.Builder.Node node, ViewSchema vs, Database.Schema baseSchema, ViewTable vTable, Operation.ExpressionParsingContext expressionParsingContext, ref Database.MetaColumn metaColumn) { // Check if we have a type mismatch Type columnValueType = metaColumn != null ? metaColumn.Type : null; if (value.type != null) { if (columnValueType != null && columnValueType != value.type) { DebugUtility.LogWarning("While building column '" + name + "' : " + "Cannot override type from '" + columnValueType.Name + "' to '" + value.type.Name + "'"); } columnValueType = value.type; } // Parse expression value Operation.Expression.ParseIdentifierOption parseOpt = new Operation.Expression.ParseIdentifierOption(vs, vTable, true, false, columnValueType, expressionParsingContext); parseOpt.formatError = (string s, Operation.Expression.ParseIdentifierOption opt) => { return(FormatErrorContextInfo(vs, vTable) + " : " + s); }; Operation.Expression expression = Operation.Expression.ParseIdentifier(value, parseOpt); // Build declaration with the type we've just parsed BuildOrUpdateDeclaration(ref metaColumn, expression.type); IViewColumn result = (IViewColumn)Operation.ColumnCreator.CreateViewColumnExpression(expression); ViewColumn vc = new ViewColumn(); vc.m_MetaLink = m_MetaLink; vc.viewTable = vTable; vc.ParsingContext = expressionParsingContext; result.SetColumn(vc, null); return(result); }
// Set a Node value to the merged result of it's sub entries public static void BuildNodeValueDefault(ViewTable.Builder.Node node, long row, ViewSchema vs, Database.Schema baseSchema, ViewTable parentViewTable, Operation.ExpressionParsingContext expressionParsingContext, Database.MetaColumn metaColumn) { //set the entry for merge column if (metaColumn.DefaultMergeAlgorithm != null && metaColumn.Type != null) { ViewColumnNode.IViewColumnNode column = BuildOrGetColumnNode(parentViewTable, metaColumn, metaColumn.Name, expressionParsingContext); Operation.Expression expression = Operation.ColumnCreator.CreateTypedExpressionColumnMerge(metaColumn.Type, parentViewTable, row, column.GetColumn(), metaColumn); column.SetEntry(row, expression, null); } }
//A column under a <Node> (or <View>) element is either a declaration (build meta data only) or defines an entry in the parent's ViewColumnNode public void BuildNodeValue(ViewTable.Builder.Node node, long row, ViewSchema vs, Database.Schema baseSchema, ViewTable parentViewTable, Operation.ExpressionParsingContext expressionParsingContext, ref Database.MetaColumn metaColum) { BuildOrUpdateDeclaration(ref metaColum); //If the parent's node data type is Node if (node.parent != null && node.parent.data.type == ViewTable.Builder.Node.Data.DataType.Node) { // this column is an entry in the parent's column var option = new Operation.Expression.ParseIdentifierOption(vs, parentViewTable, true, true, metaColum != null ? metaColum.Type : null, expressionParsingContext); option.formatError = (string s, Operation.Expression.ParseIdentifierOption opt) => { return(FormatErrorContextInfo(vs, parentViewTable) + " : " + s); }; Operation.Expression expression = Operation.Expression.ParseIdentifier(value, option); //if the meta column does not have a type defined yet, define it as the expression's type. if (metaColum.Type == null) { metaColum.Type = expression.type; } ViewColumnNode.IViewColumnNode column = BuildOrGetColumnNode(parentViewTable, metaColum, name, expressionParsingContext); column.SetEntry(row, expression, m_MetaLink); } }
static ViewColumnNode.IViewColumnNode BuildOrGetColumnNode(ViewTable vTable, Database.MetaColumn metaColumn, string columnName, Operation.ExpressionParsingContext expressionParsingContext) { var column = vTable.GetColumnByName(columnName); if (column == null) { var columnNode = (ViewColumnNode.IViewColumnNode)Operation.ColumnCreator.CreateColumn(typeof(ViewColumnNodeTyped <>), metaColumn.Type); ViewColumnNode viewColumnNode = new ViewColumnNode(vTable, metaColumn, expressionParsingContext); columnNode.SetColumn(viewColumnNode); vTable.SetColumn(metaColumn, columnNode.GetColumn()); return(columnNode); } // View table use expand column to decorate the IViewColumnNode with required functionality for expanding rows. // So we need to get the underlying column, which is the IViewColumnNode we want. if (column is IColumnDecorator) { column = (column as IColumnDecorator).GetBaseColumn(); } if (column is ViewColumnNode.IViewColumnNode) { return((ViewColumnNode.IViewColumnNode)column); } else { throw new Exception("Expecting column '" + vTable.GetName() + "." + metaColumn.Name + "' to be a from a node data type (ViewColumnNode) but is of type '" + column.GetType().Name + "'"); } }
//A column under a <Node> (or <View>) element is either a declaration (build meta data only) or defines an entry in the parent's ViewColumnNode public void BuildNodeValue(ViewTable.Builder.BuildingData buildingData, ViewTable vTable, ViewTable.Builder.Node node, long row, ViewTable parentViewTable, Operation.ExpressionParsingContext expressionParsingContext, ref Database.MetaColumn metaColum) { BuildOrUpdateDeclaration(buildingData, vTable, ref metaColum, expressionParsingContext); //If the parent's node data type is Node if (node.parent != null && node.parent.data.type == ViewTable.Builder.Node.Data.DataType.Node) { // this column is an entry in the parent's column var option = new Operation.Expression.ParseIdentifierOption(buildingData.Schema, parentViewTable, true, true, metaColum != null ? metaColum.Type.scriptingType : null, expressionParsingContext); option.formatError = (string s, Operation.Expression.ParseIdentifierOption opt) => { return(FormatErrorContextInfo(buildingData.Schema, parentViewTable) + " : " + s); }; Operation.Expression expression = Operation.Expression.ParseIdentifier(value, option); //if the meta column does not have a type defined yet, define it as the expression's type. if (metaColum.Type.scriptingType == null) { DataMatchMethod matchMethod = expression.type == typeof(string) ? DataMatchMethod.AsString : DataMatchMethod.AsNumber; metaColum.Type = new MetaType() { scriptingType = expression.type, comparisonMethod = matchMethod }; } ViewColumnNode.IViewColumnNode column = BuildOrGetColumnNode(parentViewTable, metaColum, name, expressionParsingContext); column.SetEntry(row, expression, m_MetaLink); } }