Commit ea43781c authored by Matija Obreza's avatar Matija Obreza
Browse files

Fixed side-effects of converting AppliedFilters to AccessionFilter twice

- Fixes overviews
parent ee7ed1ac
......@@ -111,7 +111,7 @@ public class AppliedFiltersConverter {
if (filterName.contains(".")) {
int lastDot = filterName.lastIndexOf('.');
String base = filterName.substring(0, lastDot);
af.setFilterName(filterName.substring(lastDot + 1));
String newFilterName = filterName.substring(lastDot + 1);
LOG.debug("Doing accession.{} for {}", base, af.getFilterName());
switch (base) {
case "institute": {
......@@ -119,7 +119,7 @@ public class AppliedFiltersConverter {
if (ff == null) {
ff = f.holder = new InstituteFilter();
}
apply(ff, af);
apply(ff, newFilterName, af);
break;
}
case "taxonomy": {
......@@ -127,7 +127,7 @@ public class AppliedFiltersConverter {
if (ff == null) {
ff = f.taxa = new TaxonomyFilter();
}
apply(ff, af);
apply(ff, newFilterName, af);
break;
}
case "coll": {
......@@ -135,7 +135,7 @@ public class AppliedFiltersConverter {
if (ff == null) {
ff = f.coll = new AccessionCollectFilter();
}
apply(ff, af);
apply(ff, newFilterName, af);
break;
}
case "geo": {
......@@ -143,7 +143,7 @@ public class AppliedFiltersConverter {
if (ff == null) {
ff = f.geo = new AccessionGeoFilter();
}
apply(ff, af);
apply(ff, newFilterName, af);
break;
}
case "orgCty": {
......@@ -151,7 +151,7 @@ public class AppliedFiltersConverter {
if (ff == null) {
ff = f.origin = new CountryFilter();
}
apply(ff, af);
apply(ff, newFilterName, af);
break;
}
default:
......@@ -159,15 +159,14 @@ public class AppliedFiltersConverter {
}
} else {
LOG.debug("Handling {} on accession", filterName);
apply(f, af);
apply(f, af.getFilterName(), af);
}
}
return f;
}
private static void apply(AccessionFilter f, AppliedFilter af) throws Exception {
String filterName = af.getFilterName();
private static void apply(AccessionFilter f, String filterName, AppliedFilter af) throws Exception {
switch (filterName) {
case "crops": {
f.crop = take1String(af);
......@@ -294,8 +293,7 @@ public class AppliedFiltersConverter {
}
}
private static void apply(TaxonomyFilter ff, AppliedFilter af) throws Exception {
String filterName = af.getFilterName();
private static void apply(TaxonomyFilter ff, String filterName, AppliedFilter af) throws Exception {
switch (filterName) {
case "genus": {
Set<String> set = ff.genus;
......@@ -326,16 +324,14 @@ public class AppliedFiltersConverter {
}
}
private static void apply(AccessionCollectFilter ff, AppliedFilter af) {
String filterName = af.getFilterName();
private static void apply(AccessionCollectFilter ff, String filterName, AppliedFilter af) {
switch (filterName) {
default:
throw new RuntimeException("Unhandled AccessionCollect filter property=" + filterName);
}
}
private static void apply(AccessionGeoFilter ff, AppliedFilter af) {
String filterName = af.getFilterName();
private static void apply(AccessionGeoFilter ff, String filterName, AppliedFilter af) {
switch (filterName) {
case "elevation": {
ff.elevation = toNumberFilter(af);
......@@ -373,8 +369,7 @@ public class AppliedFiltersConverter {
return nf;
}
private static void apply(CountryFilter ff, AppliedFilter af) {
String filterName = af.getFilterName();
private static void apply(CountryFilter ff, String filterName, AppliedFilter af) {
switch (filterName) {
case "iso3": {
Set<String> iso3 = ff.iso3;
......@@ -397,8 +392,7 @@ public class AppliedFiltersConverter {
return af.getValues().stream().map(fv -> (UUID) ((LiteralValueFilter) fv).getValue()).collect(Collectors.toSet());
}
private static void apply(InstituteFilter ff, AppliedFilter af) {
String filterName = af.getFilterName();
private static void apply(InstituteFilter ff, String filterName, AppliedFilter af) {
switch (filterName) {
case "code": {
Set<String> code = ff.code;
......
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