Author: reto
Date: Thu Feb 24 17:54:17 2011
New Revision: 1074235
URL: http://svn.apache.org/viewvc?rev=1074235&view=rev
Log:
CLEREZZA-388: introducing VirtualProperties in finder api
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/ResourceFinder.scala
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/WilcardCondition.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=1074235&r1=1074234&r2=1074235&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
Thu Feb 24 17:54:17 2011
@@ -176,7 +176,7 @@ class GraphIndexer(definitions: TripleCo
logger.debug("indexing "+vProperty+" with
values "+(vProperty.value(resource)).length)
for (propertyValue <-
vProperty.value(resource)) {
logger.debug("indexing "+vProperty+"
with value "+(propertyValue))
- doc.add(new Field(vProperty.name,
+ doc.add(new Field(vProperty.stringKey,
propertyValue,
Field.Store.YES,
Field.Index.NOT_ANALYZED))
Modified:
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/ResourceFinder.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/ResourceFinder.scala?rev=1074235&r1=1074234&r2=1074235&view=diff
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/ResourceFinder.scala
(original)
+++
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/ResourceFinder.scala
Thu Feb 24 17:54:17 2011
@@ -42,13 +42,12 @@ trait ResourceFinder {
* Find resource with a properties whose value matches a pattern
*/
def findResources(property: UriRef, pattern: String): List[Resource] = {
+ findResources(new PropertyHolder(property),pattern)
+ }
- /*val query: Query = new TermQuery(new Term(
- FOAF.firstName.getUnicodeString, something))*/
+ def findResources(property: VirtualProperty, pattern: String):
List[Resource] = {
val query: Query = new WildcardQuery(new Term(
- property.getUnicodeString, pattern))
- /*val query: Query = new FuzzyQuery(new Term(
- FOAF.firstName.getUnicodeString, something))*/
+ property.stringKey, pattern))
findResources(WildcardCondition(property, pattern))
}
}
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=1074235&r1=1074234&r2=1074235&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
Thu Feb 24 17:54:17 2011
@@ -24,21 +24,25 @@ import org.apache.clerezza.rdf.scala.uti
import org.apache.clerezza.rdf.scala.utils.Preamble._
abstract class VirtualProperty {
- def name: String
+ /**
+ * As opposed to toString this doesn't need to be human readable but
unique (as with
+ * a strong hash
+ */
+ val stringKey: String
def value(node: RichGraphNode): Seq[String]
}
class PropertyHolder(property: UriRef) extends VirtualProperty {
- def name = property.getUnicodeString
+ val stringKey = property.getUnicodeString
def value(node: RichGraphNode): Seq[String] = for (v <- node/property)
yield v*
}
class JoinVirtualProperty(properties: List[VirtualProperty]) extends
VirtualProperty {
- def name = "Join of ..."
+ val stringKey = "Join of ..."
def value(node: RichGraphNode): Seq[String] = Seq("")
}
class PathVirtualProperty(properties: List[VirtualProperty]) extends
VirtualProperty {
- def name = "Path ..."
+ val stringKey = "Path ..."
def value(node: RichGraphNode): Seq[String] = Seq("")
}
\ No newline at end of file
Modified:
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/WilcardCondition.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/WilcardCondition.scala?rev=1074235&r1=1074234&r2=1074235&view=diff
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/WilcardCondition.scala
(original)
+++
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/WilcardCondition.scala
Thu Feb 24 17:54:17 2011
@@ -24,9 +24,11 @@ import org.apache.lucene.search.Query
import org.apache.lucene.search.WildcardQuery
import org.apache.lucene.index.Term
-case class WildcardCondition(property: UriRef, pattern: String) extends
Condition {
+case class WildcardCondition(property: VirtualProperty, pattern: String)
extends Condition {
+
+ def this(uriRefProperty: UriRef, pattern: String) = this(new
PropertyHolder(uriRefProperty), pattern)
def query: Query = new WildcardQuery(new Term(
- property.getUnicodeString, pattern))
+ property.stringKey, pattern))
}