Commit 31b5d099 authored by Matija Obreza's avatar Matija Obreza

Merge branch...

Merge branch 'ui-514-fao-institute-code-applied-value-is-parsed-to-lower-case-if-user-applies-filter-by-enter' into 'master'

Fix: FAO institute code applied value is parsed to lower case if user applies filter by "Enter";

Closes genesys-ui#514

See merge request genesys-pgr/genesys-server!454
parents 95708b17 78fbf83e
......@@ -17,8 +17,11 @@ package org.genesys.catalog.model.filters;
import static org.genesys.catalog.model.QPartner.partner;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonGetter;
import org.apache.commons.collections4.CollectionUtils;
import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.blocks.model.filters.UuidModelFilter;
......@@ -70,9 +73,13 @@ public class PartnerFilter extends UuidModelFilter<PartnerFilter, Partner> {
and.and(description.buildQuery(partnerPath.description));
}
if (CollectionUtils.isNotEmpty(wiewsCodes)) {
and.and(partnerPath.institutes.any().code.in(wiewsCodes));
and.and(partnerPath.institutes.any().code.in(wiewsCodes()));
}
return and;
}
@JsonGetter("wiewsCodes")
public Set<String> wiewsCodes() {
return wiewsCodes != null ? wiewsCodes.stream().map(String::toUpperCase).collect(Collectors.toSet()) : Collections.emptySet();
}
}
......@@ -17,8 +17,11 @@ package org.genesys2.server.service.filter;
import static org.genesys2.server.model.impl.QFaoInstitute.faoInstitute;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonGetter;
import org.apache.commons.collections.CollectionUtils;
import org.genesys.blocks.model.filters.BasicModelFilter;
import org.genesys.blocks.model.filters.StringFilter;
......@@ -73,7 +76,7 @@ public class InstituteFilter extends BasicModelFilter<InstituteFilter, FaoInstit
super.buildPredicate(institute, institute._super, and);
if (code != null && !code.isEmpty()) {
and.and(institute.code.in(code));
and.and(institute.code.in(code()));
}
if (country != null) {
and.and(country.buildQuery(institute.country));
......@@ -106,4 +109,9 @@ public class InstituteFilter extends BasicModelFilter<InstituteFilter, FaoInstit
return this.country;
}
}
@JsonGetter("code")
public Set<String> code() {
return code != null ? code.stream().map(String::toUpperCase).collect(Collectors.toSet()) : Collections.emptySet();
}
}
......@@ -19,7 +19,9 @@ import static org.genesys2.server.model.impl.QSubset.subset;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonGetter;
import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.blocks.model.filters.UuidModelFilter;
import org.genesys.catalog.model.filters.PartnerFilter;
......@@ -79,7 +81,7 @@ public class SubsetFilter extends UuidModelFilter<SubsetFilter, Subset> implemen
and.and(owner.buildQuery(subset.owner));
}
if ((institutes != null) && !institutes.isEmpty()) {
and.and(subset.institute.code.in(institutes));
and.and(subset.institute.code.in(institutes()));
}
if (title != null) {
and.and(title.buildQuery(subset.title));
......@@ -127,11 +129,12 @@ public class SubsetFilter extends UuidModelFilter<SubsetFilter, Subset> implemen
return this.owner;
}
@JsonGetter("institutes")
public synchronized Set<String> institutes() {
if (this.institutes == null) {
return this.institutes = new HashSet<>();
} else {
return this.institutes;
return this.institutes.stream().map(String::toUpperCase).collect(Collectors.toSet());
}
}
}
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