use of org.folio.dao.MappingRuleDao in project mod-source-record-manager by folio-org.
the class MappingRuleCache method loadMappingRules.
private CompletableFuture<Optional<JsonObject>> loadMappingRules(MappingRuleCacheKey key, Executor executor, MappingRuleDao mappingRuleDao) {
CompletableFuture<Optional<JsonObject>> future = new CompletableFuture<>();
executor.execute(() -> mappingRuleDao.get(key.getRecordType(), key.getTenantId()).map(optional -> optional.isPresent() ? optional : Optional.of(new JsonObject())).onComplete(ar -> {
if (ar.failed()) {
LOGGER.error("Failed to load mapping rules for tenant '{}' from data base", key.getTenantId(), ar.cause());
future.completeExceptionally(ar.cause());
return;
}
future.complete(ar.result());
}));
return future;
}
Aggregations