make defaults for groupBy configurable
We do not know which fields exist at compile time. But it is a great help to have some pre-selected fields in groupBy. Solved by adding a configuration option.
This commit is contained in:
@@ -8,9 +8,11 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -29,6 +31,7 @@ import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdbui.domain.AutocompleteProposal;
|
||||
import org.lucares.pdbui.domain.AutocompleteProposalByValue;
|
||||
import org.lucares.pdbui.domain.AutocompleteResponse;
|
||||
import org.lucares.pdbui.domain.FilterDefaults;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.PlotResponse;
|
||||
import org.lucares.pdbui.domain.PlotResponseStats;
|
||||
@@ -76,8 +79,11 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
@Value("${" + PRODUCTION_MODE + ":true}")
|
||||
private boolean modeProduction;
|
||||
|
||||
@Value("${"+QUERY_EXAMPLES+":}")
|
||||
@Value("${"+DEFAULTS_QUERY_EXAMPLES+":}")
|
||||
private String queryExamples;
|
||||
|
||||
@Value("${"+DEFAULTS_GROUP_BY+":}")
|
||||
private String defaultsGroupBy;
|
||||
|
||||
public PdbController(final PerformanceDb db, final Plotter plotter) {
|
||||
this.db = db;
|
||||
@@ -292,6 +298,17 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/filters/defaults", //
|
||||
method = RequestMethod.GET, //
|
||||
produces = MediaType.APPLICATION_JSON_VALUE //
|
||||
)
|
||||
@ResponseBody
|
||||
public FilterDefaults getFilterDefaults() {
|
||||
Set<String> groupBy = defaultsGroupBy.isBlank() ? Set.of() : Set.of(defaultsGroupBy.split("\\s*,\\s*"));
|
||||
List<String> fields = fields();
|
||||
return new FilterDefaults(fields, groupBy);
|
||||
}
|
||||
|
||||
private List<AutocompleteProposal> toAutocompleteProposals(final List<Proposal> proposals) {
|
||||
|
||||
|
||||
@@ -18,5 +18,7 @@ public interface PropertyKeys {
|
||||
*/
|
||||
String PRODUCTION_MODE = "mode.production";
|
||||
|
||||
String QUERY_EXAMPLES = "query.examples";
|
||||
String DEFAULTS_QUERY_EXAMPLES = "defaults.query.examples";
|
||||
|
||||
String DEFAULTS_GROUP_BY = "defaults.groupBy";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class FilterDefaults {
|
||||
private Set<String> groupBy;
|
||||
|
||||
private List<String> fields;
|
||||
|
||||
public FilterDefaults(final List<String> fields, final Set<String> groupBy) {
|
||||
this.fields = new ArrayList<String>(fields);
|
||||
this.groupBy = new HashSet<String>(groupBy);
|
||||
}
|
||||
|
||||
public Set<String> getGroupBy() {
|
||||
return new HashSet<String>(groupBy);
|
||||
}
|
||||
|
||||
public void setGroupBy(Set<String> groupBy) {
|
||||
this.groupBy = new HashSet<String>(groupBy);
|
||||
}
|
||||
|
||||
public List<String> getFields() {
|
||||
return new ArrayList<String>(fields);
|
||||
}
|
||||
|
||||
public void setFields(List<String> fields) {
|
||||
this.fields = new ArrayList<String>(fields);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user