예제 #1
0
        public void TestIsOrdered()
        {
            SparqlQuery query = new SparqlQuery(@"
                SELECT ?s0 ?p0 ?o0
                WHERE
                {
                    ?s0 ?p0 ?o0 .
                    {
                        SELECT DISTINCT ?s0
                        WHERE
                        {
                            ?s ?p ?o .
                            ?s @type @class .
                            {
                                ?s ?p1 ?o1 .
                                FILTER ISLITERAL(?o1) . FILTER REGEX(STR(?o1), '', 'i') .
                            }
                            UNION
                            {
                                ?s ?p1 ?s1 .
                                ?s1 ?p2 ?o2 .
                                FILTER ISLITERAL(?o2) . FILTER REGEX(STR(?o2), '', 'i') .
                            }
                        }
                        ORDER BY ?o
                    }
                }
            ");

            query.Bind("@type", rdf.type);
            query.Bind("@class", tmo.Task);

            Assert.IsTrue(string.IsNullOrEmpty(query.GetRootOrderByClause()));

            query = new SparqlQuery(@"
                SELECT ?s0 ?p0 ?o0
                WHERE
                {
                    ?s0 ?p0 ?o0 .
                    {
                        SELECT DISTINCT ?s0
                        WHERE
                        {
                            ?s ?p ?o .
                            ?s @type @class .
                            {
                                ?s ?p1 ?o1 .
                                FILTER ISLITERAL(?o1) . FILTER REGEX(STR(?o1), '', 'i') .
                            }
                            UNION
                            {
                                ?s ?p1 ?s1 .
                                ?s1 ?p2 ?o2 .
                                FILTER ISLITERAL(?o2) . FILTER REGEX(STR(?o2), '', 'i') .
                            }
                        }
                    }
                }
            ");

            query.Bind("@type", rdf.type);
            query.Bind("@class", tmo.Task);

            Assert.IsTrue(string.IsNullOrEmpty(query.GetRootOrderByClause()));

            query = new SparqlQuery(@"
                SELECT DISTINCT ?s0 FROM <http://semiodesk.com/id/8083cf10-5f90-40d4-b30a-c18fea31177b/>
                WHERE
                { 
                  ?s0 ?p0 ?o0 .
                  ?s0 a <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Visual> . 
                  ?s0 <http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#dateTime> ?o1 . 
                }
                ORDER BY ASC(?o1) LIMIT 50
            ");

            Assert.IsFalse(string.IsNullOrEmpty(query.GetRootOrderByClause()));
        }