org.semanticdesktop.nepomuk.comp.pimoservice.client
Class ClientSession

java.lang.Object
  extended by org.semanticdesktop.nepomuk.comp.pimoservice.client.DiffModelSet
      extended by org.semanticdesktop.nepomuk.comp.pimoservice.client.ClientSession
All Implemented Interfaces:
TaggingSession

public class ClientSession
extends DiffModelSet
implements TaggingSession

A ModelSet that helps editing RDF data in memory. This class supports editing one or more resources in-memory. Attention Your changes will be only in the repository, if you have called commit(). This means, that you can not find the statements in the store, if you call getMainRepository() from the PimoClient. Also the PimoQuery can't find statements which are not commited from the session. To get more information, see the WikiPage

Automatic creation of Contexts and the MagicModel

Invoking the methods getMagicModel() or any of the manipulating methods will automatically create a new NRL context in the session, together with correct NRL annotations and good metadata. If you want to get things done, use the MagicModel whereever possible and add all your triples to it. Note that you have to commit after doing changes:

The session: changes, commit, rollback, and restrictions

To manipulate data in the session, the getMagicModel(), getWorkModel() and DiffModelSet.getWorkModelSet() models should be used. MagicModel uses the WorkModelSet. These models are caching add/delete operations. The models behave as if the changes were already committed, but do not change the repository unitl commit() is called. Important: the caching of changes only works on the level of find(spo) operations, they are implemented as if the changes were already committed. SPARQL is not supported.. Changes are committed back to the database when calling "commit". Commit and rollback both set the session to be disposed. You need to either call commit() or rollback() to end a session, otherwise resources will remain open and may cause a memory leak. A warning will be logged if you don't call commit or rollback. You can keep using a ClientSession after it was commited.

Logging of changes

Changes of resources are logged. Only changes to resources within the workmodel are logged, also any changes to resources done through the magic model are logged (the magic model can cause changes in other models than the work model).

Buffering and PIMO closure inference

To speed up find() calls, triples can be buffered in a ClientSession. Call #bufferResource() to do that. Buffers are thrown away on commit or rollback calls. The buffer can also be flushed manually using DiffModelSet.bufferFlush(). The buffer is also reused for PIMO closure inference. The method bufferResourceClosure(URI, URI) will add facts about a pimo thing taken from occurrences of the thing. To realize some sophisticated Semantic Web tricks (such as Open Linked Data), it is also allowed to add triples to the buffer explcitly. Use bufferAdd(Model) to add triples to the model that should be interpreted "as if they were in the RDF repository" for read operations. Note that, as with the normal WorkModelSet, all buffer operations work on the level of find(spo) queries, and SPARQL is not supported. TODO: edit ontologies validate triples on insert setThingLabel(URI thing, String label) IDEAS for improvement: * all changes are in a database transaction * there is no buffering of changes, commit and rollback do the necessary * SPARQL queries are shot through to the database commit and rollback work only once. Why: the programmer would like to have all data from the database. The three classes PimoClient, ClientSession, PimoQuery, are under constant change, and are improved based on your requirements and feedback. Any e-mail to cop-implementation@nepomuk.semanticdesktop.org greatly welcome.

We (Gunnar and Leo) thought about renaming ClientSession to PimoSession in May 2007, but the word PIMO is too precise here, actually its more a Nepomuk session, therefore we decided to leave this name as it is.


Field Summary
protected  java.util.Set<URI> changedResources
          resources that were changed, as logged by the DiffModelSet since the last commit.
static URI DIRECT_SUBCLASS
           
static URI DIRECT_SUBPROPERTY
           
static URI INVERSE_PROPERTY
          The INVERSE and DIRECT properties are copied from CrappyInferencingConnection.
static java.lang.String SPARQL_PREAMBLE
          use this in most SPARQL queries
protected  Model workModel
          model in which new triples are added.
protected  boolean workmodelinitialized
          set to true, when the first triple is added/removed to the workmodel and the wormodel is initialized.
 
Fields inherited from class org.semanticdesktop.nepomuk.comp.pimoservice.client.DiffModelSet
added, buffer, bufferedResources, filteredLanguageCode, log, manipulatedBuffer, removed, source, workmodelset
 
Constructor Summary
protected ClientSession(PimoClient pimoClient, URI editorDocumentType)
          Create a new ClientSession.
protected ClientSession(PimoClient pimoClient, URI editorDocumentType, URI ontologyToEdit, boolean createNew)
          Create a new ClientSession, and create a new Domain Ontology.
 
Method Summary
 void addOntology(URI ontologyUri, java.io.InputStream ontology, Syntax syntax)
          add the passed ontology to the main repository.
 void addOntology(URI ontologyUri, Model ontology)
          add the passed ontology to the main repository.
 void addOntology(URI ontologyUri, Model ontology, URI metadataUri, Model metadata)
          add the passed ontology to the main repository.
 void addTag(URI resource, URI tag)
          adds a tag to a resource.
protected  void assertClass(URI clazz)
          check if the passed URI is a class and throw an exception if not
protected  void assertProperty(URI property)
          check if the passed URI is a property and throw an exception if not
protected  void assertResource(URI resource, URI clazz)
          check if the passed URI is an instance of the passed class and throw an exception if not
protected  void assertWriteableModel(URI modelUri)
          check if the passed ontology is Writeable by the user.
protected  void assertWriteableResource(URI resource, java.lang.String attemptedaction)
          check if the passed resource can be changed by the user.
protected  void beforeCommit()
          Before committing, note the change dates of changed resources.
 void bufferAdd(Model model)
          Include the passed triples in the internal buffer model.
 void bufferOpenLinkedData(URI resource)
          When the resource has a statement like PIMO:hasOtherRepresentation or RDFS:seeAlso this methoeds loads the data "linked data" in the workModel.
 void bufferResourceClosure(URI resource, URI closuretype)
          Experimental: load a resource into the working ModelSet and buffer its PIMO closure.
 void changeTypeOfResource(URI resourceUri, URI oldclass, URI newclass)
          change the type of a resource.
 void checkOntology(URI ontologyUri, java.io.InputStream ontology, Syntax syntax, boolean loadImportsRecursively)
          check if the passed ontology is a valid Information Model.
 void checkOntology(URI ontologyUri, java.io.Reader ontology, Syntax syntax, boolean loadImportsRecursively)
          check if the passed ontology is a valid Information Model.
 void close()
          dispose all changes that were made in-memory, close the in-memory models.
 void commit()
          Store the current DIFF to the server.
 boolean containsOntology(URI ontologyUri)
          true if the ontology is in the named graphs of the repo
 int copyIdentifiers(URI target, URI source)
          Copies the identifiers of the given source occurrence to the passed target PIMO thing.
 int copyIdentifiers(URI target, URI source, ModelSet sourceModelSet)
          Copies the identifiers of the given source occurrence to the passed target PIMO thing.
 URI createClass(java.lang.String name, URI superClass)
          Create a new class for the user, it gets typed an rdfs:Class.
protected  URI createContext()
           
 URI createProperty(java.lang.String name, URI superProperty)
          create a new property in the user's pimo.
 URI createPropertyNameInverse(java.lang.String name, URI superProperty, java.lang.String nameOfInverse)
          Create a property and its inverse in the user's pimo.
 URI createResource(java.lang.String name, URI ofClass)
          Create a new resource, an instance of a rdfs:Class New resources are always created in the workModel, which is a new context.
 URI createResource(URI ofClass)
          Create a new resource, an instance of a rdfs:Class New resources are always created in the workModel, which is a new context.
 URI createResourceFromGroundingOccurence(URI occurence)
          Create a Thing from a grounding occurrence, read the label, type from the working repository.
 URI createResourceFromGroundingOccurence(URI occurrence, ModelSet occurrenceModelSet, java.lang.String name, URI ofClass)
          Creates a Thing from a given occurence in the working model.
 URI createResourceFromGroundingOccurence(URI occurence, java.lang.String label)
          Create a Thing from a grounding occurrence, read the label, type from the working repository.
 URI createResourceFromGroundingOccurence(URI occurence, java.lang.String label, URI ofClass)
          Creates a Thing from a griven occurence.
 URI createTag(java.lang.String name)
          creates a new tag with name.
 URI createUri()
          creates a new URI inside the namespace returned by getUserNamespace()
 URI createUriWithName(java.lang.String name)
          Creates a new URI inside the namespace returned by getUserNamespace().
 URI createUriWithNameInNamespace(java.lang.String name, URI namespace)
          Creates a new URI inside the passed namespace.
 void deleteClass(URI clazz)
          delete a class, automatically detect in which information model it was defined.
 void deleteModel(URI context)
          delete the model identified by this context-URI.
 void deleteProperty(URI property)
          Delete this property, also delete the inverse property, if one exists.
 void deleteResource(URI resource)
          delete this resource, automatically detect which ontology it is defined in.
 void filterAndCommit()
           
 void filterExistingTriples()
           
protected  void finalize()
           
 java.util.List<URI> findDirectInstancesOf(URI clazz)
          Find direct instances of this class
 java.util.List<URI> findDirectSubClassesOfClass(URI clazz)
          return a list of direct superclasses of this class
 java.util.List<URI> findDirectSuperClassesOfClass(URI clazz)
          return a list of direct superclasses of this class
 URI findOrCreateTag(java.lang.String label)
          Find a NAO:Tag that has the passed label.
 URI findThingForOccurrence(URI informationElement)
          gets all things which have informationElement as occourrence or grounding occurrence (and as folder!)
 URI findThingWithSameIdentfiersAsInformationElement(URI informationElement)
          Find Thing with the same identifier as InformationElemetn
 URI getCleanUniqueURI(URI namespace, java.lang.String name, boolean nullifexists)
          get an URI that was not used before, use the passed ontology to create the uri in there.
 URI getDefiningModelURI(Statement s)
          get the URI of the context defining the statement s.
 URI getEditorDocumentType()
          the document type that this clinet can edit.
 Model getMagicModel()
          Get the magic model.
 URI getOrCreateThingForIdentifier(URI identifierProperty, Node identifiervalue)
          Get (or create) a thing for the passed identifier property and value.
 URI getOrCreateThingForOccurrence(URI informationElement)
          Get the Thing for an occurrence, if no occurrence/grounding occurrence exists, search for matching things.
 URI getOrCreateThingForOccurrence(URI informationElement, java.lang.String name)
          Get the Thing for an occurrence, if no occurrence/grounding occurrence exists, search for matching things.
 URI getOrCreateThingForOccurrence(URI informationElement, java.lang.String name, URI ofClass)
          Get the Thing for an occurrence, if no occurrence/grounding occurrence exists, search for matching things.
 java.lang.String getPersonalIdentifier(URI subject)
          Return the personal identifier of the passed resource, or null if no identifier was defined.
 PimoClient getPimoClient()
          The pimoclient that is bound to this session.
 URI getPimoUri()
          get the URI identifying the PIMO of the user.
 java.lang.String getTechnicalComment(URI resource)
          Returns the technical comment of the resource.
 URI getUserNamespace()
          Get the namespace of the User that is the prefix for IDs.
 URI getUserUri()
          the uri representing the user inside the PIMO
 Model getWorkModel()
          get the model in which new statements are added.
 boolean isClass(URI clazz)
          check if the passed URI is defined as an RDFS.Class, either in the WorkModel or in the main storage.
 boolean isEditingAllowed(Model context)
          Can the passed context be edited in this session?
 boolean isEditingOntology()
          check if this session is used to edit an ontology.
 boolean isLanguageFiler()
           
 boolean isResource(URI resource, URI clazz)
          check if the passed URI is defined as instance of the passed class, either in the WorkModel or in the main storage.
 java.util.List<URI> listOntologies()
          get a list of all ontologies in the Pimo-Store.
 void mergeResourceInto(URI sourceUri, URI targetUri)
          merge the data of two resources.
protected  void observeChange(Statement s)
          Observe which resources have changed.
protected  void observeChangedResource(URI r)
          the passed resource was changed, remember this.
 void removeOntology(URI ontologyUri)
          remove the ontology, identified by the passed ontology uri, from the repository.
 void removeTag(URI resource, URI tag)
          Remove the passed tag from the resource
 void replaceUri(URI sourceUri, URI targetUri)
          replace all triples that contain the source-uri as subject, predicate, or object with triples that contain the targetUri in respective places.
 void rollback()
          Rollback all changes, switches back to original version.
 void setDomainRange(URI property, URI domain, URI range)
          Set the domain and range for the property.
 void setEditingAllowed(URI ontologyUri, boolean editable)
          Set an ontology to be readable or writeable.
 void setLabel(URI resource, java.lang.String label)
          Set the preflabel and RDFSlabel of the resource to the passed label.
 void setLanguageFilter(boolean filter)
           
 void setPersonalIdentifier(URI subject, java.lang.String identifier)
          Set the Personal Identifier of a Thing.
 void setTechnicalComment(URI resource, java.lang.String comment)
          Use this function to set a technical comment about the resource.
static java.lang.String toCleanName(java.lang.String name)
          make this name clean of all characters that should not be in a uri.
 void updateOntology(URI ontologyUri, java.io.InputStream ontology, Syntax syntax)
          A combined call to removeOntology and addOntology, but without having the problem of dependencies based on imports.
 
Methods inherited from class org.semanticdesktop.nepomuk.comp.pimoservice.client.DiffModelSet
addAllInBuffer, addStatementInBuffer, bufferFlush, bufferResource, getAdded, getAddedStatements, getAddedStatementsCopy, getRemoved, getRemovedStatements, getRemovedStatementsCopy, getSource, getWorkModelSet, hasChanges, isNotDisposed, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPARQL_PREAMBLE

public static final java.lang.String SPARQL_PREAMBLE
use this in most SPARQL queries


INVERSE_PROPERTY

public static final URI INVERSE_PROPERTY
The INVERSE and DIRECT properties are copied from CrappyInferencingConnection.


DIRECT_SUBCLASS

public static final URI DIRECT_SUBCLASS

DIRECT_SUBPROPERTY

public static final URI DIRECT_SUBPROPERTY

workModel

protected Model workModel
model in which new triples are added. New workModels are created with the default document type registered in the pimoclient.


changedResources

protected java.util.Set<URI> changedResources
resources that were changed, as logged by the DiffModelSet since the last commit. Changes are recorded when triples are either added or removed to the context of the workmodel, or all modifications via through the MagicModel.


workmodelinitialized

protected boolean workmodelinitialized
set to true, when the first triple is added/removed to the workmodel and the wormodel is initialized.

Constructor Detail

ClientSession

protected ClientSession(PimoClient pimoClient,
                        URI editorDocumentType)
Create a new ClientSession. They should always be created by a PimoClient.

Parameters:
pimoClient - the client that created this session
editorDocumentType - the editor document type of this session

ClientSession

protected ClientSession(PimoClient pimoClient,
                        URI editorDocumentType,
                        URI ontologyToEdit,
                        boolean createNew)
                 throws OntologyReadonlyException,
                        NotFoundException,
                        OntologyInvalidException
Create a new ClientSession, and create a new Domain Ontology. They should always be created by a PimoClient.

Parameters:
pimoClient - the client that created this session
editorDocumentType - the editor document type of this session
ontologyToEdit - instead of creating a new context for the triples to be added, edit this ontology
createNew - set to true to create a new ontology
Throws:
OntologyReadonlyException - when the ontology is readonly
NotFoundException - when the ontology is not in the repository
OntologyInvalidException
Method Detail

addOntology

public void addOntology(URI ontologyUri,
                        java.io.InputStream ontology,
                        Syntax syntax)
                 throws RepositoryStorageException,
                        OntologyInvalidException,
                        OntologyImportsNotSatisfiedException
add the passed ontology to the main repository. The passed RDF model must only contain one ontology at a time. The ontology should have declared imports statements for other ontologies it needs, these will be automatically compared to the list of ontologies, if a prerequisite misses, an OntologyImportsNotSatisfiedException will be thrown. Before importing, the ontology will tested by merging it with its imports and checked using the PIMO-Checker. If it does not pass this test, an OntologyInvalidException is thrown.

Parameters:
ontologyUri - URI identifying the ontology in the passed rdf model
ontology - a string with a serialized form of the ontology
syntax - RDF syntax of the passed stream
formatMimetype - the rdf mimetype serialization format of the string, see RDFRepository for an explanation.
Throws:
RepositoryStorageException - if the database breaks
OntologyInvalidException - if the ontology is not valid according to PimoChecker
OntologyImportsNotSatisfiedException - if imports are missing

addOntology

public void addOntology(URI ontologyUri,
                        Model ontology)
                 throws java.lang.Exception,
                        OntologyInvalidException,
                        OntologyImportsNotSatisfiedException
add the passed ontology to the main repository. The passed RDF model must only contain one ontology at a time. The ontology should have declared imports statements for other ontologies it needs, these will be automatically compared to the list of ontologies, if a prerequisite misses, an OntologyImportsNotSatisfiedException will be thrown. Before importing, the ontology will tested by merging it with its imports and checked using the PIMO-Checker. If it does not pass this test, an OntologyInvalidException is thrown.

Parameters:
ontologyUri - URI identifying the ontology in the passed rdf model
ontology - a model with the ontology to add
formatMimetype - the rdf mimetype serialization format of the string, see RDFRepository for an explanation.
Throws:
java.lang.Exception - if the database breaks
OntologyInvalidException - if the ontology is not valid according to PimoChecker
OntologyImportsNotSatisfiedException - if imports are missing

addOntology

public void addOntology(URI ontologyUri,
                        Model ontology,
                        URI metadataUri,
                        Model metadata)
                 throws java.lang.Exception,
                        OntologyInvalidException,
                        OntologyImportsNotSatisfiedException
add the passed ontology to the main repository. The passed RDF model must only contain one ontology at a time. The ontology should have declared imports statements for other ontologies it needs, these will be automatically compared to the list of ontologies, if a prerequisite misses, an OntologyImportsNotSatisfiedException will be thrown. Before importing, the ontology will tested by merging it with its imports and checked using the PIMO-Checker. If it does not pass this test, an OntologyInvalidException is thrown.

Parameters:
ontologyUri - URI identifying the ontology in the passed rdf model
ontology - a model with the ontology to add
metadataUri - URI identifying the ontologymetadata in the passed metadata model
metadata - a model with the ontology metadata to add
Throws:
java.lang.Exception - if the database breaks
OntologyInvalidException - if the ontology is not valid according to PimoChecker
OntologyImportsNotSatisfiedException - if imports are missing

addTag

public void addTag(URI resource,
                   URI tag)
            throws OntologyInvalidException,
                   NameNotUniqueException
Description copied from interface: TaggingSession
adds a tag to a resource. The tag must be of the type NAO.Tag. You can only tag things which are in the pimo. When you tag a resource which is not in the pimo a new pimo thing will be created and adds the resource as groundingOccurrence to this thing. Every so created resource will have the type PIMO.Document. If this is not acceptable, you have the create the resource as PIMO.Thing.

Specified by:
addTag in interface TaggingSession
Parameters:
resource - resource to be tagged. Can be a Thing or any resource. If any resource, a thing will be created automatically.
tag - the tag for the resource. Tags, Things, or Resources can be passed. if the passed tag is not a tag yet, a new tag will be created using the #createTag(URI) method.
Throws:
OntologyInvalidException - when the tag is not a tag and cannot be converted to one
NameNotUniqueException - when the tag was not a tag and cannot be converted to one.

assertClass

protected void assertClass(URI clazz)
                    throws OntologyInvalidException
check if the passed URI is a class and throw an exception if not

Parameters:
clazz - the class to check
Throws:
OntologyInvalidException - if the class is not a class

assertProperty

protected void assertProperty(URI property)
                       throws OntologyInvalidException
check if the passed URI is a property and throw an exception if not

Parameters:
property - the property to check
Throws:
OntologyInvalidException - if the property is not a property

assertResource

protected void assertResource(URI resource,
                              URI clazz)
                       throws OntologyInvalidException
check if the passed URI is an instance of the passed class and throw an exception if not

Parameters:
resource - the resource in question
clazz - the class to check
Throws:
OntologyInvalidException - if the class is not a class

assertWriteableModel

protected void assertWriteableModel(URI modelUri)
                             throws OntologyReadonlyException,
                                    NotFoundException
check if the passed ontology is Writeable by the user. To be writeable, the ontology has to be in the pimo store and it has to be a user-writeable ontology, like a context created by the user or a shared domain ontology.

Parameters:
ontologyUri - the ontology to check
Throws:
OntologyReadonlyException - containing more info why this ontology cannot be changed
NotFoundException

assertWriteableResource

protected void assertWriteableResource(URI resource,
                                       java.lang.String attemptedaction)
                                throws OntologyReadonlyException,
                                       NotFoundException
check if the passed resource can be changed by the user. That means can be deleted, renamed, merged, etc. To be writeable, the resource has to be in an ontology which has to be in the pimo store and it has to be a user-writeable ontology, like a context created by the user or a shared domain ontology.

Parameters:
resource - the resource to check
attemptedaction - the attempted action to be asserted
Throws:
OntologyReadonlyException - containing more info why this ontology cannot be changed
NotFoundException - if the resource cannot be found

bufferAdd

public void bufferAdd(Model model)
Include the passed triples in the internal buffer model. Note that you can only pass in a model, not a modelset, as only one context is supported. The triples will be added to the buffer, to context PIMO.GroundingClosure. Using buffers will decrease performance slightly. Use DiffModelSet.bufferFlush() to flush the buffer.

Parameters:
model - the model to be buffered

bufferOpenLinkedData

public void bufferOpenLinkedData(URI resource)
                          throws java.lang.Exception
When the resource has a statement like PIMO:hasOtherRepresentation or RDFS:seeAlso this methoeds loads the data "linked data" in the workModel. After the data was loaded, you can access it with the workmodel. All statements are only temporarily and directly linked with the resource (resource,p,o).

Parameters:
resource - the resource for which the "linked data" should be loaded
Throws:
java.lang.Exception

bufferResourceClosure

public void bufferResourceClosure(URI resource,
                                  URI closuretype)

Experimental: load a resource into the working ModelSet and buffer its PIMO closure. With this function every statement from every groundingOccurence of the resource will be copied in the workModelSet of the ClientSession. The statements which are in the pimo will also be shown. With this method you can see all the data which is known about the resource. The data is added to the buffer of the WorkModelSet, which you can then get using DiffModelSet.getWorkModelSet() You can only modify a statement which is stored directly in the pimo. When you try to manipulate a statment from the grounding occurence then you will get an exception. When you have done correct changes you must call ClientSession.commit() to store the changes in the pimo.

This will not change anything in the data. As side-effect, it buffers the resource and changes performance on find(). Calls on find(r,?,?) are faster, all other calls when not the resource is the subject are a bit slower. To undo the buffering, call DiffModelSet.bufferFlush().

Parameters:
resource - the resource for which you want to see all statements.
closuretype - the type of closure. At the moment only PIMO.GroundingClosure is supported.

changeTypeOfResource

public void changeTypeOfResource(URI resourceUri,
                                 URI oldclass,
                                 URI newclass)
                          throws NotFoundException,
                                 OntologyReadonlyException
change the type of a resource. If a resource has more than one class, pass in the old class you want to remove and the new class you want to add.

Parameters:
resourceUri - the uri identifying the resource to modify
oldclass - the class to remove. Can be null if you just want to add a class
newclass - the class to add. Can be null if you want to remove a type and this resource had multiple types.
Throws:
NotFoundException - if the resource is not found
OntologyReadonlyException - if the resource is defined in an ontology that is readonly

checkOntology

public void checkOntology(URI ontologyUri,
                          java.io.InputStream ontology,
                          Syntax syntax,
                          boolean loadImportsRecursively)
                   throws OntologyInvalidException
check if the passed ontology is a valid Information Model. The ontology will not be added to the PIMO store, it is checked independent of it. If the passed ontology imports other ontologies, these will be loaded to satisfy the imports, before checking. As some imports may not be available in the local PIMO store, setting loadImportsRecursively tells the PimoService to download the imported ontologies as needed before checking, requiring an active internet connection.

Parameters:
ontologyUri - URI identifying the ontology in the passed rdf model
ontology - a string with a serialized form of the ontology
syntax - the rdf mimetype serialization format of the string, see RDFRepository for an explanation.
loadImportsRecursively - load imported ontologies from the web, if not present
Throws:
OntologyInvalidException - if the ontology is not valid according to PimoChecker

checkOntology

public void checkOntology(URI ontologyUri,
                          java.io.Reader ontology,
                          Syntax syntax,
                          boolean loadImportsRecursively)
                   throws OntologyInvalidException
check if the passed ontology is a valid Information Model. The ontology will not be added to the PIMO store, it is checked independent of it. If the passed ontology imports other ontologies, these will be loaded to satisfy the imports, before checking. As some imports may not be available in the local PIMO store, setting loadImportsRecursively tells the PimoService to download the imported ontologies as needed before checking, requiring an active internet connection.

Parameters:
ontologyUri - URI identifying the ontology in the passed rdf model
ontology - a string with a serialized form of the ontology
syntax - the rdf mimetype serialization format of the string, see RDFRepository for an explanation.
loadImportsRecursively - load imported ontologies from the web, if not present
Throws:
OntologyInvalidException - if the ontology is not valid according to PimoChecker

close

public void close()
dispose all changes that were made in-memory, close the in-memory models.

Overrides:
close in class DiffModelSet

commit

public void commit()
            throws ModelException

Store the current DIFF to the server. Calling commit also sets the state of this session as disposed, you don't need to close now. You can continue using Sessions after committing, this will cause a new work context to be created. To avoid creating a new context, use PimoClient.editOntology() and pass the context URI.

Committing a session does not flush the buffers. If you want to free resources and do not need buffered resources anymore, call DiffModelSet.bufferFlush().

Overrides:
commit in class DiffModelSet
Throws:
ModelException - if the storing fails

beforeCommit

protected void beforeCommit()
Before committing, note the change dates of changed resources.


containsOntology

public boolean containsOntology(URI ontologyUri)
true if the ontology is in the named graphs of the repo

Parameters:
ontologyUri -
Returns:
true, if the ontology is in the store

copyIdentifiers

public int copyIdentifiers(URI target,
                           URI source)
Copies the identifiers of the given source occurrence to the passed target PIMO thing.

Parameters:
target - the thing to copy to.
source - the source to copy from.
Returns:
the number of identifiers that have been copied

copyIdentifiers

public int copyIdentifiers(URI target,
                           URI source,
                           ModelSet sourceModelSet)
Copies the identifiers of the given source occurrence to the passed target PIMO thing. The source is queried using the passed occurrenceModelSet. Passing the sourceModelSet is supported to allow temporary models as basis for calculations

Parameters:
target - the thing to copy to.
source - the source to copy from.
sourceModelSet - the source data to read.
Returns:
the number of identifiers that have been copied

createClass

public URI createClass(java.lang.String name,
                       URI superClass)
                throws OntologyInvalidException
Create a new class for the user, it gets typed an rdfs:Class. Superclass is the passed class. New classes are always created in the workModel, which is a new context. The user can only create classes that have not been created by himself, to avoid duplication each class has to have a distinctive name.

Parameters:
name - the name of the class, used as label and part of the uri
superClass - the uri of the superclass of the created class
Returns:
the uri of the created class
Throws:
OntologyInvalidException - if the passed superClass is not defined as class in the users pimo. Or if the passed name is already the label of a class defined by the user.

createContext

protected URI createContext()
See Also:
org.semanticdesktop.services.pimoservice.PimoService#createContext()

createProperty

public URI createProperty(java.lang.String name,
                          URI superProperty)
                   throws OntologyInvalidException
create a new property in the user's pimo. It will have no inverse property assigned.

Parameters:
name - the name of the new property
superProperty - uri of the superproperty, if there is one. can be null.
Returns:
the URI of the new property.
Throws:
OntologyInvalidException - if the passed superproperty is not a property

createPropertyNameInverse

public URI createPropertyNameInverse(java.lang.String name,
                                     URI superProperty,
                                     java.lang.String nameOfInverse)
                              throws OntologyInvalidException
Create a property and its inverse in the user's pimo. In one operation. The property will have assigned the passed super-property. The inverse of the super-property will be the super-property of the created inverse. If the super-property has no inverse, this throws an exception.

Parameters:
name - name of the property
superProperty - uri of the super-property. If it is null, then the inverse will also have no super-property.
nameOfInverse - name of the inverse property
Returns:
the URI of the created property
Throws:
OntologyInvalidException - if the passed superproperty is not a property

createResource

public URI createResource(java.lang.String name,
                          URI ofClass)
                   throws OntologyInvalidException
Create a new resource, an instance of a rdfs:Class New resources are always created in the workModel, which is a new context.

Parameters:
name - the name of the resource, used as label and part of the uri
ofClass - the uri of the class of the created resource
Returns:
the uri of the created resource
Throws:
OntologyInvalidException - if the passed uri is not defined as class in the pimo.

createResource

public URI createResource(URI ofClass)
                   throws OntologyInvalidException
Create a new resource, an instance of a rdfs:Class New resources are always created in the workModel, which is a new context. The initial label of the resource will be derived from the class.

Parameters:
ofClass - the uri of the class of the created resource
Returns:
the uri of the created resource
Throws:
OntologyInvalidException - if the passed uri is not defined as class in the pimo.

createResourceFromGroundingOccurence

public URI createResourceFromGroundingOccurence(URI occurence)
                                         throws OntologyInvalidException
Create a Thing from a grounding occurrence, read the label, type from the working repository. You must not call this if this occurrence was already linked to a thing, this method does not check if a thing or occurrence exist. All identifiers from the occurence will be added to the new thing.

Parameters:
occurence - the occurrence to look at
Returns:
the created thing
Throws:
OntologyInvalidException - if no class can be detected for the information element.

createResourceFromGroundingOccurence

public URI createResourceFromGroundingOccurence(URI occurrence,
                                                ModelSet occurrenceModelSet,
                                                java.lang.String name,
                                                URI ofClass)
                                         throws OntologyInvalidException
Creates a Thing from a given occurence in the working model. The URI of the occurence will be added as groundingOccurence. All identifiers from the occurence, which can be found in occurenceModelSet will be added as statements in the model. Changes are not saved until commit().

Parameters:
occurrence - the occurence from which to create a resoucre
occurrenceModelSet - the ModelSet where to find statements over occurence
name - the name of the resource, used as label and part of the uri
ofClass - the uri of the class of the created resource
Returns:
the uri of the created resource
Throws:
OntologyInvalidException - if the passed uri is not defined as class in the pimo.

createResourceFromGroundingOccurence

public URI createResourceFromGroundingOccurence(URI occurence,
                                                java.lang.String label)
                                         throws OntologyInvalidException
Create a Thing from a grounding occurrence, read the label, type from the working repository. You must not call this if this occurrence was already linked to a thing, this method does not check if a thing or occurrence exist.

Parameters:
occurence - the occurrence to look at
label - the new label of the thing. If it is empty, the function search for a proper label
Returns:
the created thing
Throws:
OntologyInvalidException - if no class can be detected for the information element.

createResourceFromGroundingOccurence

public URI createResourceFromGroundingOccurence(URI occurence,
                                                java.lang.String label,
                                                URI ofClass)
                                         throws OntologyInvalidException
Creates a Thing from a griven occurence. The URI of the occurence will be added as groundingOccurence. All identifiers from the occurence, which can be found in the pimo will be added as statements in the model.

Parameters:
occurence - the occurence from which to create a resoucre
label - the name of the resource, used as label and part of the uri
ofClass - the uri of the class of the created resource
Returns:
the uri of the created resource
Throws:
OntologyInvalidException - if the passed uri is not defined as class in the pimo.

createTag

public URI createTag(java.lang.String name)
              throws NameNotUniqueException,
                     OntologyInvalidException
Description copied from interface: TaggingSession
creates a new tag with name. If there is already a tag with this name, no new tag will be created and a NameNotUniqueException will be thrown.

Specified by:
createTag in interface TaggingSession
Parameters:
name - name for the tag
Returns:
the uri of the newly created Tag.
Throws:
NameNotUniqueException
OntologyInvalidException

createUri

public URI createUri()
creates a new URI inside the namespace returned by getUserNamespace()

Returns:
a new URI that is unique, new and from the namespace No two uris returned here are the same.

createUriWithName

public URI createUriWithName(java.lang.String name)
Creates a new URI inside the namespace returned by getUserNamespace(). The name passed as parameter will be used inside this url, to increase readability. If a URI with that name already exists, a random part will be added to the name (the name is treated as "seed").

Parameters:
name - a name to include in the URI
Returns:
a new URI that is unique, new and from the namespace, and contains the passed name. No two uris returned here are the same.

createUriWithNameInNamespace

public URI createUriWithNameInNamespace(java.lang.String name,
                                        URI namespace)
Creates a new URI inside the passed namespace. The name passed as parameter will be used inside this url, to increase readability. If a URI with that name already exists, a random part will be added to the name (the name is treated as "seed").

Parameters:
name - a name to include in the URI
namespace - a string prefix to use in the URIs
Returns:
a new URI created within the passed namespace

deleteClass

public void deleteClass(URI clazz)
delete a class, automatically detect in which information model it was defined. Attention: this deleted only this class definition. Instances of this class will still be instances of superclasses, sub-classes will be sub-classes of any superclasses (trying to fill the gap around the deleted class).

Parameters:
clazz - to delete
Throws:
OntologyInvalidException - if something brakes during deleting the instances and subclasses. no undo though.
NotFoundException - when the class does not exist in this pimo store.
OntologyReadonlyException - if this ontology cannot be modified by the user

deleteModel

public void deleteModel(URI context)
                 throws OntologyReadonlyException,
                        NotFoundException
delete the model identified by this context-URI. The changes will be done during commit.

Parameters:
context - the context-uri.
Throws:
NotFoundException - if the context is not in the store
OntologyReadonlyException - if the ontology is read-only

deleteProperty

public void deleteProperty(URI property)
                    throws OntologyInvalidException,
                           OntologyReadonlyException,
                           DeletionNotAllowedException,
                           NotFoundException
Delete this property, also delete the inverse property, if one exists. This method will fail if there are still triples using this property. This detects automatically in which ontology the property was defined

Parameters:
property - the URI of the property to delete
Throws:
OntologyInvalidException
OntologyReadonlyException - if this ontology cannot be modified by the user
DeletionNotAllowedException - if there are still triples that use the property
NotFoundException - if the property was not found

deleteResource

public void deleteResource(URI resource)
                    throws OntologyReadonlyException,
                           NotFoundException,
                           DeletionNotAllowedException
delete this resource, automatically detect which ontology it is defined in. Will also delete all relationalProperties of this resource (including reifications) and all describingproperties os this resource. Links to occurrences are also deleted.

Parameters:
resource - the URI of the resource to delete.
Throws:
OntologyReadonlyException - if this ontology cannot be modified by the user
NotFoundException - when the resource does not exist in this pimo store.
DeletionNotAllowedException - when the ontology would become invalid by deleting this resource, this restricts deleting the owner (person) of a Pimo, for example.

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

findDirectInstancesOf

public java.util.List<URI> findDirectInstancesOf(URI clazz)
Find direct instances of this class

Parameters:
clazz - the class
Returns:
a list of direct instances, may be empty

findDirectSubClassesOfClass

public java.util.List<URI> findDirectSubClassesOfClass(URI clazz)
return a list of direct superclasses of this class

Parameters:
clazz - the class in question
Returns:
the list, or empty list if nothing found

findDirectSuperClassesOfClass

public java.util.List<URI> findDirectSuperClassesOfClass(URI clazz)
return a list of direct superclasses of this class

Parameters:
clazz - the class in question
Returns:
the list, or empty list if nothing found

findOrCreateTag

public URI findOrCreateTag(java.lang.String label)
Find a NAO:Tag that has the passed label. Label includes nao:prefLabel and nao:personalIdentifier. If not a NAO:Tag can be found, all pimo:Things of the user are considered. When a thing with the passed label exists, the type nao:Tag is added to the thing. If no Thing can be found, a new tag is created. The new Tag has the class NAO:Tag and PIMO:Topic. This method can modify the session, you may have to call commit() after this method! This method uses the pimoClient to search for possible Tags and Things, if you expect it to find one, only committed tags and things can be found!.

Parameters:
label - the label of the tag.
Returns:
the URI of the TAG

findThingForOccurrence

public URI findThingForOccurrence(URI informationElement)
gets all things which have informationElement as occourrence or grounding occurrence (and as folder!)

Returns:
the URI of the resource, which has informationElement as occourence.

findThingWithSameIdentfiersAsInformationElement

public URI findThingWithSameIdentfiersAsInformationElement(URI informationElement)
Find Thing with the same identifier as InformationElemetn

Parameters:
informationElement -
input -
Returns:

toCleanName

public static java.lang.String toCleanName(java.lang.String name)
make this name clean of all characters that should not be in a uri. Method used internally and by PimoQuery

Parameters:
name - the name to clean
Returns:
a name without funny characters.

getCleanUniqueURI

public URI getCleanUniqueURI(URI namespace,
                             java.lang.String name,
                             boolean nullifexists)
get an URI that was not used before, use the passed ontology to create the uri in there. If the uri is already taken, add some numbers to it, but only do that when nullifexists is false, otherwise return null to indicate that the uri is taken.

We should only use characters allowed in XML names, as RDF serialization may brake otherwise. Correct XML names are:

[5]     Name       ::=      (Letter | '_' | ':') (NameChar)*
     [4]     NameChar       ::=      Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender

Parameters:
namespace - namespace to use
name - a seed for generating a good name
nullifexists - if this is true, this method will return null if the passed name exists in that ontology
Returns:
a new URI

getDefiningModelURI

public URI getDefiningModelURI(Statement s)
get the URI of the context defining the statement s. This is the URI of the context that originally contained s

Parameters:
s - the statement
Returns:
the URI of the model defining this statement

getEditorDocumentType

public URI getEditorDocumentType()
the document type that this clinet can edit.

Returns:
the type as set in the constructor

getMagicModel

public Model getMagicModel()
Get the magic model. It allows you to add an remove triples to the Repository as if named graphs don't exist. Triples are removed from any model where they are in, they are added to the workmodel, using the workmodels context. A special case is when you delete a triple and add a similar triple (same subject and predicate) shortly after, then this is added to the context of the removed triple.

Returns:
the Magic Model

getOrCreateThingForOccurrence

public URI getOrCreateThingForOccurrence(URI informationElement)
                                  throws OntologyInvalidException
Get the Thing for an occurrence, if no occurrence/grounding occurrence exists, search for matching things. If a matching thing can be found, a pimo:occurrence relation will be automatically added to speed up future searches. When no suitable thing can be found, create a new thing and return it. Guess a possible class of the thing based on the class of the occurrence. Changes done by this method will only be stored if you invoke commit! Check hasChanges.

Parameters:
informationElement - the occurrence to check
Returns:
the URI of the PIMO thing that is associated with the occurrence, if not suitable thing can be found, a new one will automatically be created.
Throws:
OntologyInvalidException - if no class can be detected for the information element.

getOrCreateThingForOccurrence

public URI getOrCreateThingForOccurrence(URI informationElement,
                                         java.lang.String name)
                                  throws OntologyInvalidException
Get the Thing for an occurrence, if no occurrence/grounding occurrence exists, search for matching things. If a matching thing can be found, a pimo:occurrence relation will be automatically added to speed up future searches. When no suitable thing can be found, create a new thing and return it. Guess a possible class of the thing based on the class of the occurrence. Changes done by this method will only be stored if you invoke commit! Check hasChanges.

Parameters:
informationElement - the occurrence to check
name - the name of the new Thing, if one must be created
Returns:
the URI of the PIMO thing that is associated with the occurrence, if not suitable thing can be found, a new one will automatically be created.
Throws:
OntologyInvalidException - if no class can be detected for the information element.

getOrCreateThingForOccurrence

public URI getOrCreateThingForOccurrence(URI informationElement,
                                         java.lang.String name,
                                         URI ofClass)
                                  throws OntologyInvalidException
Get the Thing for an occurrence, if no occurrence/grounding occurrence exists, search for matching things. If a matching thing can be found, a pimo:occurrence relation will be automatically added to speed up future searches. When no suitable thing can be found, create a new thing and return it. Guess a possible class of the thing based on the class of the occurrence. Changes done by this method will only be stored if you invoke commit! Check hasChanges.

Parameters:
informationElement - the occurrence to check
name - the name of the new Thing, if one must be created
ofClass - the class of the new Thing, if one must be created
Returns:
the URI of the PIMO thing that is associated with the occurrence, if not suitable thing can be found, a new one will automatically be created.
Throws:
OntologyInvalidException - if no class can be detected for the information element.

getPersonalIdentifier

public java.lang.String getPersonalIdentifier(URI subject)
Return the personal identifier of the passed resource, or null if no identifier was defined. To get the label of a thing, refer to PimoQuery.getLabelOf(String)

Parameters:
subject - the uri to evaluate
Returns:
the identifier or null if no personal identifier set.

getPimoClient

public PimoClient getPimoClient()
The pimoclient that is bound to this session.

Returns:
the pimoclient.

getPimoUri

public URI getPimoUri()
get the URI identifying the PIMO of the user.

Returns:
the uri identifying the PIMO of the user.

getUserNamespace

public URI getUserNamespace()
Get the namespace of the User that is the prefix for IDs. Example: http://id.semanticdesktop.org/nepomuk/users/max/id/ It is basically the "Namespaceprovider-path".

Returns:
the uri namespace

getUserUri

public URI getUserUri()
the uri representing the user inside the PIMO

Returns:
the uri of the resource of the user

getWorkModel

public Model getWorkModel()
get the model in which new statements are added. This is the working model, it will be added to the RDF repository when changes are commited. the current context being editted The data about the context is added once the first triple is modified to the context.

Returns:
the workmodelset.

isClass

public boolean isClass(URI clazz)
check if the passed URI is defined as an RDFS.Class, either in the WorkModel or in the main storage.

Parameters:
clazz - the uri to check.
Returns:
true, if the URI has a type RDFS.Class

isEditingAllowed

public boolean isEditingAllowed(Model context)
                         throws NotFoundException
Can the passed context be edited in this session? Returns true, if the {getEditorDocumentType() conforms to the one of the context.

Parameters:
context - the context to test
Returns:
true, if the model can be edited
Throws:
NotFoundException - if the model cannot be identified as valid NRL context

isEditingOntology

public boolean isEditingOntology()
check if this session is used to edit an ontology.

Returns:
true, if this session edits an ontology, false if this session edits the PIMO of the user.

isLanguageFiler

public boolean isLanguageFiler()

isResource

public boolean isResource(URI resource,
                          URI clazz)
check if the passed URI is defined as instance of the passed class, either in the WorkModel or in the main storage.

Parameters:
resource - the resource in question
clazz - the uri to check.
Returns:
true, if the URI has a type RDFS.Class

listOntologies

public java.util.List<URI> listOntologies()
get a list of all ontologies in the Pimo-Store. The URIs identfying the ontologies are returned. This works on the STORE and not on the WORKMODEL! (it needs sparql)

Returns:
a list of ontology uris identifying ontologies in the PIMO store

mergeResourceInto

public void mergeResourceInto(URI sourceUri,
                              URI targetUri)
                       throws OntologyReadonlyException,
                              NotFoundException
merge the data of two resources. The data of the resource identified by the sourceUri (the source) will be added to the data of the resource identified by the targetUri, the target. The uri of the source will vanish from the store and the class and label of the target will be used for the merged instance. The source and target ontologies have to be writeable for the user.

Parameters:
sourceUri - the source resource to be merged into the target. this uri will be removed
targetUri - the target to be merged into. The class and label of it will stay.
Throws:
OntologyReadonlyException - if either the source of the target ontology are readonly for the user
NotFoundException - if source or target are not defined in your pimo

observeChange

protected void observeChange(Statement s)
Observe which resources have changed. This is called on every add/remove operation

Overrides:
observeChange in class DiffModelSet

observeChangedResource

protected void observeChangedResource(URI r)
the passed resource was changed, remember this. Used by the magicmodel to collect resources in the subject role of changed triples

Parameters:
r - this resource was changed through the magicmodel

removeOntology

public void removeOntology(URI ontologyUri)
                    throws OntologyImportsNotSatisfiedException,
                           NotFoundException,
                           OntologyInvalidException,
                           RepositoryStorageException
remove the ontology, identified by the passed ontology uri, from the repository. The ontology has to be in the list of stored ontologies (listOntologies()), if not a NotFoundException will be thrown. If the ontology is imported by other ontologies in the resource-store, a OntologyImportsNotSatisfiedException will be thrown, having the affected ontologies listed there.

Parameters:
ontologyUri - the uri to delete
Throws:
NotFoundException - if the passed ontology is not in this pimo
OntologyImportsNotSatisfiedException - if the ontology is imported by other ontologies, list the affected ontologies and remove them first.
OntologyInvalidException - when the ontology to be removed is either the user's personal pimo or the pimo-language
RepositoryStorageException - if the database has a problem removing the graph

removeTag

public void removeTag(URI resource,
                      URI tag)
Description copied from interface: TaggingSession
Remove the passed tag from the resource

Specified by:
removeTag in interface TaggingSession
Parameters:
resource - resource which is annotated with nao:hasTag to the tag
tag - uri of the tag

replaceUri

public void replaceUri(URI sourceUri,
                       URI targetUri)
replace all triples that contain the source-uri as subject, predicate, or object with triples that contain the targetUri in respective places. Do this in the workmodel.

Parameters:
sourceUri - the uri to replace
targetUri - the new uri

rollback

public void rollback()
              throws ModelException
Description copied from class: DiffModelSet
Rollback all changes, switches back to original version. Call this to free system resources taken by the transaction. This will also flush the buffers of cached resources.

Overrides:
rollback in class DiffModelSet
Throws:
ModelException - if the model cannot be initialised
See Also:
DiffModelSet.rollback()

setEditingAllowed

public void setEditingAllowed(URI ontologyUri,
                              boolean editable)
Set an ontology to be readable or writeable. This is used to change ontologies, use with care. You should not set a public ontology to being writeable unless you are sure the user has the right to do.

Parameters:
ontologyUri - the ontology to edit
editable - set to true or false

setLabel

public void setLabel(URI resource,
                     java.lang.String label)
              throws OntologyReadonlyException,
                     NotFoundException
Set the preflabel and RDFSlabel of the resource to the passed label. The resource can be a thing, class, or property. The method deletes old rdfs:label and nao:prefLabel values and replaces them.

Parameters:
resource - the resource to change
label - the new label.
Throws:
OntologyReadonlyException - when the resource is not writeable
NotFoundException - when the resource was not found or cannot be connected to an ontology in which it is defined

setLanguageFilter

public void setLanguageFilter(boolean filter)

setPersonalIdentifier

public void setPersonalIdentifier(URI subject,
                                  java.lang.String identifier)
                           throws NameNotUniqueException
Set the Personal Identifier of a Thing. The identifier must only exist for one Thing within the user-PIMO, this will be checked by this method and an exception is thrown if the identifier was already used for another thing.

Parameters:
subject - the resource to identify
identifier - the identifier. Either a String or null to indicate that the personal identifier of this subject is to be deleted.
Throws:
NameNotUniqueException - if the identifier was used for another entity before

getTechnicalComment

public java.lang.String getTechnicalComment(URI resource)
                                     throws NotFoundException
Returns the technical comment of the resource. This is the description stored with RDFS:comment. If there are more than one comment, the first founded comment will be returned.

Parameters:
resource - the resource for which to return the technical comment
Returns:
the comment or null if the
Throws:
NotFoundException

setTechnicalComment

public void setTechnicalComment(URI resource,
                                java.lang.String comment)
                         throws NotFoundException,
                                OntologyReadonlyException
Use this function to set a technical comment about the resource. This comment will be stored as RDFS:comment. A Technical Comment should contain information about, how created this resource etc.

Parameters:
resource - the resource for which to add the comment
comment - the comment for this resource
Throws:
NotFoundException - We don't allow to set comments for resources which aren't there.
OntologyReadonlyException - If the ontology that defines the resource is write-protected

updateOntology

public void updateOntology(URI ontologyUri,
                           java.io.InputStream ontology,
                           Syntax syntax)
                    throws NotFoundException,
                           OntologyInvalidException,
                           OntologyImportsNotSatisfiedException,
                           RepositoryStorageException
A combined call to removeOntology and addOntology, but without having the problem of dependencies based on imports. This works best when the new version of the ontology has the same imports than the old version.

Parameters:
ontologyUri - URI identifying the ontology in the passed rdf model
ontology - a stream with a serialized form of the ontology
syntax - the rdf syntax
Throws:
NotFoundException - if the passed ontology is not in the store at the moment
SailUpdateException - if the database breaks
OntologyInvalidException - if the ontology is not valid according to PimoChecker
OntologyImportsNotSatisfiedException - if imports are missing
RepositoryStorageException - if the updating in the repository does not work

setDomainRange

public void setDomainRange(URI property,
                           URI domain,
                           URI range)
Set the domain and range for the property. When an inverse propery exists, will also change domain/range for that. Domain/ranges that were set before will be deleted.

Parameters:
property -
domain -
range -

filterAndCommit

public void filterAndCommit()
                     throws ModelException
Throws:
ModelException

filterExistingTriples

public void filterExistingTriples()

getOrCreateThingForIdentifier

public URI getOrCreateThingForIdentifier(URI identifierProperty,
                                         Node identifiervalue)
Get (or create) a thing for the passed identifier property and value. It searches for things that have an identifierProperty with the passed identifiervalue. If no such thing exists, a new thing will be created, using the domain class of the identifierProperty as indicator which PIMO class to use.

Parameters:
identifierProperty - URI of the subproperty of NAO:identifier. see NIE:identifier for possible values, such as http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#messageId.
identifiervalue - the literal or URI of an identifier. For example "test123@example.com" for an NMO:messageId.
Returns:
the URI of the thing associated with the identifier, if no Thing existed, a new one will be created


NEPOMUK PIMOService API documentation