changeset 7:609bbd9a2dce

~ separate RDF and SQL description in different modules and let Transformer alone
author Alexandre Bertails <alexandre@bertails.org>
date Mon, 31 May 2010 09:51:11 -0400
parents 4ace3eb848d4
children cd394d9cfc8b
files src/main/scala/Main.scala src/test/scala/Test.scala
diffstat 2 files changed, 29 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/scala/Main.scala	Thu May 27 21:47:03 2010 -0400
+++ b/src/main/scala/Main.scala	Mon May 31 09:51:11 2010 -0400
@@ -2,11 +2,19 @@
 
 import scala.collection.Set
 
-object Transformer {
-  // Transformation argument:
-  type StemURI = IRI
+// RDF node types
+object RDF {
+  type RDFGraph = Set[RDFTriple]
+  case class RDFTriple (s:IRI, p:IRI, o:RDFObject)
+  sealed abstract class RDFObject
+  case class IRIObject (i:IRI) extends RDFObject
+  case class LiteralObject (l:RDFLiteral) extends RDFObject
+  type IRI = String
+  type RDFLiteral = String
+}
 
-  // Relational structure:
+// Relational structure
+object SQL {
   case class Relation ( name:RelName, header:Header, body:Body )
   type Header = Map[AttrName, (LinkType, SQLDatatype)]
   type Body = Set[Tuple]
@@ -24,15 +32,6 @@
   type RelName = String
   type AttrName = String
 
-  // RDF node types:
-  type RDFGraph = Set[RDFTriple]
-  case class RDFTriple (s:IRI, p:IRI, o:RDFObject)
-  sealed abstract class RDFObject
-  case class IRIObject (i:IRI) extends RDFObject
-  case class LiteralObject (l:RDFLiteral) extends RDFObject
-  type IRI = String
-  type RDFLiteral = String
-
   // Accessor functions:
   def pk (h:Header) : AttrName  // Assume: one primary key.
   = h.find(x => x._2._1 == Pk()).get._1
@@ -45,6 +44,16 @@
   def linktype (h:Header, a:AttrName) : LinkType = h(a)._1
   def relname (r:Relation) : RelName = r.name
 
+}
+
+object Transformer {
+
+  import RDF._
+  import SQL._
+
+  // Transformation argument:
+  type StemURI = RDF.IRI
+
   // Mapping functions:
   def relationmap (u:StemURI, r:Relation) : RDFGraph
   = body(r).flatMap(t => tuplemap(u, t, r))
@@ -59,7 +68,7 @@
   def cellmap (u:StemURI, r:Relation, a:AttrName, s:IRI, t:Tuple) : Option[RDFTriple] = {
     val h = header(r)
     lexvalue(h, t, a) match {
-      case (☹()) => None
+      case ☹() => None
       case l:LexicalValue => {
 	val p = predicatemap (u, r, a)
 	val o = linktype(h, a) match {
--- a/src/test/scala/Test.scala	Thu May 27 21:47:03 2010 -0400
+++ b/src/test/scala/Test.scala	Mon May 31 09:51:11 2010 -0400
@@ -1,4 +1,9 @@
-import w3c.sw.StemGraph.Transformer._
+package w3c.sw.StemGraph
+
+import Transformer._
+import RDF._
+import SQL._
+
 import org.scalatest.FunSuite
 
 class Test extends FunSuite {
Set up and maintained by W3C Systems Team, please report bugs to sysreq@w3.org.

W3C would like to thank Microsoft who donated the server that allows us to run this service.