de.unidu.is.annotation.rework.backend
Class JenaAnnotationService

java.lang.Object
  extended byde.unidu.is.annotation.rework.backend.JenaAnnotationService
All Implemented Interfaces:
BackendAnnotationService

public class JenaAnnotationService
extends java.lang.Object
implements BackendAnnotationService

JenaAnnoService.java Jena persistent implementation of the AnnotationSerice interface

Author:
Marc Lechtenfeld

Field Summary
protected  de.unidu.is.retrieval.pire.PIRE ir
          PIRE IR system
 JenaModel model
          JenaModel
protected  int modelType
          JenaModel type
 
Constructor Summary
JenaAnnotationService(int modelType)
          Creates a new JenaAnnoService object with the specified model type
 
Method Summary
 void addAnnotations(java.lang.String owlAnnotation)
          Adds all annotations in the specified OWL serialization.
 void addAnnotationType(java.lang.String userName, java.lang.String parentName, java.lang.String annotypeName)
          Adds a new user defined annotation type.
protected  void addSubClasses(JenaModel resModel, java.lang.String subclass, java.lang.String userName)
          Adds all subclasses of subclass to the specified model.
protected  java.lang.String createPatternQuery(AnnotationIndividual annotationPattern)
          Creates a RDQL query.
protected  de.unidu.is.retrieval.pire.PIRE createPire()
          Creates a new PIRE instance and registers the attribues "test" and "title"
 java.lang.String getAnnotation(java.lang.String annotationUri)
          Returns an OWL serialization with the desired annotation.
 java.lang.String getAnnotationOntology(java.lang.String userName)
          Returns an OWL serialization with all annotation types for a specified user
 java.lang.String getAnnotations(java.lang.String rdqlWhereClause)
          Returns an OWL serialization with all annotations, which satisfy the specified RDQL query.
 java.lang.String getAnnotations(java.lang.String owlAnnotation, java.lang.String fulltext, int numDocs)
          Returns all annotations, which satisfy the specified conditions.
protected  java.lang.String getAnnotationsRDQL(java.lang.String rdqlQuery)
          Returns an OWL serialization with all annotations, which satisfy the specified RDQL query.
 java.lang.String getAnnotationThread(java.lang.String annotableObjectUri)
          Returns an OWL serialization with the desired annotation thread.
protected  java.util.List getAnnotationThreadUris(java.lang.String annotableObjectUri)
          Returns the annotation thread (as list of URIs)
protected  de.unidu.is.retrieval.pire.PIRE getPire()
          Returns the PIRE instance.
protected  void getReplyUris(java.lang.String annotabelObjectUri, java.util.List resUriList)
          Returns all annotations, which annotate the specified annotable object (transitive closure)
protected  java.util.List getResultIntersection(java.util.List searchResults, java.util.List retrievalResults)
          Returns the intersection of the specified lists
 void importBasicOntology()
          Imports the basic ontology.
 void importOwlFile(java.lang.String owlFileUri)
          Imports an OWL file.
 void indexAllAnnotations()
          Indexes all annotations (only title and text) with PIRE
 void modifyAnnotations(java.lang.String userUri, java.lang.String owlAnnotation)
          Replaces all annotations, which are mentioned in the specified ontology, if the annotation is created by the specified user and the annotation has got no childs.
 void removeAnnotation(java.lang.String userUri, java.lang.String annotationUri)
          Removes the annotation with the specified URI, if the annotation is created by the specified user and the annotation has got no childs.
protected  java.util.List retrieveAnnotations(java.lang.String query, int numDocs)
          Returns all relevant annotations (as ProbDoc list)
protected  java.util.List searchAnnotations(java.lang.String owlAnnotation)
          Returns all annotations, which satisfy the specified conditions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

public JenaModel model
JenaModel


modelType

protected int modelType
JenaModel type


ir

protected de.unidu.is.retrieval.pire.PIRE ir
PIRE IR system

Constructor Detail

JenaAnnotationService

public JenaAnnotationService(int modelType)
                      throws ModelException
Creates a new JenaAnnoService object with the specified model type

Parameters:
modelType - Model type (JenaModel.MEMORY or JenaModel.PERSISTENT)
Throws:
ModelException - if a model error occurs
Method Detail

importOwlFile

public void importOwlFile(java.lang.String owlFileUri)
                   throws ModelException
Imports an OWL file.

Parameters:
owlFileUri - URI of the OWL file to be imported
Throws:
ModelException - if a model error occurs

importBasicOntology

public void importBasicOntology()
                         throws ModelException
Imports the basic ontology. See specified OWL file

Throws:
ModelException - if a model error occurs

addAnnotations

public void addAnnotations(java.lang.String owlAnnotation)
                    throws ModelException
Adds all annotations in the specified OWL serialization.

Specified by:
addAnnotations in interface BackendAnnotationService
Parameters:
owlAnnotation - OWL serialization to be imported
Throws:
ModelException - if a model error occurs

getAnnotation

public java.lang.String getAnnotation(java.lang.String annotationUri)
                               throws ModelException,
                                      ResourceNotFoundException
Returns an OWL serialization with the desired annotation.

Specified by:
getAnnotation in interface BackendAnnotationService
Parameters:
annotationUri - URI of the desired annotation
Returns:
OWL serialization with the desired annotation
Throws:
ModelException - if a model error occurs
ResourceNotFoundException - if the desired annotation does not exist

getReplyUris

protected void getReplyUris(java.lang.String annotabelObjectUri,
                            java.util.List resUriList)
Returns all annotations, which annotate the specified annotable object (transitive closure)

Parameters:
annotabelObjectUri - URI of the annotation
resUriList - List of URIs

getAnnotationThreadUris

protected java.util.List getAnnotationThreadUris(java.lang.String annotableObjectUri)
                                          throws ModelException
Returns the annotation thread (as list of URIs)

Parameters:
annotableObjectUri - URI of the annotation
Returns:
List of URIs (annotations)
Throws:
ModelException - if a model error occurs

getAnnotationThread

public java.lang.String getAnnotationThread(java.lang.String annotableObjectUri)
                                     throws ModelException
Returns an OWL serialization with the desired annotation thread.

Specified by:
getAnnotationThread in interface BackendAnnotationService
Parameters:
annotableObjectUri - URI of the annotable object
Returns:
OWL serialization of the thread
Throws:
ModelException

getAnnotationsRDQL

protected java.lang.String getAnnotationsRDQL(java.lang.String rdqlQuery)
                                       throws ModelException
Returns an OWL serialization with all annotations, which satisfy the specified RDQL query.

Parameters:
rdqlQuery - RDQL query
Returns:
OWL serialization
Throws:
ModelException - if a model error occurs

createPatternQuery

protected java.lang.String createPatternQuery(AnnotationIndividual annotationPattern)
Creates a RDQL query.

Parameters:
annotationPattern - Annotation pattern
Returns:
RDQL query

searchAnnotations

protected java.util.List searchAnnotations(java.lang.String owlAnnotation)
                                    throws ModelException
Returns all annotations, which satisfy the specified conditions. A condition will be ignored, if the parameter is null.

Parameters:
owlAnnotation - OWL serialization with annotation pattern
Returns:
List of anntotation URIs
Throws:
ModelException - if a model error occurs

retrieveAnnotations

protected java.util.List retrieveAnnotations(java.lang.String query,
                                             int numDocs)
                                      throws ModelException
Returns all relevant annotations (as ProbDoc list)

Parameters:
query - Terms
numDocs - Number of documents to retrieve
Returns:
List of ProbDoc instances
Throws:
ModelException

getResultIntersection

protected java.util.List getResultIntersection(java.util.List searchResults,
                                               java.util.List retrievalResults)
Returns the intersection of the specified lists

Parameters:
searchResults - List of URIs
retrievalResults - List of ProbDoc instances
Returns:
Intersection (List of ProbDoc instances)

getAnnotations

public java.lang.String getAnnotations(java.lang.String owlAnnotation,
                                       java.lang.String fulltext,
                                       int numDocs)
                                throws ModelException
Returns all annotations, which satisfy the specified conditions. A condition will be ignored, if the parameter is null.

Specified by:
getAnnotations in interface BackendAnnotationService
Parameters:
fulltext - Terms (Only available, if you use the persistent model
numDocs - Maximum number of annotations
Throws:
ModelException

getAnnotations

public java.lang.String getAnnotations(java.lang.String rdqlWhereClause)
                                throws ModelException
Returns an OWL serialization with all annotations, which satisfy the specified RDQL query. Specify only WHERE clause! (Query variable is ?x)

Specified by:
getAnnotations in interface BackendAnnotationService
Parameters:
rdqlWhereClause - RDQL query (Only WHERE clause!)
Returns:
OWL serialization
Throws:
ModelException - if a model error occurs

modifyAnnotations

public void modifyAnnotations(java.lang.String userUri,
                              java.lang.String owlAnnotation)
                       throws ModelException,
                              NoPermissionException
Replaces all annotations, which are mentioned in the specified ontology, if the annotation is created by the specified user and the annotation has got no childs. (The annotations in the database are replaced by the specified annotations.)

Specified by:
modifyAnnotations in interface BackendAnnotationService
Parameters:
userUri - URI of the user, who wants to modify the annotation
owlAnnotation - OWL serialization with modified annotations
Throws:
ModelException - if a model error occurs
NoPermissionException - if user is not the creator of the annotaion or the annotation is not a leaf

removeAnnotation

public void removeAnnotation(java.lang.String userUri,
                             java.lang.String annotationUri)
                      throws ModelException,
                             ResourceNotFoundException,
                             NoPermissionException
Removes the annotation with the specified URI, if the annotation is created by the specified user and the annotation has got no childs.

Specified by:
removeAnnotation in interface BackendAnnotationService
Parameters:
userUri - URI of the user
annotationUri - URI of the annotation to be removed
Throws:
NoPermissionException - if the user has no permission to remove a annotation
ResourceNotFoundException - if a resource does not exist
ModelException - if a model error occurs

addSubClasses

protected void addSubClasses(JenaModel resModel,
                             java.lang.String subclass,
                             java.lang.String userName)
                      throws ModelException,
                             ResourceNotFoundException,
                             java.net.URISyntaxException
Adds all subclasses of subclass to the specified model. (Only subclasses of the user and public subclasses)

Parameters:
resModel - Model to be modified
subclass - Subclass
userName - Username (no URI!)
Throws:
ModelException - if a model error occurs
ResourceNotFoundException - if a resource does not exist
java.net.URISyntaxException - if user name is not valid (as a part of an URI)

getAnnotationOntology

public java.lang.String getAnnotationOntology(java.lang.String userName)
                                       throws ModelException,
                                              ResourceNotFoundException,
                                              java.net.URISyntaxException
Returns an OWL serialization with all annotation types for a specified user

Specified by:
getAnnotationOntology in interface BackendAnnotationService
Parameters:
userName - User name (no URI!)
Returns:
OWL serialization
Throws:
ModelException - if a model error occurs
ResourceNotFoundException - if a resource does not exist
java.net.URISyntaxException - if userUri is not valid

addAnnotationType

public void addAnnotationType(java.lang.String userName,
                              java.lang.String parentName,
                              java.lang.String annotypeName)
                       throws ModelException,
                              ResourceNotFoundException,
                              java.net.URISyntaxException
Adds a new user defined annotation type. The new type will be added as subclass of parentUri and will be linked with the user (userUri).

Specified by:
addAnnotationType in interface BackendAnnotationService
Parameters:
userName - Name of the user
parentName - Name of the super class
annotypeName - Name of new annotation type (only the name, no URI!)
Throws:
java.net.URISyntaxException - if userUri is not valid
ModelException - if a model error occurs
ResourceNotFoundException - if a resource does not exist

getPire

protected de.unidu.is.retrieval.pire.PIRE getPire()
Returns the PIRE instance. If the instance does not exist, a new one will be created.


createPire

protected de.unidu.is.retrieval.pire.PIRE createPire()
Creates a new PIRE instance and registers the attribues "test" and "title"

Returns:
PIRE instance

indexAllAnnotations

public void indexAllAnnotations()
                         throws ModelException
Indexes all annotations (only title and text) with PIRE

Throws:
ModelException - if a model error occurs