use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class DocumentPositionsCriteriaModifier method restrictToUserLocations.
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) {
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)));
}
}
}
use of com.qcadoo.model.api.EntityList 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)));
}
}
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class ResourcesCriteriaModifier method restrictToUserLocations.
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) {
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.in(LOCATION_ID, locationIds));
}
}
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class OperationWorkTimeServiceTest method mockEntityList.
private static EntityList mockEntityList(final List<Entity> entities) {
final EntityList entityList = mock(EntityList.class);
given(entityList.iterator()).willAnswer((Answer<Iterator<Entity>>) invocation -> ImmutableList.copyOf(entities).iterator());
given(entityList.isEmpty()).willReturn(entities.isEmpty());
return entityList;
}
use of com.qcadoo.model.api.EntityList in project mes by qcadoo.
the class OperationWorkTimeServiceTest method shouldEstimateTotalOrderTimeWithAdditionalTime.
@Test
public void shouldEstimateTotalOrderTimeWithAdditionalTime() throws Exception {
// // given
EntityList operationComponents = mockEntityList(Arrays.asList(operComp1, operComp2, operComp3));
// when
operationWorkTime = operationWorkTimeService.estimateTotalWorkTime(operationComponents, operationRuns, false, true, false);
// // then
assertEquals(operationWorkTime.getLaborWorkTime(), new Integer(6930));
assertEquals(operationWorkTime.getMachineWorkTime(), new Integer(2730));
}
Aggregations