Commit 877bfe99 authored by oleg.pahhomov's avatar oleg.pahhomov

SA0140-611 | add cachekey to filtering cache

parent 5043f05c
......@@ -52,4 +52,14 @@ public class Element {
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Element{");
sb.append("id=").append(id);
sb.append(", code='").append(code).append('\'');
sb.append(", nameEt='").append(nameEt).append('\'');
sb.append('}');
return sb.toString();
}
}
......@@ -49,4 +49,17 @@ public class GraphType {
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("GraphType{");
sb.append("id=").append(id);
sb.append(", widget=").append(widget);
sb.append(", type=").append(type);
sb.append(", defaultType=").append(defaultType);
sb.append(", mapRule=").append(mapRule);
sb.append(", verticalRule=").append(verticalRule);
sb.append('}');
return sb.toString();
}
}
......@@ -14,6 +14,7 @@ import javax.persistence.Transient;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Getter
@Setter
......@@ -31,4 +32,17 @@ public class Diagram {
@Transient
private List<DiagramData> diagramData = new ArrayList<>();
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Diagram diagram = (Diagram) o;
return Objects.equals(id, diagram.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}
......@@ -15,6 +15,7 @@ import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Objects;
@Getter
......@@ -41,6 +42,9 @@ public class DiagramData {
@Column(columnDefinition = "jsonb")
private Graph graphEn;
@Transient
private Diagram diagramObj;
public Graph getGraph(Language lang) {
return lang.isEt() ? graphEt : graphEn;
}
......
......@@ -36,8 +36,8 @@ public class GraphService {
private ElementService elementService;
private FilterService filterService;
@Cacheable("GraphService_filterData")
public GraphDto filterData(Diagram diagram, DiagramData diagramData, Filters config) {
@Cacheable(value = "GraphService_filterData", key = "#diagramData.hashCode().concat(#config.hashCode())")
public GraphDto filterData(DiagramData diagramData, Filters config) {
log.info("filtering now");
Language lang = config.getLang();
List<FilterDto> filterDtos = getFilters(lang, diagramData);
......@@ -50,12 +50,12 @@ public class GraphService {
graphDto.setFilters(frontEndFilters(filterDtos));
graphDto.setMapType(getMapType(config));
graphDto.setDiagramDataId(diagramData.getId());
graphDto.setDiagramCreatedAt(diagram.getCreatedAt());
graphDto.setDiagramCreatedAt(diagramData.getDiagramObj().getCreatedAt());
return graphDto;
}
@Cacheable("GraphService_fullData")
public GraphDto fullData(Diagram diagram, DiagramData diagramData, Filters config) {
public GraphDto fullData(DiagramData diagramData, Filters config) {
Language lang = config.getLang();
List<FilterDto> filterDtos = getFilters(lang, diagramData);
updateRegionFiltersByEhak(filterDtos, config);
......@@ -64,7 +64,7 @@ public class GraphService {
graphDto.setFilters(frontEndFilters(filterDtos));
graphDto.setMapType(getMapType(config));
graphDto.setDiagramDataId(diagramData.getId());
graphDto.setDiagramCreatedAt(diagram.getCreatedAt());
graphDto.setDiagramCreatedAt(diagramData.getDiagramObj().getCreatedAt());
return graphDto;
}
......
......@@ -124,9 +124,11 @@ public class WidgetService {
if (filterType.filterGraphData()) {
log.info("going to filter: {}", filters);
dto.setDiagram(graphService.filterData(diagram, data, filters));
data.setDiagramObj(diagram);
dto.setDiagram(graphService.filterData(data, filters));
} else {
dto.setDiagram(graphService.fullData(diagram, data, filters));
data.setDiagramObj(diagram);
dto.setDiagram(graphService.fullData(data, filters));
}
return dto;
}
......
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