bridgedb / BridgeDb

The BridgeDb Library source code
https://bridgedb.org/
Apache License 2.0
28 stars 21 forks source link

Derby database loading feature #185

Closed hbasaric closed 2 years ago

hbasaric commented 2 years ago

New feature request: When loading a local derby database using the GdbProvider.fromConfigFile(); method, check if less than 5 DataSources are registered. If so, stop loading the database and throw an Exception. Details/Background: When loading local Derby databases, the DataSourceTxt.init(); method must first be invoked. This loads all data sources into the registry. If this is not done, the program will try to register DataSources from information found in the Derby file. Currently, the SQL schema of the Derby files does not support the fullName of the DataSources. Thus, when querying the Derby files for the fullName of the DataSources, they return "Unknown". The program will attempt to register multiple DataSources with different sysCodes, but all under the same fullName ("Unknown"). This throws an IllegalArgumentException (caught by the findOrRegister() method in DataSource.java), because one cannot register multiple sysCodes with the same fullName. To prevent this from happening, we would like to check if DataSourceTxt.init() was not invoked before loading the Derby database; i.e. if less than 5 DataSources are registered.

hbasaric commented 2 years ago

The following commit solved the issue: https://github.com/bridgedb/BridgeDb/commit/aa9bb8b929ba2d3f842f4d8b77577dc14b1acd9a