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

SA0140-537 | clean up unused code

parent 4e5314cc
......@@ -2,14 +2,12 @@ package ee.stat.dashboard.service.dashboard;
import ee.stat.dashboard.config.security.StatUser;
import ee.stat.dashboard.model.dashboard.Dashboard;
import ee.stat.dashboard.repository.DashboardRepository;
import ee.stat.dashboard.service.widget.widget.dto.PinningStrategy;
import ee.stat.dashboard.util.StatBadRequestException;
import ee.stat.dashboard.util.StatNotFoundRequestException;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
import static ee.stat.dashboard.util.ErrorCode.dashboard_is_hidden;
......@@ -18,15 +16,12 @@ import static ee.stat.dashboard.util.ErrorCode.dashboard_must_be_of_admin_type;
import static ee.stat.dashboard.util.ErrorCode.dashboard_must_be_regional;
import static ee.stat.dashboard.util.ErrorCode.my_dashboard_cannot_be_pinned;
import static ee.stat.dashboard.util.ErrorCode.my_dashboard_does_not_exist;
import static ee.stat.dashboard.util.StatListUtil.first;
import static org.apache.commons.collections4.CollectionUtils.isEmpty;
@Service
@AllArgsConstructor
public class DashboardFinder {
private DashboardServiceCache dashboardServiceCache;
private DashboardRepository dashboardRepository;
public Dashboard findValidDashboard(Long id, StatUser user) {
Dashboard dashboard = findById(id);
......@@ -46,12 +41,6 @@ public class DashboardFinder {
return dashboard;
}
public Dashboard findValidMyDashboard(StatUser user) {
List<Dashboard> myDashboards = dashboardRepository.findByAppUser(user.getId());
mustHave(myDashboards);
return first(myDashboards);
}
public Dashboard findValidDashboardForSaveRegion(Long id) {
Dashboard dashboard = findById(id);
mustBeVisible(dashboard);
......@@ -71,12 +60,6 @@ public class DashboardFinder {
}
}
private void mustHave(List<Dashboard> myDashboards) {
if (isEmpty(myDashboards)) {
throw new StatNotFoundRequestException(my_dashboard_does_not_exist);
}
}
private void ifTypeIsUserUsersMustMatch(StatUser user, Dashboard dashboard) {
if (dashboard.getUserType().isUser()) {
if (user == null || !Objects.equals(user.getId(), dashboard.getAppUser())) {
......
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