From e7e5ed02b326c8ac05594f66b5d1f86e8ab806d1 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 25 Jun 2021 19:27:02 +0300 Subject: [PATCH] Add query db fallback for DMPs (cherry picked from commit d1df83f689a735c9c55f30d969385f1bce509d2d) --- .../logic/managers/DataManagementPlanManager.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index dbf63563c..ab1ac3d84 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -130,11 +130,16 @@ public class DataManagementPlanManager { QueryableList items = null; QueryableList authItems = null; if (apiContext.getOperationsContext().getElasticRepository().getDmpRepository() != null) { - DmpCriteria criteria = DmpCriteriaMapper.toElasticCriteria(dataManagementPlanTableRequest.getCriteria()); - dmps = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().query(criteria); - if (dmps != null && !dmps.isEmpty()) { - List finalDmps = dmps; - items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().where((builder, root) -> root.get("id").in(finalDmps.stream().map(Dmp::getId).collect(Collectors.toList()))); + try { + DmpCriteria criteria = DmpCriteriaMapper.toElasticCriteria(dataManagementPlanTableRequest.getCriteria()); + dmps = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().query(criteria); + if (dmps != null && !dmps.isEmpty()) { + List finalDmps = dmps; + items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().where((builder, root) -> root.get("id").in(finalDmps.stream().map(Dmp::getId).collect(Collectors.toList()))); + } + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + items = null; } } if (items == null) {