changeset 17:5653130b620a

+ 2 Employees test
author Eric Prud'hommeaux <eric@w3.org>
date Tue, 08 Jun 2010 16:58:32 -0400
parents add26642a710 (current diff) edc6c17a664d (diff)
children c7cca0b31bb9
files
diffstat 1 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/scala/Main.scala	Tue Jun 08 16:55:37 2010 -0400
+++ b/src/main/scala/Main.scala	Tue Jun 08 16:58:32 2010 -0400
@@ -127,20 +127,22 @@
   }
 
   def cellmap (u:StemIRI, rn:RelName, h:Header, a:AttrName, s:IRI, t:Tuple) : Option[Triple] = {
-    if (h.pk.find(x => x == a) != None)
-      None
-    else
-      lexvalue(h, t, a) match {
-	case ☹() => None
-	case l:LexicalValue => {
-	  val p = predicatemap (u, rn, a)
-	  val o = h.fks.get(a) match {
-  	    case Some(target:Target) => ObjectIRI(nodemap(u, target.rel, target.attr, l))
-	    case None => ObjectLiteral(literalmap(l, sqlDatatype(h, a)))
-	  }
-	  Some(Triple(s, p, o))
-	}
+    def hasForeignKeys(a:AttrName):Boolean = h.fks.get(a).isDefined
+    lexvalue(h, t, a) match {
+      case _ if h.pk contains a => None
+      case ☹()                  => None
+      case l:LexicalValue if hasForeignKeys(a) => {
+	val target = h.fks(a)
+	val p = predicatemap (u, rn, a)
+	val o = ObjectIRI(nodemap(u, target.rel, target.attr, l))
+	Some(Triple(s, p, o))
       }
+      case l:LexicalValue => {
+	val p = predicatemap (u, rn, a)
+	val o = ObjectLiteral(literalmap(l, sqlDatatype(h, a)))
+	Some(Triple(s, p, o))
+      }
+    }
   }
 
   def nodemap (u:StemIRI, rn:RelName, a:AttrName, l:LexicalValue) : IRI =
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.