Commit e65be6d9 authored by Andrus Aru's avatar Andrus Aru

repo update 31.01.2029

parent 454c2f24
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<groupId>ee.stat</groupId> <groupId>ee.stat</groupId>
<artifactId>stat-dashboard-backend</artifactId> <artifactId>stat-dashboard-backend</artifactId>
<version>0.16.3</version> <version>1.0.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<!--<packaging>${packaging}</packaging>--> <!--<packaging>${packaging}</packaging>-->
<!-- mvn clean package -Dpackaging=jar/war--> <!-- mvn clean package -Dpackaging=jar/war-->
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version> <version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
......
...@@ -52,14 +52,4 @@ public class Element { ...@@ -52,14 +52,4 @@ public class Element {
public int hashCode() { public int hashCode() {
return Objects.hash(id); 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,17 +49,4 @@ public class GraphType { ...@@ -49,17 +49,4 @@ public class GraphType {
public int hashCode() { public int hashCode() {
return Objects.hash(id); 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();
}
} }
...@@ -8,4 +8,6 @@ import java.util.List; ...@@ -8,4 +8,6 @@ import java.util.List;
public interface UserDashboardRepository extends JpaRepository<UserDashboard, Long> { public interface UserDashboardRepository extends JpaRepository<UserDashboard, Long> {
List<UserDashboard> findAllByDashboardAndAndAppUser(Long dashboard, Long appUser); List<UserDashboard> findAllByDashboardAndAndAppUser(Long dashboard, Long appUser);
void deleteByDashboard(Long dashboard);
} }
...@@ -10,9 +10,9 @@ public interface UserGraphTypeRepository extends JpaRepository<UserGraphType, Lo ...@@ -10,9 +10,9 @@ public interface UserGraphTypeRepository extends JpaRepository<UserGraphType, Lo
List<UserGraphType> findAllByUserWidget(Long userWidget); List<UserGraphType> findAllByUserWidget(Long userWidget);
List<UserGraphType> findAllByGraphTypeIn(List<Long> graphType);
List<UserGraphType> findAllByUserWidgetIn(List<Long> userWidget); List<UserGraphType> findAllByUserWidgetIn(List<Long> userWidget);
void deleteByIdIn(List<Long> ids); void deleteByIdIn(List<Long> ids);
void deleteByGraphTypeIn(List<Long> ids);
} }
...@@ -13,4 +13,6 @@ public interface UserLegendRepository extends JpaRepository<UserLegend, Long> { ...@@ -13,4 +13,6 @@ public interface UserLegendRepository extends JpaRepository<UserLegend, Long> {
List<UserLegend> findAllByUserGraphTypeIn(List<Long> userGraphType); List<UserLegend> findAllByUserGraphTypeIn(List<Long> userGraphType);
void deleteByIdIn(List<Long> ids); void deleteByIdIn(List<Long> ids);
void deleteByUserGraphTypeIn(List<Long> ids);
} }
...@@ -51,7 +51,7 @@ public class ElementCustomRepositoryImpl implements ElementCustomRepository { ...@@ -51,7 +51,7 @@ public class ElementCustomRepositoryImpl implements ElementCustomRepository {
@Override @Override
public List<Element> findAllByClfCodeAndRoleOrderByName(ClassifierCode code, RoleStrategy role, Language language, DashboardStatus status, DashboardUserType userType) { public List<Element> findAllByClfCodeAndRoleOrderByName(ClassifierCode code, RoleStrategy role, Language language, DashboardStatus status, DashboardUserType userType) {
String roleExistsCondition = role.hasDashboard() ? " and rd.id is not null \n" : " and rd.id is null \n"; String roleExistsCondition = role.hasDashboard() ? " and d.id is not null \n" : " and d.id is null \n";
String order = language.isEt() ? " order by e.name_et asc \n" : " order by e.name_en asc \n"; String order = language.isEt() ? " order by e.name_et asc \n" : " order by e.name_en asc \n";
String select = "SELECT DISTINCT e.*\n" + String select = "SELECT DISTINCT e.*\n" +
"from Element e\n" + "from Element e\n" +
......
...@@ -10,6 +10,7 @@ import ee.stat.dashboard.repository.DashboardWidgetRepository; ...@@ -10,6 +10,7 @@ import ee.stat.dashboard.repository.DashboardWidgetRepository;
import ee.stat.dashboard.repository.DomainConnectionRepository; import ee.stat.dashboard.repository.DomainConnectionRepository;
import ee.stat.dashboard.repository.DomainRepository; import ee.stat.dashboard.repository.DomainRepository;
import ee.stat.dashboard.repository.RoleDashboardRepository; import ee.stat.dashboard.repository.RoleDashboardRepository;
import ee.stat.dashboard.repository.UserDashboardRepository;
import ee.stat.dashboard.repository.WidgetDomainRepository; import ee.stat.dashboard.repository.WidgetDomainRepository;
import ee.stat.dashboard.service.admin.widget.UserWidgetDeleteService; import ee.stat.dashboard.service.admin.widget.UserWidgetDeleteService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -34,10 +35,12 @@ public class DashboardDeleteService { ...@@ -34,10 +35,12 @@ public class DashboardDeleteService {
private DomainConnectionRepository domainConnectionRepository; private DomainConnectionRepository domainConnectionRepository;
private DomainRepository domainRepository; private DomainRepository domainRepository;
private RoleDashboardRepository roleDashboardRepository; private RoleDashboardRepository roleDashboardRepository;
private UserDashboardRepository userDashboardRepository;
public void delete(Dashboard dashboard) { public void delete(Dashboard dashboard) {
dashboardRegionRepository.deleteByDashboard(dashboard.getId()); dashboardRegionRepository.deleteByDashboard(dashboard.getId());
userWidgetDeleteService.deleteUserWidgets(dashboard); userWidgetDeleteService.deleteUserWidgets(dashboard);
userDashboardRepository.deleteByDashboard(dashboard.getId());
widgetDomainRepository.deleteByDashboard(dashboard.getId()); widgetDomainRepository.deleteByDashboard(dashboard.getId());
dashboardWidgetRepository.deleteByDashboard(dashboard.getId()); dashboardWidgetRepository.deleteByDashboard(dashboard.getId());
......
...@@ -77,7 +77,7 @@ public class DashboardDomainService { ...@@ -77,7 +77,7 @@ public class DashboardDomainService {
List<Domain> existingDomains = domainRepository.findByDashboard(dashboard.getId()); List<Domain> existingDomains = domainRepository.findByDashboard(dashboard.getId());
existingDomains.removeAll(domainsToSave); existingDomains.removeAll(domainsToSave);
if (isNotEmpty(existingWidgetDomains)) { if (isNotEmpty(existingDomains)) {
domainRepository.deleteAll(existingDomains); domainRepository.deleteAll(existingDomains);
} }
} }
......
...@@ -23,10 +23,8 @@ import ee.stat.dashboard.service.statdata.xml.XmlValue; ...@@ -23,10 +23,8 @@ import ee.stat.dashboard.service.statdata.xml.XmlValue;
import ee.stat.dashboard.service.statsync.StatDbUpdater; import ee.stat.dashboard.service.statsync.StatDbUpdater;
import ee.stat.dashboard.service.statsync.dto.StatDbResponse; import ee.stat.dashboard.service.statsync.dto.StatDbResponse;
import ee.stat.dashboard.service.statsync.dto.StatDbUpdaterException; import ee.stat.dashboard.service.statsync.dto.StatDbUpdaterException;
import ee.stat.dashboard.util.StatListUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -129,7 +127,7 @@ public class GraphTypeAdminService { ...@@ -129,7 +127,7 @@ public class GraphTypeAdminService {
existingFilterValues.removeAll(savedFilterValues); existingFilterValues.removeAll(savedFilterValues);
if (isNotEmpty(existingFilterValues)) { if (isNotEmpty(existingFilterValues)) {
widgetDeleteService.deleteFilterValues(existingFilterValues, true); widgetDeleteService.deleteFilterValues(existingFilterValues);
} }
existingFilters.removeAll(savedFilters); existingFilters.removeAll(savedFilters);
if (isNotEmpty(existingFilters)) { if (isNotEmpty(existingFilters)) {
...@@ -138,10 +136,10 @@ public class GraphTypeAdminService { ...@@ -138,10 +136,10 @@ public class GraphTypeAdminService {
userLegendValueRepository.deleteByFilterValueIn(ids); userLegendValueRepository.deleteByFilterValueIn(ids);
} }
widgetDeleteService.deleteFilters(existingFilters, true); widgetDeleteService.deleteFilters(existingFilters);
existingGraphTypes.removeAll(newGraphTypes); existingGraphTypes.removeAll(newGraphTypes);
widgetCacheManager.updateGraphType(graphTypeIdsForCache(existingGraphTypes, newGraphTypes)); widgetCacheManager.updateGraphType(graphTypeIdsForCache(existingGraphTypes, newGraphTypes));
widgetDeleteService.deleteGraphTypes(existingGraphTypes, true); widgetDeleteService.deleteGraphTypes(existingGraphTypes);
} }
private GraphType graphType(WidgetAdminResponse widget, GraphTypeAdminDto graphTypeAdminDto) { private GraphType graphType(WidgetAdminResponse widget, GraphTypeAdminDto graphTypeAdminDto) {
......
...@@ -59,17 +59,6 @@ public class UserWidgetDeleteService { ...@@ -59,17 +59,6 @@ public class UserWidgetDeleteService {
deleteUserData(Arrays.asList(userWidget)); deleteUserData(Arrays.asList(userWidget));
} }
public void deleteUserLegends(List<Long> userGraphTypeIds) {
List<UserLegend> userLegends = userGraphTypeIds.isEmpty() ? new ArrayList<>() : userLegendRepository.findAllByUserGraphTypeIn(userGraphTypeIds);
List<Long> userLegendIds = userLegends.stream().map(UserLegend::getId).collect(Collectors.toList());
deleteUserLegendValues(userLegendIds);
if (isNotEmpty(userLegendIds)) {
userLegendRepository.deleteByIdIn(userLegendIds);
}
}
public void deleteUserFilters(List<Long> userGraphTypeIds) { public void deleteUserFilters(List<Long> userGraphTypeIds) {
List<UserFilter> userFilters = userGraphTypeIds.isEmpty() ? new ArrayList<>() : userFilterRepository.findAllByUserGraphTypeIn(userGraphTypeIds); List<UserFilter> userFilters = userGraphTypeIds.isEmpty() ? new ArrayList<>() : userFilterRepository.findAllByUserGraphTypeIn(userGraphTypeIds);
List<Long> userFilterIds = userFilters.stream().map(UserFilter::getId).collect(Collectors.toList()); List<Long> userFilterIds = userFilters.stream().map(UserFilter::getId).collect(Collectors.toList());
...@@ -81,23 +70,6 @@ public class UserWidgetDeleteService { ...@@ -81,23 +70,6 @@ public class UserWidgetDeleteService {
} }
} }
public void deleteUserLegendValues(List<Long> userLegendIds) {
List<UserLegendValue> legendValues = userLegendIds.isEmpty() ? new ArrayList<>() : userLegendValueRepository.findAllByUserLegendIn(userLegendIds);
List<Long> userLegendValueIds = legendValues.stream().map(UserLegendValue::getId).collect(Collectors.toList());
if (isNotEmpty(userLegendValueIds)) {
userLegendValueRepository.deleteByIdIn(userLegendValueIds);
}
}
public void deleteUserFilterValues(List<Long> userFilterIds) {
List<UserFilterValue> userFilterValues = userFilterIds.isEmpty() ? new ArrayList<>() : userFilterValueRepository.findAllByUserFilterIn(userFilterIds);
List<Long> userFilterValuesIds = userFilterValues.stream().map(UserFilterValue::getId).collect(Collectors.toList());
if (isNotEmpty(userFilterValuesIds)) {
userFilterValueRepository.deleteByIdIn(userFilterValuesIds);
}
}
public void deleteUserFiltersByFilter(List<Long> filterIds) { public void deleteUserFiltersByFilter(List<Long> filterIds) {
if (isNotEmpty(filterIds)) { if (isNotEmpty(filterIds)) {
userFilterRepository.deleteByFilterIn(filterIds); userFilterRepository.deleteByFilterIn(filterIds);
...@@ -105,13 +77,24 @@ public class UserWidgetDeleteService { ...@@ -105,13 +77,24 @@ public class UserWidgetDeleteService {
} }
} }
public void deleteUserFilterValuesByValue(List<Long> filterValuesIds) { public void deleteUserFilterValuesByFilterValue(List<Long> filterValuesIds) {
if (isNotEmpty(filterValuesIds)) { if (isNotEmpty(filterValuesIds)) {
userFilterValueRepository.deleteByFilterValueIn(filterValuesIds); userFilterValueRepository.deleteByFilterValueIn(filterValuesIds);
userLegendValueRepository.deleteByFilterValueIn(filterValuesIds); userLegendValueRepository.deleteByFilterValueIn(filterValuesIds);
} }
} }
private void deleteUserLegends(List<Long> userGraphTypeIds) {
List<UserLegend> userLegends = userGraphTypeIds.isEmpty() ? new ArrayList<>() : userLegendRepository.findAllByUserGraphTypeIn(userGraphTypeIds);
List<Long> userLegendIds = userLegends.stream().map(UserLegend::getId).collect(Collectors.toList());
deleteUserLegendValues(userLegendIds);
if (isNotEmpty(userLegendIds)) {
userLegendRepository.deleteByIdIn(userLegendIds);
}
}
private void deleteUserData(List<UserWidget> userWidgets) { private void deleteUserData(List<UserWidget> userWidgets) {
List<Long> userWidgetsIds = userWidgets.stream().map(UserWidget::getId).collect(Collectors.toList()); List<Long> userWidgetsIds = userWidgets.stream().map(UserWidget::getId).collect(Collectors.toList());
List<UserGraphType> allByUserWidget = userWidgets.isEmpty() ? new ArrayList<>() : userGraphTypeRepository.findAllByUserWidgetIn(userWidgetsIds); List<UserGraphType> allByUserWidget = userWidgets.isEmpty() ? new ArrayList<>() : userGraphTypeRepository.findAllByUserWidgetIn(userWidgetsIds);
...@@ -124,4 +107,21 @@ public class UserWidgetDeleteService { ...@@ -124,4 +107,21 @@ public class UserWidgetDeleteService {
userGraphTypeRepository.deleteByIdIn(userGraphTypeIds); userGraphTypeRepository.deleteByIdIn(userGraphTypeIds);
} }
} }
private void deleteUserLegendValues(List<Long> userLegendIds) {
List<UserLegendValue> legendValues = userLegendIds.isEmpty() ? new ArrayList<>() : userLegendValueRepository.findAllByUserLegendIn(userLegendIds);
List<Long> userLegendValueIds = legendValues.stream().map(UserLegendValue::getId).collect(Collectors.toList());
if (isNotEmpty(userLegendValueIds)) {
userLegendValueRepository.deleteByIdIn(userLegendValueIds);
}
}
private void deleteUserFilterValues(List<Long> userFilterIds) {
List<UserFilterValue> userFilterValues = userFilterIds.isEmpty() ? new ArrayList<>() : userFilterValueRepository.findAllByUserFilterIn(userFilterIds);
List<Long> userFilterValuesIds = userFilterValues.stream().map(UserFilterValue::getId).collect(Collectors.toList());
if (isNotEmpty(userFilterValuesIds)) {
userFilterValueRepository.deleteByIdIn(userFilterValuesIds);
}
}
} }
package ee.stat.dashboard.service.admin.widget; package ee.stat.dashboard.service.admin.widget;
import ee.stat.dashboard.model.user.widget.UserGraphType;
import ee.stat.dashboard.model.widget.back.Excel; import ee.stat.dashboard.model.widget.back.Excel;
import ee.stat.dashboard.model.widget.back.Filter; import ee.stat.dashboard.model.widget.back.Filter;
import ee.stat.dashboard.model.widget.back.FilterValue; import ee.stat.dashboard.model.widget.back.FilterValue;
...@@ -18,6 +19,7 @@ import ee.stat.dashboard.repository.GraphTypeRepository; ...@@ -18,6 +19,7 @@ import ee.stat.dashboard.repository.GraphTypeRepository;
import ee.stat.dashboard.repository.StatDbDataRepository; import ee.stat.dashboard.repository.StatDbDataRepository;
import ee.stat.dashboard.repository.StatDbRepository; import ee.stat.dashboard.repository.StatDbRepository;
import ee.stat.dashboard.repository.UserGraphTypeRepository; import ee.stat.dashboard.repository.UserGraphTypeRepository;
import ee.stat.dashboard.repository.UserLegendRepository;
import ee.stat.dashboard.repository.WidgetDomainRepository; import ee.stat.dashboard.repository.WidgetDomainRepository;
import ee.stat.dashboard.repository.WidgetExcelImportRepository; import ee.stat.dashboard.repository.WidgetExcelImportRepository;
import ee.stat.dashboard.repository.WidgetRepository; import ee.stat.dashboard.repository.WidgetRepository;
...@@ -49,6 +51,7 @@ public class WidgetDeleteService { ...@@ -49,6 +51,7 @@ public class WidgetDeleteService {
private DiagramDataRepository diagramDataRepository; private DiagramDataRepository diagramDataRepository;
private WidgetExcelImportRepository widgetExcelImportRepository; private WidgetExcelImportRepository widgetExcelImportRepository;
private UserGraphTypeRepository userGraphTypeRepository; private UserGraphTypeRepository userGraphTypeRepository;
private UserLegendRepository userLegendRepository;
private DashboardWidgetRepository dashboardWidgetRepository; private DashboardWidgetRepository dashboardWidgetRepository;
private UserWidgetDeleteService userWidgetDeleteService; private UserWidgetDeleteService userWidgetDeleteService;
...@@ -72,7 +75,7 @@ public class WidgetDeleteService { ...@@ -72,7 +75,7 @@ public class WidgetDeleteService {
dashboardWidgetRepository.deleteByWidget(widget.getId()); dashboardWidgetRepository.deleteByWidget(widget.getId());
userWidgetDeleteService.deleteUserWidgets(widget); userWidgetDeleteService.deleteUserWidgets(widget);
deleteGraphTypes(graphTypeRepository.findAllByWidgetOrderByIdAsc(widget.getId()), false); deleteGraphTypes(graphTypeRepository.findAllByWidgetOrderByIdAsc(widget.getId()));
List<StatDb> statDbs = statDbRepository.findByWidget(widget.getId()); List<StatDb> statDbs = statDbRepository.findByWidget(widget.getId());
if (isNotEmpty(statDbs)) { if (isNotEmpty(statDbs)) {
...@@ -85,42 +88,40 @@ public class WidgetDeleteService { ...@@ -85,42 +88,40 @@ public class WidgetDeleteService {
widgetRepository.deleteById(widget.getId()); widgetRepository.deleteById(widget.getId());
} }
public void deleteGraphTypes(List<GraphType> existingGraphTypes, boolean deleteUser) { public void deleteGraphTypes(List<GraphType> existingGraphTypes) {
List<Long> graphTypeIds = existingGraphTypes.stream().map(GraphType::getId).collect(Collectors.toList()); List<Long> graphTypeIds = existingGraphTypes.stream().map(GraphType::getId).collect(Collectors.toList());
List<Filter> filters = graphTypeIds.isEmpty() ? new ArrayList<>() : filterRepository.findAllByGraphTypeInOrderByIdAsc(graphTypeIds); List<Filter> filters = graphTypeIds.isEmpty() ? new ArrayList<>() : filterRepository.findAllByGraphTypeInOrderByIdAsc(graphTypeIds);
deleteFilters(filters, deleteUser); deleteFilters(filters);
if (deleteUser){
userGraphTypeRepository.deleteByGraphTypeIn(graphTypeIds);
}
if (isNotEmpty(graphTypeIds)) { if (isNotEmpty(graphTypeIds)) {
List<UserGraphType> userGraphTypes = userGraphTypeRepository.findAllByGraphTypeIn(graphTypeIds);
if (isNotEmpty(userGraphTypes)){
List<Long> userGraphTypeIds = userGraphTypes.stream().map(UserGraphType::getId).collect(Collectors.toList());
userLegendRepository.deleteByUserGraphTypeIn(userGraphTypeIds);
userGraphTypeRepository.deleteByIdIn(userGraphTypeIds);
}
diagramDataRepository.deleteByGraphTypeIn(graphTypeIds); diagramDataRepository.deleteByGraphTypeIn(graphTypeIds);
statDbDataRepository.deleteByGraphTypeIn(graphTypeIds); statDbDataRepository.deleteByGraphTypeIn(graphTypeIds);
graphTypeRepository.deleteByIdIn(graphTypeIds); graphTypeRepository.deleteByIdIn(graphTypeIds);
} }
} }
public void deleteFilters(List<Filter> filters, boolean deleteUser) { public void deleteFilters(List<Filter> filters) {
List<Long> filterIds = filters.stream().map(Filter::getId).collect(Collectors.toList()); List<Long> filterIds = filters.stream().map(Filter::getId).collect(Collectors.toList());
List<FilterValue> filterValues = filters.isEmpty() ? new ArrayList<>() : filterValueRepository.findAllByFilterIn(filterIds); List<FilterValue> filterValues = filters.isEmpty() ? new ArrayList<>() : filterValueRepository.findAllByFilterIn(filterIds);
deleteFilterValues(filterValues, deleteUser); deleteFilterValues(filterValues);
userWidgetDeleteService.deleteUserFiltersByFilter(filterIds);
if (deleteUser){
userWidgetDeleteService.deleteUserFiltersByFilter(filterIds);
}
if (isNotEmpty(filterIds)) { if (isNotEmpty(filterIds)) {
filterRepository.deleteByIdIn(filterIds); filterRepository.deleteByIdIn(filterIds);
} }
} }
public void deleteFilterValues(List<FilterValue> filterValues, boolean deleteUser) { public void deleteFilterValues(List<FilterValue> filterValues) {
List<Long> filterValuesIds = filterValues.stream().map(FilterValue::getId).collect(Collectors.toList()); List<Long> filterValuesIds = filterValues.stream().map(FilterValue::getId).collect(Collectors.toList());
if (deleteUser){ userWidgetDeleteService.deleteUserFilterValuesByFilterValue(filterValuesIds);
userWidgetDeleteService.deleteUserFilterValuesByValue(filterValuesIds);
}
if (isNotEmpty(filterValuesIds)) { if (isNotEmpty(filterValuesIds)) {
filterValueRepository.deleteByIdIn(filterValuesIds); filterValueRepository.deleteByIdIn(filterValuesIds);
......
...@@ -50,6 +50,12 @@ public class DashboardSaveService { ...@@ -50,6 +50,12 @@ public class DashboardSaveService {
private DashboardFinder dashboardFinder; private DashboardFinder dashboardFinder;
private DashboardWidgetRepository widgetRepository; private DashboardWidgetRepository widgetRepository;
public Long saveWidgetsAndSetVisited(Long dashboardId, UserWidgetsDto dto, StatUser user) {
Dashboard dashboard = dashboardFinder.dashboardForSaveWidgets(dashboardId, user);
setVisited(dashboard, user);
return saveWidgets(dashboard, user, dto);
}
public Long saveRegion(Long id, UserDashboardDto dto, StatUser user) { public Long saveRegion(Long id, UserDashboardDto dto, StatUser user) {
if (dto.getRegion() == null) throw badRequest(id, "region").get(); if (dto.getRegion() == null) throw badRequest(id, "region").get();
Dashboard dashboard = dashboardFinder.findValidDashboardForSaveRegion(id); Dashboard dashboard = dashboardFinder.findValidDashboardForSaveRegion(id);
...@@ -71,12 +77,6 @@ public class DashboardSaveService { ...@@ -71,12 +77,6 @@ public class DashboardSaveService {
return id; return id;
} }
public Long saveWidgetsAndSetVisited(Long dashboardId, UserWidgetsDto dto, StatUser user) {
Dashboard dashboard = dashboardFinder.dashboardForSaveWidgets(dashboardId, user);
setVisited(dashboard, user);
return saveWidgets(dashboard, user, dto);
}
public Long saveWidgets(Dashboard dashboard, StatUser user, UserWidgetsDto dto) { public Long saveWidgets(Dashboard dashboard, StatUser user, UserWidgetsDto dto) {
if (dashboard.getUserType().isAdmin()) { if (dashboard.getUserType().isAdmin()) {
List<WidgetDomain> widgetDomains = widgetDomainRepository.findAllByDashboard(dashboard.getId()); List<WidgetDomain> widgetDomains = widgetDomainRepository.findAllByDashboard(dashboard.getId());
......
...@@ -38,10 +38,10 @@ public class DashboardService { ...@@ -38,10 +38,10 @@ public class DashboardService {
public DashboardResponse map(Dashboard dashboard, Language lang, StatUser user) { public DashboardResponse map(Dashboard dashboard, Language lang, StatUser user) {
DashboardResponse dto = dashboardConverter.mapSimpleWRegion(dashboard, lang, user); DashboardResponse dto = dashboardConverter.mapSimpleWRegion(dashboard, lang, user);
if (dashboard.getUserType().isUser()) { if (dashboard.getUserType().isAdmin()) {
dto.setWidgets(dashboardWidgetService.getWidgets(dashboard, lang));
} else {
dto.setElements(domainService.loadDomainsAndWidgets(dashboard.getId(), lang)); dto.setElements(domainService.loadDomainsAndWidgets(dashboard.getId(), lang));
} else {
dto.setWidgets(dashboardWidgetService.getWidgets(dashboard, lang));
} }
if (user != null) { if (user != null) {
dto.setSelectedWidgets(userWidgetService.getSelectedWidgets(dashboard, user)); dto.setSelectedWidgets(userWidgetService.getSelectedWidgets(dashboard, user));
......
...@@ -56,7 +56,7 @@ public class TimeFilterManagement { ...@@ -56,7 +56,7 @@ public class TimeFilterManagement {
value.setOrderNr(i); value.setOrderNr(i);
value.setSelected(i == 0); value.setSelected(i == 0);
} }
widgetDeleteService.deleteFilterValues(valuesToRemove, true); widgetDeleteService.deleteFilterValues(valuesToRemove);
filterValueRepository.saveAll(existingTimeFilterValues); filterValueRepository.saveAll(existingTimeFilterValues);
filterValueRepository.flush(); filterValueRepository.flush();
......
...@@ -23,7 +23,7 @@ public class DiagramService { ...@@ -23,7 +23,7 @@ public class DiagramService {
if (diagramOp.isPresent()) { if (diagramOp.isPresent()) {
return diagramOp.get(); return diagramOp.get();
} else { } else {
log.error("Diagram is missing, should not happen {}", widget.getId()); log.error("Diagram is missing, should not happen for widget {}", widget.getId());
return null; return null;
} }
} }
......
...@@ -4,7 +4,6 @@ import ee.stat.dashboard.model.classifier.Element; ...@@ -4,7 +4,6 @@ import ee.stat.dashboard.model.classifier.Element;
import ee.stat.dashboard.model.widget.back.Filter; import ee.stat.dashboard.model.widget.back.Filter;
import ee.stat.dashboard.model.widget.back.enums.Language; import ee.stat.dashboard.model.widget.back.enums.Language;
import ee.stat.dashboard.model.widget.back.enums.MapType; import ee.stat.dashboard.model.widget.back.enums.MapType;
import ee.stat.dashboard.model.widget.front.Diagram;
import ee.stat.dashboard.model.widget.front.DiagramData; import ee.stat.dashboard.model.widget.front.DiagramData;
import ee.stat.dashboard.model.widget.front.FilterSerie; import ee.stat.dashboard.model.widget.front.FilterSerie;
import ee.stat.dashboard.model.widget.front.Graph; import ee.stat.dashboard.model.widget.front.Graph;
...@@ -15,7 +14,6 @@ import ee.stat.dashboard.service.widget.widget.dto.Filters; ...@@ -15,7 +14,6 @@ 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.GraphDto;
import ee.stat.dashboard.service.widget.widget.dto.UserFilterDto; import ee.stat.dashboard.service.widget.widget.dto.UserFilterDto;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -28,7 +26,6 @@ import java.util.stream.Collectors; ...@@ -28,7 +26,6 @@ import java.util.stream.Collectors;
import static org.apache.commons.collections4.CollectionUtils.isNotEmpty; import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;
@Service @Service
@Slf4j
@AllArgsConstructor @AllArgsConstructor