public Set<Long> findIdsOfEffectiveProgressForDay(Entity pps, boolean corrected) { Set<Long> pfdIds = Sets.newHashSet(); if (corrected) { pfdIds = pps.getHasManyField(ProductionPerShiftFields.PROGRES_FOR_DAYS).stream() .filter(pfd -> pfd.getBooleanField(ProgressForDayFields.CORRECTED)).map(pfdf -> pfdf.getId()) .collect(Collectors.toSet()); } else { pfdIds = pps.getHasManyField(ProductionPerShiftFields.PROGRES_FOR_DAYS).stream() .filter(pfd -> !pfd.getBooleanField(ProgressForDayFields.CORRECTED) == corrected).map(pfdf -> pfdf.getId()) .collect(Collectors.toSet()); } return pfdIds; }
private Entity findForOrder(Entity parentOrder, Entity coverageProduct) { return coverageProduct .getHasManyField(CoverageProductFields.COVERAGE_PRODUCT_LOGGINGS) .stream() .filter(e -> Objects.nonNull(e.getBelongsToField(CoverageProductLoggingFields.ORDER))) .filter(entity -> entity.getBelongsToField(CoverageProductLoggingFields.ORDER).getId() .equals(parentOrder.getId())).findFirst().get(); }
private void checkDeliveredProductsSynchronizationStatus(StateChangeContext stateChangeContext) { final Set<String> notSynchronizedOrderedProducts = stateChangeContext.getOwner() .getHasManyField(DeliveryFields.DELIVERED_PRODUCTS).stream() .map(productsHolder -> productsHolder.getBelongsToField(DeliveredProductFields.PRODUCT)) .filter(product -> isBlank(product.getStringField(ProductFields.EXTERNAL_NUMBER))) .map(product -> product.getStringField(ProductFields.NUMBER)).collect(Collectors.toSet()); if(!notSynchronizedOrderedProducts.isEmpty()){ stateChangeContext.addValidationError("deliveries.deliveredProducts.notSynchronized", false, String.join(", ", notSynchronizedOrderedProducts)); } }
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)); } } }
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)); } } }
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)); } } }
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)); } } }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filter) { 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("locationId", locationIds)); } } }
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.in(LOCATION_ID, locationIds)); } } }
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)); } } }
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<Long> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .map(Entity::getId).collect(Collectors.toSet()); scb.add(SearchRestrictions.in("location.id", locationIds)); } } }
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<Long> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .map(Entity::getId).collect(Collectors.toSet()); scb.add(SearchRestrictions.in("location.id", locationIds)); } } }
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<Long> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .map(Entity::getId).collect(Collectors.toSet()); scb.add(SearchRestrictions.in("location.id", locationIds)); } } }
public void selectProductionLine(final SearchCriteriaBuilder searchCriteriaBuilder, final FilterValueHolder filterValueHolder) { if (filterValueHolder.has(MaintenanceEventFields.DIVISION)) { Long divisionId = filterValueHolder.getLong(MaintenanceEventFields.DIVISION); Entity division = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_DIVISION).get( divisionId); List<Long> productionLinesIds = division.getHasManyField(DivisionFieldsPL.PRODUCTION_LINES).stream() .map(Entity::getId).collect(Collectors.toList()); if (productionLinesIds.isEmpty()) { return; } searchCriteriaBuilder.add(SearchRestrictions.in("id", productionLinesIds)); } }
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))); } } }
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))); } } }
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))); } } }
private boolean deletePreviousReservations(List<Entity> orderedOrDeliveredProducts) { int countReservations = 0; for (Entity p : orderedOrDeliveredProducts) { EntityList reservations = p.getHasManyField(DeliveredProductFields.RESERVATIONS); countReservations += reservations.size(); reservations.stream().forEach(reservation -> { reservation.getDataDefinition().delete(reservation.getId()); }); } return countReservations > 0; }
public void showEntriesForTechnology(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { if (filterValue.has(TECHNOLOGY_PARAMETER)) { Entity technology = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY).get(filterValue.getLong(TECHNOLOGY_PARAMETER)); scb.createAlias(OperCompTimeCalculationsFields.TECHNOLOGY_OPERATION_COMPONENT, "opr", JoinType.LEFT); scb.add(SearchRestrictions.in("opr.id", technology.getHasManyField( TechnologyFields.OPERATION_COMPONENTS).stream().map(e -> e.getId()).collect(Collectors.toList()))); scb.add(SearchRestrictions.isNull(OperCompTimeCalculationsFields.ORDER_TIME_CALCULATION)); } else { scb.add(SearchRestrictions.idEq(0l)); } } }
private void setWarehouseCriteriaModifier(final ViewDefinitionState view, Entity helper) { LookupComponent warehouseLookup = (LookupComponent) view.getComponentByReference("locationTo"); Entity placeOfIssue = helper.getBelongsToField("placeOfIssue"); OptionalLong locationTo = helper.getHasManyField("corrections").stream() .mapToLong(correction -> correction.getBelongsToField(ProductToIssueCorrectionFields.LOCATION).getId()).findAny(); FilterValueHolder filter = warehouseLookup.getFilterValue(); filter.put("locationFrom", placeOfIssue.getId()); if (locationTo.isPresent()) { filter.put("locationTo", locationTo.getAsLong()); } warehouseLookup.setFilterValue(filter); }