--- a/src/test/scala/RDB2RDFTest.scala Thu Jan 07 20:48:44 2010 -0500
+++ b/src/test/scala/RDB2RDFTest.scala Thu Jan 07 23:31:54 2010 -0500
@@ -12,16 +12,6 @@
val db:DatabaseDesc = DatabaseDesc(
Map(Relation("Employee") ->
- RelationDesc(Option(Attribute("id")),
- Map(Attribute("id") -> Value(Datatype.INTEGER),
- Attribute("lastName") -> Value(Datatype.STRING),
- Attribute("birthday") -> Value(Datatype.DATE),
- Attribute("manager") -> ForeignKey(Relation("Employee"), Attribute("id")),
- Attribute("address") -> ForeignKey(Relation("Address"), Attribute("id"))))
- ))
-
- val db2:DatabaseDesc = DatabaseDesc(
- Map(Relation("Employee") ->
RelationDesc(Option(Attribute("empid")),
Map(Attribute("empid") -> Value(Datatype.INTEGER),
Attribute("lastName") -> Value(Datatype.STRING),
@@ -44,15 +34,15 @@
val sparqlSelect = sparqlParser.parseAll(sparqlParser.select, """
PREFIX empP : <http://hr.example/DB/Employee#>
SELECT ?emp {
-?emp empP:manager <http://hr.example/DB/Employee/id.18#record>
+?emp empP:manager <http://hr.example/DB/Employee/empid.18#record>
}
""").get
val sqlParser = Sql()
val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_emp.id AS A_emp
+SELECT R_emp.empid AS A_emp
FROM Employee AS R_emp
- INNER JOIN Employee AS R_id18
- WHERE R_id18.id=R_emp.manager AND R_id18.id=18 AND R_emp.id IS NOT NULL
+ INNER JOIN Employee AS R_empid18
+ WHERE R_empid18.empid=R_emp.manager AND R_empid18.empid=18 AND R_emp.empid IS NOT NULL
""").get
val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
@@ -63,16 +53,16 @@
val sparqlSelect = sparqlParser.parseAll(sparqlParser.select, """
PREFIX empP : <http://hr.example/DB/Employee#>
SELECT ?emp {
-?emp empP:manager <http://hr.example/DB/Employee/id.18#record>
+?emp empP:manager <http://hr.example/DB/Employee/empid.18#record>
}
""").get
val sqlParser = Sql()
val StemUrlString = "\"http://hr.example/DB/\""
val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT CONCAT(""" + StemUrlString + """, "Employee", "/", "id", ".", R_emp.id, "#record") AS A_emp
+SELECT CONCAT(""" + StemUrlString + """, "Employee", "/", "empid", ".", R_emp.empid, "#record") AS A_emp
FROM Employee AS R_emp
- INNER JOIN Employee AS R_id18
- WHERE R_id18.id=R_emp.manager AND R_id18.id=18 AND R_emp.id IS NOT NULL
+ INNER JOIN Employee AS R_empid18
+ WHERE R_empid18.empid=R_emp.manager AND R_empid18.empid=18 AND R_emp.empid IS NOT NULL
""").get
val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, true)
assert(generated === parsed)
@@ -92,7 +82,7 @@
val parsed = sqlParser.parseAll(sqlParser.select, """
SELECT CONCAT("\"", R_emp.lastName, "\"^^<http://www.w3.org/2001/XMLSchema#string>") AS A_name
FROM Employee AS R_emp
- WHERE R_emp.id IS NOT NULL AND R_emp.lastName IS NOT NULL
+ WHERE R_emp.empid IS NOT NULL AND R_emp.lastName IS NOT NULL
""").get
val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, true)
assert(generated === parsed)
@@ -104,15 +94,15 @@
val sparqlSelect = sparqlParser.parseAll(sparqlParser.select, """
PREFIX empP : <http://hr.example/DB/Employee#>
SELECT ?manager {
-<http://hr.example/DB/Employee/id.18#record> empP:manager ?manager
+<http://hr.example/DB/Employee/empid.18#record> empP:manager ?manager
}
""").get
val sqlParser = Sql()
val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_manager.id AS A_manager
- FROM Employee AS R_id18
+SELECT R_manager.empid AS A_manager
+ FROM Employee AS R_empid18
INNER JOIN Employee AS R_manager
- WHERE R_manager.id=R_id18.manager AND R_id18.id=18 AND R_manager.id IS NOT NULL
+ WHERE R_manager.empid=R_empid18.manager AND R_empid18.empid=18 AND R_manager.empid IS NOT NULL
""").get
val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
@@ -132,10 +122,10 @@
""").get
val sqlParser = Sql()
val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_emp.id AS A_emp
+SELECT R_emp.empid AS A_emp
FROM Employee AS R_emp
INNER JOIN Employee AS R_18
- WHERE R_18.id=R_emp.manager AND R_18.id=18 AND R_emp.id IS NOT NULL
+ WHERE R_18.empid=R_emp.manager AND R_18.empid=18 AND R_emp.empid IS NOT NULL
""").get
val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
@@ -153,10 +143,10 @@
""").get
val sqlParser = Sql()
val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_emp1.id AS A_emp1, R_emp2.id AS A_emp2, R_emp1.lastName AS A_sharedName
+SELECT R_emp1.empid AS A_emp1, R_emp2.empid AS A_emp2, R_emp1.lastName AS A_sharedName
FROM Employee AS R_emp1
INNER JOIN Employee AS R_emp2 ON R_emp2.lastName=R_emp1.lastName
- WHERE R_emp1.id IS NOT NULL AND R_emp1.lastName IS NOT NULL AND R_emp2.id IS NOT NULL
+ WHERE R_emp1.empid IS NOT NULL AND R_emp1.lastName IS NOT NULL AND R_emp2.empid IS NOT NULL
""").get
val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
@@ -181,7 +171,7 @@
WHERE R_emp .lastName IS NOT NULL AND R_emp .empid IS NOT NULL
AND R_manager.lastName IS NOT NULL AND R_manager.empid IS NOT NULL
""").get
- val generated = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
}
@@ -191,7 +181,7 @@
PREFIX empP : <http://hr.example/DB/Employee#>
SELECT ?empName {
?emp empP:lastName ?empName .
- ?emp empP:manager <http://hr.example/DB/Employee/id.18#record>
+ ?emp empP:manager <http://hr.example/DB/Employee/empid.18#record>
}
""").get
val sqlParser = Sql()
@@ -201,7 +191,7 @@
WHERE R_emp.manager=18 AND R_emp.lastName IS NOT NULL
AND R_emp.empid IS NOT NULL
""").get
- val generated = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(generated === parsed)
}
@@ -222,7 +212,7 @@
WHERE R_empid18.empid=R_emp.manager AND R_empid18.empid=18 AND R_emp.lastName IS NOT NULL
AND R_emp.empid IS NOT NULL
""").get
- val generated = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
}
@@ -247,7 +237,7 @@
AND R_emp.empid IS NOT NULL
AND R_manager.empid IS NOT NULL
""").get
- val generated = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
}
@@ -291,7 +281,7 @@
AND R_taskLead.birthday IS NOT NULL AND R_ltask.taskid IS NOT NULL
AND R_lower.id IS NOT NULL AND R_upper.id IS NOT NULL
""").get
- val generated = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
+ val generated = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), true, false)
assert(generated === parsed)
}
@@ -346,7 +336,7 @@
AND (R_union1._DISJOINT_!=0 OR R_union1.A_who=R_who.empid)
AND (R_union1._DISJOINT_!=1 OR R_union1.A_who=R_who.empid)
""").get
- val transformed = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(transformed === parsed)
}
@@ -399,7 +389,7 @@
AND (R_union0._DISJOINT_!=1 OR R_who.empid=R_union0.A_who)
AND R_union0.A_bday IS NOT NULL AND R_union0.A_who IS NOT NULL AND R_who.lastName="Smith"
""").get
- val transformed = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(transformed === parsed)
}
@@ -454,7 +444,7 @@
AND (R_union1._DISJOINT_!=1 OR R_union1.A_who=R_who.empid)
AND R_who.birthday IS NOT NULL AND R_who.empid IS NOT NULL AND R_who.lastName="Smith"
""").get
- val transformed = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(transformed === parsed)
}
@@ -509,7 +499,7 @@
AND (R_union1._DISJOINT_!=1 OR R_who.birthday=R_union1.A_bday)
AND R_union1.A_bday IS NOT NULL AND R_who.empid IS NOT NULL AND R_who.lastName="Smith"
""").get
- val transformed = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(transformed === parsed)
}
@@ -539,7 +529,7 @@
) AS R_opt1 ON R_opt1.A_emp=R_emp.empid
WHERE R_emp.empid IS NOT NULL AND R_emp.lastName IS NOT NULL
""").get
- val transformed = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(transformed === parsed)
}
@@ -569,7 +559,7 @@
AND R_emp.lastName IS NOT NULL
AND R_opt1.A_emp IS NOT NULL
""").get
- val transformed = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(transformed === parsed)
}
@@ -606,7 +596,7 @@
) AS R_opt1 ON R_opt1.A_emp=R_emp.empid
WHERE R_emp.empid IS NOT NULL AND R_emp.lastName IS NOT NULL
""").get
- val transformed = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(transformed === parsed)
}
@@ -650,7 +640,7 @@
AND R_emp3.empid IS NOT NULL AND R_emp3.lastName IS NOT NULL AND R_emp3.lastName<R_emp4.lastName
AND R_emp4.empid IS NOT NULL AND R_emp4.lastName IS NOT NULL AND R_opt1.A_birthday IS NOT NULL
""").get
- val transformed = RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
+ val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
assert(transformed === parsed)
}