Skip to content

mbari-org/expd-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EXPD

EXPD is a Java API for simplifying access to MBARI's expedition database (also called EXPD). It uses JDBC for data access. It also contains conditional logic to allow tasks such as selecting the best available navigation data and oxygen data.

Adding to your project

This library is available on Maven Central.

<dependency>
    <groupId>org.mbari.expd</groupId>
    <artifactId>expd-jdbc</artifactId>
    <version>2.0.0</version>
</dependency>

Usage for developers

You either initialize the DAO with a connection parameters or through environment variables.

import java.util.Optional;
import org.mbari.expd.jdbc.DAOFactoryImpl;
import org.mbari.expd.jdbc.JdbcParameters;

// Using connection parameters
var jdbcParams = new JdbcParameters("jdbc:mysql://localhost:3306/expd", "root", "password", Optional.of("org.mariadb.jdbc.Driver"));
DAOFactory daoFactory = new DAOFactoryImpl(jdbcParams);


// Using environment variables: set these in your shell or IDE run configuration
// export EXPD_JDBC_URL="jdbc:mysql://localhost:3306/expd"
// export EXPD_JDBC_USER="root"
// export EXPD_JDBC_PASSWORD="password"
// export EXPD_JDBC_DRIVER="org.mariadb.jdbc.Driver"
DAOFactory daoFactory = new DAOFactoryImpl(); // will use environment variables

// Use the daoFactory to get DAOs
var diveDAO = daoFactory.getDiveDAO();

Examples

To get a list of all ROVs

import org.mbari.expd.jdbc.BaseDAOImpl;

List<String> rovs = BaseDAOImpl.getAllRovNames();

To get all dives for a particular ROV:

import org.mbari.expd.DiveDAO;
import org.mbari.expd.jdbc.DiveDAOImpl;

DiveDAO dao = daoFactory.getDiveDAO();

Collection<Dive> divesForRov = dao.findByPlatform(rovNameAsString);


// Example converting them to a list of dive numbers:
List<Integer> diveNumbersForRov = divesForRov.stream()
        .map(Dive::getDiveNumber)
        .sorted()
        .toList();

To get a dive object by ROV name and dive number

import org.mbari.expd.DiveDAO;
import org.mbari.expd.jdbc.DiveDAOImpl;

DiveDAO dao = daoFactory.getDiveDAO();

// returns null if no match is found
Dive dive = dao.findByPlatformAndDiveNumber("Ventana", 123);

To get other data for a particular dive:

Position

// latitude, longitude, depth
import org.mbari.expd.NavigationDatum;
import org.mbari.expd.NavigationDatumDAO;
import org.mbari.expd.jdbc.NavigationDAOImpl;

// You'll need a Dive object 
NavigationDAO dao = daoFactory.getNavigationDAO();
List<NavigationDatum> nav = dao.fetchBestnavigationData(dive);

CTD

// salinity (psu), temperature (celsius), pressure (dbar)
import org.mbari.expd.CtdDatum;
import org.mbari.expd.CtdDatumDAO;
import org.mbari.expd.jdbc.CtdDatumDAOImpl;

// You'll need a Dive object 
CtdDatumDAO dao = daoFactory.getCtdDatumDAO();
List<CtdDatum> ctd = dao.fetchCtdData(dive);

Camera logs

// timecode, recordedTimestamp. Useful when you're doing dive quality analysis later on
import org.mbari.expd.CameraDatum;
import org.mbari.expd.CameraDatumDAO;
import org.mbari.expd.jdbc.CameraDatumDAOImpl;

// You'll need a Dive object 
CameraDatumDAO dao = daoFactory.getCameraDatumDAO();
List<CameraDatum> cam = dao.fetchCameraData(dive);

About

Java libraries for accessing MBARI's expedition data

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages