Protege 3.5

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

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

public class DefaultDatabaseFrameDb
extends AbstractDatabaseFrameDb


Field Summary
 
Fields inherited from class edu.stanford.smi.protege.storage.database.AbstractDatabaseFrameDb
_connections, _driver, _frameFactory, _isInclude, _password, _table, _url, _user, log, SLOW_QUERY_PROPERTY
 
Constructor Summary
DefaultDatabaseFrameDb()
           
 
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.
 boolean commitTransaction()
           
 void createTable()
           
 void deleteFrame(Frame frame)
           
protected  void endBatch()
           
 void ensureEmptyTableExists()
           
 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)
           
 Set getFramesWithAnyValue(Slot slot, Facet facet, boolean isTemplate)
           
 Map<Frame,Map<Sft,List>> getFrameValues()
           
 Map<Sft,List> getFrameValues(Frame frame)
           
 Set<Frame> getMatchingFrames(Slot slot, Facet facet, boolean isTemplate, String value, int maxMatches)
           
 Set<Reference> getMatchingReferences(String value, int maxMatches)
           
 Set<Reference> getReferences(Object value)
           
 int getSimpleInstanceCount()
           
 int getSlotCount()
           
 String getTable()
           
 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 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 reinitialize()
           
 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
 void replaceFrame(Frame original, Frame replacement)
          Replace all references of the frame original with the frame replacement.
 boolean rollbackTransaction()
           
protected  void saveFrames(KnowledgeBase kb)
           
protected  void saveValues(Frame frame, Slot slot, Facet facet, boolean isTemplate, Collection values)
           
 boolean setCaching(RemoteSession session, boolean doCache)
           
static void setModifiable(boolean modifiable)
           
 void setValues(Frame frame, Slot slot, Facet facet, boolean isTemplate, Collection values)
           
 String toString()
           
 
Methods inherited from class edu.stanford.smi.protege.storage.database.AbstractDatabaseFrameDb
close, createConnection, createRuntimeException, executeQuery, executeQuery, executeQuery, executeQuery, executeUpdate, executeUpdate, getCurrentConnection, getFrameFactory, getName, getTableName, getTransactionStatusMonitor, initialize, isNullValue, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultDatabaseFrameDb

public DefaultDatabaseFrameDb()
Method Detail

getClosure

public Set getClosure(Frame frame,
                      Slot slot,
                      Facet facet,
                      boolean isTemplate)

getTable

public String getTable()

setModifiable

public static void setModifiable(boolean modifiable)

ensureEmptyTableExists

public void ensureEmptyTableExists()
                            throws SQLException
Throws:
SQLException

createTable

public void createTable()
                 throws SQLException
Throws:
SQLException

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)

getReferences

public Set<Reference> getReferences(Object value)

getMatchingReferences

public Set<Reference> getMatchingReferences(String value,
                                            int maxMatches)

removeValue

public void removeValue(Frame frame,
                        Slot slot,
                        Facet facet,
                        boolean isTemplate,
                        Object value)

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)

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.

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

getMatchingFrames

public Set<Frame> getMatchingFrames(Slot slot,
                                    Facet facet,
                                    boolean isTemplate,
                                    String value,
                                    int maxMatches)
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)

getFramesWithAnyValue

public Set getFramesWithAnyValue(Slot slot,
                                 Facet facet,
                                 boolean isTemplate)

setValues

public void setValues(Frame frame,
                      Slot slot,
                      Facet facet,
                      boolean isTemplate,
                      Collection values)

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.

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)

getFrameValues

public Map<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
Overrides:
beginTransaction in class AbstractDatabaseFrameDb

commitTransaction

public boolean commitTransaction()
Specified by:
commitTransaction in interface NarrowFrameStore
Overrides:
commitTransaction in class AbstractDatabaseFrameDb

rollbackTransaction

public boolean rollbackTransaction()
Specified by:
rollbackTransaction in interface NarrowFrameStore
Overrides:
rollbackTransaction in class AbstractDatabaseFrameDb

replaceFrame

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


getClsCount

public int getClsCount()

getSlotCount

public int getSlotCount()

getFacetCount

public int getFacetCount()

getFrameCount

public int getFrameCount()

getFrames

public Set getFrames()

getSimpleInstanceCount

public int getSimpleInstanceCount()

getFrame

public Frame getFrame(FrameID id)

getDelegate

public NarrowFrameStore getDelegate()

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.

Parameters:
original - the frame in the database being replaced
replacement - the replacement frame that does not exist in the database before the call.

reinitialize

public void reinitialize()

setCaching

public boolean setCaching(RemoteSession session,
                          boolean doCache)

toString

public String toString()
Overrides:
toString in class Object

Protege 3.5

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