Commit 9cc765e7 authored by Kristian Ntavidi's avatar Kristian Ntavidi
Browse files

Merge branch 'Development' of...

Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
parents 72b18b77 42a22b4a
......@@ -24,11 +24,11 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
public QueryableList<Researcher> getWithCriteria(ResearcherCriteria criteria) {
QueryableList<Researcher> 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() + "%")));
query.where((builder, root) ->builder.or(builder.like(builder.lower(root.get("reference")), "%" + criteria.getLike().toLowerCase() + "%")));
if (criteria.getName() != null && !criteria.getName().isEmpty())
query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getName().toUpperCase() + "%")));
query.where((builder, root) ->builder.or(builder.like(builder.lower(root.get("label")), "%" + criteria.getName().toLowerCase() + "%")));
if (criteria.getReference() != null && !criteria.getReference().isEmpty())
query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("reference")), criteria.getReference().toUpperCase())));
query.where((builder, root) ->builder.or(builder.like(root.get("reference"), criteria.getReference())));
return query;
}
......
......@@ -673,7 +673,7 @@ public class DataManagementPlanManager {
if (newDmp.getResearchers() != null && !newDmp.getResearchers().isEmpty()) {
for (eu.eudat.data.entities.Researcher researcher : newDmp.getResearchers()) {
ResearcherCriteria criteria = new ResearcherCriteria();
criteria.setLike(researcher.getReference());
criteria.setReference(researcher.getReference());
List<eu.eudat.data.entities.Researcher> entries = researcherRepository.getWithCriteria(criteria).toList();
if (entries != null && !entries.isEmpty()) researcher.setId(entries.get(0).getId());
else {
......
......@@ -49,6 +49,7 @@ public class ResearcherManager {
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()));
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();
for (eu.eudat.models.data.dmp.Researcher item : researchers) {
if (item.getKey().equals("Internal"))
......
......@@ -94,10 +94,12 @@ public class Researcher implements DataModel<eu.eudat.data.entities.Researcher,
researcher.setId(UUID.fromString(this.id));
if (this.key != null) {
if (this.key.toLowerCase().equals("internal")) {
if (this.reference != null) {
if (this.reference != null && !this.reference.startsWith("dmp:")) {
researcher.setReference("dmp:" + this.reference);
} else {
} else if (this.reference == null) {
researcher.setReference("dmp:" + this.id);
} else {
researcher.setReference(this.reference);
}
} else {
if ((this.key + ":").equals(this.reference.substring(0, this.key.length() + 1))) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment