edu.stanford.smi.protege.storage.database
Class DefaultDatabaseFrameDb
java.lang.Object
edu.stanford.smi.protege.storage.database.AbstractDatabaseFrameDb
edu.stanford.smi.protege.storage.database.DefaultDatabaseFrameDb
- All Implemented Interfaces:
- NarrowFrameStore, DatabaseFrameDb
public class DefaultDatabaseFrameDb
- extends AbstractDatabaseFrameDb
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)
|
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 |
DefaultDatabaseFrameDb
public DefaultDatabaseFrameDb()
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 valueindex
- 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 slotfacet
- the facetisTemplate
- whether we are looking at template valuesvalue
- the regexp to use for matchingmaxMatches
- 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 frameslot
- the slotfacet
- 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 replacedreplacement
- the replacement frame that does not exist in the database before the call.
reinitialize
public void reinitialize()
toString
public String toString()
- Overrides:
toString
in class Object
Submit a bug report or feature request
Protégé is a trademark of Stanford University.
Copyright (c) 1998-2010 Stanford University.