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

SA0140-537 | fix save preferences using deleted widgets

parent 78b1dca7
......@@ -8,6 +8,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.time.LocalDateTime;
import java.util.Objects;
@Getter
@Setter
......@@ -29,4 +30,20 @@ public class DashboardWidget {
this.widget = widget;
this.createdAt = LocalDateTime.now();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DashboardWidget that = (DashboardWidget) o;
return Objects.equals(id, that.id) &&
Objects.equals(dashboard, that.dashboard) &&
Objects.equals(widget, that.widget) &&
Objects.equals(createdAt, that.createdAt);
}
@Override
public int hashCode() {
return Objects.hash(id, dashboard, widget, createdAt);
}
}
......@@ -94,6 +94,7 @@ public class DashboardSaveService {
List<DashboardWidget> dashboardWidgets = widgetRepository.findAllByDashboard(dashboard.getId());
if (isNotEmpty(dashboardWidgets)) {
List<UserWidget> userWidgets = dashboardWidgets.stream()
.filter(dw -> dto.getSelectedWidgets().contains(dw.getWidget()))
.map(dashboardWidget -> mapFromDashboardWidget(dashboardWidget, user, dashboard, dto.getSelectedWidgets()))
.collect(Collectors.toList());
userWidgetRepository.saveAll(userWidgets);
......
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