Improve external researcher support

This commit is contained in:
George Kalampokis 2021-06-17 18:48:18 +03:00
parent 885f897adc
commit 42a22b4a65
3 changed files with 3 additions and 2 deletions

View File

@ -28,7 +28,7 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
if (criteria.getName() != null && !criteria.getName().isEmpty()) if (criteria.getName() != null && !criteria.getName().isEmpty())
query.where((builder, root) ->builder.or(builder.like(builder.lower(root.get("label")), "%" + criteria.getName().toLowerCase() + "%"))); query.where((builder, root) ->builder.or(builder.like(builder.lower(root.get("label")), "%" + criteria.getName().toLowerCase() + "%")));
if (criteria.getReference() != null && !criteria.getReference().isEmpty()) if (criteria.getReference() != null && !criteria.getReference().isEmpty())
query.where((builder, root) ->builder.or(builder.like(builder.lower(root.get("reference")), criteria.getReference().toLowerCase()))); query.where((builder, root) ->builder.or(builder.like(root.get("reference"), criteria.getReference())));
return query; return query;
} }

View File

@ -673,7 +673,7 @@ public class DataManagementPlanManager {
if (newDmp.getResearchers() != null && !newDmp.getResearchers().isEmpty()) { if (newDmp.getResearchers() != null && !newDmp.getResearchers().isEmpty()) {
for (eu.eudat.data.entities.Researcher researcher : newDmp.getResearchers()) { for (eu.eudat.data.entities.Researcher researcher : newDmp.getResearchers()) {
ResearcherCriteria criteria = new ResearcherCriteria(); ResearcherCriteria criteria = new ResearcherCriteria();
criteria.setLike(researcher.getReference()); criteria.setReference(researcher.getReference());
List<eu.eudat.data.entities.Researcher> entries = researcherRepository.getWithCriteria(criteria).toList(); List<eu.eudat.data.entities.Researcher> entries = researcherRepository.getWithCriteria(criteria).toList();
if (entries != null && !entries.isEmpty()) researcher.setId(entries.get(0).getId()); if (entries != null && !entries.isEmpty()) researcher.setId(entries.get(0).getId());
else { else {

View File

@ -49,6 +49,7 @@ public class ResearcherManager {
QueryableList<eu.eudat.data.entities.Researcher> items = apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(researcherCriteriaRequest.getCriteria()); QueryableList<eu.eudat.data.entities.Researcher> items = apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(researcherCriteriaRequest.getCriteria());
items.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), principal.getId())); items.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), principal.getId()));
List<eu.eudat.models.data.dmp.Researcher> researchers = items.select(item -> new eu.eudat.models.data.dmp.Researcher().fromDataModel(item)); List<eu.eudat.models.data.dmp.Researcher> researchers = items.select(item -> new eu.eudat.models.data.dmp.Researcher().fromDataModel(item));
researchers = researchers.stream().filter(item -> item.getKey().equals("Internal")).collect(Collectors.toList());
Map<String, String> keyToSourceMap = configLoader.getKeyToSourceMap(); Map<String, String> keyToSourceMap = configLoader.getKeyToSourceMap();
for (eu.eudat.models.data.dmp.Researcher item : researchers) { for (eu.eudat.models.data.dmp.Researcher item : researchers) {
if (item.getKey().equals("Internal")) if (item.getKey().equals("Internal"))