@Override public int getPax(int prayerId) { try { SimpleTurn turn = jdbc.queryForObject(sqlSt.getPax(), new SimpleTurnMapper(), prayerId); return turn.getPax(); } catch (EmptyResultDataAccessException e) { return 0; } }
@Override public int getTurnID(int prayer_id, String day, String hour) { SimpleTurn foundTurn; try { foundTurn = jdbc.queryForObject(sqlSt.getTurn(), new SimpleTurnMapper(), prayer_id, day, hour); return foundTurn.getUid(); } catch (EmptyResultDataAccessException e) { throw new RuntimeException( "Something went really wrong, since it should have returned a prayer_id"); } }
@Override public SimpleTurn mapRow(ResultSet rs, int number) throws SQLException { SimpleTurn turn; int uid = rs.getInt("uid"); int prayer_id = rs.getInt("prayer_id"); String day = rs.getString("day"); String hour = rs.getString("hour"); String status = rs.getString("status"); String notes = rs.getString("notes"); int pax = rs.getInt("pax"); try { turn = new SimpleTurn( uid, prayer_id, DayOfWeek.valueOf(day), SimpleTurn.getTurnByHour(hour), TurnStatus.valueOf(status), notes, pax); } catch (TurnException e) { throw new RuntimeException(e.toString()); } return turn; }
@Override public List<Prayer> getPrayersOnTurn(DayOfWeek dow, int turn) throws TurnException { List<Prayer> prayers = jdbc.query( sqlSt.getPrayersOnTurn(), new PrayerMapper(), dow.name(), SimpleTurn.getHourByTurn(turn)); return prayers; }