edu.stanford.smi.protegex.owl.model.triplestore
Interface TripleStoreModel

All Known Implementing Classes:
AbstractTripleStoreModel

public interface TripleStoreModel

The TripleStoreModel is an access layer on top of the normal OWLModel.

Author:
Holger Knublauch

Method Summary
 TripleStore createTripleStore(String name)
          A low level method that creates and adds a new TripleStore to implement imports.
 void deleteTripleStore(TripleStore tripleStore)
          Deletes an imported TripleStore.
 void endTripleStoreChanges()
          Must be called after changes were made in any TripleStore.
 TripleStore getActiveTripleStore()
          Gets the currently "active" TripleStore, which all future set operations will be operating on.
 TripleStore getHomeTripleStore(RDFResource resource)
          Gets the "home" triple store of a given resource.
 Collection getPropertyValues(RDFResource resource, RDFProperty property)
          A low-level access method to access property values while the usual API methods are in an invalid state.
 Collection getSlotValues(edu.stanford.smi.protege.model.Instance instance, edu.stanford.smi.protege.model.Slot slot)
          Similar to getPropertyValues but for native Protege slots and instances.
 TripleStore getTopTripleStore()
          Gets the "top" TripleStore, which is the first user-editable TripleStore, from which all imports start.
 TripleStore getTripleStore(int index)
          Gets a TripleStore by its index.
 TripleStore getTripleStore(String name)
          Gets the TripleStore with a given name.
 TripleStore getTripleStoreByDefaultNamespace(String namespace)
          Gets the first TripleStore that uses a given default namespace.
 List getTripleStores()
          Gets the TripleStores which provide an RDF triple-based view onto this OWLModel.
 boolean isActiveTriple(RDFResource subject, RDFProperty predicate, Object object)
          Checks if a given triple is stored in the currently active TripleStore.
 boolean isEditableTriple(RDFResource subject, RDFProperty predicate, Object object)
          Checks if a given triple is stored in an editable TripleStore.
 boolean isEditableTripleStore(TripleStore ts)
           
 Iterator listTriplesWithSubject(RDFResource subject)
          Combines the result of the corresponding method of each TripleStore.
 Iterator listUserTripleStores()
          Provides an Iterator on all user TripleStores, i.e. all results of getTripleStores() except for the first (system) TripleStore.
 void replaceJavaObject(RDFResource subject)
           
 void setActiveTripleStore(TripleStore tripleStore)
          Specifies which TripleStore shall be the active one for future write operations.
 void setHomeTripleStore(RDFResource resource, TripleStore tripleStore)
          Moves a given RDFResource into another "home" TripleStore.
 void updateEditableResourceState()
          Changes the isIncluded() value of all resources to reflect the currently active TripleStore.
 

Method Detail

createTripleStore

public TripleStore createTripleStore(String name)
A low level method that creates and adds a new TripleStore to implement imports.

Parameters:
name - the name of the new TripleStore (must be unique)
Returns:
the new TripleStore

deleteTripleStore

public void deleteTripleStore(TripleStore tripleStore)
Deletes an imported TripleStore.

Parameters:
tripleStore - the TripleStore to delete (must be neither system nor top TripleStore)

endTripleStoreChanges

public void endTripleStoreChanges()
Must be called after changes were made in any TripleStore. This will internally synchronize several Protege model features with the OWL/RDF triples.


getActiveTripleStore

public TripleStore getActiveTripleStore()
Gets the currently "active" TripleStore, which all future set operations will be operating on.

Returns:
the active TripleStore
See Also:
getTripleStores(), setActiveTripleStore(edu.stanford.smi.protegex.owl.model.triplestore.TripleStore)

getHomeTripleStore

public TripleStore getHomeTripleStore(RDFResource resource)
Gets the "home" triple store of a given resource. This can be used to determine the TripleStore where changes on the resource should be performed consistently. In the default implementation, the home TripleStore is the one that contains a :NAME slot value of the resource.

Parameters:
resource - the RDFResource to find the home TripleStore of
Returns:
the home TripleStore

getPropertyValues

public Collection getPropertyValues(RDFResource resource,
                                    RDFProperty property)
A low-level access method to access property values while the usual API methods are in an invalid state. This may be necessary during the direct manipulation of triples on a TripleStore level.

Parameters:
resource - the resource to get the property values of
property - the property to get the values of
Returns:
a Collection of property values (may include RDFSLiterals)

getSlotValues

public Collection getSlotValues(edu.stanford.smi.protege.model.Instance instance,
                                edu.stanford.smi.protege.model.Slot slot)
Similar to getPropertyValues but for native Protege slots and instances.

Parameters:
instance - the instance to get the values of
slot - the slot to get the values of
Returns:
a Collection of slot values (not including RDFSLiterals)

getTripleStore

public TripleStore getTripleStore(String name)
Gets the TripleStore with a given name. For additional TripleStores, the name corresponds to the import URI.

Parameters:
name - the name / import URI of the TripleStore
Returns:
the TripleStore or null if none of this name exists

getTripleStoreByDefaultNamespace

public TripleStore getTripleStoreByDefaultNamespace(String namespace)
Gets the first TripleStore that uses a given default namespace.

Parameters:
namespace - the namespace
Returns:
the TripleStore or null

getTripleStore

public TripleStore getTripleStore(int index)
Gets a TripleStore by its index. This is equivalent to getTripleStores().get(index);.

Parameters:
index - the index of the TripleStore to get
Returns:
the TripleStore

getTripleStores

public List getTripleStores()
Gets the TripleStores which provide an RDF triple-based view onto this OWLModel. Warning: This is work in progress!

Returns:
a collection of TripleStore objects

getTopTripleStore

public TripleStore getTopTripleStore()
Gets the "top" TripleStore, which is the first user-editable TripleStore, from which all imports start.

Returns:
the top TripleStore (never null)

isActiveTriple

public boolean isActiveTriple(RDFResource subject,
                              RDFProperty predicate,
                              Object object)
Checks if a given triple is stored in the currently active TripleStore. This is a shortcut for getActiveTripleStore().contains(...).

Parameters:
subject - the subject of the triple
predicate - the predicate of the triple
object - the object of the triple
Returns:
true if the value is found in the active TripleStore

isEditableTriple

public boolean isEditableTriple(RDFResource subject,
                                RDFProperty predicate,
                                Object object)
Checks if a given triple is stored in an editable TripleStore. Editable TripleStores are those that could be saved to a local file, using the OWLModel's URIResolver.

Parameters:
subject - the subject of the triple
predicate - the predicate of the triple
object - the object of the triple
Returns:
true if the value is found in an editable TripleStore

isEditableTripleStore

public boolean isEditableTripleStore(TripleStore ts)

listTriplesWithSubject

public Iterator listTriplesWithSubject(RDFResource subject)
Combines the result of the corresponding method of each TripleStore.

Parameters:
subject - the subject to get all triples of
Returns:
an Iterator of Triples

listUserTripleStores

public Iterator listUserTripleStores()
Provides an Iterator on all user TripleStores, i.e. all results of getTripleStores() except for the first (system) TripleStore.

Returns:
an Iterator of TripleStore objects

replaceJavaObject

public void replaceJavaObject(RDFResource subject)

setActiveTripleStore

public void setActiveTripleStore(TripleStore tripleStore)
Specifies which TripleStore shall be the active one for future write operations.

Parameters:
tripleStore - one of the results of a recent call to getTripleStores().

setHomeTripleStore

public void setHomeTripleStore(RDFResource resource,
                               TripleStore tripleStore)
Moves a given RDFResource into another "home" TripleStore. This does not move any other triples but only moves the low-level information about which TripleStore shall be regarded as the "home" in the future. In Protege, this is the graph where the :NAME slot value is stored, i.e. moving the home means moving the :NAME value.

Parameters:
resource - the RDFResource to move
tripleStore - the new home TripleStoe

updateEditableResourceState

public void updateEditableResourceState()
Changes the isIncluded() value of all resources to reflect the currently active TripleStore. This should be called if the editable flag is relevant (e.g. in a user interface) after changes of the active TripleStore.