edu.stanford.smi.protegex.owl.model.framestore
Class OWLFrameStore

java.lang.Object
  extended byedu.stanford.smi.protege.model.framestore.AbstractFrameStore
      extended byedu.stanford.smi.protege.model.framestore.FrameStoreAdapter
          extended byedu.stanford.smi.protegex.owl.model.framestore.OWLFrameStore
All Implemented Interfaces:
edu.stanford.smi.protege.model.framestore.FrameStore

public class OWLFrameStore
extends edu.stanford.smi.protege.model.framestore.FrameStoreAdapter

A FrameStore with specific support for OWL ontologies. While most calls simply forward to their default implementation, some calls are intercepted to do some extra work:

The goal of this architecture is to make sure that there a no unused anonymous classes around. This cannot be done through a garbage collection because then components such as the Jena synchronizers could not be able to delete a class when it should be deleted.
Normally, all anonymous classes are used only in one place (their host class). The host can be a restriction (as facet override in the all and some restrictions), a slot (e.g. via domain and range), or a named class (e.g. as superclass or disjoint class). Much of the logic for this deleting of depending classes is encapsulated in the subtypes of RDFSClass. Some extra cases, however (especially restrictions) must be handled with care.
With restrictions, the rule that anonymous classes are only attached to a single host is no longer valid. Restrictions store their filler as a facet override. In the case of all and some restrictions, these overrides can be (anonymous) classes. The same classes are mapped into facet overrides in the host class -- they are not cloned because there is only one representation in the corresponding Jena/OWL model.
These anonymous classes have the restriction as host, and they are deleted when the restriction is deleted or changes its filler. As a consequence, the following actions are performed by this FrameStore:
Finally, the OWLFrameStore also makes sure that if a named class has an intersection as equivalent class, then all named operands of these intersections are also superclasses of the host class. Note that this is maintained in both direction, i.e. if someone removes an intersection, then the named operands are also automatically removed, no matter whether the user intended to also add the class as a superclass. These side effects need to be considered by OWL API users.

Author:
Holger Knublauch

Field Summary
static boolean allowDuplicateOwnSlotValues
           
private  AllValuesFromRestrictionUpdater allValuesFromRestrictionUpdater
           
static boolean autoDeleteOfAnonymousClses
          An ugly trick to prevent anonymous classes from being deleted as a side effect
private  CardinalityRestrictionUpdater cardinalityRestrictionUpdater
           
private  Hashtable class2Updater
          A Hashtable from Java restriction Class objects to the responsible RestrictionUpdaters
private  boolean deletingRDFSDatatype
           
private  Hashtable facet2Updater
          A Hashtable from Facets to the responsible RestrictionUpdaters
protected  boolean facetHandlingBlocked
          A flag to prevent infinite recursion when a superclass has been added or removed
private  HasValueRestrictionUpdater hasValueRestrictionUpdater
           
static String IGNORE_PREFIXES_IN_SEARCH
           
private  AbstractOWLModel owlModel
           
protected  boolean superclassHandlingBlocked
          A flag to prevent infinite recursion when a facet override has been changed.
private  boolean superclassSynchronizationBlocked
           
 boolean suppressUpdateRDFSDomain
           
private  boolean suppressUpdateTemplateSlots
           
 
Fields inherited from class edu.stanford.smi.protege.model.framestore.AbstractFrameStore
 
Fields inherited from interface edu.stanford.smi.protege.model.framestore.FrameStore
UNLIMITED_MATCHES
 
Constructor Summary
OWLFrameStore(AbstractOWLModel owlModel)
           
 
Method Summary
 void addDirectSuperclass(edu.stanford.smi.protege.model.Cls cls, edu.stanford.smi.protege.model.Cls superCls)
           
 void addDirectSuperslot(edu.stanford.smi.protege.model.Slot slot, edu.stanford.smi.protege.model.Slot superSlot)
           
 void addDirectTemplateSlot(edu.stanford.smi.protege.model.Cls cls, edu.stanford.smi.protege.model.Slot slot)
           
 void addDirectType(edu.stanford.smi.protege.model.Instance instance, edu.stanford.smi.protege.model.Cls type)
           
private  void addNamedOperandsToDirectSuperclasses(OWLNamedClass cls, OWLIntersectionClass superCls)
           
private  List convertInternalFormatToRDFSLiterals(Collection values)
           
private  List convertRDFSLiteralsToInternalFormat(Collection values)
           
 void copyFacetValuesIntoNamedClses()
           
private  void copyFacetValuesIntoOWLNamedClass(OWLRestriction restriction)
           
private  void copyFacetValuesIntoOWLNamedClass(RDFSNamedClass cls, OWLRestriction restriction)
           
 edu.stanford.smi.protege.model.Cls createCls(edu.stanford.smi.protege.model.FrameID id, String name, Collection directTypes, Collection directSuperclasses, boolean loadDefaults)
           
 edu.stanford.smi.protege.model.SimpleInstance createSimpleInstance(edu.stanford.smi.protege.model.FrameID id, String name, Collection directTypes, boolean loadDefaults)
           
 edu.stanford.smi.protege.model.Slot createSlot(edu.stanford.smi.protege.model.FrameID id, String name, Collection directTypes, Collection directSuperslots, boolean loadDefaults)
           
private  void deleteAnonymousClass(OWLAnonymousClass cls)
           
private  void deleteAnonymousClasses(Collection clses, Collection survivors)
           
private  void deleteAnonymousClses(Collection clses)
           
private  void deleteAnonymousTree(OWLAnonymousClass anonymousClass)
           
 void deleteCls(edu.stanford.smi.protege.model.Cls cls)
           
private  void deleteDependingAnonymousClses(edu.stanford.smi.protege.model.Cls cls)
           
private  void deleteDependingAnonymousClses(edu.stanford.smi.protege.model.Slot slot)
           
private  void deleteDependingListInstances(edu.stanford.smi.protege.model.Instance instance)
           
private  void deleteListChain(RDFList list)
           
private  void deleteListInstance(RDFList li)
          Deletes a RDFList cleanly from its list.
private  void deleteNamedClass(RDFSNamedClass cls)
           
private  void deleteNamedClassFromUnionDomainsAndRanges(RDFSNamedClass cls)
           
 void deleteQuantifierRestrictions(OWLProperty property)
          Deletes all QuantifierRestrictions (and the expressions where they are used) which restrict a given propertyerty.
private  void deleteRDFListsThatArePropertyValues(RDFResource resource)
           
 void deleteSimpleInstance(edu.stanford.smi.protege.model.SimpleInstance simpleInstance)
           
 void deleteSlot(edu.stanford.smi.protege.model.Slot slot)
          Deletes the depending classes (anonymous domains and ranges) of the slot being deleted.
private  void ensureRDFSSubClassOfStatementsExistForNamedOperands(OWLIntersectionClass intersectionClass)
           
 Collection getClsesToDelete(edu.stanford.smi.protege.model.Cls cls)
          A slighly adjusted version of DeleteSimplificationFrameStore that ignores links through the anonymous root class.
 Set getClsesWithMatchingBrowserText(String value, Collection superclasses, int maxMatches)
           
 Collection getConvertedValues(Collection values)
           
private  edu.stanford.smi.protege.model.framestore.DeleteSimplificationFrameStore getDeleteSimplificationFrameStore()
           
 List getDirectOwnSlotValuesConverting(edu.stanford.smi.protege.model.Frame frame, edu.stanford.smi.protege.model.Slot slot)
           
 Set getFramesWithMatchingDirectOwnSlotValue(edu.stanford.smi.protege.model.Slot slot, String value, int maxMatches)
           
private  void getFramesWithMatchingHelper(edu.stanford.smi.protege.model.Slot slot, String value, int maxMatches, Set results)
           
 List getLiteralValues(List values)
           
 Set getMatchingReferences(String value, int maxMatches)
           
 Collection getOwnSlotValuesConverting(edu.stanford.smi.protege.model.Frame frame, edu.stanford.smi.protege.model.Slot slot)
           
 List getPropertyValueLiterals(RDFResource frame, RDFProperty slot)
           
private  Collection getSlotsToDelete(edu.stanford.smi.protege.model.Slot slot)
           
private  void initRestrictionUpdaters()
           
static boolean isIgnorePrefixesInSearch(OWLModel owlModel)
           
private  boolean isReachableByAnotherRoute(edu.stanford.smi.protege.model.Cls subclass, Collection classesToBeDeleted)
           
private static void log(String str)
           
private  void printDeprecationWarning(String methodName)
           
 void removeDirectSuperclass(edu.stanford.smi.protege.model.Cls cls, edu.stanford.smi.protege.model.Cls superCls)
           
 void removeDirectSuperslot(edu.stanford.smi.protege.model.Slot slot, edu.stanford.smi.protege.model.Slot superslot)
           
 void removeDirectTemplateSlot(edu.stanford.smi.protege.model.Cls cls, edu.stanford.smi.protege.model.Slot slot)
           
 void removeDirectType(edu.stanford.smi.protege.model.Instance instance, edu.stanford.smi.protege.model.Cls directType)
           
private  void removeNamedOperandsFromDirectSuperclasses(OWLNamedClass cls, OWLIntersectionClass intersectionCls, edu.stanford.smi.protege.model.Slot slot)
           
 void setDirectOwnSlotValues(edu.stanford.smi.protege.model.Frame frame, edu.stanford.smi.protege.model.Slot slot, Collection values)
           
 void setDirectTemplateFacetValues(edu.stanford.smi.protege.model.Cls cls, edu.stanford.smi.protege.model.Slot slot, edu.stanford.smi.protege.model.Facet facet, Collection values)
           
 void setDirectTemplateSlotValues(edu.stanford.smi.protege.model.Cls cls, edu.stanford.smi.protege.model.Slot slot, Collection values)
           
 void setSuperclassSynchronizationBlocked(boolean value)
           
private  void updatePropertyAllowedClasses(RDFProperty property, Collection values)
           
private  void updatePropertyValueType(RDFProperty property, Collection values)
          Updates the ValueType of a datatype slot in response to changes in the range.
private  void updateRDFSDomain(RDFProperty property)
           
private  void updateRDFSSubClassOf(RDFSNamedClass cls)
          Updates the values of rdfs:subClassOf (and owl:equivalentClass) in response to changes in the :SLOT-DIRECT-SUPERCLASSES.
private  void updateRestrictions(OWLNamedClass cls, RDFProperty slot, edu.stanford.smi.protege.model.Facet facet)
           
private  void updateSlotDomain(edu.stanford.smi.protege.model.Slot slot, Collection values)
          Updates the values of :SLOT-DIRECT-DOMAIN and :SLOT-DIRECT-TEMPLATE-SLOTS in response to changes in rdfs:domain.
 
Methods inherited from class edu.stanford.smi.protege.model.framestore.FrameStoreAdapter
beginTransaction, commitTransaction, createFacet, deleteFacet, executeQuery, getClsCount, getClses, getClsesWithAnyDirectTemplateSlotValue, getClsesWithDirectTemplateFacetValue, getClsesWithDirectTemplateSlotValue, getClsesWithMatchingDirectTemplateFacetValue, getClsesWithMatchingDirectTemplateSlotValue, getDirectDomain, getDirectInstances, getDirectlyOverriddenTemplateFacets, getDirectlyOverriddenTemplateSlots, getDirectOwnSlotValues, getDirectOwnSlotValuesClosure, getDirectOwnSlotValuesCount, getDirectSubclasses, getDirectSubslots, getDirectSuperclasses, getDirectSuperslots, getDirectTemplateFacetValues, getDirectTemplateSlots, getDirectTemplateSlotValues, getDirectTypes, getDomain, getEvents, getFacetCount, getFacets, getFrame, getFrame, getFrameCount, getFrameName, getFrames, getFramesWithAnyDirectOwnSlotValue, getFramesWithDirectOwnSlotValue, getInstances, getOverriddenTemplateFacets, getOverriddenTemplateSlots, getOwnFacets, getOwnFacetValues, getOwnSlots, getOwnSlotValues, getReferences, getSimpleInstanceCount, getSlotCount, getSlots, getSubclasses, getSubslots, getSuperclasses, getSuperslots, getTemplateFacets, getTemplateFacetValues, getTemplateSlots, getTemplateSlotValues, getTypes, moveDirectOwnSlotValue, moveDirectSubclass, moveDirectSubslot, moveDirectTemplateSlot, moveDirectType, reinitialize, removeDirectTemplateFacetOverrides, rollbackTransaction, setFrameName
 
Methods inherited from class edu.stanford.smi.protege.model.framestore.AbstractFrameStore
close, getDelegate, getName, onSetDelegate, setDelegate, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

class2Updater

private Hashtable class2Updater
A Hashtable from Java restriction Class objects to the responsible RestrictionUpdaters


facet2Updater

private Hashtable facet2Updater
A Hashtable from Facets to the responsible RestrictionUpdaters


facetHandlingBlocked

protected boolean facetHandlingBlocked
A flag to prevent infinite recursion when a superclass has been added or removed


allValuesFromRestrictionUpdater

private AllValuesFromRestrictionUpdater allValuesFromRestrictionUpdater

cardinalityRestrictionUpdater

private CardinalityRestrictionUpdater cardinalityRestrictionUpdater

hasValueRestrictionUpdater

private HasValueRestrictionUpdater hasValueRestrictionUpdater

owlModel

private AbstractOWLModel owlModel

superclassHandlingBlocked

protected boolean superclassHandlingBlocked
A flag to prevent infinite recursion when a facet override has been changed.


suppressUpdateTemplateSlots

private boolean suppressUpdateTemplateSlots

IGNORE_PREFIXES_IN_SEARCH

public static final String IGNORE_PREFIXES_IN_SEARCH
See Also:
Constant Field Values

superclassSynchronizationBlocked

private boolean superclassSynchronizationBlocked

deletingRDFSDatatype

private boolean deletingRDFSDatatype

autoDeleteOfAnonymousClses

public static boolean autoDeleteOfAnonymousClses
An ugly trick to prevent anonymous classes from being deleted as a side effect


allowDuplicateOwnSlotValues

public static boolean allowDuplicateOwnSlotValues

suppressUpdateRDFSDomain

public boolean suppressUpdateRDFSDomain
Constructor Detail

OWLFrameStore

public OWLFrameStore(AbstractOWLModel owlModel)
Method Detail

addDirectSuperclass

public void addDirectSuperclass(edu.stanford.smi.protege.model.Cls cls,
                                edu.stanford.smi.protege.model.Cls superCls)

addDirectSuperslot

public void addDirectSuperslot(edu.stanford.smi.protege.model.Slot slot,
                               edu.stanford.smi.protege.model.Slot superSlot)

addDirectType

public void addDirectType(edu.stanford.smi.protege.model.Instance instance,
                          edu.stanford.smi.protege.model.Cls type)

addNamedOperandsToDirectSuperclasses

private void addNamedOperandsToDirectSuperclasses(OWLNamedClass cls,
                                                  OWLIntersectionClass superCls)

convertInternalFormatToRDFSLiterals

private List convertInternalFormatToRDFSLiterals(Collection values)

convertRDFSLiteralsToInternalFormat

private List convertRDFSLiteralsToInternalFormat(Collection values)

copyFacetValuesIntoOWLNamedClass

private void copyFacetValuesIntoOWLNamedClass(RDFSNamedClass cls,
                                              OWLRestriction restriction)

copyFacetValuesIntoOWLNamedClass

private void copyFacetValuesIntoOWLNamedClass(OWLRestriction restriction)

copyFacetValuesIntoNamedClses

public void copyFacetValuesIntoNamedClses()

createCls

public edu.stanford.smi.protege.model.Cls createCls(edu.stanford.smi.protege.model.FrameID id,
                                                    String name,
                                                    Collection directTypes,
                                                    Collection directSuperclasses,
                                                    boolean loadDefaults)

createSlot

public edu.stanford.smi.protege.model.Slot createSlot(edu.stanford.smi.protege.model.FrameID id,
                                                      String name,
                                                      Collection directTypes,
                                                      Collection directSuperslots,
                                                      boolean loadDefaults)

createSimpleInstance

public edu.stanford.smi.protege.model.SimpleInstance createSimpleInstance(edu.stanford.smi.protege.model.FrameID id,
                                                                          String name,
                                                                          Collection directTypes,
                                                                          boolean loadDefaults)

deleteAnonymousClass

private void deleteAnonymousClass(OWLAnonymousClass cls)

deleteAnonymousClses

private void deleteAnonymousClses(Collection clses)

deleteAnonymousClasses

private void deleteAnonymousClasses(Collection clses,
                                    Collection survivors)

deleteAnonymousTree

private void deleteAnonymousTree(OWLAnonymousClass anonymousClass)

deleteCls

public void deleteCls(edu.stanford.smi.protege.model.Cls cls)

deleteDependingAnonymousClses

private void deleteDependingAnonymousClses(edu.stanford.smi.protege.model.Cls cls)

deleteDependingAnonymousClses

private void deleteDependingAnonymousClses(edu.stanford.smi.protege.model.Slot slot)

deleteDependingListInstances

private void deleteDependingListInstances(edu.stanford.smi.protege.model.Instance instance)

deleteRDFListsThatArePropertyValues

private void deleteRDFListsThatArePropertyValues(RDFResource resource)

deleteListInstance

private void deleteListInstance(RDFList li)
Deletes a RDFList cleanly from its list. This will update all references to it (e.g. if it is a direct own slot value somewhere, then it will replace those with the rest of this.

Parameters:
li - the RDFList to delete

deleteNamedClass

private void deleteNamedClass(RDFSNamedClass cls)

deleteNamedClassFromUnionDomainsAndRanges

private void deleteNamedClassFromUnionDomainsAndRanges(RDFSNamedClass cls)

deleteQuantifierRestrictions

public void deleteQuantifierRestrictions(OWLProperty property)
Deletes all QuantifierRestrictions (and the expressions where they are used) which restrict a given propertyerty. This is needed when a property changes its type.

Parameters:
property - the restricted property

deleteSimpleInstance

public void deleteSimpleInstance(edu.stanford.smi.protege.model.SimpleInstance simpleInstance)

deleteListChain

private void deleteListChain(RDFList list)

deleteSlot

public void deleteSlot(edu.stanford.smi.protege.model.Slot slot)
Deletes the depending classes (anonymous domains and ranges) of the slot being deleted.

Parameters:
slot - the Slot being deleted

ensureRDFSSubClassOfStatementsExistForNamedOperands

private void ensureRDFSSubClassOfStatementsExistForNamedOperands(OWLIntersectionClass intersectionClass)

getClsesToDelete

public Collection getClsesToDelete(edu.stanford.smi.protege.model.Cls cls)
A slighly adjusted version of DeleteSimplificationFrameStore that ignores links through the anonymous root class.

Parameters:
cls -
Returns:
see the super method

getDeleteSimplificationFrameStore

private edu.stanford.smi.protege.model.framestore.DeleteSimplificationFrameStore getDeleteSimplificationFrameStore()

getDirectOwnSlotValuesConverting

public List getDirectOwnSlotValuesConverting(edu.stanford.smi.protege.model.Frame frame,
                                             edu.stanford.smi.protege.model.Slot slot)

getPropertyValueLiterals

public List getPropertyValueLiterals(RDFResource frame,
                                     RDFProperty slot)

getLiteralValues

public List getLiteralValues(List values)

getOwnSlotValuesConverting

public Collection getOwnSlotValuesConverting(edu.stanford.smi.protege.model.Frame frame,
                                             edu.stanford.smi.protege.model.Slot slot)

getConvertedValues

public Collection getConvertedValues(Collection values)

getClsesWithMatchingBrowserText

public Set getClsesWithMatchingBrowserText(String value,
                                           Collection superclasses,
                                           int maxMatches)

getFramesWithMatchingDirectOwnSlotValue

public Set getFramesWithMatchingDirectOwnSlotValue(edu.stanford.smi.protege.model.Slot slot,
                                                   String value,
                                                   int maxMatches)

getFramesWithMatchingHelper

private void getFramesWithMatchingHelper(edu.stanford.smi.protege.model.Slot slot,
                                         String value,
                                         int maxMatches,
                                         Set results)

getMatchingReferences

public Set getMatchingReferences(String value,
                                 int maxMatches)

getSlotsToDelete

private Collection getSlotsToDelete(edu.stanford.smi.protege.model.Slot slot)

initRestrictionUpdaters

private void initRestrictionUpdaters()

isIgnorePrefixesInSearch

public static boolean isIgnorePrefixesInSearch(OWLModel owlModel)

isReachableByAnotherRoute

private boolean isReachableByAnotherRoute(edu.stanford.smi.protege.model.Cls subclass,
                                          Collection classesToBeDeleted)

log

private static void log(String str)

removeDirectSuperclass

public void removeDirectSuperclass(edu.stanford.smi.protege.model.Cls cls,
                                   edu.stanford.smi.protege.model.Cls superCls)

removeDirectSuperslot

public void removeDirectSuperslot(edu.stanford.smi.protege.model.Slot slot,
                                  edu.stanford.smi.protege.model.Slot superslot)

removeDirectType

public void removeDirectType(edu.stanford.smi.protege.model.Instance instance,
                             edu.stanford.smi.protege.model.Cls directType)

removeNamedOperandsFromDirectSuperclasses

private void removeNamedOperandsFromDirectSuperclasses(OWLNamedClass cls,
                                                       OWLIntersectionClass intersectionCls,
                                                       edu.stanford.smi.protege.model.Slot slot)

setDirectOwnSlotValues

public void setDirectOwnSlotValues(edu.stanford.smi.protege.model.Frame frame,
                                   edu.stanford.smi.protege.model.Slot slot,
                                   Collection values)

setSuperclassSynchronizationBlocked

public void setSuperclassSynchronizationBlocked(boolean value)

addDirectTemplateSlot

public void addDirectTemplateSlot(edu.stanford.smi.protege.model.Cls cls,
                                  edu.stanford.smi.protege.model.Slot slot)

printDeprecationWarning

private void printDeprecationWarning(String methodName)

removeDirectTemplateSlot

public void removeDirectTemplateSlot(edu.stanford.smi.protege.model.Cls cls,
                                     edu.stanford.smi.protege.model.Slot slot)

updateRDFSDomain

private void updateRDFSDomain(RDFProperty property)

setDirectTemplateFacetValues

public void setDirectTemplateFacetValues(edu.stanford.smi.protege.model.Cls cls,
                                         edu.stanford.smi.protege.model.Slot slot,
                                         edu.stanford.smi.protege.model.Facet facet,
                                         Collection values)

setDirectTemplateSlotValues

public void setDirectTemplateSlotValues(edu.stanford.smi.protege.model.Cls cls,
                                        edu.stanford.smi.protege.model.Slot slot,
                                        Collection values)

updatePropertyAllowedClasses

private void updatePropertyAllowedClasses(RDFProperty property,
                                          Collection values)

updatePropertyValueType

private void updatePropertyValueType(RDFProperty property,
                                     Collection values)
Updates the ValueType of a datatype slot in response to changes in the range.


updateRestrictions

private void updateRestrictions(OWLNamedClass cls,
                                RDFProperty slot,
                                edu.stanford.smi.protege.model.Facet facet)

updateRDFSSubClassOf

private void updateRDFSSubClassOf(RDFSNamedClass cls)
Updates the values of rdfs:subClassOf (and owl:equivalentClass) in response to changes in the :SLOT-DIRECT-SUPERCLASSES.

Parameters:
cls - the RDFSClass that has changed its superclasses

updateSlotDomain

private void updateSlotDomain(edu.stanford.smi.protege.model.Slot slot,
                              Collection values)
Updates the values of :SLOT-DIRECT-DOMAIN and :SLOT-DIRECT-TEMPLATE-SLOTS in response to changes in rdfs:domain.

Parameters:
slot -
values -