Protege 3.3.1

edu.stanford.smi.protege.storage.database
Class DatabaseFrameDb

java.lang.Object
  extended by edu.stanford.smi.protege.storage.database.DatabaseFrameDb
All Implemented Interfaces:
NarrowFrameStore

public class DatabaseFrameDb
extends Object
implements NarrowFrameStore


Nested Class Summary
static class DatabaseFrameDb.Column
           
 
Constructor Summary
DatabaseFrameDb()
           
 
Method Summary
 void addValues(Frame frame, Slot slot, Facet facet, boolean isTemplate, Collection values)
           
protected  void beginBatch()
           
 boolean beginTransaction(String name)
           
 boolean checkMySQLBug()
          This routine checks for a bug in mysql.
 void close()
           
 boolean commitTransaction()
           
 void createNewTableAndIndices()
           
 void deleteFrame(Frame frame)
           
protected  void endBatch()
           
 void executeQuery(Query query, QueryCallback callback)
          The executeQuery method allows for complex queries.
 FrameID generateFrameID()
           
 Set getClosure(Frame frame, Slot slot, Facet facet, boolean isTemplate)
           
 int getClsCount()
           
protected  RobustConnection getCurrentConnection()
           
 NarrowFrameStore getDelegate()
           
 int getFacetCount()
           
 Frame getFrame(FrameID id)
           
 int getFrameCount()
           
 FrameFactory getFrameFactory()
           
 Set getFrames()
           
 Set getFrames(Slot slot, Facet facet, boolean isTemplate, Object value)
           
 Set getFramesWithAnyValue(Slot slot, Facet facet, boolean isTemplate)
           
 CacheMap<Frame,Map<Sft,List>> getFrameValues()
           
 Map<Sft,List> getFrameValues(Frame frame)
           
 Set 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.
 Set<Reference> getReferences(Object value)
           
 int getSimpleInstanceCount()
           
 int getSlotCount()
           
 String getTable()
           
 String getTableName()
           
 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 initialize(FrameFactory factory, String driver, String url, String user, String pass, String table, boolean isInclude)
           
 void moveValue(Frame frame, Slot slot, Facet facet, boolean isTemplate, int from, int index)
          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 overwriteKB(KnowledgeBase kb, boolean saveFrames)
           
 void removeValue(Frame frame, Slot slot, Facet facet, boolean isTemplate, Object value)
           
 void removeValues(Frame frame, Slot slot, Facet facet, boolean isTemplate)
           
 void replaceFrame(Frame frame)
          A complete hack to work around problems with the java packages feature
 boolean rollbackTransaction()
           
protected  void saveFrames(KnowledgeBase kb)
           
protected  void saveValues(Frame frame, Slot slot, Facet facet, boolean isTemplate, Collection values)
           
protected  void setMemoryProjectId(int memoryProjectId)
           
static void setModifiable(boolean modifiable)
           
 void setName(String name)
          The Narrow Frame store has a standard set/get name interface.
 void setValues(Frame frame, Slot slot, Facet facet, boolean isTemplate, Collection values)
           
 boolean tableExists()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DatabaseFrameDb

public DatabaseFrameDb()
Method Detail

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.

getClosure

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

getCurrentConnection

protected RobustConnection getCurrentConnection()
                                         throws SQLException
Throws:
SQLException

close

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

setMemoryProjectId

protected void setMemoryProjectId(int memoryProjectId)

initialize

public void initialize(FrameFactory factory,
                       String driver,
                       String url,
                       String user,
                       String pass,
                       String table,
                       boolean isInclude)

getFrameFactory

public FrameFactory getFrameFactory()

getTable

public String getTable()

setModifiable

public static void setModifiable(boolean modifiable)

getTableName

public String getTableName()

tableExists

public boolean tableExists()

createNewTableAndIndices

public void createNewTableAndIndices()

checkMySQLBug

public boolean checkMySQLBug()
This routine checks for a bug in mysql. MySQL hack - there is a bug in mysql where SELECT statements will fail to produce the correct result because of these index statements. There is a bug report out to mysql for this problem on the page http://bugs.mysql.com/bug.php?id=16121 Right now we are working around this problem by disabling indexing. Sometime I need to investigate exactly which mysql's are bad.


deleteFrame

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

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

removeValue

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

removeValues

public void removeValues(Frame frame,
                         Slot slot,
                         Facet facet,
                         boolean isTemplate)

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 index)
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
index - the position of the value after this call

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

getMatchingFrames

public Set 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

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

setValues

public void setValues(Frame frame,
                      Slot slot,
                      Facet facet,
                      boolean isTemplate,
                      Collection values)
Specified by:
setValues 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

getFrameValues

public CacheMap<Frame,Map<Sft,List>> getFrameValues()

getFrameValues

public Map<Sft,List> getFrameValues(Frame frame)

beginBatch

protected void beginBatch()
                   throws SQLException
Throws:
SQLException

endBatch

protected void endBatch()
                 throws SQLException
Throws:
SQLException

overwriteKB

public void overwriteKB(KnowledgeBase kb,
                        boolean saveFrames)
                 throws SQLException
Throws:
SQLException

saveFrames

protected void saveFrames(KnowledgeBase kb)
                   throws SQLException
Throws:
SQLException

saveValues

protected void saveValues(Frame frame,
                          Slot slot,
                          Facet facet,
                          boolean isTemplate,
                          Collection values)
                   throws SQLException
Throws:
SQLException

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.

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

toString

public String toString()
Overrides:
toString in class Object

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

getFrameCount

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

getFrames

public Set getFrames()
Specified by:
getFrames 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

generateFrameID

public FrameID generateFrameID()
Specified by:
generateFrameID in interface NarrowFrameStore

getDelegate

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

Protege 3.3.1

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