private List<Entity> getDraftsOrdersFromDB() { return dataDefinitionService .get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER) .find() .add(SearchRestrictions.isNotNull(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)) .add(SearchRestrictions.isNotNull(OrderFields.TECHNOLOGY)) .add(SearchRestrictions.eq(OrderFields.STATE, OrderStateStringValues.PENDING)) .add(SearchRestrictions.eq(OrderFields.ACTIVE, true)).list().getEntities(); } }
private Entity getAssignmentToShift(final Entity shift, final Date date) { boolean shiftWorks = shiftsService.checkIfShiftWorkAtDate(date, shift); if (shiftWorks) { return dataDefinitionService .get(AssignmentToShiftConstants.PLUGIN_IDENTIFIER, AssignmentToShiftConstants.MODEL_ASSIGNMENT_TO_SHIFT) .find().add(SearchRestrictions.belongsTo(SHIFT, shift)).add(SearchRestrictions.le(START_DATE, date)) .addOrder(SearchOrders.desc(START_DATE)).setMaxResults(1).uniqueResult(); } else { return null; } }
public void showMachinePartsWithoutGivenProduct(final SearchCriteriaBuilder searchCriteriaBuilder, final FilterValueHolder filterValueHolder) { productCriteriaModifiers.showProductsWithoutGivenProduct(searchCriteriaBuilder, filterValueHolder); searchCriteriaBuilder.add(SearchRestrictions.eq(ProductFieldsCMP.MACHINE_PART, true)); }
private List<Entity> getCoverageProductLoggingCovereges(final Entity coverageProduct, final Date farthestCoverageDate) { return coverageProduct .getHasManyField(CoverageProductFields.COVERAGE_PRODUCT_LOGGINGS) .find() .add(SearchRestrictions.eq(CoverageProductLoggingFields.EVENT_TYPE, CoverageProductLoggingEventType.DELIVERY.getStringValue())) .add(SearchRestrictions.gt(CoverageProductLoggingFields.DATE, farthestCoverageDate)) .addOrder(SearchOrders.asc(CoverageProductLoggingFields.DATE)).list().getEntities(); }
private List<Entity> getOrdersFromDB(final Date coverageToDate) { return dataDefinitionService .get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER) .find() .add(SearchRestrictions.le(OrderFields.START_DATE, coverageToDate)) .add(SearchRestrictions.isNotNull(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)) .add(SearchRestrictions.isNotNull(OrderFields.TECHNOLOGY)) .add(SearchRestrictions.or(SearchRestrictions.eq(OrderFields.STATE, OrderStateStringValues.PENDING), SearchRestrictions.eq(OrderFields.STATE, OrderStateStringValues.ACCEPTED), SearchRestrictions.eq(OrderFields.STATE, OrderStateStringValues.INTERRUPTED))) .add(SearchRestrictions.eq(OrderFields.ACTIVE, true)).list().getEntities(); }
private List<Entity> getCoverageProductLoggingDemands(final Entity coverageProduct, final Date farthestCoverageDate) { return coverageProduct .getHasManyField(CoverageProductFields.COVERAGE_PRODUCT_LOGGINGS) .find() .add(SearchRestrictions.or(SearchRestrictions.eq(CoverageProductLoggingFields.EVENT_TYPE, CoverageProductLoggingEventType.ORDER_INPUT.getStringValue()), SearchRestrictions.eq(CoverageProductLoggingFields.EVENT_TYPE, CoverageProductLoggingEventType.OPERATION_INPUT.getStringValue()))) .add(SearchRestrictions.gt(CoverageProductLoggingFields.DATE, farthestCoverageDate)) .addOrder(SearchOrders.asc(CoverageProductLoggingFields.DATE)).list().getEntities(); }
private Optional<Entity> findStorageLocationForProduct(final Entity product, final Entity location) { SearchCriteriaBuilder scb = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_STORAGE_LOCATION).find(); scb.add(SearchRestrictions.belongsTo(StorageLocationFields.PRODUCT, product)); scb.add(SearchRestrictions.belongsTo(StorageLocationFields.LOCATION, location)); return Optional.ofNullable(scb.setMaxResults(1).uniqueResult()); }
private List<Entity> getOrdersFromDB() { return dataDefinitionService .get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER) .find() .add(SearchRestrictions.isNotNull(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)) .add(SearchRestrictions.isNotNull(OrderFields.TECHNOLOGY)) .add(SearchRestrictions.or(SearchRestrictions.eq(OrderFields.STATE, OrderStateStringValues.PENDING), SearchRestrictions.eq(OrderFields.STATE, OrderStateStringValues.ACCEPTED), SearchRestrictions.eq(OrderFields.STATE, OrderStateStringValues.IN_PROGRESS), SearchRestrictions.eq(OrderFields.STATE, OrderStateStringValues.INTERRUPTED))) .add(SearchRestrictions.eq(OrderFields.ACTIVE, true)).list().getEntities(); }
public List<Entity> findRegistryEntries(Entity order, Entity product) { return dataDefinitionService .get(OrderSuppliesConstants.PLUGIN_IDENTIFIER, OrderSuppliesConstants.MODEL_COVERAGE_REGISTER).find() .add(SearchRestrictions.belongsTo(CoverageRegisterFields.ORDER, order)) .add(SearchRestrictions.belongsTo(CoverageRegisterFields.PRODUCT, product)).list().getEntities(); }
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 filterByCrew(final SearchCriteriaBuilder scb, final FilterValueHolder filterValueHolder) { if (filterValueHolder.has(CREW_FILTER_VALUE)) { Long crewId = filterValueHolder.getLong(CREW_FILTER_VALUE); scb.add(SearchRestrictions.eq(StaffFields.CREW + ".id", crewId)); } }
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 checkIfProductIsProduced(final Entity order, final Entity product) { return (order .getHasManyField(OrderFieldsBPC.PRODUCTION_COUNTING_QUANTITIES) .find() .add(SearchRestrictions.belongsTo(ProductionCountingQuantityFields.PRODUCT, product)) .add(SearchRestrictions.eq(ProductionCountingQuantityFields.ROLE, ProductionCountingQuantityRole.PRODUCED.getStringValue())).list().getTotalNumberOfEntities() > 0); }
public void showResourcesForProductInWarehouse(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { if (!filterValue.has(L_PRODUCT) || !filterValue.has(L_LOCATION_FROM)) { return; } Long productId = filterValue.getLong(L_PRODUCT); Long locationId = filterValue.getLong(L_LOCATION_FROM); scb.createAlias(ResourceFields.PRODUCT, L_PRODUCT, JoinType.INNER) .createAlias(ResourceFields.LOCATION, L_LOCATION_FROM, JoinType.INNER) .add(SearchRestrictions.eq(L_PRODUCT + ".id", productId)) .add(SearchRestrictions.eq(L_LOCATION_FROM + ".id", locationId)); }
public void showWorkstationsForProductionLine(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { if (filterValue.has(TechnologyOperationComponentFields.PRODUCTION_LINE)) { Long productionLineId = filterValue.getLong(TechnologyOperationComponentFields.PRODUCTION_LINE); scb.createAlias(TechnologyOperationComponentFields.PRODUCTION_LINE, TechnologyOperationComponentFields.PRODUCTION_LINE, JoinType.INNER).add( SearchRestrictions.eq(TechnologyOperationComponentFields.PRODUCTION_LINE + ".id", productionLineId)); } } }
public Entity getDefaultAction() { return dataDefinitionService.get(CmmsMachinePartsConstants.PLUGIN_IDENTIFIER, CmmsMachinePartsConstants.MODEL_ACTION) .find().add(SearchRestrictions.eq(ActionFields.IS_DEFAULT, true)).setMaxResults(1).uniqueResult(); } }
public List<Entity> findRegistryEntries(Entity order) { return dataDefinitionService .get(OrderSuppliesConstants.PLUGIN_IDENTIFIER, OrderSuppliesConstants.MODEL_COVERAGE_REGISTER).find() .add(SearchRestrictions.belongsTo(CoverageRegisterFields.ORDER, order)).list().getEntities(); }
@Override public List<Entity> getShiftsWorkingAtDate(final Date date) { return dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_SHIFT).find() .add(SearchRestrictions.eq(getDayOfWeekName(date) + WORKING_LITERAL, true)).list().getEntities(); }
private List<Entity> getCoverageProductsForOrder(final Entity order) { SearchCriteriaBuilder scb = dataDefinitionService.get(OrderSuppliesConstants.PLUGIN_IDENTIFIER, OrderSuppliesConstants.MODEL_COVERAGE_PRODUCT).find(); scb.add(SearchRestrictions.belongsTo(CoverageProductFields.ORDER, OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER, order.getId())); return scb.list().getEntities(); }
public void showAllPallets(final ViewDefinitionState view, final ComponentState state, final String[] args) { GridComponent palletGrid = (GridComponent) view.getComponentByReference("grid"); palletGrid.setCustomRestriction(searchBuilder -> searchBuilder.add(SearchRestrictions.ge(PalletStorageStateDtoFields.TOTAL_QUANTITY,BigDecimal.ZERO))); CheckBoxComponent isShiftFilter = (CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_SHIFT_FILTER); CheckBoxComponent isFreeFilter = (CheckBoxComponent) view.getComponentByReference(PalletStorageStateDtoFields.IS_FREE_FILTER); isShiftFilter.setChecked(false); isFreeFilter.setChecked(false); isShiftFilter.requestComponentUpdateState(); isFreeFilter.requestComponentUpdateState(); }