~ changed all e.g. sql.SQL into sql.
--- a/src/main/scala/RDB2RDFMain.scala Sun Jan 03 23:15:40 2010 -0500
+++ b/src/main/scala/RDB2RDFMain.scala Sun Jan 03 23:25:03 2010 -0500
@@ -45,7 +45,7 @@
sql.RelAlias(sql.Name("R_" + a + v))
}
- def relAliasFromLiteral(l:sparql.SparqlLiteral):sql.RelAlias = {
+ def relAliasFromLiteral(l:sparql.Literal):sql.RelAlias = {
sql.RelAlias(sql.Name("R_" + l.lit.lexicalForm))
}
@@ -58,10 +58,10 @@
// println("equiv+= " + toString(constrainMe) + "=" + value)
//R2RState(state.joins, state.varmap, state.exprs + RelationalExpressionEq(constrainMe,PrimaryExpressionTyped(SQLDatatype.INTEGER,Name(u.v.s))))
val relvar = if (enforeForeignKeys) sql.RelAliasAttribute(constrainMe.relalias, sql.Attribute(sql.Name(u.attr.s))) else constrainMe
- R2RState(state.joins, state.varmap, state.exprs + sql.RelationalExpressionEq(sql.PrimaryExpressionAttr(relvar),sql.PrimaryExpressionTyped(sql.SQLDatatype.INTEGER,sql.Name(u.v.s))))
+ R2RState(state.joins, state.varmap, state.exprs + sql.RelationalExpressionEq(sql.PrimaryExpressionAttr(relvar),sql.PrimaryExpressionTyped(sql.Datatype.INTEGER,sql.Name(u.v.s))))
}
- def literalConstraint(state:R2RState, constrainMe:sql.RelAliasAttribute, lit:sparql.SparqlLiteral, dt:sql.SQLDatatype):R2RState = {
+ def literalConstraint(state:R2RState, constrainMe:sql.RelAliasAttribute, lit:sparql.Literal, dt:sql.Datatype):R2RState = {
// println("equiv+= " + toString(attr) + "=" + lit)
R2RState(state.joins, state.varmap, state.exprs + sql.RelationalExpressionEq(sql.PrimaryExpressionAttr(constrainMe),sql.PrimaryExpressionTyped(dt,sql.Name(lit.lit.lexicalForm))))
}
@@ -118,11 +118,11 @@
reldesc.attributes(constrainMe.attribute) match {
case sql.ForeignKey(fkrel, fkattr) =>
RDFNoder(rel, constrainMe, Set())
- case sql.Value(sql.SQLDatatype("Int")) =>
+ case sql.Value(sql.Datatype("Int")) =>
IntMapper(constrainMe, Set())
- case sql.Value(sql.SQLDatatype("String")) =>
+ case sql.Value(sql.Datatype("String")) =>
StringMapper(constrainMe, Set())
- case sql.Value(sql.SQLDatatype("Date")) =>
+ case sql.Value(sql.Datatype("Date")) =>
DateMapper(constrainMe, Set())
}
} else {
@@ -212,7 +212,7 @@
def findVars(gp:sparql.GraphPattern):Set[sparql.Var] = {
gp match {
- case sparql.TableFilter(gp2:sparql.GraphPattern, expr:sparql.SparqlExpression) =>
+ case sparql.TableFilter(gp2:sparql.GraphPattern, expr:sparql.Expression) =>
findVars(gp2)
case sparql.TriplesBlock(triplepatterns) =>
@@ -255,33 +255,33 @@
varmap(vvar) match {
case IntMapper(relalias, _) => sql.PrimaryExpressionAttr(relalias)
case StringMapper(relalias, _) =>
- sql.Concat(List(sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),sql.Name("\\\"")),
+ sql.Concat(List(sql.PrimaryExpressionTyped(sql.Datatype("String"),sql.Name("\\\"")),
sql.PrimaryExpressionAttr(relalias),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),sql.Name("\\\"^^<http://www.w3.org/2001/XMLSchema#string>"))))
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),sql.Name("\\\"^^<http://www.w3.org/2001/XMLSchema#string>"))))
case DateMapper(relalias, _) => sql.PrimaryExpressionAttr(relalias)
case RDFNoder(relation, relalias, _) =>
- sql.Concat(List(sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),sql.Name(stem.s)),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),relation.n),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),sql.Name("/")),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),relalias.attribute.n),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),sql.Name(".")),
+ sql.Concat(List(sql.PrimaryExpressionTyped(sql.Datatype("String"),sql.Name(stem.s)),
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),relation.n),
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),sql.Name("/")),
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),relalias.attribute.n),
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),sql.Name(".")),
sql.PrimaryExpressionAttr(relalias),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),sql.Name("#record"))))
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),sql.Name("#record"))))
case RDFBNoder(relation, relalias, _) =>
- sql.Concat(List(sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),sql.Name("_:")),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),relation.n),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),sql.Name(".")),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),relalias.attribute.n),
- sql.PrimaryExpressionTyped(sql.SQLDatatype("String"),sql.Name(".")),
+ sql.Concat(List(sql.PrimaryExpressionTyped(sql.Datatype("String"),sql.Name("_:")),
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),relation.n),
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),sql.Name(".")),
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),relalias.attribute.n),
+ sql.PrimaryExpressionTyped(sql.Datatype("String"),sql.Name(".")),
sql.PrimaryExpressionAttr(relalias)))
}
}
- def filter2expr(varmap:Map[sparql.Var, SQL2RDFValueMapper], f:sparql.SparqlPrimaryExpression):sql.RelationalExpression = {
+ def filter2expr(varmap:Map[sparql.Var, SQL2RDFValueMapper], f:sparql.PrimaryExpression):sql.RelationalExpression = {
val (lTerm:sparql.Term, rTerm:sparql.Term, sqlexpr) = f match { // sqlexpr::((sql.RelAliasAttribute,sql.PrimaryExpressionAttr)=>sql.RelationalExpression)
- case sparql.SparqlPrimaryExpressionEq(l, r) => (l.term, r.term, sql.RelationalExpressionEq(_,_))
- case sparql.SparqlPrimaryExpressionLt(l, r) => (l.term, r.term, sql.RelationalExpressionLt(_,_))
+ case sparql.PrimaryExpressionEq(l, r) => (l.term, r.term, sql.RelationalExpressionEq(_,_))
+ case sparql.PrimaryExpressionLt(l, r) => (l.term, r.term, sql.RelationalExpressionLt(_,_))
}
// sql.RelationalExpressionEq(_,_) === (x,y) => PrymaryExpressionEq(x,y)
lTerm match {
@@ -295,7 +295,7 @@
case sparql.TermVar(v) => { // :sparql.Var
sql.PrimaryExpressionAttr(varToAttribute(varmap, v))
}
- case sparql.TermLit(lit) => null // :sparql.SparqlLiteral => sql.PrimaryExpressionTyped(sql.SQLDatatype, lit.n)
+ case sparql.TermLit(lit) => null // :sparql.Literal => sql.PrimaryExpressionTyped(sql.Datatype, lit.n)
}
sqlexpr(sql.PrimaryExpressionAttr(l), r)
}
@@ -306,12 +306,12 @@
def mapGraphPattern(db:sql.DatabaseDesc, state:R2RState, gp:sparql.GraphPattern, pk:PrimaryKey, enforceForeignKeys:Boolean):R2RState = {
gp match {
- case sparql.TableFilter(gp2:sparql.GraphPattern, expr:sparql.SparqlExpression) => {
+ case sparql.TableFilter(gp2:sparql.GraphPattern, expr:sparql.Expression) => {
val state2 = mapGraphPattern(db, state, gp2, pk, enforceForeignKeys)
/* Add constraints for all the FILTERS */
val filterExprs:Set[sql.RelationalExpression] =
- expr.conjuncts.toSet map ((x:sparql.SparqlPrimaryExpression) => filter2expr(state2.varmap, x))
+ expr.conjuncts.toSet map ((x:sparql.PrimaryExpression) => filter2expr(state2.varmap, x))
R2RState(state2.joins, state2.varmap, state2.exprs ++ filterExprs)
}
@@ -337,9 +337,9 @@
val (outerState, outerDisjoints, no) = incPair
val disjointState = mapGraphPattern(db, emptyState, disjoint, pk, enforceForeignKeys)
val disjointVars = findVars(disjoint)
- val disjointNo = sql.NamedAttribute(sql.PrimaryExpressionTyped(sql.SQLDatatype.INTEGER,sql.Name("" + no)), sql.AttrAlias(sql.Name("_DISJOINT_")))
+ val disjointNo = sql.NamedAttribute(sql.PrimaryExpressionTyped(sql.Datatype.INTEGER,sql.Name("" + no)), sql.AttrAlias(sql.Name("_DISJOINT_")))
val disjointNoAliasAttr = sql.RelAliasAttribute(unionAlias, sql.Attribute(sql.Name("_DISJOINT_")))
- val disjointCond = sql.RelationalExpressionNe(sql.PrimaryExpressionAttr(disjointNoAliasAttr), sql.PrimaryExpressionTyped(sql.SQLDatatype.INTEGER,sql.Name("" + no)))
+ val disjointCond = sql.RelationalExpressionNe(sql.PrimaryExpressionAttr(disjointNoAliasAttr), sql.PrimaryExpressionTyped(sql.Datatype.INTEGER,sql.Name("" + no)))
val attrlist:Set[sql.NamedAttribute] = unionVars.foldLeft(Set(disjointNo))((attrs, v) => {
val attrOrNull = if (disjointState.varmap.contains(v)) varToAttribute(disjointState.varmap, v) else sql.ConstNULL()
@@ -472,8 +472,8 @@
}
}
- def apply (db:sql.DatabaseDesc, sparquery:sparql.SparqlSelect, stem:StemURI, pk:PrimaryKey, enforceForeignKeys:Boolean, concat:Boolean) : sql.Select = {
- val sparql.SparqlSelect(attrs, triples) = sparquery
+ def apply (db:sql.DatabaseDesc, sparquery:sparql.Select, stem:StemURI, pk:PrimaryKey, enforceForeignKeys:Boolean, concat:Boolean) : sql.Select = {
+ val sparql.Select(attrs, triples) = sparquery
/* Create an object to hold our compilation state. */
val initState = R2RState(
--- a/src/main/scala/SPARQL.scala Sun Jan 03 23:15:40 2010 -0500
+++ b/src/main/scala/SPARQL.scala Sun Jan 03 23:25:03 2010 -0500
@@ -13,14 +13,14 @@
import MyParsers._
-case class SparqlSelect(attrs:SparqlAttributeList, gp:GraphPattern)
+case class Select(attrs:SparqlAttributeList, gp:GraphPattern)
case class SparqlAttributeList(attributelist:List[Var])
sealed abstract class GraphPattern
case class TriplesBlock(triplepatterns:List[TriplePattern]) extends GraphPattern
case class TableConjunction(gps:List[GraphPattern]) extends GraphPattern
case class TableDisjunction(gps:List[GraphPattern]) extends GraphPattern
-case class TableFilter(gp:GraphPattern, expr:SparqlExpression) extends GraphPattern
+case class TableFilter(gp:GraphPattern, expr:Expression) extends GraphPattern
case class OptionalGraphPattern(gp:GraphPattern) extends GraphPattern
case class GraphGraphPattern(gp:GraphPattern) extends GraphPattern
@@ -35,13 +35,13 @@
sealed abstract class O
case class OUri(obj:ObjUri) extends O
case class OVar(v:Var) extends O
-case class OLit(lit:SparqlLiteral) extends O
+case class OLit(lit:Literal) extends O
sealed abstract class P
case class PUri(stem:Stem, rel:Rel, attr:Attr) extends P
case class PVar(v:Var) extends P
-case class SparqlLiteral(lit:RDFLiteral)
+case class Literal(lit:RDFLiteral)
case class Stem(s:String)
case class Attr(s:String)
@@ -49,38 +49,38 @@
case class Var(s:String)
-case class SparqlExpression(conjuncts:List[SparqlPrimaryExpression])
-sealed abstract class SparqlPrimaryExpression
-case class SparqlPrimaryExpressionEq(left:SparqlTermExpression, right:SparqlTermExpression) extends SparqlPrimaryExpression
-case class SparqlPrimaryExpressionLt(left:SparqlTermExpression, right:SparqlTermExpression) extends SparqlPrimaryExpression
+case class Expression(conjuncts:List[PrimaryExpression])
+sealed abstract class PrimaryExpression
+case class PrimaryExpressionEq(left:SparqlTermExpression, right:SparqlTermExpression) extends PrimaryExpression
+case class PrimaryExpressionLt(left:SparqlTermExpression, right:SparqlTermExpression) extends PrimaryExpression
case class SparqlTermExpression(term:Term)
sealed abstract class Term
case class TermUri(obj:ObjUri) extends Term
case class TermVar(v:Var) extends Term
-case class TermLit(lit:SparqlLiteral) extends Term
+case class TermLit(lit:Literal) extends Term
case class Sparql() extends JavaTokenParsers {
- def select:Parser[SparqlSelect] =
- rep(prefixdecls) ~ "SELECT" ~ attributelist ~ opt("WHERE") ~ groupgraphpattern ^^ { case x~"SELECT"~a~w~gp => SparqlSelect(a, gp) }
+ def select:Parser[Select] =
+ rep(prefixdecls) ~ "SELECT" ~ attributelist ~ opt("WHERE") ~ groupgraphpattern ^^ { case x~"SELECT"~a~w~gp => Select(a, gp) }
def prefixdecls:Parser[Unit] =
"PREFIX" ~ name ~ ":" ~ qnameORuri ^^ { case "PREFIX"~pre~":"~u => prefixes += (pre -> u) }
- def filter:Parser[SparqlExpression] =
+ def filter:Parser[Expression] =
"FILTER" ~ "(" ~ expression ~ ")" ^^ { case "FILTER"~"("~expression~")" => expression }
- def expression:Parser[SparqlExpression] =
+ def expression:Parser[Expression] =
repsep(primaryexpression, "&&") ^^
- { SparqlExpression(_) }
+ { Expression(_) }
- def primaryexpression:Parser[SparqlPrimaryExpression] = (
+ def primaryexpression:Parser[PrimaryExpression] = (
value ~ "=" ~ value ^^
- { case left ~ "=" ~ right => SparqlPrimaryExpressionEq(left, right) }
+ { case left ~ "=" ~ right => PrimaryExpressionEq(left, right) }
| value ~ "<" ~ value ^^
- { case left ~ "<" ~ right => SparqlPrimaryExpressionLt(left, right) }
+ { case left ~ "<" ~ right => PrimaryExpressionLt(left, right) }
)
def value:Parser[SparqlTermExpression] = (
@@ -100,7 +100,7 @@
// case class TriplesBlock(triplepatterns:List[TriplePattern]) extends GraphPattern
// case class TableConjunction(gps:List[GraphPattern]) extends GraphPattern
// case class TableDisjunction(gps:List[GraphPattern]) extends GraphPattern
-// case class TableFilter(gp:GraphPattern, expr:SparqlExpression) extends GraphPattern
+// case class TableFilter(gp:GraphPattern, expr:Expression) extends GraphPattern
// case class OptionalGraphPattern(gp:GraphPattern) extends GraphPattern
// case class GraphGraphPattern(gp:GraphPattern) extends GraphPattern
@@ -111,7 +111,7 @@
case (Some(TriplesBlock(l)), ~(TableFilter(null, expr), None )) => Some(TableFilter(TriplesBlock(l), expr))
case (None, ~(TableFilter(null, expr), Some(TriplesBlock(r)))) => Some(TableFilter(TriplesBlock(r), expr))
case (Some(TriplesBlock(l)), ~(TableFilter(null, expr), Some(TriplesBlock(r)))) => Some(TableFilter(TriplesBlock(l ++ r), expr))
- case (Some(TableFilter(TriplesBlock(l), SparqlExpression(lexp))), ~(TableFilter(null, SparqlExpression(expr)), Some(TriplesBlock(r)))) => Some(TableFilter(TriplesBlock(l ++ r), SparqlExpression(lexp ++ expr)))
+ case (Some(TableFilter(TriplesBlock(l), Expression(lexp))), ~(TableFilter(null, Expression(expr)), Some(TriplesBlock(r)))) => Some(TableFilter(TriplesBlock(l ++ r), Expression(lexp ++ expr)))
// case (None, ~(TableConjunction(gps), None )) => TableConjunction(gps)
// case (Some(gp), ~(TableConjunction(gps), None )) => TableConjunction(List(List(gp) ++ gps))
@@ -161,10 +161,10 @@
| name~":"~name ^^ { case prefix~":"~localName => prefixes(prefix) + localName }
)
- def literal:Parser[SparqlLiteral] =
+ def literal:Parser[Literal] =
stringLiteral~"^^"~qnameORuri ^^
{
- case lit~"^^"~dt => SparqlLiteral(RDFLiteral(lit.substring(1,lit.size - 1), dt match {
+ case lit~"^^"~dt => Literal(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
--- a/src/main/scala/SQL.scala Sun Jan 03 23:15:40 2010 -0500
+++ b/src/main/scala/SQL.scala Sun Jan 03 23:25:03 2010 -0500
@@ -96,7 +96,7 @@
case class PrimaryExpressionAttr(fqattribute:RelAliasAttribute) extends PrimaryExpression {
override def toString = "" + fqattribute
}
-case class PrimaryExpressionTyped(datatype:SQLDatatype, i:Name) extends PrimaryExpression {
+case class PrimaryExpressionTyped(datatype:Datatype, i:Name) extends PrimaryExpression {
override def toString = i.s /* "'" + i.s + "'" */ /* + datatype */
}
case class ConstNULL() extends PrimaryExpression {
@@ -112,17 +112,17 @@
implicit def fromStringToName(s:String):Name = Name(s)
}
-case class SQLDatatype(name:String) {
+case class Datatype(name:String) {
override def toString = "/* " + name + " */"
}
-object SQLDatatype {
- val STRING = SQLDatatype("String")
- val INTEGER = SQLDatatype("Int")
- val DATE = SQLDatatype("Date")
+object Datatype {
+ val STRING = Datatype("String")
+ val INTEGER = Datatype("Int")
+ val DATE = Datatype("Date")
}
sealed abstract class ValueDescription
-case class Value(datatype:SQLDatatype) extends ValueDescription
+case class Value(datatype:Datatype) extends ValueDescription
case class ForeignKey(rel:Relation, attr:Attribute) extends ValueDescription
case class DatabaseDesc(relationdescs:Map[Relation,RelationDesc])
@@ -209,8 +209,8 @@
def primaryexpression:Parser[Expression] = (
fqattribute ^^ { PrimaryExpressionAttr(_) }
- | int ^^ { i => PrimaryExpressionTyped(SQLDatatype.INTEGER, Name(i)) }
- | chars ^^ { x => PrimaryExpressionTyped(SQLDatatype.STRING, Name(x.substring(1, x.size - 1))) }
+ | int ^^ { i => PrimaryExpressionTyped(Datatype.INTEGER, Name(i)) }
+ | chars ^^ { x => PrimaryExpressionTyped(Datatype.STRING, Name(x.substring(1, x.size - 1))) }
| "NULL" ^^ { case "NULL" => ConstNULL() }
| "CONCAT" ~ "(" ~ rep1sep(expression, ",") ~ ")" ^^ { case "CONCAT"~"("~expressions~")" => Concat(expressions) }
| "(" ~ expression ~ ")" ^^ { case "("~x~")" => x }
--- a/src/test/scala/RDB2RDFTest.scala Sun Jan 03 23:15:40 2010 -0500
+++ b/src/test/scala/RDB2RDFTest.scala Sun Jan 03 23:25:03 2010 -0500
@@ -2,7 +2,7 @@
import org.scalatest.FunSuite
import java.net.URI
-import w3c.sw.sql.{Sql,DatabaseDesc,Relation,RelationDesc,Attribute,Value,SQLDatatype,ForeignKey,Name}
+import w3c.sw.sql.{Sql,DatabaseDesc,Relation,RelationDesc,Attribute,Value,Datatype,ForeignKey,Name}
import w3c.sw.sparql.Sparql
import w3c.sw.rdb2rdf.{RDB2RDF,StemURI,
PrimaryKey // nuke
@@ -13,9 +13,9 @@
val db:DatabaseDesc = DatabaseDesc(
Map(Relation("Employee") ->
RelationDesc(Option(Attribute("id")),
- Map(Attribute("id") -> Value(SQLDatatype.INTEGER),
- Attribute("lastName") -> Value(SQLDatatype.STRING),
- Attribute("birthday") -> Value(SQLDatatype.DATE),
+ 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"))))
))
@@ -23,11 +23,11 @@
val db2:DatabaseDesc = DatabaseDesc(
Map(Relation("Employee") ->
RelationDesc(Option(Attribute("id")),
- Map(Attribute("id") -> Value(SQLDatatype.INTEGER),
- Attribute("lastName") -> Value(SQLDatatype.STRING),
- Attribute("birthday") -> Value(SQLDatatype.DATE),
- Attribute("manager") -> Value(SQLDatatype.INTEGER),
- Attribute("address") -> Value(SQLDatatype.INTEGER))),
+ Map(Attribute("id") -> Value(Datatype.INTEGER),
+ Attribute("lastName") -> Value(Datatype.STRING),
+ Attribute("birthday") -> Value(Datatype.DATE),
+ Attribute("manager") -> Value(Datatype.INTEGER),
+ Attribute("address") -> Value(Datatype.INTEGER))),
Relation("Manage") ->
RelationDesc(None,
Map(Attribute("manager") -> ForeignKey(Relation("Employee"), Attribute("id")),
--- a/src/test/scala/SQLTest.scala Sun Jan 03 23:15:40 2010 -0500
+++ b/src/test/scala/SQLTest.scala Sun Jan 03 23:25:03 2010 -0500
@@ -85,7 +85,7 @@
AttrAlias(Name("A_empName"))))),
TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))))),
Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager")))),
- PrimaryExpressionTyped(SQLDatatype.INTEGER,Name("18"))),
+ PrimaryExpressionTyped(Datatype.INTEGER,Name("18"))),
RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName")))))))))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -106,7 +106,7 @@
Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager")))),
PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id"))))),
RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("lastName")))),
- PrimaryExpressionTyped(SQLDatatype.STRING,Name("Johnson"))),
+ PrimaryExpressionTyped(Datatype.STRING,Name("Johnson"))),
RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName")))))))))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -200,7 +200,7 @@
Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_union1")),Attribute(Name("A_who")))),
PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_who")),Attribute(Name("id"))))),
RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_who")),Attribute(Name("lastName")))),
- PrimaryExpressionTyped(SQLDatatype.STRING,Name("Smith")))))))
+ PrimaryExpressionTyped(Datatype.STRING,Name("Smith")))))))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -229,13 +229,13 @@
SELECT CONCAT(""" + QuotedBaseURI + """, "Employee", "/", "id", ".", R_emp.id, "#record") AS A_emp
FROM Employee AS R_emp
"""
- val expected = Select(AttributeList(Set(NamedAttribute(Concat(List(PrimaryExpressionTyped(SQLDatatype("String"),Name("http://hr.example/DB/")),
- PrimaryExpressionTyped(SQLDatatype("String"),Name("Employee")),
- PrimaryExpressionTyped(SQLDatatype("String"),Name("/")),
- PrimaryExpressionTyped(SQLDatatype("String"),Name("id")),
- PrimaryExpressionTyped(SQLDatatype("String"),Name(".")),
+ val expected = Select(AttributeList(Set(NamedAttribute(Concat(List(PrimaryExpressionTyped(Datatype("String"),Name("http://hr.example/DB/")),
+ PrimaryExpressionTyped(Datatype("String"),Name("Employee")),
+ PrimaryExpressionTyped(Datatype("String"),Name("/")),
+ PrimaryExpressionTyped(Datatype("String"),Name("id")),
+ PrimaryExpressionTyped(Datatype("String"),Name(".")),
PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("id")))),
- PrimaryExpressionTyped(SQLDatatype("String"),Name("#record")))),
+ PrimaryExpressionTyped(Datatype("String"),Name("#record")))),
AttrAlias(Name("A_emp"))))),
TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))))),
None)
@@ -260,9 +260,9 @@
RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("id"))))),
ExprConjunction(Set(
RelationalExpressionLt(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("id")))),
- PrimaryExpressionTyped(SQLDatatype.INTEGER,Name("5"))),
+ PrimaryExpressionTyped(Datatype.INTEGER,Name("5"))),
RelationalExpressionLt(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("id")))),
- PrimaryExpressionTyped(SQLDatatype.INTEGER,Name("3")))
+ PrimaryExpressionTyped(Datatype.INTEGER,Name("3")))
))))))
assert(expected === (a.parseAll(a.select, e).get))
}
--- a/src/test/scala/SparqlTest.scala Sun Jan 03 23:15:40 2010 -0500
+++ b/src/test/scala/SparqlTest.scala Sun Jan 03 23:25:03 2010 -0500
@@ -11,7 +11,7 @@
val e = """
?emp <http://hr.example/DB/Employee#lastName> "bob"^^<http://www.w3.org/2001/XMLSchema#string>
"""
- val expected = TriplesBlock(List(TriplePattern(SVar(Var("emp")),PUri(Stem("http://hr.example/DB"),Rel("Employee"),Attr("lastName")),OLit(SparqlLiteral(RDFLiteral("bob",Datatype(new URI("http://www.w3.org/2001/XMLSchema#string"))))))))
+ val expected = TriplesBlock(List(TriplePattern(SVar(Var("emp")),PUri(Stem("http://hr.example/DB"),Rel("Employee"),Attr("lastName")),OLit(Literal(RDFLiteral("bob",Datatype(new URI("http://www.w3.org/2001/XMLSchema#string"))))))))
assert(expected === (a.parseAll(a.triplesblock, e).get))
}
@@ -20,7 +20,7 @@
val e = """
?emp <http://hr.example/DB/Employee#age> "21"^^<http://www.w3.org/2001/XMLSchema#integer>
"""
- val expected = TriplesBlock(List(TriplePattern(SVar(Var("emp")),PUri(Stem("http://hr.example/DB"),Rel("Employee"),Attr("age")),OLit(SparqlLiteral(RDFLiteral("21",Datatype(new URI("http://www.w3.org/2001/XMLSchema#integer"))))))))
+ val expected = TriplesBlock(List(TriplePattern(SVar(Var("emp")),PUri(Stem("http://hr.example/DB"),Rel("Employee"),Attr("age")),OLit(Literal(RDFLiteral("21",Datatype(new URI("http://www.w3.org/2001/XMLSchema#integer"))))))))
assert(expected === (a.parseAll(a.triplesblock, e).get))
}
@@ -59,23 +59,23 @@
assert(expected === (a.parseAll(a.value, e).get))
}
- test("SparqlPrimaryExpressionEq") {
+ test("PrimaryExpressionEq") {
val a = Sparql()
val e = """
?emp<?emp
"""
- val expected = SparqlPrimaryExpressionLt(SparqlTermExpression(TermVar(Var("emp"))), SparqlTermExpression(TermVar(Var("emp"))))
+ val expected = PrimaryExpressionLt(SparqlTermExpression(TermVar(Var("emp"))), SparqlTermExpression(TermVar(Var("emp"))))
assert(expected === (a.parseAll(a.primaryexpression, e).get))
}
- test("SparqlExpression") {
+ test("Expression") {
val a = Sparql()
val e = """
?manBday < ?empBday && ?grandManBday < ?manBday
"""
- val expected = SparqlExpression(List(
- SparqlPrimaryExpressionLt(SparqlTermExpression(TermVar(Var("manBday"))), SparqlTermExpression(TermVar(Var("empBday")))),
- SparqlPrimaryExpressionLt(SparqlTermExpression(TermVar(Var("grandManBday"))), SparqlTermExpression(TermVar(Var("manBday"))))))
+ val expected = Expression(List(
+ PrimaryExpressionLt(SparqlTermExpression(TermVar(Var("manBday"))), SparqlTermExpression(TermVar(Var("empBday")))),
+ PrimaryExpressionLt(SparqlTermExpression(TermVar(Var("grandManBday"))), SparqlTermExpression(TermVar(Var("manBday"))))))
assert(expected === (a.parseAll(a.expression, e).get))
}
@@ -84,9 +84,9 @@
val e = """
FILTER(?manBday < ?empBday && ?grandManBday < ?manBday)
"""
- val expected = SparqlExpression(List(
- SparqlPrimaryExpressionLt(SparqlTermExpression(TermVar(Var("manBday"))), SparqlTermExpression(TermVar(Var("empBday")))),
- SparqlPrimaryExpressionLt(SparqlTermExpression(TermVar(Var("grandManBday"))), SparqlTermExpression(TermVar(Var("manBday"))))))
+ val expected = Expression(List(
+ PrimaryExpressionLt(SparqlTermExpression(TermVar(Var("manBday"))), SparqlTermExpression(TermVar(Var("empBday")))),
+ PrimaryExpressionLt(SparqlTermExpression(TermVar(Var("grandManBday"))), SparqlTermExpression(TermVar(Var("manBday"))))))
assert(expected === (a.parseAll(a.filter, e).get))
}
@@ -99,7 +99,7 @@
}
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("empName"), Var("manageName"))),
TriplesBlock(
List(
@@ -120,7 +120,7 @@
}
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("empName"), Var("manageName"))),
TriplesBlock(
List(
@@ -140,7 +140,7 @@
}
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("empName"), Var("manageName"))),
TableFilter(
TriplesBlock(
@@ -149,10 +149,10 @@
SVar(Var("emp")),
PUri(Stem("http://hr.example/DB"),Rel("Employee"),Attr("lastName")),
OVar(Var("empName"))))),
- SparqlExpression(List(
- SparqlPrimaryExpressionLt(SparqlTermExpression(TermVar(Var("manBday"))),
+ Expression(List(
+ PrimaryExpressionLt(SparqlTermExpression(TermVar(Var("manBday"))),
SparqlTermExpression(TermVar(Var("empBday")))),
- SparqlPrimaryExpressionLt(SparqlTermExpression(TermVar(Var("grandManBday"))),
+ PrimaryExpressionLt(SparqlTermExpression(TermVar(Var("grandManBday"))),
SparqlTermExpression(TermVar(Var("manBday"))))))))
assert(tps === a.parseAll(a.select, e).get)
}
@@ -167,7 +167,7 @@
}
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("empName"), Var("manageName"))),
TriplesBlock(
List(
@@ -213,7 +213,7 @@
SELECT ?x { { ?x <http://hr.example/DB/Employee#manager> ?y} }
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("x"))),
TriplesBlock(
List(
@@ -230,7 +230,7 @@
SELECT ?x { { ?x <http://hr.example/DB/Employee#manager> ?y} { ?x <http://hr.example/DB/Employee#manager> ?y} }
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("x"))),
TableConjunction(List(
TriplesBlock(
@@ -254,7 +254,7 @@
SELECT ?x { { ?x <http://hr.example/DB/Employee#manager> ?y} UNION { ?x <http://hr.example/DB/Employee#manager> ?y} }
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("x"))),
TableDisjunction(List(
TriplesBlock(
@@ -278,7 +278,7 @@
SELECT ?x { { ?x <http://hr.example/DB/Employee#manager> ?y} OPTIONAL { ?x <http://hr.example/DB/Employee#manager> ?y} }
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("x"))),
TableConjunction(List(
TriplesBlock(
@@ -303,7 +303,7 @@
SELECT ?x { OPTIONAL { ?x <http://hr.example/DB/Employee#manager> ?y} }
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("x"))),
OptionalGraphPattern(
TriplesBlock(
@@ -329,7 +329,7 @@
?managed <http://hr.example/DB/Employee#lastName> ?name } }
"""
val tps =
- SparqlSelect(
+ Select(
SparqlAttributeList(List(Var("name"))),
TableConjunction(List(
TriplesBlock(
@@ -337,7 +337,7 @@
TriplePattern(
SVar(Var("who")),
PUri(Stem("http://hr.example/DB"),Rel("Employee"),Attr("lastName")),
- OLit(SparqlLiteral(RDFLiteral("Smith",Datatype(new URI("http://www.w3.org/2001/XMLSchema#string")))))))),
+ OLit(Literal(RDFLiteral("Smith",Datatype(new URI("http://www.w3.org/2001/XMLSchema#string")))))))),
TableDisjunction(List(
TriplesBlock(
List(