de.unidu.is.annotation.rework.ontology
Class JenaModel

java.lang.Object
  extended byde.unidu.is.annotation.rework.ontology.JenaModel

public class JenaModel
extends java.lang.Object

JenaModel.java Extended Jena model with additional functions.

Author:
Marc Lechtenfeld

Field Summary
protected  java.lang.String DEFAULT_NAMESPACE
          Default namespace of the ontology
protected  com.hp.hpl.jena.rdf.model.InfModel infModel
          Inference model
static int MEMORY
          Memory model
protected  com.hp.hpl.jena.ontology.OntModel model
          Ontology model
protected  java.lang.String namespace
          Ontology namespace
protected  com.hp.hpl.jena.ontology.OntModelSpec ontModelSpec
          ModelSpec
static int PERSISTENT
          Persistent model
protected static java.lang.String REWORK
          Namespace in owl file
 
Constructor Summary
JenaModel()
          Creates a new instance without a model.
JenaModel(int modelType)
          Creates a new instance with the specified model.
JenaModel(int modelType, java.lang.String owlModel)
          Creates a new instance with the specified model and imports the specified owl serialization.
 
Method Summary
 void addAnnotation(JenaModel sourceModel, java.lang.String annotationUri)
          Adds the specified annotation to the model by creating a clone of the individual.
 void addAnnotations(JenaModel sourceModel, java.util.List annotationUris)
          Adds the specified annotations to the model by creating clones of the individuals.
 void addSubClass(java.lang.String parentUri, java.lang.String classUri)
          Adds the subclass classUri to the class parentUri
protected  void createMemoryModel()
          Creates a memory model.
 void createModel(int modelType)
          Creates a new Jena model.
protected  void createPersistentModel()
          Creates a persistent model.
 void createTypesAsAnnotationTypes(java.util.List annotationtypes)
          Declares the specified annotation types as instances of annotation
 java.lang.String getAllAnnotationsRdqlQuery(java.lang.String modelNamespace)
          Returns a rdql query, that returns all annotations
 java.util.List getAllAnnotationUris()
          Returns a list of all annotation URIs
 java.util.List getIndividualURIs(java.lang.String rdqlQuery)
          Returns a list of all instances (URIs), which satisfy the query.
 java.lang.String getNamespace()
          Returns the namespace of the ontology
 com.hp.hpl.jena.ontology.OntModel getOntModel()
          Returns the Jena OntModel object.
 java.lang.String getOwlSerialization()
          Serializes the model
 java.util.List getSubClasses(java.lang.String parentClassUri, boolean direct)
          Returns all subclass names of the class classname
 java.lang.String getUserNamespace(java.lang.String user)
          Returns the user's namespace Example: http://rework.is.informatik.uni-duisburg.de/owl/Alan_Smith#");
 void importOWLFile(java.lang.String owlFileUri)
          Imports an OWL file.
 void importOwlSerialization(java.lang.String owlModel)
          Imports an OWL serialization.
protected  void init()
          Sets the namespace of the model.
 AnnotationIndividual loadAnnotationIndividual(java.lang.String annotationUri)
          Returns a AnnotationIndiviual with the specified URI
 void setNamespace(java.lang.String namespace)
          Sets a new namespace.
 void updateAnnotations(JenaModel sourceModel, java.util.List annotationUris)
          Updates all annotations, which are mentioned in the specified list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERSISTENT

public static final int PERSISTENT
Persistent model

See Also:
Constant Field Values

MEMORY

public static final int MEMORY
Memory model

See Also:
Constant Field Values

REWORK

protected static final java.lang.String REWORK
Namespace in owl file

See Also:
Constant Field Values

model

protected com.hp.hpl.jena.ontology.OntModel model
Ontology model


ontModelSpec

protected final com.hp.hpl.jena.ontology.OntModelSpec ontModelSpec
ModelSpec


infModel

protected com.hp.hpl.jena.rdf.model.InfModel infModel
Inference model


namespace

protected java.lang.String namespace
Ontology namespace


DEFAULT_NAMESPACE

protected final java.lang.String DEFAULT_NAMESPACE
Default namespace of the ontology

See Also:
Constant Field Values
Constructor Detail

JenaModel

public JenaModel()
Creates a new instance without a model. To create the model (persistent or memory) call createModel


JenaModel

public JenaModel(int modelType)
          throws ModelException
Creates a new instance with the specified model.

Parameters:
modelType - Jena model type (JenaModel.PERSISTENT or JenaModel.MEMORY)
Throws:
ModelException - if an model error occurs

JenaModel

public JenaModel(int modelType,
                 java.lang.String owlModel)
          throws ModelException
Creates a new instance with the specified model and imports the specified owl serialization.

Parameters:
modelType - Model type (JenaModel.PERSISTENT or JenaModel.MEMORY)
owlModel - OWL serialization to import
Throws:
ModelException - if an model error occurs
Method Detail

init

protected void init()
             throws ModelException
Sets the namespace of the model.

Throws:
ModelException - if an model error occurs

getNamespace

public java.lang.String getNamespace()
Returns the namespace of the ontology

Returns:
Ontology's namespace

getUserNamespace

public java.lang.String getUserNamespace(java.lang.String user)
                                  throws java.lang.NullPointerException,
                                         java.net.URISyntaxException
Returns the user's namespace Example: http://rework.is.informatik.uni-duisburg.de/owl/Alan_Smith#");

Parameters:
user - Username (without blank)
Returns:
Namespace of the user
Throws:
java.lang.NullPointerException - If user is null
java.net.URISyntaxException - If user name is invalid (as a part of an uri)

setNamespace

public void setNamespace(java.lang.String namespace)
                  throws java.net.URISyntaxException
Sets a new namespace.

Parameters:
namespace - New namespace
Throws:
java.net.URISyntaxException - If namespace is not a valid URI

getOntModel

public com.hp.hpl.jena.ontology.OntModel getOntModel()
                                              throws ModelException
Returns the Jena OntModel object.

Throws:
ModelException - if an model error occurs

createModel

public void createModel(int modelType)
                 throws ModelException
Creates a new Jena model.

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

createPersistentModel

protected void createPersistentModel()
                              throws ModelException
Creates a persistent model. (Database)

Throws:
ModelException - if an model error occurs

createMemoryModel

protected void createMemoryModel()
Creates a memory model.


importOwlSerialization

public void importOwlSerialization(java.lang.String owlModel)
                            throws ModelException
Imports an OWL serialization.

Parameters:
owlModel - Serialized owl model
Throws:
ModelException - if an model error occurs

importOWLFile

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

Parameters:
owlFileUri - URI of the OWL file to import
Throws:
ModelException - if an model error occurs

getOwlSerialization

public java.lang.String getOwlSerialization()
                                     throws ModelException
Serializes the model

Returns:
OWL serialization of the model
Throws:
ModelException

addSubClass

public void addSubClass(java.lang.String parentUri,
                        java.lang.String classUri)
                 throws ModelException,
                        ResourceNotFoundException
Adds the subclass classUri to the class parentUri

Parameters:
parentUri - Parent class of the new class
classUri - New subclass
Throws:
ModelException - if an model error occurs
ResourceNotFoundException - if parent class does not exist

getSubClasses

public java.util.List getSubClasses(java.lang.String parentClassUri,
                                    boolean direct)
                             throws ModelException
Returns all subclass names of the class classname

Parameters:
parentClassUri - URI of the class
direct - Only direct subclasses?
Returns:
List of all subclasses (URIs)
Throws:
ModelException - if an model error occurs

createTypesAsAnnotationTypes

public void createTypesAsAnnotationTypes(java.util.List annotationtypes)
                                  throws ModelException
Declares the specified annotation types as instances of annotation

Parameters:
annotationtypes - List of annotation types (String without namespace)
Throws:
ModelException - if a model error occurs

getIndividualURIs

public java.util.List getIndividualURIs(java.lang.String rdqlQuery)
Returns a list of all instances (URIs), which satisfy the query.

Parameters:
rdqlQuery - rdql Query
Returns:
List of URIs (of instances)

addAnnotation

public void addAnnotation(JenaModel sourceModel,
                          java.lang.String annotationUri)
                   throws ModelException
Adds the specified annotation to the model by creating a clone of the individual.

Parameters:
sourceModel - JenaModel of the specified annotation
annotationUri - URI of the annotation to add
Throws:
ModelException - if a model error occurs

addAnnotations

public void addAnnotations(JenaModel sourceModel,
                           java.util.List annotationUris)
                    throws ModelException
Adds the specified annotations to the model by creating clones of the individuals.

Parameters:
sourceModel - JenaModel of the specified annotation
Throws:
ModelException - if a model error occurs

loadAnnotationIndividual

public AnnotationIndividual loadAnnotationIndividual(java.lang.String annotationUri)
Returns a AnnotationIndiviual with the specified URI

Parameters:
annotationUri - URI of the annotation
Returns:
AnnotationIndividual instance

getAllAnnotationsRdqlQuery

public java.lang.String getAllAnnotationsRdqlQuery(java.lang.String modelNamespace)
Returns a rdql query, that returns all annotations

Parameters:
modelNamespace - Namespace
Returns:
RDQL query

getAllAnnotationUris

public java.util.List getAllAnnotationUris()
                                    throws ModelException
Returns a list of all annotation URIs

Returns:
List of URIs (of annotations)
Throws:
ModelException - if a model exception occurs

updateAnnotations

public void updateAnnotations(JenaModel sourceModel,
                              java.util.List annotationUris)
                       throws ModelException
Updates all annotations, which are mentioned in the specified list

Parameters:
sourceModel - Model of the updated annotations
annotationUris - List of URIs of annotations
Throws:
ModelException