/// <summary> /// Converts the Algebra back to a SPARQL Query. /// </summary> /// <returns></returns> public SparqlQuery ToQuery() { SparqlQuery q = _pattern.ToQuery(); q.Limit = _limit; q.Offset = _offset; return(q); }
/// <summary> /// Converts the Algebra back to a SPARQL Query. /// </summary> /// <returns></returns> public SparqlQuery ToQuery() { SparqlQuery q = _pattern.ToQuery(); if (_having != null) { q.Having = _having; } return(q); }
/// <summary> /// Converts the Algebra back to a SPARQL Query. /// </summary> /// <returns></returns> public SparqlQuery ToQuery() { SparqlQuery q = _pattern.ToQuery(); if (_ordering != null) { q.OrderBy = _ordering; } return(q); }
/// <summary> /// Converts the Algebra back to a SPARQL Query /// </summary> /// <returns></returns> public SparqlQuery ToQuery() { SparqlQuery q = _pattern.ToQuery(); foreach (SparqlVariable var in _variables) { q.AddVariable(var); } if (_variables.All(v => v.IsResultVariable)) { q.QueryType = SparqlQueryType.SelectAll; } else { q.QueryType = SparqlQueryType.Select; } return(q); }
private void TestSubstitution(SparqlQuery q, String findVar, INode replaceTerm, IEnumerable <String> expected, IEnumerable <String> notExpected) { Console.WriteLine("Input Query:"); Console.WriteLine(this._formatter.Format(q)); Console.WriteLine(); ISparqlAlgebra algebra = q.ToAlgebra(); VariableSubstitutionTransformer transformer = new VariableSubstitutionTransformer(findVar, replaceTerm); try { ISparqlAlgebra resAlgebra = transformer.Optimise(algebra); algebra = resAlgebra; } catch (Exception ex) { //Ignore errors Console.WriteLine("Error Transforming - " + ex.Message); Console.WriteLine(ex.StackTrace); Console.WriteLine(); } SparqlQuery resQuery = algebra.ToQuery(); String resText = this._formatter.Format(resQuery); Console.WriteLine("Resulting Query:"); Console.WriteLine(resText); Console.WriteLine(); foreach (String x in expected) { Assert.IsTrue(resText.Contains(x), "Expected Transformed Query to contain string '" + x + "'"); } foreach (String x in notExpected) { Assert.IsFalse(resText.Contains(x), "Transformed Query contained string '" + x + "' which was not expected"); } }