public static Func <IEnumerable <Action> > spo(PolarTripleStore store, SparqlNode s, SparqlNode p, SparqlNode o)
 {
     return(() => store.Contains(new Triple(s.Value, p.Value, o.Value)) ? new Action[] { (() =>
         {
             Console.WriteLine("sdf");
         }) } : Enumerable.Empty <Action>());
 }
Пример #2
0
 public override void CreateNodes(PolarTripleStore store)
 {
     foreach (var alternative in alternatives)
     {
         alternative.CreateNodes(store);
         sparqlResultSet.ResetDiapason(startVariable, alternative.endIndexVariable);
     }
 }
 internal static Func <IEnumerable <Action> > sPO(PolarTripleStore store, SparqlNode sEntityCode, VariableNode pParameter, VariableNode oParameter)
 {
     return(() => store
            .GetTriplesWithSubject(sEntityCode.Value)
            .Select(triple => new Action(() =>
     {
         pParameter.Value = triple.Predicate;
         oParameter.Value = triple.Object;
     })));
 }
 internal static Func <IEnumerable <Action> > sPo(PolarTripleStore store, SparqlNode sEntityCode, VariableNode predicateVariableNode, SparqlNode oEntityCode)
 {
     return(() => store
            .GetTriplesWithSubjectObject(sEntityCode.Value, oEntityCode.Value)
            .Select(triple => triple.Predicate)
            .Select(predicate => new Action(() =>
     {
         predicateVariableNode.Value = predicate;
     })));
 }
 internal static Func <IEnumerable <Action> > Spo(PolarTripleStore store, VariableNode subj, SparqlNode pEntityCode, SparqlNode oEntityCode)
 {
     return(() => store
            .GetTriplesWithPredicateObject(pEntityCode.Value, oEntityCode.Value)
            .Select(triple => triple.Subject)
            .Select(sub => new Action(() =>
     {
         subj.Value = sub;
     })));
 }
 internal static Func <IEnumerable <Action> > spO(PolarTripleStore store, SparqlNode subjNode, SparqlNode pEntityCode, VariableNode obj)
 {
     return(() => store
            .GetTriplesWithSubjectPredicate(subjNode.Value, pEntityCode.Value)
            .Select(triple => triple.Object)
            .Select(newObj => new Action(() =>
     {
         obj.Value = newObj;
     })));
 }
Пример #7
0
 public virtual void CreateNodes(PolarTripleStore store)
 {
     if (graphUri != null)
     {
         graphUri.CreateNode(store);
     }
     foreach (var sparqlWhereItem in Triples)
     {
         sparqlWhereItem.CreateNodes(store);
     }
 }
Пример #8
0
 internal override void CreateNode(PolarTripleStore store)
 {
     base.CreateNode(store);
 }
Пример #9
0
 internal override void CreateNode(PolarTripleStore store)
 {
     Value = store.GetUriNode(Uri);
 }
Пример #10
0
 internal override void CreateNode(PolarTripleStore store)
 {
     Value = store.GetLiteralNode(type == null ? null :type.Uri, Content, lang);
 }
Пример #11
0
        public void CreateNodes(PolarTripleStore store)
        {
            Subj.CreateNode(store);
            Pred.CreateNode(store);
            Obj.CreateNode(store);
            Graph.CreateNode(store);
            //   GraphIsDataProperty.Sync(o.graph, p.graph);
            VariableNode sVariableNode = this.Subj as VariableNode;
            VariableNode pVariableNode = this.Pred as VariableNode;
            VariableNode oVariableNode = this.Obj as VariableNode;

            if (sVariableNode != null && sVariableNode.isNew)
            {
                sVariableNode.isNew = false;
                if (pVariableNode != null && pVariableNode.isNew)
                {
                    pVariableNode.isNew = false;
                    if (oVariableNode != null && oVariableNode.isNew)
                    {
                        oVariableNode.isNew          = false;
                        SelectVariableValuesOrFilter = RPackComplexExtensionInt.SPO(store, sVariableNode, pVariableNode, oVariableNode, Graph);
                    }
                    else
                    {
                        SelectVariableValuesOrFilter = RPackComplexExtensionInt.SPo(store, sVariableNode, pVariableNode, this.Obj);
                    }
                }
                else
                {
                    if (oVariableNode != null && oVariableNode.isNew)
                    {
                        SelectVariableValuesOrFilter = RPackComplexExtensionInt.SpO(store, sVariableNode, this.Pred, oVariableNode);
                    }
                    else
                    {
                        SelectVariableValuesOrFilter = RPackComplexExtensionInt.Spo(store, sVariableNode, this.Pred, this.Obj);
                    }
                }
            }
            else
            {
                if (pVariableNode != null && pVariableNode.isNew)
                {
                    pVariableNode.isNew = false;
                    if (oVariableNode != null && oVariableNode.isNew)
                    {
                        SelectVariableValuesOrFilter = RPackComplexExtensionInt.sPO(store, this.Subj, pVariableNode, oVariableNode);
                        oVariableNode.isNew          = false;
                    }
                    else
                    {
                        SelectVariableValuesOrFilter = RPackComplexExtensionInt.sPo(store, this.Subj, pVariableNode, this.Obj);
                    }
                }
                else
                {
                    if (oVariableNode != null && oVariableNode.isNew)
                    {
                        SelectVariableValuesOrFilter = RPackComplexExtensionInt.spO(store, this.Subj, this.Pred, oVariableNode);
                        oVariableNode.isNew          = false;
                    }
                    else
                    {
                        SelectVariableValuesOrFilter = RPackComplexExtensionInt.spo(store, this.Subj, this.Pred, this.Obj);
                    }
                }
            }
        }
Пример #12
0
 internal virtual void CreateNode(PolarTripleStore store)
 {
     throw new NotImplementedException();
 }
Пример #13
0
        public SparqlResultSet Run(PolarTripleStore store)
        {
            ResultSet.Store = store;
            SparqlWhere.CreateNodes(store);

            foreach (SparqlNode filterConstant in FilterConstants)
            {
                filterConstant.CreateNode(store);
            }
            SparqlWhere.Run(ResultSet);


            switch (ResultSet.ResultType)
            {
            case ResultType.Describe:
                ResultSet.GraphResult = store.CreateGraph();
                var variablesIndexes = variables.Select(s => ResultSet.Variables[s].index).ToArray();
                foreach (var result in ResultSet.Results)
                {
                    foreach (var variableIndex in variablesIndexes)
                    {
                        foreach (var triple in store.GetTriplesWithSubject(result[variableIndex]))
                        {
                            ResultSet.GraphResult.Assert(triple);
                        }
                        foreach (var triple in store.GetTriplesWithObject(result[variableIndex]))
                        {
                            ResultSet.GraphResult.Assert(triple);
                        }
                    }
                }
                ResultSet.GraphResult.Build();
                break;

            case ResultType.Select:
                foreach (var func in ListSolutionModifiersOrder)
                {
                    ResultSet.Results = new List <SparqlResult>(func(ResultSet.Results));
                }

                if (!all)
                {
                    ResultSet = new SparqlResultSet(ResultSet, variables);
                }
                ResultSet.DistinctReduse(isDistinct, isReduce);
                foreach (var func in ListSolutionModifiersCount)
                {
                    ResultSet.Results = new List <SparqlResult>(func(ResultSet.Results));
                }
                break;

            case ResultType.Construct:
                ResultSet.GraphResult = store.CreateGraph();
                foreach (var result in ResultSet.Results)
                {
                    Func <SparqlNode, INode> GetValueNode = node =>
                    {
                        if (node is VariableNode)
                        {
                            return(result[(node as VariableNode).index]);
                        }
                        SparqlUriNode uriNode = node as SparqlUriNode;
                        if (uriNode != null)
                        {
                            return(store.GetUriNode(uriNode.Uri) ??
                                   ResultSet.GraphResult.CreateUriNode(uriNode.Uri));
                        }
                        SparqlLiteralNode literlNode = node as SparqlLiteralNode;
                        if (literlNode != null)
                        {
                            return(store.GetLiteralNode(literlNode.type.Uri, literlNode.Content, literlNode.lang) ??
                                   (literlNode.lang != null
                                           ? ResultSet.GraphResult.CreateLiteralNode(literlNode.Content.ToString(),
                                                                                     literlNode.lang)
                                           : ResultSet.GraphResult.CreateLiteralNode(literlNode.Content.ToString(),
                                                                                     literlNode.type.Uri)));
                        }
                        throw new NotImplementedException();
                    };
                    foreach (var sparqlTriplet in Construct.Triples.Cast <SparqlTriple>())
                    {
                        ResultSet.GraphResult.Assert(new Triple(GetValueNode(sparqlTriplet.Subj),
                                                                GetValueNode(sparqlTriplet.Pred),
                                                                GetValueNode(sparqlTriplet.Obj)));
                    }
                }
                ResultSet.GraphResult.Build();
                break;

            case ResultType.Ask:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(ResultSet);
        }
Пример #14
0
 public void CreateNodes(PolarTripleStore store)
 {
     SelectVariableValuesOrFilter = () => Filter(resultSet.VariablesValues) ? Enumerable.Repeat <Action>(() => { }, 1) : Enumerable.Empty <Action>();
 }
 internal static Func <IEnumerable <Action> > SpO(PolarTripleStore store, VariableNode s, SparqlNode pEntityCode, VariableNode o)
 {
     throw new NotImplementedException();
 }
 internal static Func <IEnumerable <Action> > SPO(PolarTripleStore store, VariableNode sParameter, VariableNode pParameter, VariableNode oParameter, SparqlNode graph)
 {
     throw new NotImplementedException();
 }