use of org.folio.inventory.dataimport.handlers.matching.util.MatchingParametersRelations in project mod-inventory by folio-org.
the class AbstractMatchEventHandler method handle.
@Override
public CompletableFuture<DataImportEventPayload> handle(DataImportEventPayload dataImportEventPayload) {
CompletableFuture<DataImportEventPayload> future = new CompletableFuture<>();
dataImportEventPayload.getEventsChain().add(dataImportEventPayload.getEventType());
Context context = constructContext(dataImportEventPayload.getTenant(), dataImportEventPayload.getToken(), dataImportEventPayload.getOkapiUrl());
mappingMetadataCache.get(dataImportEventPayload.getJobExecutionId(), context).toCompletionStage().thenCompose(metadataOptional -> metadataOptional.map(mappingMetadataDto -> doMatching(dataImportEventPayload, mappingMetadataDto, new MatchingParametersRelations())).orElse(CompletableFuture.failedFuture(new EventProcessingException(MAPPING_METADATA_NOT_FOUND_MSG)))).whenComplete((matched, throwable) -> {
if (throwable != null) {
future.completeExceptionally(throwable);
} else {
if (Boolean.TRUE.equals(matched)) {
dataImportEventPayload.setEventType(getMatchedEventType());
} else {
dataImportEventPayload.setEventType(getNotMatchedEventType());
}
future.complete(dataImportEventPayload);
}
});
return future;
}
Aggregations