Protege 3.4.1

edu.stanford.smi.protege.model.framestore
Class MergingNarrowFrameStore

java.lang.Object
  extended by edu.stanford.smi.protege.model.framestore.MergingNarrowFrameStore
All Implemented Interfaces:
NarrowFrameStore

public class MergingNarrowFrameStore
extends Object
implements NarrowFrameStore

All queries go to all frame stores. Writes go to the primary (delegate) frame store.

Author:
Ray Fergerson

Constructor Summary
MergingNarrowFrameStore(Object kbLock)
           
 
Method Summary
 void addActiveChildFrameStore(NarrowFrameStore childFrameStore, String parentName)
           
 void addActiveFrameStore(NarrowFrameStore frameStore)
           
 void addActiveFrameStore(NarrowFrameStore parent, Collection childNames)
           
 void addRelation(String parent, String child)
           
 void addValues(Frame frame, Slot slot, Facet facet, boolean isTemplate, Collection values)
           
 boolean beginTransaction(String name)
           
 void close()
           
 boolean commitTransaction()
           
 void deleteFrame(Frame frame)
           
 void dumpFrameStores()
           
 void dumpFrameStores(Level lev)
           
 void executeQuery(Query query, QueryCallback callback)
          The executeQuery method allows for complex queries.
static MergingNarrowFrameStore get(KnowledgeBase kb)
          A utility hack to get the merging frame store from a kb until I can decide what sort of "real" API access to provide.
 NarrowFrameStore getActiveFrameStore()
           
 Collection<NarrowFrameStore> getAllFrameStores()
           
 Collection<NarrowFrameStore> getAvailableFrameStores()
           
 Set getClosure(Frame frame, Slot slot, Facet facet, boolean isTemplate)
           
 int getClsCount()
           
 NarrowFrameStore getDelegate()
           
 int getFacetCount()
           
 Frame getFrame(FrameID id)
           
 int getFrameCount()
           
 Set getFrames()
           
 Set getFrames(Slot slot, Facet facet, boolean isTemplate, Object value)
           
 NarrowFrameStore getFrameStore(String name)
           
 Set getFramesWithAnyValue(Slot slot, Facet facet, boolean isTemplate)
           
 Set<Frame> getMatchingFrames(Slot slot, Facet facet, boolean isTemplate, String value, int maxMatches)
           
 Set<Reference> getMatchingReferences(String value, int maxMatches)
           
 String getName()
          The Narrow Frame store has a standard set/get name interface.
 Slot getNameSlot()
           
static NarrowFrameStore getNarrowFrameStore(KnowledgeBase kb, Class clazz)
           
 Set<Reference> getReferences(Object value)
           
 int getSimpleInstanceCount()
           
 int getSlotCount()
           
 NarrowFrameStore getSystemFrameStore()
           
static NarrowFrameStore getSystemFrameStore(KnowledgeBase kb)
           
 NarrowFrameStore getTopFrameStore()
           
 TransactionMonitor getTransactionStatusMonitor()
          Retrieves a transaction status monitor for transactions.
 List getValues(Frame frame, Slot slot, Facet facet, boolean isTemplate)
          Obtains the values of a slot/facet to a frame.
 int getValuesCount(Frame frame, Slot slot, Facet facet, boolean isTemplate)
           
 void moveValue(Frame frame, Slot slot, Facet facet, boolean isTemplate, int from, int to)
          Retrieves the list of values associated with the (frame, slot, facet, isTemplate) combination and moves the item at the position from to the position to.
 void reinitialize()
           
 void removeFrameStore(NarrowFrameStore frameStore)
           
 void removeValue(Frame frame, Slot slot, Facet facet, boolean isTemplate, Object value)
           
 void replaceFrame(Frame frame)
          A complete hack to work around problems with the java packages feature
 void replaceFrame(Frame original, Frame replacement)
          Replace all references of the frame original with the frame replacement.
 boolean rollbackTransaction()
           
 NarrowFrameStore setActiveFrameStore(NarrowFrameStore nfs)
           
 NarrowFrameStore setActiveFrameStore(String name)
           
 void setName(String name)
          The Narrow Frame store has a standard set/get name interface.
 void setQueryAllFrameStores(boolean b)
           
 void setRemoveFrameStores(Collection<NarrowFrameStore> narrowFrameStores)
          Set frame stores to remove values from.
 void setSuppressDuplicates(boolean suppressDuplicates)
           
 void setTopFrameStore(String name)
          Sets the top frame store, used to decide the root below which all framesstores are "available".
 void setValues(Frame frame, Slot slot, Facet facet, boolean isTemplate, Collection values)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MergingNarrowFrameStore

public MergingNarrowFrameStore(Object kbLock)
Method Detail

get

public static MergingNarrowFrameStore get(KnowledgeBase kb)
A utility hack to get the merging frame store from a kb until I can decide what sort of "real" API access to provide.


getSystemFrameStore

public static NarrowFrameStore getSystemFrameStore(KnowledgeBase kb)

getNarrowFrameStore

public static NarrowFrameStore getNarrowFrameStore(KnowledgeBase kb,
                                                   Class clazz)

getSystemFrameStore

public NarrowFrameStore getSystemFrameStore()

getAvailableFrameStores

public Collection<NarrowFrameStore> getAvailableFrameStores()

getAllFrameStores

public Collection<NarrowFrameStore> getAllFrameStores()

getName

public String getName()
Description copied from interface: NarrowFrameStore
The Narrow Frame store has a standard set/get name interface. One of the purposes of this interface is to allow the MergingNarrowFrameStore match names of the narrow frame stores of including and included projects. For this purpose the name of the narrow frame store is the string representation of the uri for the project.

Specified by:
getName in interface NarrowFrameStore
Returns:
the name of this narrow frame store.

setName

public void setName(String name)
Description copied from interface: NarrowFrameStore
The Narrow Frame store has a standard set/get name interface. One of the purposes of this interface is to allow the MergingNarrowFrameStore match names of the narrow frame stores of including and included projects. For this purpose the name of the narrow frame store is the string representation of the uri for the project.

Specified by:
setName in interface NarrowFrameStore
Parameters:
name - - the name of the Narrow Frame Store.

getActiveFrameStore

public NarrowFrameStore getActiveFrameStore()

setRemoveFrameStores

public void setRemoveFrameStores(Collection<NarrowFrameStore> narrowFrameStores)
Set frame stores to remove values from. The collection should not include the "active" frame store, which is handled separately.

Parameters:
narrowFrameStores - Collection of NarrowFrameStores

getFrameStore

public NarrowFrameStore getFrameStore(String name)

addRelation

public void addRelation(String parent,
                        String child)

dumpFrameStores

public void dumpFrameStores()

dumpFrameStores

public void dumpFrameStores(Level lev)

addActiveFrameStore

public void addActiveFrameStore(NarrowFrameStore frameStore)

addActiveChildFrameStore

public void addActiveChildFrameStore(NarrowFrameStore childFrameStore,
                                     String parentName)

removeFrameStore

public void removeFrameStore(NarrowFrameStore frameStore)

addActiveFrameStore

public void addActiveFrameStore(NarrowFrameStore parent,
                                Collection childNames)

getNameSlot

public Slot getNameSlot()

setTopFrameStore

public void setTopFrameStore(String name)
Sets the top frame store, used to decide the root below which all framesstores are "available". If you don't set a top frame store then the active frame store is assumed to be the top. If a top frame store is set then changing the active frame store does not affect the top.


getTopFrameStore

public NarrowFrameStore getTopFrameStore()

setActiveFrameStore

public NarrowFrameStore setActiveFrameStore(NarrowFrameStore nfs)

setQueryAllFrameStores

public void setQueryAllFrameStores(boolean b)

setSuppressDuplicates

public void setSuppressDuplicates(boolean suppressDuplicates)

setActiveFrameStore

public NarrowFrameStore setActiveFrameStore(String name)

getDelegate

public NarrowFrameStore getDelegate()
Specified by:
getDelegate in interface NarrowFrameStore

getFrameCount

public int getFrameCount()
Specified by:
getFrameCount in interface NarrowFrameStore

getFrames

public Set getFrames()
Specified by:
getFrames in interface NarrowFrameStore

getClsCount

public int getClsCount()
Specified by:
getClsCount in interface NarrowFrameStore

getSlotCount

public int getSlotCount()
Specified by:
getSlotCount in interface NarrowFrameStore

getFacetCount

public int getFacetCount()
Specified by:
getFacetCount in interface NarrowFrameStore

getSimpleInstanceCount

public int getSimpleInstanceCount()
Specified by:
getSimpleInstanceCount in interface NarrowFrameStore

getFrame

public Frame getFrame(FrameID id)
Specified by:
getFrame in interface NarrowFrameStore

getValues

public List getValues(Frame frame,
                      Slot slot,
                      Facet facet,
                      boolean isTemplate)
Description copied from interface: NarrowFrameStore
Obtains the values of a slot/facet to a frame. It consists of a list of Strings, Integers Floats and Frames. This call does one of several things. If facet == null then we are looking at a slot value. In this case, if isTemplate is true, then the frame is a class, the slot is a template slot and the value is a default facet value. If facet != null then we are looking at a facet value. In this case, if isTemplate is true then the frame is a class, the slot is a template slot and the value is a default facet value.

Specified by:
getValues in interface NarrowFrameStore
Parameters:
frame - - the frame
slot - the slot
facet - the facet. If this is non-null then we are looking at a facet value.
isTemplate - to be determined
Returns:
a list of the values of the slot of the frame.

getValuesCount

public int getValuesCount(Frame frame,
                          Slot slot,
                          Facet facet,
                          boolean isTemplate)
Specified by:
getValuesCount in interface NarrowFrameStore

addValues

public void addValues(Frame frame,
                      Slot slot,
                      Facet facet,
                      boolean isTemplate,
                      Collection values)
Specified by:
addValues in interface NarrowFrameStore

moveValue

public void moveValue(Frame frame,
                      Slot slot,
                      Facet facet,
                      boolean isTemplate,
                      int from,
                      int to)
Description copied from interface: NarrowFrameStore
Retrieves the list of values associated with the (frame, slot, facet, isTemplate) combination and moves the item at the position from to the position to. Indexing is done starting from 0.

Specified by:
moveValue in interface NarrowFrameStore
Parameters:
frame - the frame (as used in getValues)
slot - the slot (as used in getValues)
facet - the facet (as used in getValues)
isTemplate - whether it is a template (as used in getValues)
from - the starting position of a value
to - the position of the value after this call

removeValue

public void removeValue(Frame frame,
                        Slot slot,
                        Facet facet,
                        boolean isTemplate,
                        Object value)
Specified by:
removeValue in interface NarrowFrameStore

setValues

public void setValues(Frame frame,
                      Slot slot,
                      Facet facet,
                      boolean isTemplate,
                      Collection values)
Specified by:
setValues in interface NarrowFrameStore

getFrames

public Set getFrames(Slot slot,
                     Facet facet,
                     boolean isTemplate,
                     Object value)
Specified by:
getFrames in interface NarrowFrameStore

getFramesWithAnyValue

public Set getFramesWithAnyValue(Slot slot,
                                 Facet facet,
                                 boolean isTemplate)
Specified by:
getFramesWithAnyValue in interface NarrowFrameStore

getMatchingFrames

public Set<Frame> getMatchingFrames(Slot slot,
                                    Facet facet,
                                    boolean isTemplate,
                                    String value,
                                    int maxMatches)
Specified by:
getMatchingFrames in interface NarrowFrameStore
Parameters:
slot - the slot
facet - the facet
isTemplate - whether we are looking at template values
value - the regexp to use for matching
maxMatches - the max number of matches (-1 for get all)
Returns:
See Also:
KnowledgeBase.getMatchingFrames

getReferences

public Set<Reference> getReferences(Object value)
Specified by:
getReferences in interface NarrowFrameStore

getMatchingReferences

public Set<Reference> getMatchingReferences(String value,
                                            int maxMatches)
Specified by:
getMatchingReferences in interface NarrowFrameStore

executeQuery

public void executeQuery(Query query,
                         QueryCallback callback)
Description copied from interface: NarrowFrameStore
The executeQuery method allows for complex queries. It is asynchronous so that in server-client mode the server knowledge base lock will not be held for an excessive amount of time. The contract specifies that the implementor must call one of the QueryCallback methods in a separate thread. This makes it possible for the caller to know how to retrieve the results in a synchronous way without worrying about deadlock.

Specified by:
executeQuery in interface NarrowFrameStore

getClosure

public Set getClosure(Frame frame,
                      Slot slot,
                      Facet facet,
                      boolean isTemplate)
Specified by:
getClosure in interface NarrowFrameStore

deleteFrame

public void deleteFrame(Frame frame)
Specified by:
deleteFrame in interface NarrowFrameStore

close

public void close()
Specified by:
close in interface NarrowFrameStore

replaceFrame

public void replaceFrame(Frame frame)
Description copied from interface: NarrowFrameStore
A complete hack to work around problems with the java packages feature

Specified by:
replaceFrame in interface NarrowFrameStore

beginTransaction

public boolean beginTransaction(String name)
Specified by:
beginTransaction in interface NarrowFrameStore

commitTransaction

public boolean commitTransaction()
Specified by:
commitTransaction in interface NarrowFrameStore

rollbackTransaction

public boolean rollbackTransaction()
Specified by:
rollbackTransaction in interface NarrowFrameStore

getTransactionStatusMonitor

public TransactionMonitor getTransactionStatusMonitor()
Description copied from interface: NarrowFrameStore
Retrieves a transaction status monitor for transactions. If this call returns null then it means that transactions are not supported.

Specified by:
getTransactionStatusMonitor in interface NarrowFrameStore
Returns:
A TransactionMonitor object that tracks the status of transactions.

reinitialize

public void reinitialize()
Specified by:
reinitialize in interface NarrowFrameStore

replaceFrame

public void replaceFrame(Frame original,
                         Frame replacement)
Description copied from interface: NarrowFrameStore
Replace all references of the frame original with the frame replacement. This (somewhat expensive) routine is used when the user wants to change the name of a frame. The result of this call is that the original frame is deleted and the replacement frame takes over in each position where the original frame occured. When the name of a frame is being changed, the caller will create a new frame (the replacement) with the new name and will then delete the original frame.

Specified by:
replaceFrame in interface NarrowFrameStore
Parameters:
original - the frame in the database being replaced
replacement - the replacement frame that does not exist in the database before the call.

Protege 3.4.1

Submit a bug report or feature request
Protégé is a trademark of Stanford University.
Copyright (c) 1998-2009 Stanford University.