Skip to content

Commit

Permalink
#11574 Add environment samples to sample status map
Browse files Browse the repository at this point in the history
  • Loading branch information
Levente Gal committed Sep 27, 2023
1 parent 24b6cd8 commit 9dbcb74
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Date> pathogenTestSq = cq.subquery(Date.class);
// Root<PathogenTest> pathogenTestRoot = pathogenTestSq.from(PathogenTest.class);
// Path<Number> pathogenTestDate = pathogenTestRoot.get(PathogenTest.TEST_DATE_TIME);
// pathogenTestSq.select((Expression<Date>) (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<Date> pathogenTestSq = cq.subquery(Date.class);
Root<PathogenTest> pathogenTestRoot = pathogenTestSq.from(PathogenTest.class);
Path<Number> pathogenTestDate = pathogenTestRoot.get(PathogenTest.TEST_DATE_TIME);
pathogenTestSq.select((Expression<Date>) (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 + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 9dbcb74

Please sign in to comment.