org.ow2.weblab.core.helper.impl
Class JenaResourceHelper

java.lang.Object
  extended by org.ow2.weblab.core.helper.impl.JenaResourceHelper
All Implemented Interfaces:
ResourceHelper
Direct Known Subclasses:
JenaResourceHelperExtended, JenaSingleResourceHelper

public class JenaResourceHelper
extends java.lang.Object
implements ResourceHelper

This is an implementation of the ResourceHelper. It loads every Annotations that are on this object and in the inner Resources. If the loaded Resource is an Annotation, its content won't be loaded.

Author:
EADS WebLab Team
To do:
Prevent the direct instantiation of this class.
Date:
2008-11-25

Field Summary
protected  BackEndJenaHelper bejh
          An handler for the Jena model behind.
protected  org.ow2.weblab.core.model.Resource resource
          The current Resource object loaded.
protected  java.util.Map<java.lang.String,org.ow2.weblab.core.model.Resource> resourcesMap
          Map to remember the mapping between sub-resources and resource URIs
 
Constructor Summary
JenaResourceHelper()
           
 
Method Summary
protected  void addComposedQuery(org.ow2.weblab.core.model.ComposedQuery cq)
           
protected  void addComposedResource(org.ow2.weblab.core.model.ComposedResource rc)
           
protected  void addDocument(org.ow2.weblab.core.model.Document cu)
           
protected  void addMediaUnit(org.ow2.weblab.core.model.MediaUnit mu)
           
protected  void addPieceOfKnowledge(org.ow2.weblab.core.model.PieceOfKnowledge pok)
           
protected  void addResource(org.ow2.weblab.core.model.Resource res)
          Method recursively called to add every resources in the model and in the map.
protected  void addResultSet(org.ow2.weblab.core.model.ResultSet rs)
           
protected  void addSimilarityQuery(org.ow2.weblab.core.model.SimilarityQuery sq)
           
 java.util.List<java.lang.String> getLitsOnPredSubj(java.lang.String uriSubj, java.lang.String uriPred)
           
 java.util.List<java.lang.String> getLitsOnPredSubj(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String language)
           
 java.util.Set<java.lang.String> getPreds()
           
 java.util.Set<java.lang.String> getPredsOnSubj(java.lang.String uriSubj)
           
 java.lang.String getRdfXml()
           
 org.ow2.weblab.core.model.Resource getResource()
           
 org.ow2.weblab.core.model.Resource getResource(java.lang.String uri)
           
 java.util.List<java.lang.String> getRessOnPredSubj(java.lang.String uriSubj, java.lang.String uriPred)
           
<T extends org.ow2.weblab.core.model.Resource>
T
getSpecificResource(java.lang.String uri, java.lang.Class<T> specificClass)
           
 java.util.Set<java.lang.String> getSubjs()
           
 java.util.Set<java.lang.String> getSubjsOnPred(java.lang.String uriPred)
           
 java.util.Set<java.lang.String> getSubjsOnPredLit(java.lang.String uriPred, java.lang.String litObj)
           
 java.util.Set<java.lang.String> getSubjsOnPredRes(java.lang.String uriPred, java.lang.String uriObj)
           
 java.lang.Class<? extends org.ow2.weblab.core.model.Resource> getType(java.lang.String uri)
           
 boolean hasLitStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String litObj)
           
 boolean hasResStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String uriObj)
           
 boolean isDefinedResource(java.lang.String uri)
          Tests if the given URI is defined as a named resource in the PieceOfKnowledge.
 boolean isFullyDefinedResource(java.lang.String uri)
           
 void loadFromRdfXml(java.lang.String rdfXml)
          Loads an RDF/XML String, to be queried.
protected  void loadFromRdfXml(java.lang.String rdfXml, boolean add)
           
 void setResource(org.ow2.weblab.core.model.Resource resource)
          Fixes the current Resource that is manipulated by the helper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resource

protected org.ow2.weblab.core.model.Resource resource
The current Resource object loaded.


resourcesMap

protected java.util.Map<java.lang.String,org.ow2.weblab.core.model.Resource> resourcesMap
Map to remember the mapping between sub-resources and resource URIs


bejh

protected BackEndJenaHelper bejh
An handler for the Jena model behind.

Constructor Detail

JenaResourceHelper

public JenaResourceHelper()
Method Detail

getResource

public org.ow2.weblab.core.model.Resource getResource(java.lang.String uri)
                                               throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
Specified by:
getResource in interface ResourceHelper
Parameters:
uri - The URI of a Resource that must be defined in RDF statements and in the Resource tree.
Returns:
A Resource, which is a sub-resource of the Resource behind this helper, and that its URI is uri.
Throws:
org.ow2.weblab.core.extended.exception.WebLabCheckedException - If uri is not a valid Resource and a defined URI in RDF.

getSpecificResource

public <T extends org.ow2.weblab.core.model.Resource> T getSpecificResource(java.lang.String uri,
                                                                            java.lang.Class<T> specificClass)
                                                                 throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
Specified by:
getSpecificResource in interface ResourceHelper
Type Parameters:
T - The real class of the Resource to load.
Parameters:
uri - The URI of a Resource that must be defined in RDF statements and in the Resource tree.
specificClass - The class of the Resource represented by uri.
Returns:
A Resource, which is a sub-resource of the Resource behind this helper, and that its URI is uri.
Throws:
org.ow2.weblab.core.extended.exception.WebLabCheckedException - If uri is not a valid Resource and a defined URI in RDF.

getType

public java.lang.Class<? extends org.ow2.weblab.core.model.Resource> getType(java.lang.String uri)
                                                                      throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
Specified by:
getType in interface ResourceHelper
Parameters:
uri - The URI of a Resource that must be defined in RDF statements and in the Resource tree.
Returns:
The class of the Resource represented by uri.
Throws:
org.ow2.weblab.core.extended.exception.WebLabCheckedException - If uri is not a valid Resource and a defined URI in RDF.

setResource

public void setResource(org.ow2.weblab.core.model.Resource resource)
Description copied from interface: ResourceHelper
Fixes the current Resource that is manipulated by the helper.
It also process resource to load every Annotation that are present in its Resource tree.

Specified by:
setResource in interface ResourceHelper
Parameters:
resource - The Resource to be considered by this helper.

addResource

protected void addResource(org.ow2.weblab.core.model.Resource res)
Method recursively called to add every resources in the model and in the map.

Parameters:
res - The resource to add.

addSimilarityQuery

protected void addSimilarityQuery(org.ow2.weblab.core.model.SimilarityQuery sq)
Parameters:
sq - The similarity query to add.

addComposedQuery

protected void addComposedQuery(org.ow2.weblab.core.model.ComposedQuery cq)
Parameters:
cq - The composed unit to add.

addComposedResource

protected void addComposedResource(org.ow2.weblab.core.model.ComposedResource rc)
Parameters:
rc - The resourceCollection to add.

addResultSet

protected void addResultSet(org.ow2.weblab.core.model.ResultSet rs)
Parameters:
rs - The resultSet to add.

addPieceOfKnowledge

protected void addPieceOfKnowledge(org.ow2.weblab.core.model.PieceOfKnowledge pok)
Parameters:
a - The pok to add.

addMediaUnit

protected void addMediaUnit(org.ow2.weblab.core.model.MediaUnit mu)
Parameters:
mu - The mediaUnit to add.

addDocument

protected void addDocument(org.ow2.weblab.core.model.Document cu)
Parameters:
cu -

getLitsOnPredSubj

public java.util.List<java.lang.String> getLitsOnPredSubj(java.lang.String uriSubj,
                                                          java.lang.String uriPred)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
Returns:
A List containing values of every literal that are object of statements having uriPred as predicate and uriSubj as subject in the PieceOfKnowledge.

getPredsOnSubj

public java.util.Set<java.lang.String> getPredsOnSubj(java.lang.String uriSubj)
Parameters:
uriSubj - The URI of the subject resource.
Returns:
A Set containing URIs of every named resources that are predicate of any statement having uriSubj as subject in the PieceOfKnowledge.

getRessOnPredSubj

public java.util.List<java.lang.String> getRessOnPredSubj(java.lang.String uriSubj,
                                                          java.lang.String uriPred)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
Returns:
A List containing URIs of every named resources that are object of statements having uriPred as predicate and uriSubj as subject in the PieceOfKnowledge.

getSubjs

public java.util.Set<java.lang.String> getSubjs()
Returns:
A Set containing URIs of every named resources that are subject of any statement in the PieceOfKnowledge.

getSubjsOnPred

public java.util.Set<java.lang.String> getSubjsOnPred(java.lang.String uriPred)
Parameters:
uriPred - The URI of the predicate resource.
Returns:
A Set containing URIs of every named resources that are subject of statements having uriPred as predicate in the PieceOfKnowledge.

getSubjsOnPredLit

public java.util.Set<java.lang.String> getSubjsOnPredLit(java.lang.String uriPred,
                                                         java.lang.String litObj)
Parameters:
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.
Returns:
A Set containing URIs of every named resources that are subject of statements having uriPred as predicate and litObj as object literal value in the PieceOfKnowledge.

getSubjsOnPredRes

public java.util.Set<java.lang.String> getSubjsOnPredRes(java.lang.String uriPred,
                                                         java.lang.String uriObj)
Parameters:
uriPred - The URI of the predicate resource.
uriObj - The URI of the object resource.
Returns:
A Set containing URIs of every named resources that are subject of statements having uriPred as predicate and uriObj as object named resource URI in the PieceOfKnowledge.

hasLitStat

public boolean hasLitStat(java.lang.String uriSubj,
                          java.lang.String uriPred,
                          java.lang.String litObj)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.
Returns:
Whether or not the PieceOfKnowledge contains at least one statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.

hasResStat

public boolean hasResStat(java.lang.String uriSubj,
                          java.lang.String uriPred,
                          java.lang.String uriObj)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
uriObj - The URI of the object resource.
Returns:
Whether or not the PieceOfKnowledge contains at least one statement having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.

isDefinedResource

public boolean isDefinedResource(java.lang.String uri)
Tests if the given URI is defined as a named resource in the PieceOfKnowledge.

Parameters:
uri - The URI to test existence in the PieceOfKnowledge.
Returns:
true if the URI is defined as a named resource URI in the PieceOfKnowledge.

loadFromRdfXml

public void loadFromRdfXml(java.lang.String rdfXml)
                    throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
Loads an RDF/XML String, to be queried.

Parameters:
rdfXml - A RDF/XML content to be loaded.
Throws:
org.ow2.weblab.core.extended.exception.WebLabCheckedException - If the rdfXml is not an RDF/XML valid String.

loadFromRdfXml

protected void loadFromRdfXml(java.lang.String rdfXml,
                              boolean add)
Parameters:
rdfXml - An RDF/XML String to be loaded or added to teh current model
add - Whether to add rdfXml to current model or to create a new model from scratch.

getResource

public org.ow2.weblab.core.model.Resource getResource()
Specified by:
getResource in interface ResourceHelper
Returns:
The upper level Resource currently handled by the helper.

isFullyDefinedResource

public boolean isFullyDefinedResource(java.lang.String uri)
Specified by:
isFullyDefinedResource in interface ResourceHelper
Parameters:
uri - An URI to test existence in RDF and in loaded sub-resources.
Returns:
Whether or not uri represents a WebLab Resource present in Resource tree and an RDF resource.

getPreds

public java.util.Set<java.lang.String> getPreds()
Returns:
A Set containing URIs of properties that are predicate of any statement in the PieceOfKnowledge.

getRdfXml

public java.lang.String getRdfXml()
Returns:
A valid RDF/XML String of the current changed made.

getLitsOnPredSubj

public java.util.List<java.lang.String> getLitsOnPredSubj(java.lang.String uriSubj,
                                                          java.lang.String uriPred,
                                                          java.lang.String language)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
language - The xml:lang attribute for this literal.
Returns:
A List containing values in language language of every literal that are object of statements having uriPred as predicate and uriSubj as subject in the PieceOfKnowledge. For more information about language attribute, see http://www.w3.org/TR/REC-xml/#sec-lang-tag.


Copyright © 2004-2010. All Rights Reserved.