Created
November 17, 2017 15:04
-
-
Save Romeh/0b5cc33aeef9e0ef7a2032c5729fe32b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public List<AlertEntry> getAlertForServiceId(String serviceId) { | |
final String sql = "serviceId = ?"; | |
// create the sql query object with entity type of the value part of the key value cache | |
SqlQuery<String, AlertEntry> query = new SqlQuery<>(AlertEntry.class, sql); | |
// set the query params | |
query.setArgs(serviceId); | |
//then execute it over the cache | |
return Optional.ofNullable(getAlertsCache().query(query).getAll().stream().map(stringAlertEntryEntry -> stringAlertEntryEntry.getValue()).collect(Collectors.toList())) | |
.orElseThrow(() -> new ResourceNotFoundException(String.format("Alert for %s not found", serviceId))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment