--- a/directmapping/src/test/scala/DirectMappingTest.scala Fri Nov 26 17:32:04 2010 -0500
+++ b/directmapping/src/test/scala/DirectMappingTest.scala Fri Nov 26 18:38:33 2010 -0500
@@ -26,9 +26,9 @@
testDirectMapping("2 People 1 Addresses 1 Department", db_multi_key, directgraph_multi_key)
- testDirectMapping("2 People 1 Addresses 1 Department 2 Projects 1 Task", db_ref_no_pk, directmapping_ref_no_pk)
+ testDirectMapping("2 People 1 Addresses 1 Department 2 Projects 1 Task", db_ref_no_pk, directgraph_ref_no_pk)
- testDirectMapping("1 People 1 Addresses 1 Offices", db_hier_tabl_proto, directmapping_hier_tabl_proto)
+ testDirectMapping("1 People 1 Addresses 1 Offices", db_hier_tabl_proto, directgraph_hier_tabl_proto)
testDirectMapping("1 People 1 Addresses 1 Offices 1 ExectutiveOffices", db_hier_tabl, directgraph_hier_tabl)
--- a/sharedtestdata/src/main/scala/DirectMappingSpec.scala Fri Nov 26 17:32:04 2010 -0500
+++ b/sharedtestdata/src/main/scala/DirectMappingSpec.scala Fri Nov 26 18:38:33 2010 -0500
@@ -21,7 +21,7 @@
val directgraph_emp_adder = TurtleParser.toGraph("""
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
-<People/ID.7#_> <People#ID> "7"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<People/ID.7#_> <People#ID> 7 .
<People/ID.7#_> <People#fname> "Bob"^^<http://www.w3.org/2001/XMLSchema#string> .
<People/ID.7#_> <People#addr> <Addresses/ID.18#_> .
<People/ID.8#_> <People#ID> 8 .
@@ -32,7 +32,6 @@
""")
-
val db_multi_key = SqlParser.parseAll(SqlParser.ddl, """
CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
@@ -46,26 +45,28 @@
INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (8, "Sue", NULL, NULL, NULL);
""").get
- val directgraph_multi_key:Graph =
- Set(
- Triple(IRI("People/ID.7#_"),IRI("People#deptName"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#deptCity"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#deptName_deptCity"),IRI("Department/ID.23#_")),
+ val directgraph_multi_key = TurtleParser.toGraph("""
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+<People/ID.7#_> <People#deptName> "accounting"^^xsd:string .
+<People/ID.7#_> <People#deptCity> "Cambridge"^^xsd:string .
+<People/ID.7#_> <People#deptName_deptCity> <Department/ID.23#_> .
- Triple(IRI("Department/ID.23#_"),IRI("Department#ID"),TypedLiteral("23",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#name"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#manager"),IRI("People/ID.8#_")),
+<Department/ID.23#_> <Department#ID> 23 .
+<Department/ID.23#_> <Department#name> "accounting"^^xsd:string .
+<Department/ID.23#_> <Department#city> "Cambridge"^^xsd:string .
+<Department/ID.23#_> <Department#manager> <People/ID.8#_> .
- Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
- Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+<People/ID.7#_> <People#ID> 7 .
+<People/ID.7#_> <People#fname> "Bob"^^xsd:string .
+<People/ID.7#_> <People#addr> <Addresses/ID.18#_> .
+<People/ID.8#_> <People#ID> 8 .
+<People/ID.8#_> <People#fname> "Sue"^^xsd:string .
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string"))))
+<Addresses/ID.18#_> <Addresses#ID> 18 .
+<Addresses/ID.18#_> <Addresses#city> "Cambridge"^^xsd:string .
+<Addresses/ID.18#_> <Addresses#state> "MA"^^xsd:string .
+""")
+
val db_ref_no_pk = SqlParser.parseAll(SqlParser.ddl, """
CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
@@ -98,46 +99,47 @@
INSERT INTO TaskAssignments (worker, project, deptName, deptCity) VALUES (7, "pencil survey", "accounting", "Cambridge");
""").get
- val directmapping_ref_no_pk =
- Set(
- Triple(BNode("a"), IRI("Projects#lead"), IRI("People/ID.8#_")),
- Triple(BNode("a"), IRI("Projects#name"), TypedLiteral("pencil survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("a"), IRI("Projects#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("a"), IRI("Projects#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("a"), IRI("Projects#deptName_deptCity"), IRI("Department/ID.23#_")),
-
- Triple(BNode("b"), IRI("Projects#lead"), IRI("People/ID.8#_")),
- Triple(BNode("b"), IRI("Projects#name"), TypedLiteral("eraser survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("b"), IRI("Projects#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("b"), IRI("Projects#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("b"), IRI("Projects#deptName_deptCity"), IRI("Department/ID.23#_")),
+ val directgraph_ref_no_pk = TurtleParser.toGraph("""
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+_:a <Projects#lead> <People/ID.8#_> .
+_:a <Projects#name> "pencil survey"^^xsd:string .
+_:a <Projects#deptName> "accounting"^^xsd:string .
+_:a <Projects#deptCity> "Cambridge"^^xsd:string .
+_:a <Projects#deptName_deptCity> <Department/ID.23#_> .
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#worker"), IRI("People/ID.7#_")),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#project"), TypedLiteral("pencil survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptName_deptCity"), IRI("Department/ID.23#_")),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#project_deptName_deptCity"), BNode("a")),
-
- Triple(IRI("People/ID.7#_"),IRI("People#deptName"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#deptCity"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#deptName_deptCity"),IRI("Department/ID.23#_")),
+_:b <Projects#lead> <People/ID.8#_> .
+_:b <Projects#name> "eraser survey"^^xsd:string .
+_:b <Projects#deptName> "accounting"^^xsd:string .
+_:b <Projects#deptCity> "Cambridge"^^xsd:string .
+_:b <Projects#deptName_deptCity> <Department/ID.23#_> .
- Triple(IRI("Department/ID.23#_"),IRI("Department#ID"),TypedLiteral("23",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#name"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#manager"),IRI("People/ID.8#_")),
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#worker> <People/ID.7#_> .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#project> "pencil survey"^^xsd:string .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#deptName> "accounting"^^xsd:string .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#deptCity> "Cambridge"^^xsd:string .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#deptName_deptCity> <Department/ID.23#_> .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#project_deptName_deptCity> _:a .
- Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
- Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+<People/ID.7#_> <People#deptName> "accounting"^^xsd:string .
+<People/ID.7#_> <People#deptCity> "Cambridge"^^xsd:string .
+<People/ID.7#_> <People#deptName_deptCity> <Department/ID.23#_> .
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
- )
+<Department/ID.23#_> <Department#ID> 23 .
+<Department/ID.23#_> <Department#name> "accounting"^^xsd:string .
+<Department/ID.23#_> <Department#city> "Cambridge"^^xsd:string .
+<Department/ID.23#_> <Department#manager> <People/ID.8#_> .
+
+<People/ID.7#_> <People#ID> 7 .
+<People/ID.7#_> <People#fname> "Bob"^^xsd:string .
+<People/ID.7#_> <People#addr> <Addresses/ID.18#_> .
+<People/ID.8#_> <People#ID> 8 .
+<People/ID.8#_> <People#fname> "Sue"^^xsd:string .
+
+<Addresses/ID.18#_> <Addresses#ID> 18 .
+<Addresses/ID.18#_> <Addresses#city> "Cambridge"^^xsd:string .
+<Addresses/ID.18#_> <Addresses#state> "MA"^^xsd:string .
+""")
+
val db_hier_tabl_proto = SqlParser.parseAll(SqlParser.ddl, """
CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
@@ -151,20 +153,21 @@
INSERT INTO Offices (ID, building, ofcNumber) VALUES (18, 32, "G528");
""").get
- val directmapping_hier_tabl_proto:Graph =
- Set(
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#building"),TypedLiteral("32",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ofcNumber"),TypedLiteral("G528",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ val directgraph_hier_tabl_proto = TurtleParser.toGraph("""
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+<Addresses/ID.18#_> <Offices#ID> 18 .
+<Addresses/ID.18#_> <Offices#building> 32 .
+<Addresses/ID.18#_> <Offices#ofcNumber> "G528"^^xsd:string .
- Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+<People/ID.7#_> <People#ID> 7 .
+<People/ID.7#_> <People#fname> "Bob"^^xsd:string .
+<People/ID.7#_> <People#addr> <Addresses/ID.18#_> .
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
- )
+<Addresses/ID.18#_> <Addresses#ID> 18 .
+<Addresses/ID.18#_> <Addresses#city> "Cambridge"^^xsd:string .
+<Addresses/ID.18#_> <Addresses#state> "MA"^^xsd:string .
+""")
+
val db_hier_tabl = SqlParser.parseAll(SqlParser.ddl, """
CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
@@ -182,22 +185,22 @@
INSERT INTO ExecutiveOffices (ID, desk) VALUES (18, "oak");
""").get
- val directgraph_hier_tabl:Graph =
- Set(
- Triple(IRI("Addresses/ID.18#_"),IRI("ExecutiveOffices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("ExecutiveOffices#desk"),TypedLiteral("oak",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ val directgraph_hier_tabl = TurtleParser.toGraph("""
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+<Addresses/ID.18#_> <ExecutiveOffices#ID> 18 .
+<Addresses/ID.18#_> <ExecutiveOffices#desk> "oak"^^xsd:string .
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#building"),TypedLiteral("32",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ofcNumber"),TypedLiteral("G528",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+<Addresses/ID.18#_> <Offices#ID> 18 .
+<Addresses/ID.18#_> <Offices#building> 32 .
+<Addresses/ID.18#_> <Offices#ofcNumber> "G528"^^xsd:string .
- Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+<People/ID.7#_> <People#ID> 7 .
+<People/ID.7#_> <People#fname> "Bob"^^xsd:string .
+<People/ID.7#_> <People#addr> <Addresses/ID.18#_> .
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
- )
+<Addresses/ID.18#_> <Addresses#ID> 18 .
+<Addresses/ID.18#_> <Addresses#city> "Cambridge"^^xsd:string .
+<Addresses/ID.18#_> <Addresses#state> "MA"^^xsd:string .
+""")
}
--- a/sparql/src/main/scala/SPARQL.scala Fri Nov 26 17:32:04 2010 -0500
+++ b/sparql/src/main/scala/SPARQL.scala Fri Nov 26 18:38:33 2010 -0500
@@ -6,7 +6,7 @@
object MyParsers extends RegexParsers {
- val uri = """[a-zA-Z0-9:/#_\.\-]+""".r
+ val uri = """[a-zA-Z0-9:/#_\.\-\+]+""".r
val integer = """[0-9]+""".r
val name = """[a-zA-Z][a-zA-Z0-9_-]*|[a-zA-Z_][a-zA-Z0-9_]+""".r
var prefixes:Map[String, String] = Map()
--- a/turtle/src/main/scala/turtle.scala Fri Nov 26 17:32:04 2010 -0500
+++ b/turtle/src/main/scala/turtle.scala Fri Nov 26 18:38:33 2010 -0500
@@ -6,7 +6,7 @@
object MyParsers extends RegexParsers {
- val uri = """[a-zA-Z0-9:/#_\.\-]+""".r
+ val uri = """[a-zA-Z0-9:/#_\.\-\+]+""".r
val integer = """[0-9]+""".r
val name = """[a-zA-Z][a-zA-Z0-9_-]*|[a-zA-Z_][a-zA-Z0-9_]+""".r
var prefixes:Map[String, String] = Map()
--- a/turtle/src/test/scala/turtleTest.scala Fri Nov 26 17:32:04 2010 -0500
+++ b/turtle/src/test/scala/turtleTest.scala Fri Nov 26 18:38:33 2010 -0500
@@ -6,8 +6,9 @@
class TurtleTest extends FunSuite {
- test("parse 1") {
+ val turtleParser = Turtle()
+ test("directgraph_emp_adder") {
val directgraph_emp_adder:Graph =
Set(
Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
@@ -32,11 +33,210 @@
<Addresses/ID.18#_> <Addresses#city> "Cambridge"^^xsd:string .
<Addresses/ID.18#_> <Addresses#state> "MA"^^xsd:string .
"""
+ assert(directgraph_emp_adder === turtleParser.toGraph(turtle_emp_adder))
+ }
- val turtleParser = Turtle()
+ test("directgraph_multi_key") {
+ val directgraph_multi_key:Graph =
+ Set(
+ Triple(IRI("People/ID.7#_"),IRI("People#deptName"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#deptCity"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#deptName_deptCity"),IRI("Department/ID.23#_")),
- assert(directgraph_emp_adder === turtleParser.parseAll(turtleParser.turtle, turtle_emp_adder).get)
+ Triple(IRI("Department/ID.23#_"),IRI("Department#ID"),TypedLiteral("23",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#name"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#manager"),IRI("People/ID.8#_")),
+ Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+ Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string"))))
+
+ val turtle_multi_key:String = """
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+<People/ID.7#_> <People#deptName> "accounting"^^xsd:string .
+<People/ID.7#_> <People#deptCity> "Cambridge"^^xsd:string .
+<People/ID.7#_> <People#deptName_deptCity> <Department/ID.23#_> .
+
+<Department/ID.23#_> <Department#ID> "23"^^xsd:integer .
+<Department/ID.23#_> <Department#name> "accounting"^^xsd:string .
+<Department/ID.23#_> <Department#city> "Cambridge"^^xsd:string .
+<Department/ID.23#_> <Department#manager> <People/ID.8#_> .
+
+<People/ID.7#_> <People#ID> "7"^^xsd:integer .
+<People/ID.7#_> <People#fname> "Bob"^^xsd:string .
+<People/ID.7#_> <People#addr> <Addresses/ID.18#_> .
+<People/ID.8#_> <People#ID> "8"^^xsd:integer .
+<People/ID.8#_> <People#fname> "Sue"^^xsd:string .
+
+<Addresses/ID.18#_> <Addresses#ID> "18"^^xsd:integer .
+<Addresses/ID.18#_> <Addresses#city> "Cambridge"^^xsd:string .
+<Addresses/ID.18#_> <Addresses#state> "MA"^^xsd:string .
+"""
+ assert(directgraph_multi_key === turtleParser.toGraph(turtle_multi_key))
+ }
+
+ test("directgraph_ref_no_pk") {
+ val directgraph_ref_no_pk:Graph =
+ Set(
+ Triple(BNode("a"), IRI("Projects#lead"), IRI("People/ID.8#_")),
+ Triple(BNode("a"), IRI("Projects#name"), TypedLiteral("pencil survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("a"), IRI("Projects#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("a"), IRI("Projects#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("a"), IRI("Projects#deptName_deptCity"), IRI("Department/ID.23#_")),
+
+ Triple(BNode("b"), IRI("Projects#lead"), IRI("People/ID.8#_")),
+ Triple(BNode("b"), IRI("Projects#name"), TypedLiteral("eraser survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("b"), IRI("Projects#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("b"), IRI("Projects#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("b"), IRI("Projects#deptName_deptCity"), IRI("Department/ID.23#_")),
+
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#worker"), IRI("People/ID.7#_")),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#project"), TypedLiteral("pencil survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptName_deptCity"), IRI("Department/ID.23#_")),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#project_deptName_deptCity"), BNode("a")),
+
+ Triple(IRI("People/ID.7#_"),IRI("People#deptName"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#deptCity"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#deptName_deptCity"),IRI("Department/ID.23#_")),
+
+ Triple(IRI("Department/ID.23#_"),IRI("Department#ID"),TypedLiteral("23",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#name"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#manager"),IRI("People/ID.8#_")),
+
+ Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+ Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
+ )
+
+ val turtle_ref_no_pk:String = """
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+_:a <Projects#lead> <People/ID.8#_> .
+_:a <Projects#name> "pencil survey"^^xsd:string .
+_:a <Projects#deptName> "accounting"^^xsd:string .
+_:a <Projects#deptCity> "Cambridge"^^xsd:string .
+_:a <Projects#deptName_deptCity> <Department/ID.23#_> .
+
+_:b <Projects#lead> <People/ID.8#_> .
+_:b <Projects#name> "eraser survey"^^xsd:string .
+_:b <Projects#deptName> "accounting"^^xsd:string .
+_:b <Projects#deptCity> "Cambridge"^^xsd:string .
+_:b <Projects#deptName_deptCity> <Department/ID.23#_> .
+
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#worker> <People/ID.7#_> .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#project> "pencil survey"^^xsd:string .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#deptName> "accounting"^^xsd:string .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#deptCity> "Cambridge"^^xsd:string .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#deptName_deptCity> <Department/ID.23#_> .
+<TaskAssignments/worker.7_project.pencil+survey#_> <TaskAssignments#project_deptName_deptCity> _:a .
+
+<People/ID.7#_> <People#deptName> "accounting"^^xsd:string .
+<People/ID.7#_> <People#deptCity> "Cambridge"^^xsd:string .
+<People/ID.7#_> <People#deptName_deptCity> <Department/ID.23#_> .
+
+<Department/ID.23#_> <Department#ID> "23"^^xsd:integer .
+<Department/ID.23#_> <Department#name> "accounting"^^xsd:string .
+<Department/ID.23#_> <Department#city> "Cambridge"^^xsd:string .
+<Department/ID.23#_> <Department#manager> <People/ID.8#_> .
+
+<People/ID.7#_> <People#ID> "7"^^xsd:integer .
+<People/ID.7#_> <People#fname> "Bob"^^xsd:string .
+<People/ID.7#_> <People#addr> <Addresses/ID.18#_> .
+<People/ID.8#_> <People#ID> "8"^^xsd:integer .
+<People/ID.8#_> <People#fname> "Sue"^^xsd:string .
+
+<Addresses/ID.18#_> <Addresses#ID> "18"^^xsd:integer .
+<Addresses/ID.18#_> <Addresses#city> "Cambridge"^^xsd:string .
+<Addresses/ID.18#_> <Addresses#state> "MA"^^xsd:string .
+"""
+ assert(directgraph_ref_no_pk === turtleParser.toGraph(turtle_ref_no_pk))
+ }
+
+ test("directgraph_hier_tabl_proto") {
+ val directgraph_hier_tabl_proto:Graph =
+ Set(
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#building"),TypedLiteral("32",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ofcNumber"),TypedLiteral("G528",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
+ )
+ val turtle_hier_tabl_proto:String = """
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+<Addresses/ID.18#_> <Offices#ID> "18"^^xsd:integer .
+<Addresses/ID.18#_> <Offices#building> "32"^^xsd:integer .
+<Addresses/ID.18#_> <Offices#ofcNumber> "G528"^^xsd:string .
+
+<People/ID.7#_> <People#ID> "7"^^xsd:integer .
+<People/ID.7#_> <People#fname> "Bob"^^xsd:string .
+<People/ID.7#_> <People#addr> <Addresses/ID.18#_> .
+
+<Addresses/ID.18#_> <Addresses#ID> "18"^^xsd:integer .
+<Addresses/ID.18#_> <Addresses#city> "Cambridge"^^xsd:string .
+<Addresses/ID.18#_> <Addresses#state> "MA"^^xsd:string .
+"""
+ assert(directgraph_hier_tabl_proto === turtleParser.toGraph(turtle_hier_tabl_proto))
+ }
+
+ test("directgraph_hier_tabl") {
+ val directgraph_hier_tabl:Graph =
+ Set(
+ Triple(IRI("Addresses/ID.18#_"),IRI("ExecutiveOffices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("ExecutiveOffices#desk"),TypedLiteral("oak",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#building"),TypedLiteral("32",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ofcNumber"),TypedLiteral("G528",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#integer"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
+ )
+
+ val turtle_hier_tabl:String = """
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+<Addresses/ID.18#_> <ExecutiveOffices#ID> "18"^^xsd:integer .
+<Addresses/ID.18#_> <ExecutiveOffices#desk> "oak"^^xsd:string .
+
+<Addresses/ID.18#_> <Offices#ID> "18"^^xsd:integer .
+<Addresses/ID.18#_> <Offices#building> "32"^^xsd:integer .
+<Addresses/ID.18#_> <Offices#ofcNumber> "G528"^^xsd:string .
+
+<People/ID.7#_> <People#ID> "7"^^xsd:integer .
+<People/ID.7#_> <People#fname> "Bob"^^xsd:string .
+<People/ID.7#_> <People#addr> <Addresses/ID.18#_> .
+
+<Addresses/ID.18#_> <Addresses#ID> "18"^^xsd:integer .
+<Addresses/ID.18#_> <Addresses#city> "Cambridge"^^xsd:string .
+<Addresses/ID.18#_> <Addresses#state> "MA"^^xsd:string .
+"""
+ assert(directgraph_hier_tabl === turtleParser.toGraph(turtle_hier_tabl))
}
}
+