Add query db fallback for DMPs

This commit is contained in:
George Kalampokis 2021-06-25 19:27:02 +03:00
parent 4a4042d621
commit d1df83f689
1 changed files with 10 additions and 5 deletions

View File

@ -130,12 +130,17 @@ public class DataManagementPlanManager {
QueryableList<DMP> items = null; QueryableList<DMP> items = null;
QueryableList<DMP> authItems = null; QueryableList<DMP> authItems = null;
if (apiContext.getOperationsContext().getElasticRepository().getDmpRepository() != null) { if (apiContext.getOperationsContext().getElasticRepository().getDmpRepository() != null) {
try {
DmpCriteria criteria = DmpCriteriaMapper.toElasticCriteria(dataManagementPlanTableRequest.getCriteria()); DmpCriteria criteria = DmpCriteriaMapper.toElasticCriteria(dataManagementPlanTableRequest.getCriteria());
dmps = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().query(criteria); dmps = apiContext.getOperationsContext().getElasticRepository().getDmpRepository().query(criteria);
if (dmps != null && !dmps.isEmpty()) { if (dmps != null && !dmps.isEmpty()) {
List<Dmp> finalDmps = dmps; List<Dmp> finalDmps = dmps;
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().where((builder, root) -> root.get("id").in(finalDmps.stream().map(Dmp::getId).collect(Collectors.toList()))); 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) { if (items == null) {
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria()); items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());