public IEnumerable <SparqlResult> SPoVarGraphs(VariableNode subj, VariableNode pred,
                                                ObjectVariants obj, SparqlResult variablesBindings, VariableDataSet variableDataSet)
 {
     if (variableDataSet.Any())
     {
         return(variableDataSet.SelectMany(g =>
                                           store
                                           .NamedGraphs
                                           .GetTriplesWithObjectFromGraph(obj, g, (s, p) =>
                                                                          variablesBindings.Add(p, pred, s, subj, g, variableDataSet.Variable))));
     }
     return(store
            .NamedGraphs
            .GetTriplesWithObject(obj, (s, p, g) =>
                                  variablesBindings.Add(p, pred, s, subj, g, variableDataSet.Variable)));
 }
Exemplo n.º 2
0
 private SparqlResult SetValues(SparqlResult result, TripleOVStruct triple)
 {
     if (Subject == null)
     {
         result.Add(triple.Subject, sVariableNode);
     }
     if (Predicate == null)
     {
         result.Add(triple.Predicate, pVariableNode);
     }
     if (Object == null)
     {
         result.Add(triple.Object, oVariableNode);
     }
     return(result);
 }
 public IEnumerable <SparqlResult> spO(ObjectVariants subjNode, ObjectVariants predicateNode,
                                       VariableNode obj, SparqlResult variablesBindings)
 {
     return(store.GetTriplesWithSubjectPredicate(subjNode, predicateNode)
            .ToArray()
            .Select(node => variablesBindings.Add(node, obj)));
 }
 public IEnumerable <SparqlResult> sPoVarGraphs(ObjectVariants subj, VariableNode pred, ObjectVariants obj, SparqlResult variablesBindings, VariableDataSet variableDataSet)
 {
     if (variableDataSet.Any())
     {
         return(variableDataSet.SelectMany(g =>
                                           store.NamedGraphs.GetPredicate(subj, obj, g)
                                           .Select(p => variablesBindings.Add(p, pred, g, variableDataSet.Variable))));
     }
     else
     {
         return(store
                .NamedGraphs
                .GetTriplesWithSubjectObject(subj, obj, (p, g) =>
                                             variablesBindings.Add(p, pred, g, variableDataSet.Variable)));
     }
 }
 public IEnumerable <SparqlResult> SPOGraphs(VariableNode subj, VariableNode predicate, VariableNode obj, SparqlResult variablesBindings, DataSet graphs)
 {
     return(graphs.SelectMany(g =>
                              store.NamedGraphs
                              .GetTriplesFromGraph(g, (s, p, o) =>
                                                   variablesBindings.Add(s, subj, p, predicate, o, obj))));
 }
 public IEnumerable <SparqlResult> spoVarGraphs(ObjectVariants subjectNode, ObjectVariants predicateNode, ObjectVariants objectNode,
                                                SparqlResult variablesBindings, VariableDataSet graphs)
 {
     return((graphs.Any()
         ? graphs.Where(g => store.NamedGraphs.Contains(subjectNode, predicateNode, objectNode, g))
         : store.NamedGraphs.GetGraph(subjectNode, predicateNode, objectNode))
            .Select(g => variablesBindings.Add(g, graphs.Variable)));
 }
 public IEnumerable <SparqlResult> sPOGraphs(ObjectVariants subj, VariableNode pred,
                                             VariableNode obj, SparqlResult variablesBindings, DataSet graphs)
 {
     return(graphs.SelectMany(g => store
                              .NamedGraphs
                              .GetTriplesWithSubjectFromGraph(subj, g, (p, o) =>
                                                              variablesBindings.Add(p, pred, o, obj))));
 }
 public IEnumerable <SparqlResult> sPoGraphs(ObjectVariants subj, VariableNode pred, ObjectVariants obj, SparqlResult variablesBindings, DataSet graphs)
 {
     return(graphs.SelectMany(graph =>
                              store
                              .NamedGraphs
                              .GetPredicate(subj, obj, graph)
                              .Select(p => variablesBindings.Add(p, pred))));
 }
 public IEnumerable <SparqlResult> spOGraphs(ObjectVariants subjNode, ObjectVariants predicateNode,
                                             VariableNode obj, SparqlResult variablesBindings, DataSet graphs)
 {
     return(graphs.SelectMany(graph => store
                              .NamedGraphs
                              .GetObject(subjNode, predicateNode, graph) // if graphs is empty, Gets All named graphs
                              .Select(o => variablesBindings.Add(o, obj))));
 }
 public IEnumerable <SparqlResult> SpOGraphs(VariableNode sVar, ObjectVariants predicate, VariableNode oVar, SparqlResult variablesBindings, DataSet graphs)
 {
     return(graphs.SelectMany(graph =>
                              store
                              .NamedGraphs
                              .GetTriplesWithPredicateFromGraph(predicate, graph,
                                                                (s, o) => variablesBindings.Add(s, sVar, o, oVar))));
 }
 public IEnumerable <SparqlResult> SPOVarGraphs(VariableNode subj, VariableNode predicate, VariableNode obj, SparqlResult variablesBindings, VariableDataSet variableDataSet)
 {
     if (variableDataSet.Any())
     {
         return(variableDataSet.SelectMany(g =>
                                           store
                                           .NamedGraphs
                                           .GetTriplesFromGraph(g, (s, p, o) =>
                                                                variablesBindings.Add(s, subj, p, predicate, o, obj, g,
                                                                                      variableDataSet.Variable))));
     }
     return(store
            .NamedGraphs
            .GetAll((s, p, o, g) =>
                    variablesBindings.Add(s, subj, p, predicate, o, obj, g,
                                          variableDataSet.Variable)));
 }
 public IEnumerable <SparqlResult> SPoGraphs(VariableNode subj, VariableNode pred,
                                             ObjectVariants obj, SparqlResult variablesBindings, DataSet graphs)
 {
     return(graphs.SelectMany(g =>
                              store
                              .NamedGraphs
                              .GetTriplesWithObjectFromGraph(obj, g, (s, p) =>
                                                             variablesBindings.Add(p, pred, s, subj))));
 }
Exemplo n.º 13
0
 public IEnumerable <SparqlResult> ApplyFilters(SparqlResult variablesBindings, VariableNode variable,
                                                IEnumerable <ObjectVariants> baseStoreCall)
 {
     return(this.listOfFilters.Aggregate(baseStoreCall
                                         .Select(node => new KeyValuePair <ObjectVariants, SparqlResult>(node, variablesBindings.Add(node, variable))),
                                         (current, sparqlFilter) => current.Where(valueAndResult => sparqlFilter.SparqlExpression.Test(valueAndResult.Value)))
            .Select(pair => pair.Key)
            .Select(node => variablesBindings.Add(node, variable)));
 }
 public IEnumerable <SparqlResult> SpoVarGraphs(VariableNode subj, ObjectVariants predicateNode,
                                                ObjectVariants objectNode, SparqlResult variablesBindings, VariableDataSet variableDataSet)
 {
     if (variableDataSet.Any())
     {
         return(variableDataSet.SelectMany(g => store
                                           .NamedGraphs
                                           .GetSubject(predicateNode, objectNode, g)
                                           .Select(s => variablesBindings.Add(s, subj, g, variableDataSet.Variable))));
     }
     else
     {
         return(store
                .NamedGraphs
                .GetTriplesWithPredicateObject(predicateNode, objectNode,
                                               (s, g) => variablesBindings.Add(s, subj, g, variableDataSet.Variable)));
     }
 }
 // from merged named graphs
 public IEnumerable <SparqlResult> spOVarGraphs(ObjectVariants subjNode, ObjectVariants predicateNode,
                                                VariableNode obj, SparqlResult variablesBindings, VariableDataSet variableDataSet)
 {
     if (variableDataSet.Any())
     {
         return(variableDataSet.SelectMany(g => store
                                           .NamedGraphs
                                           .GetObject(subjNode, predicateNode, g)
                                           .Select(o => variablesBindings.Add(o, obj, g, variableDataSet.Variable))));
     }
     else
     {
         return(store
                .NamedGraphs
                .GetTriplesWithSubjectPredicate(subjNode, predicateNode,
                                                ((o, g) => variablesBindings.Add(o, obj, g, variableDataSet.Variable))));
     }
     // if graphVariable is null, ctor check this.
 }
 public IEnumerable <SparqlResult> SpoGraphs(VariableNode subj, ObjectVariants predicateNode,
                                             ObjectVariants objectNode, SparqlResult variablesBindings, DataSet graphs)
 {
     return(graphs.SelectMany(g =>
                              store.NamedGraphs
                              .GetSubject(predicateNode, objectNode, g)
                              // if graphs is empty, Gets All named graphs
                              .Select(node => variablesBindings.Add(node, subj))));
     // if graphVariable is null, ctor check this.
 }
Exemplo n.º 17
0
 private SparqlResult SetValues(SparqlResult result, QuadOVStruct quad)
 {
     if (Subject == null)
     {
         result.Add(quad.Subject, sVariableNode);
     }
     if (Predicate == null)
     {
         result.Add(quad.Predicate, pVariableNode);
     }
     if (Object == null)
     {
         result.Add(quad.Object, oVariableNode);
     }
     if (!isGKnown)
     {
         result.Add(quad.Graph, variableDataSet.Variable);
     }
     return(result);
 }
 public IEnumerable <SparqlResult> SpOVarGraphs(VariableNode sVar, ObjectVariants predicate, VariableNode oVar, SparqlResult variablesBindings, VariableDataSet graphs)
 {
     if (graphs.Any())
     {
         return
             (graphs.SelectMany(g =>
                                store.NamedGraphs.GetTriplesWithPredicateFromGraph(predicate, g, (s, o) =>
                                                                                   variablesBindings.Add(s, sVar, o, oVar, g, graphs.Variable))));
     }
     else
     {
         return(store.NamedGraphs.GetTriplesWithPredicate(predicate, (s, o, g) =>
                                                          variablesBindings.Add(s, sVar, o, oVar, g, graphs.Variable)));
     }
 }
Exemplo n.º 19
0
        private SparqlResult SetValues(SparqlResult result, QuadOVStruct quad)
        {
            if (this.Subject == null)
            {
                result.Add(quad.Subject, this.sVariableNode);
            }

            if (this.Predicate == null)
            {
                result.Add(quad.Predicate, this.pVariableNode);
            }

            if (this.Object == null)
            {
                result.Add(quad.Object, this.oVariableNode);
            }

            if (!this.isGKnown)
            {
                result.Add(quad.Graph, this.variableDataSet.Variable);
            }

            return(result);
        }
Exemplo n.º 20
0
        private IEnumerable <SparqlResult> OneRowResult(IEnumerable <SparqlResult> variableBindings, SparqlExpressionAsVariable[] asExpressions)
        {
            var oneRowResult = new SparqlResult(q);

            oneRowResult.SetSelection(asExpressions.Select(exprVar => exprVar.variableNode));
            foreach (var sparqlExpressionAsVariable in asExpressions)
            {
                oneRowResult.Add(sparqlExpressionAsVariable
                                 .RunExpressionCreateBind(new SparqlGroupOfResults(q)
                {
                    Group = variableBindings
                }),
                                 sparqlExpressionAsVariable.variableNode);
            }
            return(Enumerable.Range(0, 1).Select(i => oneRowResult));
        }
Exemplo n.º 21
0
        private IEnumerable <SparqlResult> SetVariablesValues(SparqlResult variableBinding, StoreCallCase @case)
        {
            switch (@case)
            {
            case StoreCallCase.spo:
                return(spo(Subject, Predicate, Object, variableBinding));

            case StoreCallCase.spO:
                return(q.Store.GetTriplesWithSubjectPredicate(Subject, Predicate).Select(o => variableBinding.Add(o, oVariableNode)));

            case StoreCallCase.sPo:
                return(q.Store.GetTriplesWithSubjectObject(Subject, Object).Select(p => variableBinding.Add(p, pVariableNode)));

            case StoreCallCase.sPO:
                return(q.Store.GetTriplesWithSubject(Subject).Select(t => SetValues(variableBinding, t)));

            case StoreCallCase.Spo:
                return(q.Store.GetSubjects(Predicate, Object).Select(s => variableBinding.Add(s, sVariableNode)));

            case StoreCallCase.SpO:
                return(q.Store.GetTriplesWithPredicate(Predicate).Select(t => SetValues(variableBinding, t)));

            case StoreCallCase.SPo:
                return(q.Store.GetTriplesWithObject(Object).Select(t => SetValues(variableBinding, t)));

            case StoreCallCase.SPO:
                return(q.Store.GetTriples((s, p, o) => variableBinding.Add(s, sVariableNode, p, pVariableNode, o, oVariableNode)));


            case StoreCallCase.gspo:
                return(spoGraphs(variableBinding));

            case StoreCallCase.gspO:
                return(graphs.SelectMany(graph =>
                                         q.Store.NamedGraphs
                                         .GetObject(Subject, Predicate, graph)

                                         .Select(o => variableBinding.Add(o, oVariableNode))));

            case StoreCallCase.gsPo:
                return(graphs.SelectMany(graph =>
                                         q.Store.NamedGraphs
                                         .GetPredicate(Subject, Object, graph)

                                         .Select(p => variableBinding.Add(p, pVariableNode))));

            case StoreCallCase.gsPO:
                return(graphs.SelectMany(g =>
                                         q.Store
                                         .NamedGraphs
                                         .GetTriplesWithSubjectFromGraph(Subject, g)

                                         .Select(quad => SetValues(variableBinding, quad))));

            case StoreCallCase.gSpo:
                return(graphs.SelectMany(graph =>
                                         q.Store.NamedGraphs
                                         .GetSubject(Predicate, Object, graph)

                                         .Select(s => variableBinding.Add(s, sVariableNode))));

            case StoreCallCase.gSpO:
                return(graphs.SelectMany(g =>
                                         q.Store
                                         .NamedGraphs
                                         .GetTriplesWithPredicateFromGraph(Predicate, g)

                                         .Select(quad => SetValues(variableBinding, quad))));

            case StoreCallCase.gSPo:
                return(graphs.SelectMany(g =>
                                         q.Store
                                         .NamedGraphs
                                         .GetTriplesWithObjectFromGraph(Object, g)

                                         .Select(quad => SetValues(variableBinding, quad))));

            case StoreCallCase.gSPO:
                return(graphs.SelectMany(g => q.Store.NamedGraphs.GetTriplesFromGraph(g, (s, p, o) => variableBinding.Add(s, sVariableNode, p, pVariableNode, o, oVariableNode))));

            case StoreCallCase.Gspo:
                return((variableDataSet.Any()
                        ? variableDataSet.Where(g => q.Store.NamedGraphs.Contains(Subject, Predicate, Object, g))
                        : q.Store.NamedGraphs.GetGraph(Subject, Predicate, Object))

                       .Select(g => variableBinding.Add(g, variableDataSet.Variable)));

            case StoreCallCase.GspO:
                if (variableDataSet.Any())
                {
                    return(variableDataSet.SelectMany(g => q.Store
                                                      .NamedGraphs
                                                      .GetObject(Subject, Predicate, g)

                                                      .Select(o => variableBinding.Add(o, oVariableNode, g, variableDataSet.Variable))));
                }
                else
                {
                    return(q.Store
                           .NamedGraphs
                           .GetTriplesWithSubjectPredicate(Subject, Predicate)

                           .Select(quad => SetValues(variableBinding, quad)));
                }

            // if graphVariable is null, ctor check this.
            case StoreCallCase.GsPo:
                if (variableDataSet.Any())
                {
                    return(variableDataSet.SelectMany(g =>
                                                      q.Store.NamedGraphs.GetPredicate(Subject, Object, g)

                                                      .Select(p => variableBinding.Add(p, pVariableNode, g, variableDataSet.Variable))));
                }
                else
                {
                    return(q.Store
                           .NamedGraphs
                           .GetTriplesWithSubjectObject(Subject, Object)

                           .Select(quad => SetValues(variableBinding, quad)));
                }

            case StoreCallCase.GsPO:
                if (variableDataSet.Any())
                {
                    return(variableDataSet.SelectMany(g => q.Store
                                                      .NamedGraphs
                                                      .GetTriplesWithSubjectFromGraph(Subject, g)

                                                      .Select(quad => SetValues(variableBinding, quad))));
                }
                else
                {
                    return(q.Store
                           .NamedGraphs
                           .GetTriplesWithSubject(Subject)

                           .Select(quad => SetValues(variableBinding, quad)));
                }

            case StoreCallCase.GSpo:
                if (variableDataSet.Any())
                {
                    return(variableDataSet.SelectMany(g => q.Store
                                                      .NamedGraphs
                                                      .GetSubject(Predicate, Object, g)

                                                      .Select(s => variableBinding.Add(s, sVariableNode, g, variableDataSet.Variable))));
                }
                else
                {
                    return(q.Store
                           .NamedGraphs
                           .GetTriplesWithPredicateObject(Predicate, Object)

                           .Select(quad => SetValues(variableBinding, quad)));
                }

            case StoreCallCase.GSpO:
                ObjectVariants predicate = Predicate;
                if (variableDataSet.Any())
                {
                    return
                        (variableDataSet.SelectMany(
                             g => q.Store.NamedGraphs.GetTriplesWithPredicateFromGraph(predicate, g)

                             .Select(quad => SetValues(variableBinding, quad))));
                }
                else
                {
                    return(q.Store.NamedGraphs.GetTriplesWithPredicate(predicate)

                           .Select(quad => SetValues(variableBinding, quad)));
                }

            case StoreCallCase.GSPo:
                if (variableDataSet.Any())
                {
                    return(variableDataSet.SelectMany(g => q.Store
                                                      .NamedGraphs
                                                      .GetTriplesWithObjectFromGraph(Object, g))

                           .Select(quad => SetValues(variableBinding, quad)));
                }
                return(q.Store
                       .NamedGraphs
                       .GetTriplesWithObject(Object)

                       .Select(quad => SetValues(variableBinding, quad)));

            case StoreCallCase.GSPO:
                if (variableDataSet.Any())
                {
                    return(variableDataSet.SelectMany(g =>
                                                      q.Store
                                                      .NamedGraphs
                                                      .GetTriplesFromGraph(g, (s, p, o) =>
                                                                           variableBinding.Add(s, sVariableNode, p, pVariableNode, o, oVariableNode, g,
                                                                                               variableDataSet.Variable))));
                }
                return(q.Store
                       .NamedGraphs
                       .GetAll((s, p, o, g) =>
                               variableBinding.Add(s, sVariableNode, p, pVariableNode, o, oVariableNode, g,
                                                   variableDataSet.Variable)));

            default:
                throw new ArgumentOutOfRangeException("case");
            }
        }
 public IEnumerable <SparqlResult> SpO(VariableNode sVar, ObjectVariants predicate, VariableNode oVar, SparqlResult variablesBindings)
 {
     return(store
            .GetTriplesWithPredicate(predicate).
            Select(t => variablesBindings.Add(t.Subject, sVar, t.Object, oVar)));
 }
 public IEnumerable <SparqlResult> Spo(VariableNode subj, ObjectVariants predicateNode, ObjectVariants objectNode, SparqlResult variablesBindings)
 {
     return(store
            .GetTriplesWithPredicateObject(predicateNode, objectNode)
            .Select(node => variablesBindings.Add(node, subj)));
 }
 public IEnumerable <SparqlResult> sPo(ObjectVariants subj, VariableNode pred, ObjectVariants obj, SparqlResult variablesBindings)
 {
     return(store
            .GetTriplesWithSubjectObject(subj, obj)
            .Select(newObj => variablesBindings.Add(newObj, pred)));
 }
 public IEnumerable <SparqlResult> SPo(VariableNode subj, VariableNode predicate, ObjectVariants obj, SparqlResult variablesBindings)
 {
     return(store
            .GetTriplesWithObject(obj, (s, p) =>
                                  variablesBindings.Add(p, predicate, s, subj)));
 }
 public IEnumerable <SparqlResult> SPO(VariableNode subj, VariableNode predicate, VariableNode obj, SparqlResult variablesBindings)
 {
     return(store
            .GetTriples((s, p, o)
                        => variablesBindings.Add(s, subj, p, predicate, o, obj)));
 }