Fix Endpoind For Researchers get

This commit is contained in:
Diamantis Tziotzios 2019-02-11 15:46:29 +02:00
parent cd1bd66d2c
commit 9af0fed9fe
3 changed files with 8 additions and 7 deletions

View File

@ -28,7 +28,7 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
public QueryableList<Project> getWithCriteria(ProjectCriteria criteria) { public QueryableList<Project> getWithCriteria(ProjectCriteria criteria) {
QueryableList<Project> query = getDatabaseService().getQueryable(Project.class); QueryableList<Project> query = getDatabaseService().getQueryable(Project.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) 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("label")), "%" + criteria.getLike().toUpperCase() + "%"),
builder.or(builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%")))); builder.or(builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%"))));
if (criteria.getPeriodEnd() != null) if (criteria.getPeriodEnd() != null)

View File

@ -22,11 +22,11 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
@Override @Override
public QueryableList<Researcher> getWithCriteria(ResearcherCriteria criteria) { public QueryableList<Researcher> getWithCriteria(ResearcherCriteria criteria) {
QueryableList<Researcher> query = this.getDatabaseService().getQueryable(Researcher.class); QueryableList<Researcher> query = asQueryable();
if (criteria.getLike() != null) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike())); query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%")));
if (criteria.getName() != null) if (criteria.getName() != null && !criteria.getName().isEmpty())
query.where((builder, root) -> builder.equal(root.get("label"), criteria.getName())); query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getName().toUpperCase() + "%")));
return query; return query;
} }

View File

@ -34,7 +34,8 @@ public class ResearcherManager {
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos); ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) { for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) {
eu.eudat.models.data.dmp.Researcher researcher = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ResearcherBuilder.class) 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()) .name(externalListingItem.getName())
.build(); .build();
researchers.add(researcher); researchers.add(researcher);