--- a/src/main/scala/RDB2RDFMain.scala Wed Dec 30 11:19:36 2009 -0500
+++ b/src/main/scala/RDB2RDFMain.scala Wed Dec 30 11:27:02 2009 -0500
@@ -16,8 +16,9 @@
case class R2RState(joins:Set[AliasedResource], varmap:Map[Var, SQL2RDFValueMapper], exprs:Set[PrimaryExpression])
sealed abstract class SQL2RDFValueMapper(relaliasattr:RelAliasAttribute)
+ case class IntMapper(relaliasattr:RelAliasAttribute) extends SQL2RDFValueMapper(relaliasattr)
case class StringMapper(relaliasattr:RelAliasAttribute) extends SQL2RDFValueMapper(relaliasattr)
- case class IntMapper(relaliasattr:RelAliasAttribute) extends SQL2RDFValueMapper(relaliasattr)
+ case class DateMapper(relaliasattr:RelAliasAttribute) extends SQL2RDFValueMapper(relaliasattr)
case class RDFNoder(relation:Relation, relaliasattr:RelAliasAttribute) extends SQL2RDFValueMapper(relaliasattr)
case class RDFBNoder(relation:Relation, relaliasattr:RelAliasAttribute) extends SQL2RDFValueMapper(relaliasattr)
@@ -108,10 +109,12 @@
reldesc.attributes(constrainMe.attribute) match {
case ForeignKey(fkrel, fkattr) =>
RDFNoder(rel, constrainMe)
+ case Value(SQLDatatype("Int")) =>
+ IntMapper(constrainMe)
case Value(SQLDatatype("String")) =>
StringMapper(constrainMe)
- case Value(SQLDatatype("Int")) =>
- IntMapper(constrainMe)
+ case Value(SQLDatatype("Date")) =>
+ DateMapper(constrainMe)
}
} else {
RDFBNoder(rel, constrainMe)
@@ -127,8 +130,9 @@
}
def toString(mapper:SQL2RDFValueMapper) : String = {
mapper match {
+ case IntMapper(relalias) => "INT: " + toString(relalias)
case StringMapper(relalias) => "STRING: " + toString(relalias)
- case IntMapper(relalias) => "INT: " + toString(relalias)
+ case DateMapper(relalias) => "DATE: " + toString(relalias)
case RDFNoder(relation, relalias) => "RDFNoder: " + relation.n.s + ", " + toString(relalias)
case RDFBNoder(relation, relalias) => "RDFBNoder: " + relation.n.s + ", " + toString(relalias)
}
@@ -213,8 +217,9 @@
def varToAttribute(varmap:Map[Var, SQL2RDFValueMapper], vvar:Var):RelAliasAttribute = {
varmap(vvar) match {
+ case IntMapper(relalias) => relalias
case StringMapper(relalias) => relalias
- case IntMapper(relalias) => relalias
+ case DateMapper(relalias) => relalias
case RDFNoder(relation, relalias) => relalias
case RDFBNoder(relation, relalias) => relalias
}
@@ -249,8 +254,9 @@
def nullGuard(varmap:Map[Var, SQL2RDFValueMapper], vvar:Var):PrimaryExpression = {
val mapper:SQL2RDFValueMapper = varmap(vvar)
val aattr = mapper match {
+ case IntMapper(relalias) => relalias
case StringMapper(relalias) => relalias
- case IntMapper(relalias) => relalias
+ case DateMapper(relalias) => relalias
case RDFNoder(relation, relalias) => relalias
case RDFBNoder(relation, relalias) => relalias
}
@@ -318,9 +324,10 @@
} else {
/* This variable is new to the outer context. */
val mapper:SQL2RDFValueMapper = disjointState.varmap(v) match {
+ case IntMapper(constrainMe) => IntMapper(unionAliasAttr)
+ case StringMapper(constrainMe) => StringMapper(unionAliasAttr)
+ case DateMapper(constrainMe) => DateMapper(unionAliasAttr)
case RDFNoder(rel, constrainMe) => RDFNoder(rel, unionAliasAttr)
- case StringMapper(constrainMe) => StringMapper(unionAliasAttr)
- case IntMapper(constrainMe) => IntMapper(unionAliasAttr)
case RDFBNoder(rel, constrainMe) => RDFBNoder(rel, unionAliasAttr)
}
R2RState(myState.joins, myState.varmap + (v -> mapper), myState.exprs)
--- a/src/main/scala/RDF.scala Wed Dec 30 11:19:36 2009 -0500
+++ b/src/main/scala/RDF.scala Wed Dec 30 11:27:02 2009 -0500
@@ -22,4 +22,6 @@
object RDFLiteral {
val StringDatatype = Datatype(new URI("http://www.w3.org/2001/XMLSchema#string"))
val IntegerDatatype = Datatype(new URI("http://www.w3.org/2001/XMLSchema#integer"))
+ val DateDatatype = Datatype(new URI("http://www.w3.org/2001/XMLSchema#date"))
+ // val DateTimeDatatype = Datatype(new URI("http://www.w3.org/2001/XMLSchema#dateTime"))
}
--- a/src/main/scala/SPARQL.scala Wed Dec 30 11:19:36 2009 -0500
+++ b/src/main/scala/SPARQL.scala Wed Dec 30 11:27:02 2009 -0500
@@ -156,6 +156,8 @@
case lit~"^^"~dt => SparqlLiteral(RDFLiteral(lit.substring(1,lit.size - 1), dt match {
case "http://www.w3.org/2001/XMLSchema#string" => RDFLiteral.StringDatatype
case "http://www.w3.org/2001/XMLSchema#integer" => RDFLiteral.IntegerDatatype
+ case "http://www.w3.org/2001/XMLSchema#date" => RDFLiteral.DateDatatype
+ // case "http://www.w3.org/2001/XMLSchema#dateTime" => RDFLiteral.DateTimeDatatype
case x => error("only programed to deal with string and integer, not " + x)
}))
}
--- a/src/main/scala/SQL.scala Wed Dec 30 11:19:36 2009 -0500
+++ b/src/main/scala/SQL.scala Wed Dec 30 11:27:02 2009 -0500
@@ -74,6 +74,7 @@
object SQLDatatype {
val STRING = SQLDatatype("String")
val INTEGER = SQLDatatype("Int")
+ val DATE = SQLDatatype("Date")
}
sealed abstract class ValueDescription
--- a/src/test/scala/RDB2RDFTest.scala Wed Dec 30 11:19:36 2009 -0500
+++ b/src/test/scala/RDB2RDFTest.scala Wed Dec 30 11:27:02 2009 -0500
@@ -10,7 +10,7 @@
RelationDesc(Option(Attribute("id")),
Map(Attribute("id") -> Value(SQLDatatype.INTEGER),
Attribute("lastName") -> Value(SQLDatatype.STRING),
- Attribute("birthday") -> Value(SQLDatatype.INTEGER), // !!!
+ Attribute("birthday") -> Value(SQLDatatype.DATE),
Attribute("manager") -> ForeignKey(Relation("Employee"), Attribute("id")),
Attribute("address") -> ForeignKey(Relation("Address"), Attribute("id"))))
))
@@ -20,7 +20,7 @@
RelationDesc(Option(Attribute("id")),
Map(Attribute("id") -> Value(SQLDatatype.INTEGER),
Attribute("lastName") -> Value(SQLDatatype.STRING),
- Attribute("birthday") -> Value(SQLDatatype.INTEGER), // !!!
+ Attribute("birthday") -> Value(SQLDatatype.DATE),
Attribute("manager") -> Value(SQLDatatype.INTEGER),
Attribute("address") -> Value(SQLDatatype.INTEGER))),
Relation("Manage") ->