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

SA0140-609 | fix dashboard visiblity errors and cache updating

parent 9eb220d8
......@@ -2,6 +2,7 @@ package ee.stat.dashboard.repository.custom;
import ee.stat.dashboard.model.classifier.DashboardRule;
import ee.stat.dashboard.model.dashboard.Dashboard;
import ee.stat.dashboard.model.dashboard.DashboardStatus;
import ee.stat.dashboard.model.dashboard.DashboardUserType;
import ee.stat.dashboard.model.widget.back.enums.Language;
import org.springframework.data.domain.Page;
......@@ -61,9 +62,13 @@ public class DashboardCustomRepositoryImpl implements DashboardCustomRepository
" join role_dashboard rd on d.id = rd.dashboard\n" +
"where rd.role_element = :roleElement\n" +
" and rd.dashboard_rule = :dashboardRule\n" +
" and d.user_type = :userType\n" +
" and d.status = :status\n" +
order, Dashboard.class)
.setParameter("roleElement", roleElement)
.setParameter("dashboardRule", DashboardRule.DASHBOARDS.name())
.setParameter("status", DashboardStatus.VISIBLE.name())
.setParameter("userType", DashboardUserType.ADMIN.name())
.getResultList();
}
......@@ -76,9 +81,13 @@ public class DashboardCustomRepositoryImpl implements DashboardCustomRepository
" join role_dashboard rd on d.id = rd.dashboard\n" +
"where rd.role_classifier = :roleClassifier\n" +
" and rd.dashboard_rule = :dashboardRule\n" +
" and d.user_type = :userType\n" +
" and d.status = :status\n" +
order, Dashboard.class)
.setParameter("roleClassifier", roleClassifier)
.setParameter("dashboardRule", DashboardRule.ONE_DASHBOARD.name())
.setParameter("status", DashboardStatus.VISIBLE.name())
.setParameter("userType", DashboardUserType.ADMIN.name())
.getResultList();
}
}
......@@ -17,15 +17,33 @@ public class DashboardCacheManager {
private CacheManager cacheManager;
@Caching(evict = {
@CacheEvict(value = "DashboardServiceCache_findAllByLevel", allEntries = true),
@CacheEvict(value = "ElementServiceCache_findAllByClfCodeAndRoleOrderByName", allEntries = true),
})
public void save(DashboardAdminResponse dashboard) {
}
@Caching(evict = {
@CacheEvict(value = "DashboardServiceCache_findAllByLevel", allEntries = true),
@CacheEvict(value = "DashboardServiceCache_findById", key = "#dashboard.id"),
@CacheEvict(value = "ElementServiceCache_findAllDashboardRegions", key = "#dashboard.id"),
@CacheEvict(value = "ElementServiceCache_findAllByClfCodeAndRoleOrderByName", allEntries = true)
})
public void update(DashboardAdminResponse dashboard) {
updateDomainServiceCache(dashboard.getId(), cacheManager.getCache("DomainService_loadDomainsAndWidgets"));
}
@Caching(evict = {
@CacheEvict(value = "DashboardServiceCache_findById", key = "#dashboardId"),
@CacheEvict(value = "DashboardServiceCache_findAllByLevel", allEntries = true),
@CacheEvict(value = "ElementServiceCache_findAllByClfCodeAndRoleOrderByName", allEntries = true),
})
public void delete(Long dashboardId) {
}
public void updateDomainServiceCache(List<Long> dashboardIds) {
Cache domainsAndWidgets = cacheManager.getCache("DomainService_loadDomainsAndWidgets");
for (Long dashboardId : dashboardIds) {
......@@ -40,19 +58,4 @@ public class DashboardCacheManager {
}
}
}
@Caching(evict = {
@CacheEvict(value = "DashboardServiceCache_findAllByLevel", allEntries = true),
})
public void save(DashboardAdminResponse dashboard) {
}
@Caching(evict = {
@CacheEvict(value = "DashboardServiceCache_findById", key = "#dashboardId"),
@CacheEvict(value = "DashboardServiceCache_findAllByLevel", allEntries = true),
})
public void delete(Long dashboardId) {
}
}
......@@ -21,7 +21,7 @@ public class StatUrlBuilderService_TimeFilter_NeededYearlyData_AndStatHasYearlyF
String url = statUrlBuilderService.buildUrl(simpleUrlConfig(CUBE, TIME_PERIOD)
.periods(5)
.build());
validateTimeParams("startTime=2013", url);
validateTimeParams("startTime=2014", url);
}
@Test
......@@ -39,7 +39,7 @@ public class StatUrlBuilderService_TimeFilter_NeededYearlyData_AndStatHasYearlyF
.periods(2)
.startDate(_2014_1_1)
.build());
validateTimeParams("startTime=2016", url);
validateTimeParams("startTime=2017", url);
}
@Test
......@@ -48,7 +48,7 @@ public class StatUrlBuilderService_TimeFilter_NeededYearlyData_AndStatHasYearlyF
.periods(10)
.endDate(_2023_1_1)
.build());
validateTimeParams("startTime=2008&endTime=2023", url);
validateTimeParams("startTime=2009&endTime=2023", url);
}
@Test
......@@ -68,6 +68,6 @@ public class StatUrlBuilderService_TimeFilter_NeededYearlyData_AndStatHasYearlyF
.startDate(_2014_1_1)
.endDate(_2023_1_1)
.build());
validateTimeParams("startTime=2016&endTime=2023", url);
validateTimeParams("startTime=2017&endTime=2023", url);
}
}
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