Author: reto
Date: Sun Mar  6 11:53:15 2011
New Revision: 1078454

URL: http://svn.apache.org/viewvc?rev=1078454&view=rev
Log:
CLEREZZA-388: passing test for path-virtual properties

Modified:
    
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
    
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/IndexDefinitionManager.scala
    
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala

Modified: 
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala?rev=1078454&r1=1078453&r2=1078454&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
 Sun Mar  6 11:53:15 2011
@@ -78,19 +78,25 @@ class GraphIndexer(definitionGraph: Trip
                val definitionsPreamble = new Preamble(definitionGraph)
                import definitionsPreamble._
                def asVirtualProperty(r:  RichGraphNode): VirtualProperty = {
-                               lazy val propertyList = {
+                               lazy val vPropertyList = {
                                        import collection.JavaConversions._
                                        (for (childPropertyResource <- new 
RdfList(r/CRIS.propertyList)) yield {
                                                
asVirtualProperty(childPropertyResource)
                                        }).toList
                                }
+        lazy val uriPropertyList = {
+                                       import collection.JavaConversions._
+                                       (for (childPropertyResource <- new 
RdfList(r/CRIS.propertyList)) yield {
+                                               
childPropertyResource.asInstanceOf[UriRef]
+                                       }).toList
+                               }
                          if (r.hasProperty(RDF.`type`, 
CRIS.JoinVirtualProperty)) {
                                        import collection.JavaConversions._
-                                       new JoinVirtualProperty(propertyList)
+                                       new JoinVirtualProperty(vPropertyList)
                                } else {
                                        if (r.hasProperty(RDF.`type`, 
CRIS.PathVirtualProperty)) {
             import collection.JavaConversions._
-            new PathVirtualProperty(propertyList)
+            new PathVirtualProperty(uriPropertyList)
           } else {
             //TODO add other cases
             if ((r!).isInstanceOf[UriRef]) {

Modified: 
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/IndexDefinitionManager.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/IndexDefinitionManager.scala?rev=1078454&r1=1078453&r2=1078454&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/IndexDefinitionManager.scala
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/IndexDefinitionManager.scala
 Sun Mar  6 11:53:15 2011
@@ -71,7 +71,7 @@ trait IndexDefinitionManager {
           definitionGraph.add(new TripleImpl(virtualProperty, 
CRIS.propertyList, listBNode))
           val rdfList = new RdfList(listBNode, definitionGraph)
           for (p <- l) {
-            rdfList.add(asResource(p))
+            rdfList.add(p)
           }
           virtualProperty
         }

Modified: 
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala?rev=1078454&r1=1078453&r2=1078454&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala
 Sun Mar  6 11:53:15 2011
@@ -46,13 +46,22 @@ case class JoinVirtualProperty(propertie
        def value(node: RichGraphNode): Seq[String] = Seq(singleValue(node))
 }
 
-case class PathVirtualProperty(properties: List[VirtualProperty]) extends 
VirtualProperty {
-       val stringKey = "J"+VirtualProperty.listDigest(properties)
-       def value(node: RichGraphNode): Seq[String] = Seq("")
+case class PathVirtualProperty(properties: List[UriRef]) extends 
VirtualProperty {
+       val stringKey = "J"+VirtualProperty.listDigest(for (p <- properties) 
yield PropertyHolder(p))
+       def value(node: RichGraphNode): Seq[String] =  {
+   def getPathResults(node: RichGraphNode, properties: List[UriRef]): 
Seq[String] = {
+     if (properties.size == 1) {
+       PropertyHolder(properties.head).value(node)
+     } else {
+       (for (v <- node/properties.head) yield getPathResults(v, 
properties.tail)).flatten
+     }
+   }
+   getPathResults(node, properties)
+  }
 }
 
 object VirtualProperty {
-  def listDigest(properties: List[VirtualProperty]) = {
+  protected[cris] def listDigest(properties: List[VirtualProperty]) = {
     val longString = (for (p <- properties) yield {
       p.stringKey
     }).mkString("|")


Reply via email to