+ some debugging aids
authorEric Prud'hommeaux <eric@w3.org>
Tue, 02 Nov 2010 16:55:25 -0400
changeset 251 9fcd21747a7d
parent 250 a5f27d9d047a
child 252 ebdbce2c6ea4
+ some debugging aids
directmapping/src/main/scala/DirectMapping.scala
--- a/directmapping/src/main/scala/DirectMapping.scala	Sun Oct 31 20:43:14 2010 -0400
+++ b/directmapping/src/main/scala/DirectMapping.scala	Tue Nov 02 16:55:25 2010 -0400
@@ -27,6 +27,7 @@
 	})
       KeyMap(m2)
     }
+    def contains(ck:CandidateKey) = m.contains(ck)
   }
   case class NodeMap(m:Map[RelName, KeyMap]) {
     def apply(rn:RelName) = m(rn)
@@ -39,6 +40,7 @@
       } else
 	m(rn)(k)(vs)
     }
+    def contains(rn:RelName) = m.contains(rn)
   }
   implicit def list2map (l:Set[(RelName, KeyMap)]):Map[RelName,KeyMap] = l.toMap
   implicit def list2Nmap (l:Set[(RelName, KeyMap)]):NodeMap = NodeMap(l)
@@ -158,6 +160,12 @@
     val p = predicatemap (u, r.name, as)
     val ls:List[LexicalValue] = t.lexvaluesNoNulls(as)
     val target = r.fks(as)
+    if (!nodes.contains(target.rel))
+      error("No referent relation \"" + target.rel + "\" to match " + r.name + t)
+    if (!nodes(target.rel).contains(target.key))
+      error("Relation " + target.rel + " has no attributes (" + target.key + ") to match " + r.name + t)
+    if (!nodes(target.rel)(target.key).contains(ls))
+      error("Relation " + target.rel + "(" + target.key + ") has no values " + ls + " to match " + r.name + t)
     val o:Object = nodes(target.rel)(target.key)(ls)
     Triple(s, p, o)
   }