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

java.lang.Object
  extended by org.ow2.weblab.core.helper.impl.JenaPoKHelper
All Implemented Interfaces:
PoKHelper
Direct Known Subclasses:
JenaPoKHelperExtended

public class JenaPoKHelper
extends java.lang.Object
implements PoKHelper

Implementation of AnnotationHelper based on Jena framework.
You'd rather to load this class using the HelperFactory.

Author:
EADS WebLab Team
See Also:
JenaPoKHelperExtended
To do:
Prevent the direct instantiation of this class.
Date:
2008-01-18

Field Summary
protected  boolean autoCommit
          In auto commit mode, remove and create operations are writing into pok each time they are called.
protected  BackEndJenaHelper bejh
          The Jena model containing the RDF graph
protected  org.ow2.weblab.core.model.PieceOfKnowledge pok
          The current Annotation object loaded
 
Constructor Summary
JenaPoKHelper()
           
 
Method Summary
 void commit()
          A call to commit is needed when PoKHelper do not works in "autoCommitMode".
 void createLitStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String litObj)
          Creates a statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.
 void createLitStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String litObj, java.lang.String language)
          Creates a statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.
 void createResStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String uriObj)
          Creates a statement having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.
 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)
           
 org.ow2.weblab.core.model.PieceOfKnowledge getPoK()
          Retrieve the current PieceOfKnowledge which is manipulated.
 java.util.Set<java.lang.String> getPreds()
           
 java.util.Set<java.lang.String> getPredsOnSubj(java.lang.String uriSubj)
           
 java.lang.String getRdfXml()
           
 java.util.List<java.lang.String> getRessOnPredSubj(java.lang.String uriSubj, java.lang.String uriPred)
           
 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)
           
 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.
 void loadFromRdfXml(java.lang.String rdfXml)
          Loads an RDF/XML String, to be queried.
 void removeLitStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String litObj)
          Removes every statements having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.
 void removeResStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String uriObj)
          Removes every statements having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.
 void removeStatsOnSubj(java.lang.String uriSubj)
          Removes every statements having uriSubj as subject whatever are predicate and object.
 void removeStatsWithLit(java.lang.String litObj)
          Removes every statements having litObj as object literal value whatever are subject and predicate.
 void removeStatsWithPred(java.lang.String uriPred)
          Removes every statements having uriPred as predicate whatever are subject and object.
 void removeStatsWithRes(java.lang.String uriObj)
          Removes every statements having uriObj as object named resource URI value whatever are subject and predicate.
 void setAutoCommitMode(boolean autoCommitMode)
          In auto commit mode, remove and create operations are writing into the PieceOfKnowledge each time they are called.
 void setPoK(org.ow2.weblab.core.model.PieceOfKnowledge pok)
          Fixes the current PieceOfKnowledge which 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

pok

protected org.ow2.weblab.core.model.PieceOfKnowledge pok
The current Annotation object loaded


bejh

protected BackEndJenaHelper bejh
The Jena model containing the RDF graph


autoCommit

protected boolean autoCommit
In auto commit mode, remove and create operations are writing into pok each time they are called. When performing a lot's of actions on the RDF, best practice is to set auto commit mode to false and to commit at the end of the process.

Constructor Detail

JenaPoKHelper

public JenaPoKHelper()
Method Detail

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.

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.

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.

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.

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.

createLitStat

public void createLitStat(java.lang.String uriSubj,
                          java.lang.String uriPred,
                          java.lang.String litObj,
                          java.lang.String language)
Creates a statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.
language - The language of the literal value. See http://www.w3.org/TR/REC-xml/#sec-lang-tag for more information.

createLitStat

public void createLitStat(java.lang.String uriSubj,
                          java.lang.String uriPred,
                          java.lang.String litObj)
Creates a statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.

createResStat

public void createResStat(java.lang.String uriSubj,
                          java.lang.String uriPred,
                          java.lang.String uriObj)
Creates a statement having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
uriObj - The URI of the object resource.

removeLitStat

public void removeLitStat(java.lang.String uriSubj,
                          java.lang.String uriPred,
                          java.lang.String litObj)
Removes every statements having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.

removeResStat

public void removeResStat(java.lang.String uriSubj,
                          java.lang.String uriPred,
                          java.lang.String uriObj)
Removes every statements having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
uriObj - The URI of the object resource.

removeStatsOnSubj

public void removeStatsOnSubj(java.lang.String uriSubj)
Removes every statements having uriSubj as subject whatever are predicate and object.

Parameters:
uriSubj - The URI of the subject resource.

removeStatsWithPred

public void removeStatsWithPred(java.lang.String uriPred)
Removes every statements having uriPred as predicate whatever are subject and object.

Parameters:
uriPred - The URI of the predicate resource.

removeStatsWithLit

public void removeStatsWithLit(java.lang.String litObj)
Removes every statements having litObj as object literal value whatever are subject and predicate.

Parameters:
litObj - The literal value of the object.

removeStatsWithRes

public void removeStatsWithRes(java.lang.String uriObj)
Removes every statements having uriObj as object named resource URI value whatever are subject and predicate.

Parameters:
uriObj - The URI of the object resource. The URI of the object resource.

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.

setAutoCommitMode

public void setAutoCommitMode(boolean autoCommitMode)
Description copied from interface: PoKHelper
In auto commit mode, remove and create operations are writing into the PieceOfKnowledge each time they are called. When performing a lot's of actions on the RDF, best practice is to set auto commit mode to false and to commit at the end of the process.

Specified by:
setAutoCommitMode in interface PoKHelper
Parameters:
autoCommitMode - Whether or not to commit any changes (made by create and remove operations) on 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.

getRdfXml

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

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.

commit

public void commit()
Description copied from interface: PoKHelper
A call to commit is needed when PoKHelper do not works in "autoCommitMode". Other with this call is not needed.

Specified by:
commit in interface PoKHelper
See Also:
PoKHelper.setAutoCommitMode(boolean)

getPoK

public org.ow2.weblab.core.model.PieceOfKnowledge getPoK()
Description copied from interface: PoKHelper
Retrieve the current PieceOfKnowledge which is manipulated. Please not that this will not commit any changes made into the RDF/XML if PoKHelper do not works in "autoCommitMode" and if you did not call PoKHelper.commit() method.

Specified by:
getPoK in interface PoKHelper
Returns:
The loaded PieceOfKnowledge.

setPoK

public void setPoK(org.ow2.weblab.core.model.PieceOfKnowledge pok)
Description copied from interface: PoKHelper
Fixes the current PieceOfKnowledge which is manipulated by the helper. Note that using an PoKHelper without PieceOfKnowledge will throw RuntimeException.

Specified by:
setPoK in interface PoKHelper
Parameters:
pok - An existing PieceOfKnowledge

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.

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.