--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/scala/SparqlToSparql.scala Sun Jan 31 12:02:27 2010 -0500
@@ -0,0 +1,24 @@
+/* SparqlToSparql: convert SPARQL queries to sound SQL queries.
+ *
+ * Please read from the bottom -- i.e. apply calls mapGraphPattern with the root
+ * graph pattern. mapGraphPattern handles all the graph pattern types in SPARQL,
+ * effectively peforming the Convert Graph Patterns step in SPARQL 1.0 12.2.1
+ * <http://www.w3.org/TR/rdf-sparql-query/#convertGraphPattern>
+ * with the target semantics in SQL instead of SPARQL.
+ */
+
+package w3c.sw.sparql2sparql
+
+import scala.util.parsing.combinator._
+import java.net.URI
+import w3c.sw.sql
+import w3c.sw.sql.PrettySql.toPrettySql
+import w3c.sw.sparql
+import w3c.sw.util
+
+object SparqlToSparql {
+ def apply (query:sparql.Select, constructs:List[sparql.Construct]) : sparql.Select = {
+ query
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/scala/SparqlToSparqlTest.scala Sun Jan 31 12:02:27 2010 -0500
@@ -0,0 +1,36 @@
+/* SparqlToSparqlTest: transform SPARQL to SQL and compare against a reference query.
+ * $Id$
+ */
+
+package w3c.sw
+
+import org.scalatest.FunSuite
+import java.net.URI
+import w3c.sw.sparql.Sparql
+import w3c.sw.sparql2sparql.{SparqlToSparql}
+
+/* The SparqlToSparqlTest class transforms SPARQL queries to a relational data
+ * structure and compares them to a structure parsed from SQL.
+ */
+class SparqlToSparqlTest extends FunSuite {
+
+ /* Disable turtle string-izing (SparqlToSparql parm 5) and return native format: */
+ test("cat") {
+ val sparqlParser = Sparql()
+ val query = sparqlParser.parseAll(sparqlParser.select, """
+PREFIX empP : <http://hr.example/DB/Employee#>
+SELECT ?emp {
+?emp empP:manager <http://hr.example/DB/Employee/empid.18#record>
+}
+""").get
+ val transformed = SparqlToSparql(query, List[sparql.Construct]())
+ val expected = sparqlParser.parseAll(sparqlParser.select, """
+PREFIX empP : <http://hr.example/DB/Employee#>
+SELECT ?emp {
+?emp empP:manager <http://hr.example/DB/Employee/empid.18#record>
+}
+""").get
+ assert(transformed === expected)
+ }
+
+}