Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#12566 - Task synchronization on Android pulls tasks not related with… #12621

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ private void showRepullProgressItems() {
addEntityIfViewAllowed(ImmunizationDto.class, Strings.entityImmunizations, allowedEntities);
addEntityIfViewAllowed(EventDto.class, Strings.entityEvents, allowedEntities);
addEntityIfViewAllowed(EventParticipantDto.class, Strings.entityEventParticipants, allowedEntities);
addEntityIfViewAllowed(EnvironmentDto.class, Strings.entityEnvironments, allowedEntities);
addEntityIfViewAllowed(EnvironmentSampleDto.class, Strings.entityEnvironmentSamples, allowedEntities);
addEntityIfViewAllowed(SampleDto.class, Strings.entitySamples, allowedEntities);
addEntityIfViewAllowed(PathogenTestDto.class, Strings.entityPathogenTests, allowedEntities);
addEntityIfViewAllowed(AdditionalTestDto.class, Strings.entityAdditionalTests, allowedEntities);
addEntityIfViewAllowed(EnvironmentDto.class, Strings.entityEnvironments, allowedEntities);
addEntityIfViewAllowed(EnvironmentSampleDto.class, Strings.entityEnvironmentSamples, allowedEntities);
addEntityIfViewAllowed(ContactDto.class, Strings.entityContacts, allowedEntities);
addEntityIfViewAllowed(VisitDto.class, Strings.entityVisits, allowedEntities);
addEntityIfViewAllowed(TaskDto.class, Strings.entityTasks, allowedEntities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ protected Predicate createRelevantDataFilter(CriteriaBuilder cb, CriteriaQuery c
filter = CriteriaBuilderHelper.and(cb, filter, createUserFilter(taskQueryContext));
}

Predicate criteriaFilter = this.buildCriteriaFilter(new TaskCriteria(), taskQueryContext);
filter = CriteriaBuilderHelper.and(cb, filter, criteriaFilter);

return filter;
}

Expand All @@ -144,6 +147,9 @@ public List<String> getAllActiveUuids(User user) {
filter = CriteriaBuilderHelper.and(cb, filter, userFilter);
}

Predicate criteriaFilter = this.buildCriteriaFilter(new TaskCriteria(), taskQueryContext);
filter = CriteriaBuilderHelper.and(cb, filter, criteriaFilter);

if (RequestContextHolder.isMobileSync()) {
Predicate predicate = createLimitedChangeDateFilter(cb, from);
if (predicate != null) {
Expand Down Expand Up @@ -190,7 +196,9 @@ private boolean hasContextOrNoContext(TaskCriteria taskCriteria, TaskContext tas
|| !taskCriteria.hasContextCriteria()
|| (taskCriteria.getTaskContext() == TaskContext.TRAVEL_ENTRY || taskCriteria.getTravelEntry() != null);
case ENVIRONMENT:
return taskCriteria == null || (taskCriteria.getTaskContext() == TaskContext.ENVIRONMENT || taskCriteria.getEnvironment() != null);
return taskCriteria == null
|| !taskCriteria.hasContextCriteria()
|| (taskCriteria.getTaskContext() == TaskContext.ENVIRONMENT || taskCriteria.getEnvironment() != null);
case GENERAL:
return taskCriteria == null || !taskCriteria.hasContextCriteria() || taskCriteria.getTaskContext() == TaskContext.GENERAL;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ public List<UserReferenceDto> getUsersByRegionAndRights(RegionReferenceDto regio
null,
null,
true,
true,
limitedDisease,
userRights)
.stream()
Expand Down Expand Up @@ -316,7 +315,6 @@ public List<UserReferenceDto> getUserRefsByDistrict(DistrictReferenceDto distric
districtRef != null ? Collections.singletonList(districtRef.getUuid()) : null,
null,
true,
true,
limitedDisease,
userRights)
.stream()
Expand All @@ -336,7 +334,6 @@ public List<UserReferenceDto> getUserRefsByDistrict(
districtRef != null ? Collections.singletonList(districtRef.getUuid()) : null,
null,
true,
true,
null,
excludeLimitedDiseaseUsers,
Arrays.asList(userRights))
Expand All @@ -355,7 +352,6 @@ public List<UserReferenceDto> getUserRefsByDistricts(List<DistrictReferenceDto>
districtRefs.stream().map(DistrictReferenceDto::getUuid).collect(Collectors.toList()),
null,
true,
true,
limitedDisease,
userRights)
.stream()
Expand Down Expand Up @@ -392,10 +388,7 @@ public List<UserReferenceDto> getUserRefsByInfrastructure(
@PermitAll
public List<UserReferenceDto> getAllUserRefs(boolean includeInactive) {

return userService.getUserReferences(null, null, true, !includeInactive)
.stream()
.map(UserFacadeEjb::toReferenceDto)
.collect(Collectors.toList());
return userService.getUserReferences(null, null, !includeInactive).stream().map(UserFacadeEjb::toReferenceDto).collect(Collectors.toList());
}

private List<UserReferenceDto> getAssignableUsersBasedOnContext(TaskContextIndexCriteria taskContextIndexCriteria) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,43 +198,28 @@ public List<User> getAllByDistrictsAndUserRights(List<District> districts, Colle
* @param activeOnly
* @param userRights
*/
public List<UserReference> getUserReferences(
List<String> regionUuids,
List<String> districtUuids,
boolean filterByCurrentUserJurisdiction,
boolean activeOnly,
UserRight... userRights) {
public List<UserReference> getUserReferences(List<String> regionUuids, List<String> districtUuids, boolean activeOnly, UserRight... userRights) {

return getUserReferences(regionUuids, districtUuids, null, filterByCurrentUserJurisdiction, activeOnly, userRights);
return getUserReferences(regionUuids, districtUuids, null, activeOnly, userRights);
}

public List<UserReference> getUserReferences(
List<String> regionUuids,
List<String> districtUuids,
List<String> communityUuids,
boolean filterByJurisdiction,
boolean activeOnly,
UserRight... userRights) {
return getUserReferences(regionUuids, districtUuids, communityUuids, filterByJurisdiction, activeOnly, null, userRights);
return getUserReferences(regionUuids, districtUuids, communityUuids, activeOnly, null, userRights);
}

public List<UserReference> getUserReferences(
List<String> regionUuids,
List<String> districtUuids,
List<String> communityUuids,
boolean filterByJurisdiction,
boolean activeOnly,
Disease limitedDisease,
UserRight... userRights) {
return getUserReferences(
regionUuids,
districtUuids,
communityUuids,
filterByJurisdiction,
activeOnly,
limitedDisease,
false,
Arrays.asList(userRights));
return getUserReferences(regionUuids, districtUuids, communityUuids, activeOnly, limitedDisease, false, Arrays.asList(userRights));
}

/**
Expand All @@ -254,7 +239,6 @@ public List<UserReference> getUserReferences(
List<String> regionUuids,
List<String> districtUuids,
List<String> communityUuids,
boolean filterByJurisdiction,
boolean activeOnly,
Disease limitedDisease,
boolean excludeLimitedDiseaseUsers,
Expand Down Expand Up @@ -289,7 +273,7 @@ public List<UserReference> getUserReferences(
filter = CriteriaBuilderHelper.and(cb, filter, districtFilter);
userEntityJoinUsed = true;
}
if (filterByJurisdiction) {
if (!hasRight(UserRight.SEE_PERSONAL_DATA_OUTSIDE_JURISDICTION)) {
filter = CriteriaBuilderHelper.and(cb, filter, createCurrentUserJurisdictionFilter(cb, userRoot));
userEntityJoinUsed = true;
}
Expand Down Expand Up @@ -712,10 +696,6 @@ public Predicate createUserFilter(CriteriaBuilder cb, CriteriaQuery cq, From<?,
}

public Predicate createCurrentUserJurisdictionFilter(CriteriaBuilder cb, From<?, User> from) {
if (hasRight(UserRight.SEE_PERSONAL_DATA_OUTSIDE_JURISDICTION)) {
return cb.conjunction();
}

User currentUser = getCurrentUser();

if (currentUser.getHealthFacility() != null) {
Expand Down