org.weblab_project.core.helper.impl
Class TripleSelectors

java.lang.Object
  extended by org.weblab_project.core.helper.impl.TripleSelectors
Direct Known Subclasses:
ComplexTripleSelector

public class TripleSelectors
extends java.lang.Object

Selectors Helper to ease annotations retrieval. Annotations triples are referenced by WTriple in which subject and object can be references to WebLab Resources. By default, it transforms reified triples as normal triples. It is useful if you just bother on data selection. Example:
List<WTriple> results = findInResource(myResource, null, "http://www.weblab-project.org/gld-country", null);

Author:
EADS WebLab Team
Date:
2009-03-11

Field Summary
static boolean debug
           
 boolean limit
           
static boolean multi
           
 boolean supportNullData
           
 java.lang.String[] uris
           
 
Constructor Summary
TripleSelectors()
           
TripleSelectors(boolean supportNullData, java.lang.String... uris)
           
 
Method Summary
protected  java.util.List<WTriple> applySelection(org.w3c.dom.Node data, com.hp.hpl.jena.graph.Node s, com.hp.hpl.jena.graph.Node p, com.hp.hpl.jena.graph.Node o, java.lang.String text, org.weblab_project.core.model.Resource annotated, java.util.List<org.weblab_project.core.model.Resource> resources, org.weblab_project.core.model.PieceOfKnowledge annotation)
           
protected  java.util.List<org.weblab_project.core.model.Resource> copyAndAdd(java.util.List<org.weblab_project.core.model.Resource> resources, org.weblab_project.core.model.Resource r)
          Copies a list of resources and add an object
protected  java.util.List<WTriple> find(org.weblab_project.core.model.PieceOfKnowledge annotation, com.hp.hpl.jena.graph.Node subject, com.hp.hpl.jena.graph.Node predicate, com.hp.hpl.jena.graph.Node object, java.lang.String text, org.weblab_project.core.model.Resource annotated, java.util.List<org.weblab_project.core.model.Resource> resources)
          Select RDF Triplet in an annotation
 java.util.List<WTriple> findInResource(org.weblab_project.core.model.Resource resource, Filter filter)
          Select WTriple in the resource according to constrains in a filter.
 java.util.List<WTriple> findInResource(org.weblab_project.core.model.Resource resource, java.lang.String subject, java.lang.String predicate, java.lang.String object)
          Select Triplet (Subject, Predicate, Object) in the resource and its sub elements (Segments, Annotations, sub-MediaUnit ...).
 java.util.List<WTriple> findInResource(org.weblab_project.core.model.Resource resource, java.lang.String subject, java.lang.String predicate, java.lang.String object, boolean reif)
          Select WTriple in resource according to given subject, predicate and object.
protected  java.util.List<WTriple> findMT(org.weblab_project.core.model.PieceOfKnowledge annotation, com.hp.hpl.jena.graph.Node subject, com.hp.hpl.jena.graph.Node predicate, com.hp.hpl.jena.graph.Node object, java.lang.String text, org.weblab_project.core.model.Resource annotated, java.util.List<org.weblab_project.core.model.Resource> resources)
           
 void limitToFirstLevelAnnotation(boolean limit)
           
protected static com.hp.hpl.jena.rdf.model.Model loadModel(org.w3c.dom.Node data)
          Load a model really fast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

limit

public boolean limit

debug

public static boolean debug

supportNullData

public boolean supportNullData

multi

public static boolean multi

uris

public transient java.lang.String[] uris
Constructor Detail

TripleSelectors

public TripleSelectors()

TripleSelectors

public TripleSelectors(boolean supportNullData,
                       java.lang.String... uris)
Method Detail

limitToFirstLevelAnnotation

public void limitToFirstLevelAnnotation(boolean limit)

findInResource

public java.util.List<WTriple> findInResource(org.weblab_project.core.model.Resource resource,
                                              java.lang.String subject,
                                              java.lang.String predicate,
                                              java.lang.String object)
Select Triplet (Subject, Predicate, Object) in the resource and its sub elements (Segments, Annotations, sub-MediaUnit ...). If subject, predicate or object is null, it acts as a wildcard parameter. Here is an example how to retrieve all Triplets which match the property "http://www.weblab-project.org/gld-country"

List<WTriple> results: findInResource(myResource, null, "http://www.weblab-project.org/gld-country", null);

Parameters:
subject - the subject that should match in the triplet (can be null)
predicate - the predicate that should match in the triplet (can be null)
object - the object that should match in the triplet (can be null)
Returns:
a list of WTriple that match the subject, predicate and object.

findInResource

public java.util.List<WTriple> findInResource(org.weblab_project.core.model.Resource resource,
                                              java.lang.String subject,
                                              java.lang.String predicate,
                                              java.lang.String object,
                                              boolean reif)
Select WTriple in resource according to given subject, predicate and object. Null parameters act as wildcard. It will recursively loop through Resource structure (children and their annotations) to retrieve RDF in annotations.

Parameters:
resource - a WebLab Resource on which there are annotations containing RDF
subject - the subject that should match in the triplet (can be null)
predicate - the predicate that should match in the triplet (can be null)
object - the object that should match in the triplet (can be null)
reif - if true, reified triple will not be aggregated
Returns:
a list of WTriple that match the subject, predicate and object.

findInResource

public java.util.List<WTriple> findInResource(org.weblab_project.core.model.Resource resource,
                                              Filter filter)
Select WTriple in the resource according to constrains in a filter.

Parameters:
resource - a WebLab Resource on which there are annotations containing RDF
filter - a set of constrains

copyAndAdd

protected java.util.List<org.weblab_project.core.model.Resource> copyAndAdd(java.util.List<org.weblab_project.core.model.Resource> resources,
                                                                            org.weblab_project.core.model.Resource r)
Copies a list of resources and add an object

Parameters:
resources - list of resources
r - a resource
Returns:
a copy the list and add the resource r

find

protected java.util.List<WTriple> find(org.weblab_project.core.model.PieceOfKnowledge annotation,
                                       com.hp.hpl.jena.graph.Node subject,
                                       com.hp.hpl.jena.graph.Node predicate,
                                       com.hp.hpl.jena.graph.Node object,
                                       java.lang.String text,
                                       org.weblab_project.core.model.Resource annotated,
                                       java.util.List<org.weblab_project.core.model.Resource> resources)
Select RDF Triplet in an annotation

Parameters:
annotation - an annotation
subject - the subject that should match in the triplet (can be null)
predicate - the predicate that should match in the triplet (can be null)
object - the object that should match in the triplet (can be null)
text - the text associated with the annotation if any
resources - the parent resources
Returns:
a list of triplet which matches the data in the annotation.

findMT

protected java.util.List<WTriple> findMT(org.weblab_project.core.model.PieceOfKnowledge annotation,
                                         com.hp.hpl.jena.graph.Node subject,
                                         com.hp.hpl.jena.graph.Node predicate,
                                         com.hp.hpl.jena.graph.Node object,
                                         java.lang.String text,
                                         org.weblab_project.core.model.Resource annotated,
                                         java.util.List<org.weblab_project.core.model.Resource> resources)

loadModel

protected static com.hp.hpl.jena.rdf.model.Model loadModel(org.w3c.dom.Node data)
Load a model really fast

Parameters:
data - a DOM
Returns:
a Jena Model

applySelection

protected java.util.List<WTriple> applySelection(org.w3c.dom.Node data,
                                                 com.hp.hpl.jena.graph.Node s,
                                                 com.hp.hpl.jena.graph.Node p,
                                                 com.hp.hpl.jena.graph.Node o,
                                                 java.lang.String text,
                                                 org.weblab_project.core.model.Resource annotated,
                                                 java.util.List<org.weblab_project.core.model.Resource> resources,
                                                 org.weblab_project.core.model.PieceOfKnowledge annotation)


Copyright © 2004-2010. All Rights Reserved.