changeset 40:eb720a2e4895 tip

- cc2list freshbnode -> BNode
author Eric Prud'hommeaux <eric@w3.org>
date Fri, 29 Oct 2010 17:44:47 -0400
parents a0d50a09566b
children
files src/main/scala/Main.scala
diffstat 1 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/scala/Main.scala	Fri Oct 29 14:59:33 2010 -0400
+++ b/src/main/scala/Main.scala	Fri Oct 29 17:44:47 2010 -0400
@@ -31,7 +31,6 @@
     def apply (l:(String)*):CandidateKey =
       CandidateKey(l.map{s => AttrName(s)}.toList)
   }
-  implicit def cc2list (cc:CandidateKey) = cc.attrs
 
   case class ForeignKeys (m:Map[List[AttrName], Target]) {
     def apply (l:List[AttrName]) = m(l)
@@ -172,9 +171,9 @@
     def apply(rn:RelName) = m(rn)
     def ultimateReferent (rn:RelName, k:CandidateKey, vs:List[LexicalValue], db:Database) : Node = {
       // Issue: What if fk is a rearrangement of the pk, per issue fk-pk-order?
-      if (db(rn).pk.isDefined && db(rn).fks.contains(db(rn).pk.get)) {
+      if (db(rn).pk.isDefined && db(rn).fks.contains(db(rn).pk.get.attrs)) {
 	/** Table's primary key is a foreign key. */
-	val target = db(rn).fks(db(rn).pk.get)
+	val target = db(rn).fks(db(rn).pk.get.attrs)
 	ultimateReferent(target.rel, target.key, vs, db)
       } else
 	m(rn)(k)(vs)
@@ -203,8 +202,8 @@
 
     /** Check to see if r's primary key is a hierarchical key.
      * http://www.w3.org/2001/sw/rdb2rdf/directGraph/#rule3 */
-    if (r.pk.isDefined && r.fks.contains(r.pk.get))
-      r.fks.keySet -- nullFKs - r.fks(r.pk.get).key
+    if (r.pk.isDefined && r.fks.contains(r.pk.get.attrs))
+      r.fks.keySet -- nullFKs - r.fks(r.pk.get.attrs).key.attrs
     else
       r.fks.keySet -- nullFKs
   }
@@ -219,8 +218,8 @@
 
     /** Check to see if r's primary key is a hierarchical key.
      * http://www.w3.org/2001/sw/rdb2rdf/directGraph/#rule3 */
-    if (r.pk.isDefined && r.fks.contains(r.pk.get))
-      allAttrs -- unaryFKs -- nulllist ++ r.fks(r.pk.get).key
+    if (r.pk.isDefined && r.fks.contains(r.pk.get.attrs))
+      allAttrs -- unaryFKs -- nulllist ++ r.fks(r.pk.get.attrs).key.attrs
     else
       allAttrs -- unaryFKs -- nulllist
   }
@@ -238,13 +237,13 @@
     val s:Node =
       if (r.pk.isDefined) {
 	/** Table has a primkary key. */
-	val vs = t.lexvaluesNoNulls(r.pk.get)
-	nodemap(u, r.name, r.pk.get, vs)
+	val vs = t.lexvaluesNoNulls(r.pk.get.attrs)
+	nodemap(u, r.name, r.pk.get.attrs, vs)
       } else
 	/** Table has no primkary key (but has some candidate keys). */
 	freshbnode()
     (r.candidates.map(k => {
-      val values:List[CellValue] = k.map(a => t(a))
+      val values:List[CellValue] = k.attrs.map(a => t(a))
       (k, values)
     }), s)
   }
@@ -268,7 +267,7 @@
       if (r.candidates.size > 0) {
 	// Known to have at least one key, so take the first one.
 	val k = r.candidates(0)
-	val vs = t.lexvaluesNoNulls(k)
+	val vs = t.lexvaluesNoNulls(k.attrs)
 	nodes.ultimateReferent(r.name, k, vs, db)
       } else
 	/** Table has no candidate keys. */
@@ -282,7 +281,7 @@
   }
 
   var NextBNode = 97
-  def freshbnode () : Node = {
+  def freshbnode () : BNode = {
     val ret = NextBNode
     NextBNode = NextBNode + 1
     BNode(ret.toChar.toString)
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.