--- a/src/main/scala/RDB2RDFMain.scala Sun Dec 27 00:58:09 2009 -0800
+++ b/src/main/scala/RDB2RDFMain.scala Sun Dec 27 01:06:38 2009 -0800
@@ -145,7 +145,7 @@
}
}
- def bindOnPredicate(db:DatabaseDesc, stateP:R2RState, triple:TriplePattern, pk:PrimaryKey, enforeForeignKeys:Boolean):R2RState = {
+ def bindOnPredicate(db:DatabaseDesc, stateP:R2RState, triple:TriplePattern, enforeForeignKeys:Boolean):R2RState = {
val TriplePattern(s, p, o) = triple
var state = stateP
p match {
@@ -159,7 +159,7 @@
/* Attributes that come from the subject: */
val objattr = RelAliasAttribute(relalias, attr)
state = s match {
- case SUri(u) => uriConstraint(state, RelAliasAttribute(relalias, pk.attr), u)
+ case SUri(u) => uriConstraint(state, RelAliasAttribute(relalias, db.relationdescs(rel).primarykey.get), u)
case SVar(v) => varConstraint(state, db, v, rel, relalias,
db.relationdescs(rel).primarykey match {
case Some(attr) => Some(attr)
@@ -261,7 +261,7 @@
}
}
- def apply (db:DatabaseDesc, sparql:SparqlSelect, stem:StemURI, pk:PrimaryKey) : Select = {
+ def apply (db:DatabaseDesc, sparql:SparqlSelect, stem:StemURI) : Select = {
val SparqlSelect(attrs, triples) = sparql
/* Create an object to hold our compilation state. */
@@ -272,7 +272,7 @@
)
/* Examine each triple, updating the compilation state. */
- triples.triplepatterns.foreach(s => r2rState = bindOnPredicate(db, r2rState, s, pk, true))
+ triples.triplepatterns.foreach(s => r2rState = bindOnPredicate(db, r2rState, s, true))
/* Select the attributes corresponding to the variables
* in the SPARQL SELECT. */
--- a/src/test/scala/RDB2RDFTest.scala Sun Dec 27 00:58:09 2009 -0800
+++ b/src/test/scala/RDB2RDFTest.scala Sun Dec 27 01:06:38 2009 -0800
@@ -10,7 +10,6 @@
RelationDesc(Option(Attribute("id")),
Map(Attribute("id") -> Value(SQLDatatype.INTEGER),
Attribute("lastName") -> Value(SQLDatatype.STRING),
- Attribute("birthday") -> Value(SQLDatatype.INTEGER), // !!!
Attribute("manager") -> ForeignKey(Relation("Employee"), Attribute("id")),
Attribute("address") -> ForeignKey(Relation("Address"), Attribute("id"))))
))
@@ -44,7 +43,7 @@
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
""").get
- assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id")))) === sqlSelect)
+ assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/")) === sqlSelect)
true
}
@@ -62,7 +61,7 @@
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
""").get
- assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id")))) === sqlSelect)
+ assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/")) === sqlSelect)
true
}
@@ -82,7 +81,7 @@
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
""").get
- assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id")))) === sqlSelect)
+ assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/")) === sqlSelect)
true
}
@@ -101,7 +100,7 @@
INNER JOIN Employee AS R_emp2
WHERE R_emp1.lastName=R_emp2.lastName AND R_emp1.id IS NOT NULL AND R_emp1.lastName IS NOT NULL AND R_emp2.id IS NOT NULL
""").get
- assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id")))) === sqlSelect)
+ assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/")) === sqlSelect)
true
}
@@ -123,7 +122,7 @@
AND R_emp.id IS NOT NULL
AND R_manager.id IS NOT NULL
""").get
- assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id")))) === sqlSelect)
+ assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/")) === sqlSelect)
}
test("transform tup1") {
@@ -142,7 +141,7 @@
WHERE R_id18.id=R_emp.manager AND R_id18.id=18 AND R_emp.lastName IS NOT NULL
AND R_emp.id IS NOT NULL
""").get
- assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id")))) === sqlSelect)
+ assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/")) === sqlSelect)
}
@@ -164,7 +163,7 @@
AND R_emp.id IS NOT NULL
AND R_manager.id IS NOT NULL
""").get
- assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id")))) === sqlSelect)
+ assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/")) === sqlSelect)
}
test("transform filter1") {
@@ -199,7 +198,7 @@
AND R_manager.birthday IS NOT NULL
AND R_grandManager.birthday IS NOT NULL
""").get
- assert(RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id")))) === sqlSelect)
+ assert(RDB2RDF(db2, sparqlSelect, StemURI("http://hr.example/DB/")) === sqlSelect)
}
}