use of usace.cwms.db.jooq.dao.CwmsDbBasinJooq in project cwms-radar-api by USACE.
the class BasinDao method getBasin.
public Basin getBasin(String basinId, String unitSystem, String officeId) throws SQLException {
CwmsDbBasinJooq basinJooq = new CwmsDbBasinJooq();
String[] pParentBasinId = new String[1];
Double[] pSortOrder = new Double[1];
String[] pPrimaryStreamId = new String[1];
Double[] pTotalDrainageArea = new Double[1];
Double[] pContributingDrainageArea = new Double[1];
String areaUnitIn = UnitSystem.EN.value().equals(unitSystem) ? Unit.SQUARE_MILES.getValue() : Unit.SQUARE_KILOMETERS.getValue();
dsl.connection(c -> basinJooq.retrieveBasin(c, pParentBasinId, pSortOrder, pPrimaryStreamId, pTotalDrainageArea, pContributingDrainageArea, basinId, areaUnitIn, officeId));
Basin retval = new Basin.Builder(basinId, officeId).withBasinArea(pTotalDrainageArea[0]).withContributingArea(pContributingDrainageArea[0]).withParentBasinId(pParentBasinId[0]).withSortOrder(pSortOrder[0]).build();
if (pPrimaryStreamId[0] != null) {
StreamDao streamDao = new StreamDao(dsl);
Stream primaryStream = streamDao.getStream(pPrimaryStreamId[0], unitSystem, officeId);
retval = new Basin.Builder(retval).withPrimaryStream(primaryStream).build();
}
return retval;
}
use of usace.cwms.db.jooq.dao.CwmsDbBasinJooq in project cwms-radar-api by USACE.
the class BasinDao method getAllBasins.
public List<Basin> getAllBasins(String unitSystem, String officeId) throws SQLException {
List<Basin> retval = new ArrayList<>();
CwmsDbBasinJooq basinJooq = new CwmsDbBasinJooq();
String areaUnitIn = UnitSystem.EN.value().equals(unitSystem) ? Unit.SQUARE_MILES.getValue() : Unit.SQUARE_KILOMETERS.getValue();
try {
dsl.connection(c -> {
ResultSet rs = basinJooq.catBasins(c, null, null, null, areaUnitIn, officeId);
retval.addAll(buildBasinsFromResultSet(rs, unitSystem));
});
} catch (Exception ex) {
throw new SQLException(ex);
}
return retval;
}
Aggregations