Search in sources :

Example 1 with CwmsDbBasinJooq

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;
}
Also used : CwmsDbBasinJooq(usace.cwms.db.jooq.dao.CwmsDbBasinJooq) Basin(cwms.radar.data.dto.basinconnectivity.Basin) Stream(cwms.radar.data.dto.basinconnectivity.Stream)

Example 2 with CwmsDbBasinJooq

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;
}
Also used : CwmsDbBasinJooq(usace.cwms.db.jooq.dao.CwmsDbBasinJooq) SQLException(java.sql.SQLException) Basin(cwms.radar.data.dto.basinconnectivity.Basin) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) SQLException(java.sql.SQLException)

Aggregations

Basin (cwms.radar.data.dto.basinconnectivity.Basin)2 CwmsDbBasinJooq (usace.cwms.db.jooq.dao.CwmsDbBasinJooq)2 Stream (cwms.radar.data.dto.basinconnectivity.Stream)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1