Commit e3e9909a authored by oleg.pahhomov's avatar oleg.pahhomov

SA0140-513 | change isBlank to put empty filter values

parent 9052a4a9
......@@ -25,6 +25,7 @@ import java.util.Optional;
import java.util.stream.Collectors;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.apache.commons.lang3.BooleanUtils.isTrue;
import static org.apache.commons.lang3.StringUtils.isBlank;
......@@ -43,29 +44,30 @@ public class FilterRequestBuilder {
continue;
}
if (filter.getType().isLegend()) {
filterRequest.put(filter.getName(), filter.getUpperOptions());
putAllOptions(filterRequest, filter);
continue;
}
if (MapUtils.isEmpty(params)) {
filterRequest.put(filter.getName(), filter.getUpperDefaultOptions());
} else {
String paramValue = params.get(filter.getId().toString());
if (isBlank(paramValue)) {
filterRequest.put(filter.getName(), filter.getUpperDefaultOptions());
} else {
try {
filterRequest.put(filter.getName(), getOption(filter, paramValue));
} catch (Exception ignored) {
log.error("Error with filters name: " + filter.getId() + " value: " + paramValue);
}
}
if (MapUtils.isEmpty(params) || !params.containsKey(filter.getId().toString())) {
putDefaultOptions(filterRequest, filter);
continue;
}
String paramValue = params.get(filter.getId().toString());
if (isBlank(paramValue)) {
putNoOptions(filterRequest, filter);
continue;
}
try {
putSelectedOptions(filterRequest, filter, paramValue);
} catch (Exception ignored) {
log.error("Error with filters name: " + filter.getId() + " value: " + paramValue);
putNoOptions(filterRequest, filter);
}
}
return filterRequest;
}
public Map<String, List<String>> axisFilterRequest(Filters config, Optional<FilterDto> axisOp) {
if (verticalAllRule(config.getGraphType())){
if (verticalAllRule(config.getGraphType())) {
return null;
}
if (!axisOp.isPresent()) {
......@@ -148,4 +150,20 @@ public class FilterRequestBuilder {
private boolean verticalAllRule(GraphType graphType) {
return graphType.getType().isVertical() && graphType.getVerticalRule().isAll();
}
private void putSelectedOptions(Map<String, List<String>> filterRequest, FilterDto filter, String paramValue) {
filterRequest.put(filter.getName(), getOption(filter, paramValue));
}
private void putNoOptions(Map<String, List<String>> filterRequest, FilterDto filter) {
filterRequest.put(filter.getName(), emptyList());
}
private void putDefaultOptions(Map<String, List<String>> filterRequest, FilterDto filter) {
filterRequest.put(filter.getName(), filter.getUpperDefaultOptions());
}
private void putAllOptions(Map<String, List<String>> filterRequest, FilterDto filter) {
filterRequest.put(filter.getName(), filter.getUpperOptions());
}
}
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