Protege 2.1

edu.stanford.smi.protege.storage.jdbc
Class SimpleJdbcDatabaseManager

java.lang.Object
  extended byedu.stanford.smi.protege.storage.jdbc.SimpleJdbcDatabaseManager
All Implemented Interfaces:
DatabaseConstants, DatabaseManager, Disposable

public class SimpleJdbcDatabaseManager
extends Object
implements DatabaseManager

An implementation of the database schema interface that implements a very simple database schema. This schema is described in some detail, along with its rationale at http://protege.stanford.edu/doc/design/jdbc_backend.html This schema is quite convenient for Protege itself to use because it maps directly to the way Protege works. Everything is a slot value or a facet value. The schema is totally useless for someone trying to write reasonable SQL to get information out of their knowledge base. Such a backend could certainly be developed. This is not it though!

Author:
Ray Fergerson

Nested Class Summary
static class SimpleJdbcDatabaseManager.ValueDBIndexPair
           
 
Field Summary
 
Fields inherited from interface edu.stanford.smi.protege.storage.jdbc.DatabaseConstants
TYPE_BOOLEAN, TYPE_CLASS, TYPE_FACET, TYPE_FLOAT, TYPE_INTEGER, TYPE_INVALID, TYPE_SIMPLE_INSTANCE, TYPE_SLOT, TYPE_STRING
 
Constructor Summary
SimpleJdbcDatabaseManager(String driver, String url, String tablename, String username, String password, Collection errors)
           
 
Method Summary
 void addValue(Frame frame, Slot slot, Facet facet, boolean isTemplate, Object value)
           
 boolean beginTransaction()
          returns true if transaction started successfully
 void createIndexes()
           
 void createTable()
           
 void dispose()
           
 boolean endTransaction(boolean doCommit)
          return true if transation commited successfull
 Collection getAllFrameIDs()
           
 Collection getDBReferences(Object o, int maxMatches)
          returns a collection of DBReference objects
 String getDriverLongvarcharName()
           
 String getDriverName()
           
 int getFrameCount(int type)
           
 Collection getFrameIDs(FrameID slot, FrameID facet, boolean isTemplate, String value)
           
 Collection getFramesWithAnyValue(Slot slot, Facet facet, boolean isTemplate)
          returns a collection of FrameIDs
 Collection getFramesWithValue(Slot slot, Facet facet, boolean isTemplate, Object value)
          returns a collection of FrameIDs
 int getFrameType(FrameID id)
           
 String getLongvarcharName()
           
 Collection getMatchingFrameIDs(FrameID slot, FrameID facet, boolean isTemplate, String value, int maxMatches)
           
 String getParameterLongvarcharName()
           
 String getTableName()
           
 int getValueCount(FrameID frame, FrameID slot, FrameID facet, boolean isTemplate)
           
 List getValues(FrameID frame, FrameID slot, FrameID facet, boolean isTemplate)
          returns a collection of Objects.
 boolean hasValueAtSomeFrame(Slot slot, Facet facet, boolean isTemplate)
           
 void removeAllReferences(Frame frame)
           
 void removeAllValues(Frame frame, Slot slot, Facet facet, boolean isTemplate)
           
 void removeFramesWithValue(Slot slot, Facet facet, boolean isTemplate)
           
 void removeSingleValue(Frame frame, Slot slot, Facet facet, boolean isTemplate, Object value)
           
 void saveKnowledgeBase(KnowledgeBase kb)
           
 void setTracing(boolean b)
           
 void setValue(Frame frame, Slot slot, Facet facet, boolean isTemplate, Object value)
           
 void setValues(Frame frame, Slot slot, Facet facet, boolean isTemplate, Collection values)
           
 boolean supportsTransactions()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleJdbcDatabaseManager

public SimpleJdbcDatabaseManager(String driver,
                                 String url,
                                 String tablename,
                                 String username,
                                 String password,
                                 Collection errors)
Method Detail

addValue

public void addValue(Frame frame,
                     Slot slot,
                     Facet facet,
                     boolean isTemplate,
                     Object value)
              throws SQLException
Specified by:
addValue in interface DatabaseManager
Throws:
SQLException

beginTransaction

public boolean beginTransaction()
returns true if transaction started successfully

Specified by:
beginTransaction in interface DatabaseManager

createIndexes

public void createIndexes()
                   throws SQLException
Throws:
SQLException

createTable

public void createTable()
                 throws SQLException
Throws:
SQLException

dispose

public void dispose()
Specified by:
dispose in interface Disposable

endTransaction

public boolean endTransaction(boolean doCommit)
return true if transation commited successfull

Specified by:
endTransaction in interface DatabaseManager

getFrameCount

public int getFrameCount(int type)
                  throws SQLException
Specified by:
getFrameCount in interface DatabaseManager
Throws:
SQLException

getAllFrameIDs

public Collection getAllFrameIDs()
                          throws SQLException
Specified by:
getAllFrameIDs in interface DatabaseManager
Throws:
SQLException

getDBReferences

public Collection getDBReferences(Object o,
                                  int maxMatches)
                           throws SQLException
Description copied from interface: DatabaseManager
returns a collection of DBReference objects

Specified by:
getDBReferences in interface DatabaseManager
Parameters:
o - Description of Parameter
Returns:
The DBReferences value
Throws:
SQLException - Description of Exception

getDriverLongvarcharName

public String getDriverLongvarcharName()
                                throws SQLException
Throws:
SQLException

getDriverName

public String getDriverName()
Specified by:
getDriverName in interface DatabaseManager

getFrameIDs

public Collection getFrameIDs(FrameID slot,
                              FrameID facet,
                              boolean isTemplate,
                              String value)
                       throws SQLException
Specified by:
getFrameIDs in interface DatabaseManager
Throws:
SQLException

getFrameType

public int getFrameType(FrameID id)
                 throws SQLException
Specified by:
getFrameType in interface DatabaseManager
Throws:
SQLException

getLongvarcharName

public String getLongvarcharName()
                          throws SQLException
Throws:
SQLException

getFramesWithValue

public Collection getFramesWithValue(Slot slot,
                                     Facet facet,
                                     boolean isTemplate,
                                     Object value)
                              throws SQLException
Description copied from interface: DatabaseManager
returns a collection of FrameIDs

Specified by:
getFramesWithValue in interface DatabaseManager
Throws:
SQLException

getFramesWithAnyValue

public Collection getFramesWithAnyValue(Slot slot,
                                        Facet facet,
                                        boolean isTemplate)
                                 throws SQLException
Description copied from interface: DatabaseManager
returns a collection of FrameIDs

Specified by:
getFramesWithAnyValue in interface DatabaseManager
Throws:
SQLException

getMatchingFrameIDs

public Collection getMatchingFrameIDs(FrameID slot,
                                      FrameID facet,
                                      boolean isTemplate,
                                      String value,
                                      int maxMatches)
                               throws SQLException
Specified by:
getMatchingFrameIDs in interface DatabaseManager
Throws:
SQLException

getParameterLongvarcharName

public String getParameterLongvarcharName()

getTableName

public String getTableName()
Specified by:
getTableName in interface DatabaseManager

getValueCount

public int getValueCount(FrameID frame,
                         FrameID slot,
                         FrameID facet,
                         boolean isTemplate)
                  throws SQLException
Specified by:
getValueCount in interface DatabaseManager
Throws:
SQLException

getValues

public List getValues(FrameID frame,
                      FrameID slot,
                      FrameID facet,
                      boolean isTemplate)
               throws SQLException
Description copied from interface: DatabaseManager
returns a collection of Objects. A frame is returned as a frameID

Specified by:
getValues in interface DatabaseManager
Throws:
SQLException

hasValueAtSomeFrame

public boolean hasValueAtSomeFrame(Slot slot,
                                   Facet facet,
                                   boolean isTemplate)
                            throws SQLException
Specified by:
hasValueAtSomeFrame in interface DatabaseManager
Throws:
SQLException

removeAllReferences

public void removeAllReferences(Frame frame)
                         throws SQLException
Specified by:
removeAllReferences in interface DatabaseManager
Throws:
SQLException

removeAllValues

public void removeAllValues(Frame frame,
                            Slot slot,
                            Facet facet,
                            boolean isTemplate)
                     throws SQLException
Specified by:
removeAllValues in interface DatabaseManager
Throws:
SQLException

removeFramesWithValue

public void removeFramesWithValue(Slot slot,
                                  Facet facet,
                                  boolean isTemplate)
                           throws SQLException
Specified by:
removeFramesWithValue in interface DatabaseManager
Throws:
SQLException

removeSingleValue

public void removeSingleValue(Frame frame,
                              Slot slot,
                              Facet facet,
                              boolean isTemplate,
                              Object value)
                       throws SQLException
Specified by:
removeSingleValue in interface DatabaseManager
Throws:
SQLException

saveKnowledgeBase

public void saveKnowledgeBase(KnowledgeBase kb)
                       throws SQLException
Specified by:
saveKnowledgeBase in interface DatabaseManager
Throws:
SQLException

setTracing

public void setTracing(boolean b)
Specified by:
setTracing in interface DatabaseManager

setValue

public void setValue(Frame frame,
                     Slot slot,
                     Facet facet,
                     boolean isTemplate,
                     Object value)
              throws SQLException
Specified by:
setValue in interface DatabaseManager
Throws:
SQLException

setValues

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

supportsTransactions

public boolean supportsTransactions()
Specified by:
supportsTransactions in interface DatabaseManager

toString

public String toString()

Protege 2.1

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