Commit 694fc8f7 authored by oleg.pahhomov's avatar oleg.pahhomov

SA0140-611 | add debug logging

parent be8e7caa
......@@ -14,6 +14,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;
import java.util.List;
import java.util.Objects;
@Getter
@Setter
......@@ -38,4 +39,17 @@ public class Element {
public String getName(Language lang) {
return lang.isEt() ? nameEt : nameEn;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Element element = (Element) o;
return Objects.equals(id, element.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}
......@@ -15,6 +15,7 @@ import ee.stat.dashboard.service.widget.widget.dto.Filters;
import ee.stat.dashboard.service.widget.widget.dto.GraphDto;
import ee.stat.dashboard.service.widget.widget.dto.UserFilterDto;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
......@@ -27,6 +28,7 @@ import java.util.stream.Collectors;
import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;
@Service
@Slf4j
@AllArgsConstructor
public class GraphService {
......@@ -36,6 +38,7 @@ public class GraphService {
@Cacheable("GraphService_filterData")
public GraphDto filterData(Diagram diagram, DiagramData diagramData, Filters config) {
log.info("filtering now");
Language lang = config.getLang();
List<FilterDto> filterDtos = getFilters(lang, diagramData);
updateRegionFiltersByEhak(filterDtos, config);
......@@ -70,6 +73,7 @@ public class GraphService {
for (FilterDto filter : filterDtos) {
Optional<UserFilterDto> userFilterOp = config.getUserFilters().stream().filter(v -> v.getFilter().equals(filter.getId())).findAny();
if (userFilterOp.isPresent()) {
log.info("userfilter preferences: {}", userFilterOp.get());
UserFilterDto userFilter = userFilterOp.get();
filter.getValues().forEach(v -> v.setSelected(userFilter.getValues().contains(v.getId())));
filter.recalcDefaultOptions();
......@@ -81,6 +85,7 @@ public class GraphService {
private void updateRegionFiltersByEhak(List<FilterDto> filterDtos, Filters config) {
for (FilterDto filter : filterDtos) {
if (BooleanUtils.isTrue(filter.getRegion())) {
log.info("ehak setup: {}", config.getEhakName());
filter.getValues().forEach(v -> v.setSelected(v.getOption().equalsIgnoreCase(config.getEhakName()) ? true : null));
filter.recalcDefaultOptions();
}
......@@ -100,9 +105,9 @@ public class GraphService {
GraphDto dto = new GraphDto();
dto.setPeriod(graph.getPeriod());
List<FilterSerie> series = graph.getSeries();
if (isNotEmpty(series)){
if (isNotEmpty(series)) {
for (FilterSerie filterSerie : series) {
if (filterSerie.getFilters() != null && filterSerie.getFilters().size() > 1){
if (filterSerie.getFilters() != null && filterSerie.getFilters().size() > 1) {
LinkedHashMap<String, String> newFilters = new LinkedHashMap<>();
for (String key : filterSerie.getOrder()) {
newFilters.put(key, filterSerie.getFilters().get(key));
......
......@@ -123,6 +123,7 @@ public class WidgetService {
}
if (filterType.filterGraphData()) {
log.info("going to filter: {}", filters);
dto.setDiagram(graphService.filterData(diagram, data, filters));
} else {
dto.setDiagram(graphService.fullData(diagram, data, filters));
......
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