From 9dbcb74bed5572b127f638540235a2b1aab6f919 Mon Sep 17 00:00:00 2001 From: Levente Gal Date: Wed, 27 Sep 2023 13:14:48 +0300 Subject: [PATCH] #11574 Add environment samples to sample status map --- .../sample/SampleDashboardService.java | 22 +++++++++---------- .../SampleDashboardMapComponent.java | 5 +++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/dashboard/sample/SampleDashboardService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/dashboard/sample/SampleDashboardService.java index 0dabde70408..e01938b3083 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/dashboard/sample/SampleDashboardService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/dashboard/sample/SampleDashboardService.java @@ -456,18 +456,16 @@ private Predicate createEnvironmentSampleFilter(EnvironmentSampleQueryContext qu dateFilter = cb.or(cb.between(joins.getEnvironment().get(Environment.REPORT_DATE), dateFrom, dateTo)); break; case MOST_RELEVANT: - // TODO - uncomment after link to env sample is added on pathogen test -// Subquery pathogenTestSq = cq.subquery(Date.class); -// Root pathogenTestRoot = pathogenTestSq.from(PathogenTest.class); -// Path pathogenTestDate = pathogenTestRoot.get(PathogenTest.TEST_DATE_TIME); -// pathogenTestSq.select((Expression) (Expression) cb.max(pathogenTestDate)); -// pathogenTestSq.where(cb.equal(pathogenTestRoot.get(PathogenTest.ENVIRONMENT_SAMPLE), sampleRoot)); -// -// dateFilter = cb.between( -// CriteriaBuilderHelper.coalesce(cb, Date.class, pathogenTestSq, sampleRoot.get(EnvironmentSample.SAMPLE_DATE_TIME)), -// dateFrom, -// dateTo); - dateFilter = cb.conjunction(); + Subquery pathogenTestSq = cq.subquery(Date.class); + Root pathogenTestRoot = pathogenTestSq.from(PathogenTest.class); + Path pathogenTestDate = pathogenTestRoot.get(PathogenTest.TEST_DATE_TIME); + pathogenTestSq.select((Expression) (Expression) cb.max(pathogenTestDate)); + pathogenTestSq.where(cb.equal(pathogenTestRoot.get(PathogenTest.ENVIRONMENT_SAMPLE), sampleRoot)); + + dateFilter = cb.between( + CriteriaBuilderHelper.coalesce(cb, Date.class, pathogenTestSq, sampleRoot.get(EnvironmentSample.SAMPLE_DATE_TIME)), + dateFrom, + dateTo); break; default: throw new RuntimeException("Unhandled date type [" + sampleDateType + "]"); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/sample/components/SampleDashboardMapComponent.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/sample/components/SampleDashboardMapComponent.java index 604b1e5cb0c..ba5f30a2402 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/sample/components/SampleDashboardMapComponent.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/dashboard/sample/components/SampleDashboardMapComponent.java @@ -32,12 +32,13 @@ import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.dashboard.SampleDashboardCriteria; import de.symeda.sormas.api.dashboard.sample.MapSampleDto; +import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.i18n.Captions; import de.symeda.sormas.api.i18n.I18nProperties; import de.symeda.sormas.api.i18n.Strings; import de.symeda.sormas.api.sample.SampleAssociationType; import de.symeda.sormas.api.user.UserRight; -import de.symeda.sormas.ui.UserProvider; +import de.symeda.sormas.ui.UiUtil; import de.symeda.sormas.ui.dashboard.map.BaseDashboardMapComponent; import de.symeda.sormas.ui.dashboard.sample.SampleDashboardDataProvider; import de.symeda.sormas.ui.map.LeafletMarker; @@ -57,7 +58,7 @@ public SampleDashboardMapComponent(SampleDashboardDataProvider dashboardDataProv protected void addComponents() { displayedHumanSamples = new HashSet<>(Arrays.asList(SampleAssociationType.CASE, SampleAssociationType.CONTACT, SampleAssociationType.EVENT_PARTICIPANT)); - if (UserProvider.getCurrent().hasUserRight(UserRight.ENVIRONMENT_SAMPLE_VIEW)) { + if (UiUtil.permitted(FeatureType.ENVIRONMENT_MANAGEMENT, UserRight.ENVIRONMENT_SAMPLE_VIEW)) { showEnvironmentalSamples = true; }