Guest User

Untitled

a guest
Nov 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. @Override
  2. public List<AlertEntry> getAlertForServiceId(String serviceId) {
  3. final String sql = "serviceId = ?";
  4. // create the sql query object with entity type of the value part of the key value cache
  5. SqlQuery<String, AlertEntry> query = new SqlQuery<>(AlertEntry.class, sql);
  6. // set the query params
  7. query.setArgs(serviceId);
  8. //then execute it over the cache
  9. return Optional.ofNullable(getAlertsCache().query(query).getAll().stream().map(stringAlertEntryEntry -> stringAlertEntryEntry.getValue()).collect(Collectors.toList()))
  10. .orElseThrow(() -> new ResourceNotFoundException(String.format("Alert for %s not found", serviceId)));
  11. }
Add Comment
Please, Sign In to add comment