Ejemplo n.º 1
0
 protected BaseRankingFilter(IColumnIdentifier operand, ColumnType columnType, IEnumerable <IColumnAlias> aliases, IEnumerable <IColumnExpression> expressions)
 {
     this.Operand     = operand;
     this.ColumnType  = columnType;
     this.Aliases     = aliases;
     this.Expressions = expressions;
 }
Ejemplo n.º 2
0
 public SinglePredicateFilter(IEnumerable <IColumnAlias> aliases, IEnumerable <IColumnExpression> expressions, IColumnIdentifier operand, Func <object, bool> implementation, Func <string> describeFunction)
     : base(aliases, expressions)
 {
     this.operand          = operand;
     this.implementation   = implementation;
     this.describeFunction = describeFunction;
 }
Ejemplo n.º 3
0
 public AbstractRanking(int count, IColumnIdentifier operand, ColumnType columnType, IEnumerable <IColumnAlias> aliases, IEnumerable <IColumnExpression> expressions)
     : base(operand, columnType, aliases, expressions)
 {
     if (count <= 0)
     {
         throw new ArgumentOutOfRangeException("The value of count must be strictly positive.");
     }
     TableLength = count;
 }
Ejemplo n.º 4
0
        public void Add(IColumnIdentifier indentifier, ITransformationInfo transfo)
        {
            var transformer = factory.Instantiate(transfo);

            transformer.Initialize(transfo.Code);
            if (cacheTransformers.ContainsKey(indentifier))
            {
                throw new NBiException($"You can't define two transformers for the same column. The column {indentifier.Label} has already another transformer specified.");
            }
            cacheTransformers.Add(indentifier, transformer);
        }
Ejemplo n.º 5
0
        protected object GetValueFromRow(DataRow row, IColumnIdentifier identifier)
        {
            if (identifier is ColumnOrdinalIdentifier)
            {
                var ordinal = (identifier as ColumnOrdinalIdentifier).Ordinal;
                if (ordinal <= row.Table.Columns.Count)
                {
                    return(row.ItemArray[ordinal]);
                }
                else
                {
                    throw new ArgumentException($"The variable of the predicate is identified as '{identifier.Label}' but the column in position '{ordinal}' doesn't exist. The dataset only contains {row.Table.Columns.Count} columns.");
                }
            }

            var name  = (identifier as ColumnNameIdentifier).Name;
            var alias = aliases.SingleOrDefault(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));

            if (alias != null)
            {
                return(row.ItemArray[alias.Column]);
            }

            var expression = expressions.SingleOrDefault(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));

            if (expression != null)
            {
                var result        = EvaluateExpression(expression, row);
                var expColumnName = $"exp::{name}";
                if (!row.Table.Columns.Contains(expColumnName))
                {
                    var newColumn = new DataColumn(expColumnName, typeof(object));
                    row.Table.Columns.Add(newColumn);
                }

                row[expColumnName] = result;
                return(result);
            }

            var column = row.Table.Columns.Cast <DataColumn>().SingleOrDefault(x => string.Equals(x.ColumnName, name, StringComparison.OrdinalIgnoreCase));

            if (column != null)
            {
                return(row[column.ColumnName]);
            }

            var existingNames = row.Table.Columns.Cast <DataColumn>().Select(x => x.ColumnName)
                                .Union(aliases.Select(x => x.Name)
                                       .Union(expressions.Select(x => x.Name)));

            throw new ArgumentException($"The value '{name}' is not recognized as a column position, a column name, a column alias or an expression. Possible arguments are: '{string.Join("', '", existingNames.ToArray())}'");
        }
Ejemplo n.º 6
0
        protected object GetValueFromRow(DataRow row, IColumnIdentifier identifier)
        {
            if (identifier is ColumnOrdinalIdentifier)
            {
                var ordinal = (identifier as ColumnOrdinalIdentifier).Ordinal;
                if (ordinal <= row.Table.Columns.Count)
                {
                    return(row.ItemArray[ordinal]);
                }
                else
                {
                    throw new ArgumentException($"The variable of the predicate is identified as '{identifier.Label}' but the column in position '{ordinal}' doesn't exist. The dataset only contains {row.Table.Columns.Count} columns.");
                }
            }

            var name  = (identifier as ColumnNameIdentifier).Name;
            var alias = aliases?.SingleOrDefault(x => x.Name == name);

            if (alias != null)
            {
                return(row.ItemArray[alias.Column]);
            }

            var expression = expressions?.SingleOrDefault(x => x.Name == name);

            if (expression != null)
            {
                return(EvaluateExpression(expression, row));
            }

            var column = row.Table.Columns.Cast <DataColumn>().SingleOrDefault(x => x.ColumnName == name);

            if (column != null)
            {
                return(row[column.ColumnName]);
            }

            throw new ArgumentException($"The value '{name}' is not recognized as a column name or a column position or a column alias or an expression.");
        }
Ejemplo n.º 7
0
 public SinglePredication(IPredicate predicate, IColumnIdentifier operand)
 => (Predicate, Operand) = (predicate, operand);
Ejemplo n.º 8
0
 public NewNameRenamingArgs(IColumnIdentifier originalIdentification, IScalarResolver <string> newIdentification, IMissingColumnStrategy missingColumnStrategy)
 => (OriginalIdentification, NewIdentification, MissingColumnStrategy) = (originalIdentification, newIdentification, missingColumnStrategy);
Ejemplo n.º 9
0
 public DataRowScorer(IColumnIdentifier operand, IEnumerable <IColumnAlias> aliases, IEnumerable <IColumnExpression> expressions)
 {
     this.operand     = operand;
     this.aliases     = aliases;
     this.expressions = expressions;
 }
Ejemplo n.º 10
0
 public NativeExtendEngine(ServiceLocator serviceLocator, Context context, IColumnIdentifier newColumn, string code)
     : base(serviceLocator, context, newColumn, code)
 {
 }
Ejemplo n.º 11
0
 public ColumnMapping(IColumnIdentifier candidateColumn, IColumnIdentifier referenceColumn, ColumnType type)
 {
     CandidateColumn = candidateColumn;
     ReferenceColumn = referenceColumn;
     Type            = type;
 }
Ejemplo n.º 12
0
 public UnstackArgs(IColumnIdentifier header, IEnumerable <IColumnDefinitionLight> groupBys, IEnumerable <ColumnNameIdentifier> enforcedColumns)
 => (Header, GroupBys, EnforcedColumns) = (header, groupBys, enforcedColumns);
Ejemplo n.º 13
0
 public LookupReplaceArgs(IResultSetService resultSet, ColumnMapping mapping, IColumnIdentifier replacement)
     : this(resultSet, mapping, replacement, new FailureMissingStrategy())
 {
 }
Ejemplo n.º 14
0
 public TopRanking(int count, IColumnIdentifier operand, ColumnType columnType, IEnumerable <IColumnAlias> aliases, IEnumerable <IColumnExpression> expressions)
     : base(count, operand, columnType, aliases, expressions)
 {
 }
Ejemplo n.º 15
0
 public UnstackArgs(IColumnIdentifier header, IEnumerable <IColumnDefinitionLight> groupBys)
     : this(header, groupBys, new ColumnNameIdentifier[] { })
 {
 }
Ejemplo n.º 16
0
 public TopRanking(int count, IColumnIdentifier operand, ColumnType columnType)
     : this(count, operand, columnType, null, null)
 {
 }
Ejemplo n.º 17
0
 public RankingArgs(RankingOption option, int count, IColumnIdentifier operand, ColumnType type)
 => (Option, Count, Operand, Type) = (option, count, operand, type);
Ejemplo n.º 18
0
 public ColumnMapping(IColumnIdentifier column, ColumnType type)
     : this(column, column, type)
 {
 }
Ejemplo n.º 19
0
 public static object GetValue(this DataRow row, IColumnIdentifier columnIdentifier) => columnIdentifier.GetValue(row);
Ejemplo n.º 20
0
 public Predication(IPredicate predicate, IColumnIdentifier operand)
 {
     this.Predicate = predicate;
     this.Operand   = operand;
 }
Ejemplo n.º 21
0
 public IPredication Instantiate(IPredicate predicate, IColumnIdentifier operand)
 => new SinglePredication(predicate, operand);
Ejemplo n.º 22
0
 public static DataColumn GetColumn(this DataTable table, IColumnIdentifier columnIdentifier) => columnIdentifier.GetColumn(table);
Ejemplo n.º 23
0
 public LookupReplaceArgs(IResultSetService resultSet, ColumnMapping mapping, IColumnIdentifier replacement, IMissingStrategy missingStrategy)
 => (Reference, Mapping, Replacement, MissingStrategy) = (resultSet, mapping, replacement, missingStrategy);
Ejemplo n.º 24
0
 public AbstractExtendEngine(ServiceLocator serviceLocator, Context context, IColumnIdentifier newColumn, string code)
 => (ServiceLocator, Context, NewColumn, Code) = (serviceLocator, context, newColumn, code);
Ejemplo n.º 25
0
 public RankingGroupByArgs(IGroupBy groupBy, RankingOption option, int count, IColumnIdentifier operand, ColumnType type)
     : base(option, count, operand, type) => GroupBy = groupBy;
Ejemplo n.º 26
0
 public ColumnAggregationArgs(IColumnIdentifier identifier, AggregationFunctionType function, ColumnType columnType, IList <IScalarResolver> parameters)
     : base(function, columnType, parameters)
     => (Identifier) = (identifier);
Ejemplo n.º 27
0
 public AbstractRanking(IColumnIdentifier operand, ColumnType columnType, IEnumerable <IColumnAlias> aliases, IEnumerable <IColumnExpression> expressions)
     : this(1, operand, columnType, aliases, expressions)
 {
 }
Ejemplo n.º 28
0
 public SinglePredicateFilter(IEnumerable <IColumnAlias> aliases, IEnumerable <IColumnExpression> expressions, IColumnIdentifier operand, Func <object, bool> executeFunction)
     : this(aliases, expressions, operand, executeFunction, () => "unspecified description")
 {
 }
Ejemplo n.º 29
0
 public ContextScalarResolverArgs(Context context, IColumnIdentifier columnIdentifier)
 => (Context, ColumnIdentifier) = (context, columnIdentifier);
Ejemplo n.º 30
0
 public PredicationArgs(IColumnIdentifier identifier, PredicateArgs predicate)
 => (Identifier, Predicate) = (identifier, predicate);