use of com.qcadoo.mes.materialFlowResources.constants.DocumentDtoFields.LOCATION_FROM_ID in project mes by qcadoo.
the class DocumentsCriteriaModifier method restrictToUserLocations.
private void restrictToUserLocations(SearchCriteriaBuilder scb) {
Long currentUserId = securityService.getCurrentUserId();
if (Objects.nonNull(currentUserId)) {
EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS);
if (!userLocations.isEmpty()) {
Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)).mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet());
scb.add(SearchRestrictions.or(SearchRestrictions.in(LOCATION_TO_ID, locationIds), SearchRestrictions.in(LOCATION_FROM_ID, locationIds)));
}
}
}
Aggregations