Class SQLListener

  • All Implemented Interfaces:
    MappingListener
    Direct Known Subclasses:
    SQLIdMapper

    public class SQLListener
    extends SQLBase
    implements MappingListener
    This is the root class of the SQL stack. It handles the creation of all the tables and handles all inserts, except those only required for URL and UriSpaces See CreateSQLTables method for an explanation of the tables.
    Author:
    Christian
    • Method Detail

      • registerMappingSet

        public int registerMappingSet​(DataSource source,
                                      DataSource target,
                                      boolean symetric)
                               throws BridgeDBException
        Description copied from interface: MappingListener
        Loads all the meta data for a Mapping Set.
        Specified by:
        registerMappingSet in interface MappingListener
        Parameters:
        source - The SysCode of DataSource part of the source xref/url
        target - The SysCode of DataSource part of the target xref/url
        symetric - Flag to say if mapping should be loaded one way of both ways. Creates two mapping sets this one and the inverse with one number higher.
        Returns:
        Id of the forward mappingSet.
        Throws:
        BridgeDBException - If something goes wrong. Always thrown by the URI based version as it requires extra parameters to register a mapping Set.
      • getDataSourceKey

        protected final String getDataSourceKey​(DataSource dataSource)
      • insertLink

        public void insertLink​(String sourceId,
                               String targetId,
                               int mappingSet,
                               boolean symetric)
                        throws BridgeDBException
        Description copied from interface: MappingListener
        Inserts a mapping into the system.

        Implementatins may buffer the inserts, so closeInput must be called after the last insert or inserts may be lost.

        No checking can be done that the DataSource part of the Xrefs match the declaration.

        For speed, the implemented methods is also not required to check that the MappingsSet exists nor that the mapping Set's semantic setting matches that in the insert call.

        Specified by:
        insertLink in interface MappingListener
        Parameters:
        sourceId - ID of the source xref
        targetId - ID of the target xref
        mappingSet - The ID of the mapping set to be inserted into.
        symetric - If true the inverse mapping will be inserted into the mapping set one number higher.
        Throws:
        BridgeDBException
      • dropTable

        protected void dropTable​(String name)
                          throws BridgeDBException
        Drops a single table if it exists.

        Virtuosos appears not to have the if exists syntax so errors are assumed to be table not found.

        Parameters:
        name -
        Throws:
        BridgeDBException
      • createSQLTables

        protected void createSQLTables()
                                throws BridgeDBException
        Excecutes several SQL statements to create the tables and indexes in the database.

        Table "info" is a control table used by all database version of BridgeDB, inlcuing none OPS ones. If verifies that database is called with the code that matches the schema version.

        Table DataSource holds the org.bridgedb.DataSource registry between deployments of the service. The whole table is loaded into the DataSource.class regisrty in the constructor.

        Throws:
        BridgeDBException