private boolean checkReasonNeeded(final Entity order, final String dateFieldName, final String reasonTypeFieldName, final String messageTranslationKey) { if (order.getField(dateFieldName) != null && order.getHasManyField(reasonTypeFieldName).isEmpty()) { order.addError(order.getDataDefinition().getField(reasonTypeFieldName), messageTranslationKey); return false; } return true; }
public boolean onDelete(final DataDefinition generatorContextDD, final Entity generatorContext) { if(!generatorContext.getDataDefinition().get(generatorContext.getId()).getHasManyField("technologies").isEmpty()){ generatorContext.addGlobalError("technologiesGenerator.generate.deleteContext.error", false); return false; } return true; } }
public void createTechOperCompTimeCalculations(final DataDefinition dd, final Entity technologyOperationComponent) { DataDefinition techOperCompTimeCalculationDD = dataDefinitionService.get(TimeNormsConstants.PLUGIN_IDENTIFIER, TimeNormsConstants.MODEL_TECH_OPER_COMP_TIME_CALCULATION); Entity techOperCompTimeCalculation = techOperCompTimeCalculationDD.create(); techOperCompTimeCalculation = techOperCompTimeCalculationDD.save(techOperCompTimeCalculation); technologyOperationComponent.setField(TechnologyOperationComponentFieldsTNFO.TECH_OPER_COMP_TIME_CALCULATION, techOperCompTimeCalculation); }
private void fillOrderFields(Entity warehouseIssue) { Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get( warehouseIssue.getBelongsToField(WarehouseIssueFields.ORDER).getId()); if (warehouseIssue.getDateField(WarehouseIssueFields.ORDER_START_DATE) == null) { warehouseIssue.setField(WarehouseIssueFields.ORDER_START_DATE, order.getDateField(OrderFields.START_DATE)); } if (warehouseIssue.getStringField(WarehouseIssueFields.ORDER_PRODUCTION_LINE_NUMBER) == null) { Entity orderProductionLine = order.getBelongsToField(OrderFields.PRODUCTION_LINE); warehouseIssue.setField(WarehouseIssueFields.ORDER_PRODUCTION_LINE_NUMBER, orderProductionLine.getStringField(ProductionLineFields.NUMBER)); } }
private Entity createAverageWithDataFromOrder(final Entity order, final DataDefinition avgLaborCostCalcForOrderDD) { Entity avgLaborCostCalcForOrder = avgLaborCostCalcForOrderDD.create(); avgLaborCostCalcForOrder.setField(ORDER, order); avgLaborCostCalcForOrder.setField(START_DATE, order.getField(OrderFields.START_DATE)); avgLaborCostCalcForOrder.setField(FINISH_DATE, order.getField(OrderFields.FINISH_DATE)); avgLaborCostCalcForOrder.setField(PRODUCTION_LINE, order.getBelongsToField(OrderFields.PRODUCTION_LINE)); avgLaborCostCalcForOrder.setField(BASED_ON, "01assignment"); return avgLaborCostCalcForOrder.getDataDefinition().save(avgLaborCostCalcForOrder); }
private void createOperationProductInComponent(final Entity technologyOperationComponent, final Entity product, final BigDecimal quantity, final String itemNumberInTheExplodedView) { Entity operationProductInComponent = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT).create(); operationProductInComponent.setField(OperationProductInComponentFields.OPERATION_COMPONENT, technologyOperationComponent); operationProductInComponent.setField(OperationProductInComponentFields.PRODUCT, product); operationProductInComponent.setField(OperationProductInComponentFields.QUANTITY, numberService.setScaleWithDefaultMathContext(quantity)); operationProductInComponent.setField(OperationProductInComponentFields.ITEM_NUMBER_IN_THE_EXPLODED_VIEW, itemNumberInTheExplodedView); operationProductInComponent.getDataDefinition().save(operationProductInComponent); }
private String getAddressType(final Entity address) { Long addressId = address.getId(); if (addressId == null) { return address.getStringField(AddressFields.ADDRESS_TYPE); } else { return address.getDataDefinition().get(addressId).getStringField(AddressFields.ADDRESS_TYPE); } }
private void clearSet(final DataDefinition dataDefinition, final Entity opoc, final Entity toc) { Boolean set = (Boolean) opoc.getField(OperationProductOutComponentFields.SET); if (set == null || (set && toc.getBelongsToField(TechnologyOperationComponentFields.PARENT) != null)) { opoc.setField(OperationProductOutComponentFields.SET, false); dataDefinition.save(opoc); } }
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 void deleteMaterialAvailability(final Entity order) { EntityList orderMaterialAvailability = order.getHasManyField(OrderFieldsPFTD.MATERIAL_AVAILABILITY); if (!orderMaterialAvailability.isEmpty()) { DataDefinition materialAvailabilityDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MATERIAL_AVAILABILITY); for (Entity materialAvailability : orderMaterialAvailability) { materialAvailabilityDD.delete(materialAvailability.getId()); } } }
public boolean onDelete(final DataDefinition operationalTaskDD, final Entity operationalTask) { boolean isDeleted = true; Entity techOperCompOperationalTask = operationalTask .getBelongsToField(OperationalTaskFieldsOTFO.TECH_OPER_COMP_OPERATIONAL_TASK); if (techOperCompOperationalTask != null) { isDeleted = techOperCompOperationalTask.getDataDefinition().delete(techOperCompOperationalTask.getId()) .isSuccessfull(); } return isDeleted; }
private Entity createMaterialAvailabilityEntity(final DataDefinition orderMaterialAvailabilityDD, final Entity product, final Entity order, final BigDecimal value, final Entity location) { Entity materialAvailability = orderMaterialAvailabilityDD.create(); materialAvailability.setField(MaterialAvailabilityFields.ORDER, order); materialAvailability.setField(MaterialAvailabilityFields.PRODUCT, product); materialAvailability.setField(MaterialAvailabilityFields.UNIT, product.getField(ProductFields.UNIT)); materialAvailability.setField(MaterialAvailabilityFields.REQUIRED_QUANTITY, numberService.setScaleWithDefaultMathContext(value, REQUIRED_QUANTITY_SCALE)); materialAvailability.setField(MaterialAvailabilityFields.LOCATION, location); return materialAvailability; }
@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; }
private void saveMaterialAvailability(List<Entity> materialsAvailability) { DataDefinition orderMaterialAvailabilityDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MATERIAL_AVAILABILITY); for (Entity materialAvailability : materialsAvailability) { orderMaterialAvailabilityDD.save(materialAvailability); } }
public void saveRegistryEntries(List<Entity> entries) { for (Entity entry : entries) { entry.getDataDefinition().save(entry); } }
public boolean onDelete(final DataDefinition dataDefinition, final Entity division) { if (division.getHasManyField("operations").isEmpty() && division.getHasManyField("technologyOperationComponents").isEmpty()) { return true; } division.addGlobalError("basic.division.onDelete.error"); return false; }
private void addErrorMessages(final DataDefinition assignmentToShiftDD, final Entity assignmentToShift) { assignmentToShift.addError(assignmentToShiftDD.getField(AssignmentToShiftFields.START_DATE), L_ALREADY_EXISTS); assignmentToShift.addError(assignmentToShiftDD.getField(AssignmentToShiftFields.SHIFT), L_ALREADY_EXISTS); assignmentToShift.addError(assignmentToShiftDD.getField(AssignmentToShiftFields.FACTORY), L_ALREADY_EXISTS); assignmentToShift.addError(assignmentToShiftDD.getField(AssignmentToShiftFields.CREW), L_ALREADY_EXISTS); }
@Override public String apply(final Entity from) { return from.getDataDefinition().getName(); } };
private boolean checkEffectiveDeviationNeeded(final Entity order, final String dateFieldName, final String reasonTypeFieldName, final String messageTranslationKey, final String differenceAsString) { if (order.getField(dateFieldName) != null && order.getHasManyField(reasonTypeFieldName).isEmpty()) { order.addError(order.getDataDefinition().getField(reasonTypeFieldName), messageTranslationKey, differenceAsString); return false; } return true; }
public boolean onDelete(final DataDefinition technologyOperationComponentDD, final Entity technologyOperationComponent) { boolean isDeleted = true; Entity techOperCompTimeCalculation = technologyOperationComponent .getBelongsToField(TechnologyOperationComponentFieldsTNFO.TECH_OPER_COMP_TIME_CALCULATION); if (techOperCompTimeCalculation != null) { isDeleted = techOperCompTimeCalculation.getDataDefinition().delete(techOperCompTimeCalculation.getId()) .isSuccessfull(); } return isDeleted; }