public static String locationFrom(final Entity document) { Entity locationFrom = document.getBelongsToField(DocumentFields.LOCATION_FROM); return locationFrom != null ? locationFrom.getStringField(LocationFields.NUMBER) + " - " + locationFrom.getStringField(LocationFields.NAME) : StringUtils.EMPTY; }
@Override public int compare(final Entity entity1, final Entity entity2) { return ComparisonChain .start() .compare(entity1.getDateField(CoverageProductLoggingFields.DATE), entity2.getDateField(CoverageProductLoggingFields.DATE)) .compare(entity2.getStringField(CoverageProductLoggingFields.EVENT_TYPE), entity1.getStringField(CoverageProductLoggingFields.EVENT_TYPE)).result(); } });
public static OrderState of(final Entity order) { if (order == null) { return null; } return parseString(order.getStringField(OrderFields.STATE)); }
private boolean transferNumberIsNotEmpty(final Entity transfer) { String number = transfer.getStringField(NUMBER); if (StringUtils.isEmpty(number)) { appendErrorToModelField(transfer, NUMBER, "materialFlow.validate.global.error.fillRequired"); return false; } return true; }
private void addProductsWithCheckedTechnologiesInfo(GenerationOrderResult result, Entity order) { List<Entity> products = ordersForSubproductsGenerationService.getProductNodesWithCheckedTechnologies(null, order); if (!products.isEmpty()) { products.stream() .map(node -> node.getBelongsToField(ProductStructureTreeNodeFields.PRODUCT).getStringField( ProductFields.NUMBER)).forEach(result::addProductWithoutAcceptedTechnology); } } }
private String buildDescriptionForReleaseDocument(Entity locationTo, Collection positions, String additionalInfo) { String description = buildDescription(positions); description = Strings.isNullOrEmpty(description) ? "" : description + "\n"; description += translationService.translate( "productFlowThruDivision.issue.documentGeneration.descriptionForReleaseDocument", LocaleContextHolder.getLocale(), locationTo.getStringField(LocationFields.NAME)); if (additionalInfo != null) { description += "\n" + additionalInfo; } return description; }
@Override public boolean checkIfInputProductsRequiredForTypeIsSelected(final DataDefinition entityDD, final Entity entity, final String fieldName, final String errorMessage) { String inputProductsRequiredForType = entity.getStringField(fieldName); if (inputProductsRequiredForType == null) { entity.addError(entityDD.getField(fieldName), errorMessage); return false; } return true; }
@Override public boolean canChangeDateWhenTransferToWarehouse() { Entity documentPositionParameters = parameterService.getParameter().getBelongsToField( ParameterFieldsMFR.DOCUMENT_POSITION_PARAMETERS); String changeDateWhenTransferToWarehouseType = documentPositionParameters.getStringField( ParameterFieldsMFR.CHANGE_DATE_WHEN_TRANSFER_TO_WAREHOUSE_TYPE); return !ChangeDateWhenTransferToWarehouseType.NEVER.getStringValue().equals(changeDateWhenTransferToWarehouseType); }
private void addPositionErrors(ViewDefinitionState view, Entity saved) { saved.getGlobalErrors().forEach(view::addMessage); if (!saved.getErrors().isEmpty()) { view.addMessage("materialFlow.document.fillResources.global.error.positionNotValid", ComponentState.MessageType.FAILURE, false, saved.getBelongsToField(PositionFields.PRODUCT).getStringField(ProductFields.NUMBER)); } }
public void updateProductsToIssues(final Set<Entity> warehouseIssues) { warehouseIssues.stream().forEach( wi -> fillProductsToIssue(wi.getId(), CollectionProducts.fromStringValue(wi.getStringField(WarehouseIssueFields.COLLECTION_PRODUCTS)), wi.getBelongsToField(WarehouseIssueFields.TECHNOLOGY_OPERATION_COMPONENT), wi.getBelongsToField(WarehouseIssueFields.DIVISION))); }
public boolean validateStockCorrection(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { Entity location = stockCorrection.getBelongsToField(LOCATION); if (location != null) { String locationType = location.getStringField(TYPE); if (!CONTROL_POINT.getStringValue().equals(locationType)) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationIsNotSimpleControlPoint"); return false; } } return true; }
public boolean checkIfLocationHasExternalNumber(final DataDefinition stockCorrectionDD, final Entity stockCorrection) { if (stockCorrection.getBelongsToField(LOCATION).getStringField("externalNumber") != null) { stockCorrection.addError(stockCorrectionDD.getField(LOCATION), "materialFlow.validate.global.error.locationHasExternalNumber"); return false; } return true; }
private boolean checkIfEachOrderHasNumberStartingWithMasterOrderNumber(final Entity masterOrder) { String newMasterOrderNumber = masterOrder.getStringField(MasterOrderFields.NUMBER); SearchCriterion criteria = not(like(OrderFields.NUMBER, newMasterOrderNumber + "%")); Collection<String> unsupportedOrderNumbers = masterOrderOrdersDataProvider.findBelongingOrderNumbers(masterOrder, criteria); if (unsupportedOrderNumbers.isEmpty()) { return true; } addUnsupportedOrdersError(masterOrder, MasterOrderFields.NUMBER, "masterOrders.order.number.alreadyExistsOrderWithWrongNumber", unsupportedOrderNumbers); return false; }
private void changeStorageLocationsGridEnabled(final ViewDefinitionState view) { GridComponent storageLocations = (GridComponent) view.getComponentByReference(StocktakingFields.STORAGE_LOCATIONS); FormComponent form = (FormComponent) view.getComponentByReference(L_FORM); Entity stocktaking = form.getEntity(); boolean enabled = StorageLocationMode.SELECTED.getStringValue().equals( stocktaking.getStringField(StocktakingFields.STORAGE_LOCATION_MODE)); storageLocations.setEnabled(enabled); }
@Override protected String addContent(Document document, Map<String, Object> model, Locale locale, PdfWriter writer) throws DocumentException, IOException { pdfHelper.addDocumentHeader(document, "", translationService.translate("orders.order.report.order", locale, orderEntity.getStringField(OrderFields.NUMBER)), "", new Date()); addHeaderTable(document, orderEntity, locale); addPlannedDateTable(document, orderEntity, locale); addProductQuantityTable(document, orderEntity, locale); addOwnTechnologyTable(document, orderEntity, locale); addTechnologyTable(document, orderEntity, locale); addMasterOrderTable(document, orderEntity, locale); return translationService.translate("orders.order.report.fileName", locale, orderEntity.getStringField(OrderFields.NUMBER)); }
private boolean checkNoProductsOnLocation(List<Entity> savedEntities,ViewDefinitionState view,AwesomeDynamicListComponent adl){ Entity location = ((FormComponent) view.getComponentByReference("form")).getEntity().getBelongsToField("locationFrom"); UpdateIssuesLocationsQuantityStatusHolder updateIssuesStatus = warehouseIssueService .tryUpdateIssuesLocationsQuantity(location, Optional.of(savedEntities).get()); if (!updateIssuesStatus.isUpdated()) { adl.addMessage("productFlowThruDivision.issue.state.accept.error.noProductsOnLocation", ComponentState.MessageType.FAILURE, updateIssuesStatus.getMessage(), location.getStringField(LocationFields.NUMBER)); return false; } return true; }
private void hideOrderFields(ViewDefinitionState view) { String productsSource = parameterService.getParameter().getStringField( ParameterFieldsPFTD.WAREHOUSE_ISSUE_PRODUCTS_SOURCE); if (productsSource != null) { WarehouseIssueProductsSource warehouseIssueProductsSource = WarehouseIssueProductsSource.parseString(productsSource); if (WarehouseIssueProductsSource.MANUAL.equals(warehouseIssueProductsSource)) { hideComponents(view, WarehouseIssueFields.ORDER, WarehouseIssueFields.ORDER_START_DATE, WarehouseIssueFields.ORDER_PRODUCTION_LINE_NUMBER, WarehouseIssueFields.COLLECTION_PRODUCTS); } } }
private void changeToInExecution(final Entity order) { Entity masterOrder = order.getBelongsToField(OrderFieldsMO.MASTER_ORDER); if(Objects.isNull(masterOrder)) { return; } String masterOrderStatus = masterOrder.getStringField(MasterOrderFields.STATE); if (MasterOrderState.NEW.getStringValue().equals(masterOrderStatus)) { masterOrder.setField(MasterOrderFields.STATE, MasterOrderState.IN_EXECUTION.getStringValue()); masterOrder = masterOrder.getDataDefinition().save(masterOrder); order.setField(OrderFieldsMO.MASTER_ORDER, masterOrder); } }
public void updateDescription(final ViewDefinitionState view, final ComponentState state, final String[] args) { if (parameterService.getParameter().getBooleanField(ParameterFieldsMO.COPY_DESCRIPTION)) { FormComponent form = (FormComponent) view.getComponentByReference("form"); Entity order = form.getEntity(); Entity masterOrder = order.getBelongsToField(OrderFieldsMO.MASTER_ORDER); if (masterOrder != null) { order.setField(OrderFields.DESCRIPTION, masterOrder.getStringField(MasterOrderFields.DESCRIPTION)); form.setEntity(order); } } } }
private Entity createCoverageProductLoggingForLocations(final Entity warehouse, final Date actualDate, final BigDecimal locationsQuantity) { Entity coverageProductLogging = orderSuppliesService.getCoverageProductLoggingDD().create(); coverageProductLogging.setField(CoverageProductLoggingFields.DATE, actualDate); coverageProductLogging.setField(CoverageProductLoggingFields.RESERVE_MISSING_QUANTITY, numberService.setScaleWithDefaultMathContext(locationsQuantity)); coverageProductLogging.setField(CoverageProductLoggingFields.EVENT_TYPE, CoverageProductLoggingEventType.WAREHOUSE_STATE.getStringValue()); coverageProductLogging.setField(CoverageProductLoggingFields.WAREHOUSE_NUMBER, warehouse.getStringField(LocationFields.NUMBER)); return coverageProductLogging; }