Exemplo n.º 1
0
 public SparqlOrderCondition(SparqlExpression sparqlExpression, RdfQuery11Translator q)
 {
     this.q = q;
     // TODO: Complete member initialization
     getNode        = sparqlExpression.Operator;
     AggregateLevel = sparqlExpression.AggregateLevel;
 }
Exemplo n.º 2
0
        public SparqlSeconds(SparqlExpression sparqlExpression)
        {
            // TODO: Complete member initialization
            this.sparqlExpression = sparqlExpression;

            //todo
        }
 public SparqlExpressionAsVariable(VariableNode variableNode, SparqlExpression sparqlExpression, RdfQuery11Translator q)
 {
     // TODO: Complete member initialization
     this.variableNode     = variableNode;
     this.sparqlExpression = sparqlExpression;
     this.q = q;
 }
Exemplo n.º 4
0
        public SparqlGroupConstraint(SparqlExpression sparqlExpression)
        {
            this.sparqlExpression = sparqlExpression;
            //if(sparqlExpression.Const!=null)
            // TODO: Const

            this.Constrained = sparqlExpression.TypedOperator;
        }
Exemplo n.º 5
0
        public void ReadXml(XmlReader reader)
        {
            var field = SparqlQuery.SparqlClasses.Query.SparqlQuery.CreateByTypeAttribute(reader);

            sparqlExpression   = field as SparqlExpression;
            sparqlFunctionCall = field as SparqlFunctionCall;
            variableNode       = field as VariableNode;
        }
        public AggregateExpression Count(SparqlExpression expression)
        {
            var aggregate = _distinctAggregate
                ? (ISparqlAggregate) new CountDistinctAggregate(expression.Expression)
                : new CountAggregate(expression.Expression);

            return(new AggregateExpression(aggregate));
        }
Exemplo n.º 7
0
 public SparqlLCase(SparqlExpression value)        : base(value.AggregateLevel, value.IsStoreUsed)
 {
     if (value.Const != null)
     {
         this.Const = value.Const.Change(o => o.ToLower());
     }
     else
     {
         this.Operator      = result => value.Operator(result).ToLower();
         this.TypedOperator = result => value.TypedOperator(result).Change(o => o.ToLower());
     }
 }
        public AggregateExpression GroupConcat(SparqlExpression expression, string separator = " ")
        {
            GroupConcatAggregate aggregate;

            if (separator != " ")
            {
                aggregate = new GroupConcatAggregate(expression.Expression, Constant(separator).Expression, _distinctAggregate);
            }
            else
            {
                aggregate = new GroupConcatAggregate(expression.Expression, _distinctAggregate);
            }

            return(new AggregateExpression(aggregate));
        }
Exemplo n.º 9
0
        public void ReadXml(XmlReader reader)
        {
            Enum.TryParse(reader.GetAttribute("Group"), out this.AggregateLevel);
            var readed = Query.SparqlQuery.CreateByTypeAttribute(reader);

            if (readed == null)
            {
                throw new Exception("readed null");
            }
            if ((this.sparqlFunctionCall = readed as SparqlFunctionCall) == null)
            {
                if ((this.sparqlExpression = readed as SparqlExpression) == null)
                {
                    if ((this.variableNode = readed as VariableNode) == null)
                    {
                        throw new Exception("readed null");
                    }
                }
            }
            else
            {
                var readed2 = Query.SparqlQuery.CreateByTypeAttribute(reader);
                if (readed2 == null)
                {
                    return;
                }
                if ((this.sparqlExpression = readed2 as SparqlExpression) == null)
                {
                    if ((this.variableNode = readed2 as VariableNode) == null)
                    {
                        throw new Exception("readed some else");
                    }
                }
                else
                {
                    var readed3 = Query.SparqlQuery.CreateByTypeAttribute(reader);
                    if (readed3 == null)
                    {
                        return;
                    }

                    if ((this.variableNode = readed3 as VariableNode) == null)
                    {
                        throw new Exception("readed some else");
                    }
                }
            }
        }
Exemplo n.º 10
0
        public SparqlOrderCondition(SparqlExpression sparqlExpression, string dir, RdfQuery11Translator q)
        {
            this.q = q;
            // TODO: Complete member initialization
            switch (dir.ToLower())
            {
            case "desc":
                direction = SparqlOrderDirection.Desc;
                break;

            case "asc":
            default:
                direction = SparqlOrderDirection.Asc;
                break;
            }
            getNode        = sparqlExpression.Operator;
            AggregateLevel = sparqlExpression.AggregateLevel;
        }
Exemplo n.º 11
0
        public SparqlBnode(SparqlExpression value, RdfQuery11Translator q)       : base(value.AggregateLevel, value.IsStoreUsed)
        {
            //IsDistinct = value.IsDistinct;
            //value.SetExprType(ObjectVariantEnum.Str);
            //SetExprType(ObjectVariantEnum.Iri);
            var litConst = value.Const;

            if (litConst != null)
            {
                Operator          =
                    TypedOperator = result => q.Store.NodeGenerator.CreateBlankNode(value.Const.Content + result.Id);
            }
            else
            {
                Operator          =
                    TypedOperator = result => q.Store.NodeGenerator.CreateBlankNode(value.Operator(result) + result.Id);
                //OvConstruction = o => q.Store.NodeGenerator.CreateBlankNode((string) o);
            }
        }
Exemplo n.º 12
0
        public void BindSelectVariables()
        {
            IsBound = true;

            if (SelectBuilder != null)
            {
                bool hasAggregate = SelectedVariables.Any(v => v.IsAggregate);

                foreach (SparqlVariable v in SelectedVariables)
                {
                    if (CoalescedVariables.ContainsKey(v))
                    {
                        SparqlExpression defaultValue = CoalescedVariables[v];

                        SelectBuilder.And(e => e.Coalesce(e.Variable(v.Name), defaultValue)).As(v.Name + '_');
                    }
                    else
                    {
                        SelectBuilder.And(v);
                    }

                    if (hasAggregate && !v.IsAggregate)
                    {
#if !NET35
                        SelectBuilder.GroupBy(v.Name);
#else
                        QueryBuilder.GroupBy(v.Name);
#endif
                    }
                }

                if (hasAggregate && !IsRoot)
                {
#if !NET35
                    SelectBuilder.Distinct();
#else
                    QueryBuilder.Distinct();
#endif
                }
            }
        }
        public AggregateExpression Sample(SparqlExpression expression)
        {
            var aggregate = new SampleAggregate(expression.Expression);

            return(new AggregateExpression(aggregate));
        }
Exemplo n.º 14
0
        public BooleanExpression SameTerm(SparqlExpression left, SparqlExpression right)
        {
            var sameTerm = new SameTermFunction(left.Expression, right.Expression);

            return(new BooleanExpression(sameTerm));
        }
        public AggregateExpression Max(SparqlExpression expression)
        {
            var aggregate = new MaxAggregate(expression.Expression, _distinctAggregate);

            return(new AggregateExpression(aggregate));
        }
Exemplo n.º 16
0
 public SparqlFilter(SparqlExpression sparqlExpression)
 {
     // TODO: Complete member initialization
     this.SparqlExpression = sparqlExpression;
 }
Exemplo n.º 17
0
 public BooleanExpression SameTerm(string left, SparqlExpression right)
 {
     return(SameTerm(Variable(left), right));
 }
 /// <summary>
 /// Sets the second parameter of the IF function call
 /// </summary>
 public IfElsePart Then(SparqlExpression thenExpression)
 {
     return(new IfElsePart(_ifExpression, thenExpression.Expression));
 }
        public AggregateExpression Avg(SparqlExpression expression)
        {
            var aggregate = new AverageAggregate(expression.Expression, _distinctAggregate);

            return(new AggregateExpression(aggregate));
        }
        /// <summary>
        /// Creates a call of the SAMETERM function with two expression parameters
        /// </summary>
        /// <param name="eb"></param>
        /// <param name="left">a SPARQL expression</param>
        /// <param name="right">a SPARQL expression</param>
        public static BooleanExpression SameTerm(this ExpressionBuilder eb, SparqlExpression left, SparqlExpression right)
        {
            var sameTerm = new SameTermFunction(left.Expression, right.Expression);

            return(new BooleanExpression(sameTerm));
        }
 /// <summary>
 /// Creates a call of the SAMETERM function with expression and variable parameters
 /// </summary>
 /// <param name="eb"></param>
 /// <param name="left">a SPARQL expression</param>
 /// <param name="right">a variable name</param>
 public static BooleanExpression SameTerm(this ExpressionBuilder eb, SparqlExpression left, string right)
 {
     return(eb.SameTerm(left, eb.Variable(right)));
 }
Exemplo n.º 22
0
 public BooleanExpression SameTerm(SparqlExpression left, string right)
 {
     return(SameTerm(left, Variable(right)));
 }
 /// <inheritdoc />
 public BooleanExpression Regex(SparqlExpression text, string pattern, string flags)
 {
     return(Regex(text.Expression, Constant(pattern).Expression, flags.ToConstantTerm()));
 }
Exemplo n.º 24
0
 public void ReadXml(XmlReader reader)
 {
     this.SparqlExpression = (SparqlExpression)SparqlQuery.SparqlClasses.Query.SparqlQuery.CreateByTypeAttribute(reader);
 }
Exemplo n.º 25
0
        public SparqlGroupConstraint(SparqlExpression sparqlExpression)
        {
            // TODO: Const

            Constrained = sparqlExpression.TypedOperator;
        }
        /// <summary>
        /// Sets the third parameter of the IF function call
        /// </summary>
        public RdfTermExpression Else(SparqlExpression elseExpression)
        {
            var ifElseFunc = new IfElseFunction(_ifExpression, _thenExpression, elseExpression.Expression);

            return(new RdfTermExpression(ifElseFunc));
        }
        public AggregateExpression Sum(SparqlExpression expression)
        {
            var sumAggregate = new SumAggregate(expression.Expression, _distinctAggregate);

            return(new AggregateExpression(sumAggregate));
        }
Exemplo n.º 28
0
 public SparqlCastBuilder Cast(SparqlExpression castedExpression)
 {
     return(new SparqlCastBuilder(castedExpression));
 }
Exemplo n.º 29
0
        //internal IEnumerable<VariableNode> GetVariables(int p)
        //{
        //    return Variables.Values.Cast<>.Skip(p);
        //}

        internal SparqlExpressionAsVariable CreateExpressionAsVariable(VariableNode variableNode, SparqlExpression sparqlExpression)
        {
            return(new SparqlExpressionAsVariable(variableNode, sparqlExpression, this));
        }
Exemplo n.º 30
0
 public SparqlUcase(SparqlExpression value)
     : base(o => o.ToUpperInvariant(), value, "ucase")
 {
 }