From 9af0fed9fe2d3d5713e30a3262fed4ce54e3c3ac Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Mon, 11 Feb 2019 15:46:29 +0200 Subject: [PATCH] Fix Endpoind For Researchers get --- .../eu/eudat/data/dao/entities/ProjectDaoImpl.java | 2 +- .../eu/eudat/data/dao/entities/ResearcherDaoImpl.java | 10 +++++----- .../eu/eudat/logic/managers/ResearcherManager.java | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ProjectDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ProjectDaoImpl.java index b9f8c845c..5a7b18b62 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ProjectDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ProjectDaoImpl.java @@ -28,7 +28,7 @@ public class ProjectDaoImpl extends DatabaseAccess implements ProjectDa public QueryableList getWithCriteria(ProjectCriteria criteria) { QueryableList query = getDatabaseService().getQueryable(Project.class); if (criteria.getLike() != null && !criteria.getLike().isEmpty()) - query.where((builder, root) -> + query.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"), builder.or(builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%")))); if (criteria.getPeriodEnd() != null) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ResearcherDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ResearcherDaoImpl.java index 7faa9e8f6..086adf820 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ResearcherDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ResearcherDaoImpl.java @@ -22,11 +22,11 @@ public class ResearcherDaoImpl extends DatabaseAccess implements Res @Override public QueryableList getWithCriteria(ResearcherCriteria criteria) { - QueryableList query = this.getDatabaseService().getQueryable(Researcher.class); - if (criteria.getLike() != null) - query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike())); - if (criteria.getName() != null) - query.where((builder, root) -> builder.equal(root.get("label"), criteria.getName())); + QueryableList query = asQueryable(); + if (criteria.getLike() != null && !criteria.getLike().isEmpty()) + query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"))); + if (criteria.getName() != null && !criteria.getName().isEmpty()) + query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getName().toUpperCase() + "%"))); return query; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java index 68d5fb91b..95066af1e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java @@ -34,7 +34,8 @@ public class ResearcherManager { ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos); for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) { eu.eudat.models.data.dmp.Researcher researcher = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ResearcherBuilder.class) - .label(externalListingItem.getAbbreviation()).id(externalListingItem.getId()) + .label(externalListingItem.getAbbreviation()) + .id(externalListingItem.getId()) .name(externalListingItem.getName()) .build(); researchers.add(researcher);