Wiki

Clone wiki

iMonDB / CoreAPI

iMonDB Core API

The iMonDB Core API provides the full functionality to work with iMonDB data. The following UML diagram shows a high-level overview of the iMonDB object model. For a detailed description of all member variables and methods, see the Javadoc.

uml

Connecting to the iMonDB

Connecting to the iMonDB is very straightforward by providing the IMonDBReader and IMonDBWriter classes with the suitable database information.

// create an EntityManagerFactory with information to connect to the iMonDB
EntityManagerFactory emf = IMonDBManagerFactory.createMySQLFactory("localhost", "3306", "iMonDB", "username", "password");

// create a reader or writer
IMonDBReader reader = new IMonDBReader(emf);
IMonDBWriter writer = new IMonDBWriter(emf);

// do stuff with the reader and/or writer
// ...

// close the database connection
emf.close();

The reader can be used to retrieve all the instrument settings information from the database, while the writer can be used to write new information to the database, or to update existing information. Afterwards, remember to always close the database connection at the end.

Extracting instrument settings

Instrument settings can easily be extracted from an experimental raw file by making use of the ThermoRawFileExtractor class. For each raw file the instrument on which the file was obtained, has to be provided.

File rawFile;   // the raw file from which to extract the instrument settings
String runName; // optional name for the run, otherwise the file name is used
Instrument instrument;  // the name of the instrument on which the raw file was obtained

ThermoRawFileExtractor extractor = new ThermoRawFileExtractor();
Run run = extractor.extractInstrumentData(rawFile.getAbsolutePath(), runName, instrument);

The returned object is a Run which contains various Values representing the instrument settings. This Run can optionally be stored in the iMonDB by making use of the previously described IMonDBWriter functionality.

Updated