public void addFieldsForParameter(final DataDefinition parameterDD, final Entity parameter) { parameter.setField(ParameterFieldsAGFO.TRACKING_RECORD_FOR_ORDER_TREATMENT, TrackingRecordForOrderTreatment.DURING_PRODUCTION.getStringValue()); parameter.setField(ParameterFieldsAGFO.BATCH_NUMBER_REQUIRED_PRODUCTS, false); }
public void onSave(final DataDefinition timeUsageFilterDD, final Entity timeUsageFilter) { String selected = timeUsageFilter.getStringField(TimeUsageReportFilterFields.WORKERS_SELECTION); if ("01all".equals(selected)) { timeUsageFilter.setField(TimeUsageReportFilterFields.WORKERS, null); } } }
private Entity prepareBasicProductionCounting(final Entity order, final Entity product) { Entity basicProductionCounting = getBasicProductionCountingDD().create(); basicProductionCounting.setField(BasicProductionCountingFields.ORDER, order); basicProductionCounting.setField(BasicProductionCountingFields.PRODUCT, product); basicProductionCounting.setField(BasicProductionCountingFields.PRODUCED_QUANTITY, numberService.setScaleWithDefaultMathContext(BigDecimal.ZERO)); basicProductionCounting.setField(BasicProductionCountingFields.USED_QUANTITY, numberService.setScaleWithDefaultMathContext(BigDecimal.ZERO)); return basicProductionCounting; }
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 clearHiddenFields(final Entity event) { FieldsForType fieldsForType = fieldsForTypeFactory.createFieldsForType(PlannedEventType.from(event)); List<String> fieldsToClear = fieldsForType.getHiddenFields(); for (String fieldName : fieldsToClear) { if (fieldName.equals(PlannedEventFields.REQUIRES_SHUTDOWN) || fieldName.equals(PlannedEventFields.PLANNED_SEPARATELY)) { event.setField(fieldName, false); } else { event.setField(fieldName, null); } } }
@Override public Entity createPalletNumberHelper(final Integer quantity, final boolean temporary, final List<Entity> palletNumbers) { Entity palletNumberHelper = getPalletNumberHelperDD().create(); palletNumberHelper.setField(PalletNumberHelperFields.QUANTITY, quantity); palletNumberHelper.setField(PalletNumberHelperFields.TEMPORARY, temporary); palletNumberHelper.setField(PalletNumberHelperFields.PALLET_NUMBERS, palletNumbers); palletNumberHelper = palletNumberHelper.getDataDefinition().save(palletNumberHelper); return palletNumberHelper; }
@Override public Entity createProductionCountingOperationRun(final Entity order, final Entity technologyOperationComponent, final BigDecimal runs) { Entity productionCountingOperationRun = getProductionCountingOperationRunDD().create(); productionCountingOperationRun.setField(ProductionCountingOperationRunFields.ORDER, order); productionCountingOperationRun.setField(ProductionCountingOperationRunFields.TECHNOLOGY_OPERATION_COMPONENT, technologyOperationComponent); productionCountingOperationRun.setField(ProductionCountingOperationRunFields.RUNS, numberService.setScaleWithDefaultMathContext(runs)); productionCountingOperationRun = productionCountingOperationRun.getDataDefinition().save(productionCountingOperationRun); return productionCountingOperationRun; }
private Entity copyOrderedProductToDelivered(final Entity delivery, final boolean copyQuantityAndPrice) { // ALBR deliveredProduct has a validation so we have to delete all // entities before save HM field in delivery delivery.setField(DeliveryFields.DELIVERED_PRODUCTS, Lists.newArrayList()); delivery.getDataDefinition().save(delivery); delivery.setField( DeliveryFields.DELIVERED_PRODUCTS, createDeliveredProducts(delivery, delivery.getHasManyField(DeliveryFields.ORDERED_PRODUCTS), copyQuantityAndPrice)); return delivery; // delivery.getDataDefinition().save(delivery); }
private void updateCosts(final BigDecimal newQuantity, final Entity orderMaterialCosts, final BigDecimal oldQuantity) { BigDecimal factor = newQuantity.divide(oldQuantity, numberService.getMathContext()); BigDecimal nominalCost = orderMaterialCosts.getDecimalField(TechnologyInstOperProductInCompFields.NOMINAL_COST); BigDecimal lastPurchaseCost = orderMaterialCosts .getDecimalField(TechnologyInstOperProductInCompFields.LAST_PURCHASE_COST); BigDecimal averageCost = orderMaterialCosts.getDecimalField(TechnologyInstOperProductInCompFields.AVERAGE_COST); orderMaterialCosts.setField(TechnologyInstOperProductInCompFields.COST_FOR_NUMBER, numberService.setScaleWithDefaultMathContext(newQuantity)); orderMaterialCosts.setField(TechnologyInstOperProductInCompFields.NOMINAL_COST, multiply(nominalCost, factor)); orderMaterialCosts.setField(TechnologyInstOperProductInCompFields.LAST_PURCHASE_COST, multiply(lastPurchaseCost, factor)); orderMaterialCosts.setField(TechnologyInstOperProductInCompFields.AVERAGE_COST, multiply(averageCost, factor)); }
private void setDeliveryAddressDefaultValue(final Entity delivery) { String deliveryAddress = delivery.getStringField(DELIVERY_ADDRESS); if (deliveryAddress == null) { delivery.setField(DELIVERY_ADDRESS, deliveriesService.getDeliveryAddressDefaultValue()); } }
private void clearStorageLocations(Entity delivery) { EntityList deliveredProducts = delivery.getHasManyField(DeliveryFields.DELIVERED_PRODUCTS); if (deliveredProducts != null) { for (Entity deliveryProduct : deliveredProducts) { deliveryProduct.setField(DeliveredProductFields.STORAGE_LOCATION, null); deliveryProduct.getDataDefinition().save(deliveryProduct); } } } }
public void updateRequestForQuotationProductCatalogNumber(final DataDefinition requestForQuotationProductDD, final Entity requestForQuotationProduct) { Entity requestForQuotation = requestForQuotationProduct.getBelongsToField(REQUEST_FOR_QUOTATION); Entity supplier = requestForQuotation.getBelongsToField(SUPPLIER); Entity product = requestForQuotationProduct.getBelongsToField(PRODUCT); Entity productCatalogNumber = productCatalogNumbersService.getProductCatalogNumber(product, supplier); if (productCatalogNumber != null) { requestForQuotationProduct.setField(PRODUCT_CATALOG_NUMBER, productCatalogNumber); } }
public void generateFactoryStructure(final ViewDefinitionState view) { FormComponent form = (FormComponent) view.getComponentByReference("form"); Entity maintenanceEvent = form.getEntity(); EntityTree factoryStructure = factoryStructureGenerationService.generateFactoryStructureForEntity(maintenanceEvent, "maintenanceEvent"); maintenanceEvent.setField(MaintenanceEventFields.FACTORY_STRUCTURE, factoryStructure); generatedTree = factoryStructure; form.setEntity(maintenanceEvent); }
public void setDefaultValueForTechnologyBatchRequiredField(final DataDefinition dataDefinition, final Entity entity) { if (entity.getId() != null) { return; } if (entity.getField("technologyBatchRequired") != null) { return; } Entity parameter = parameterService.getParameter(); entity.setField("technologyBatchRequired", parameter.getBooleanField("batchNumberRequiredProducts")); } }
public void saveCosts(final ViewDefinitionState viewDefinitionState, final ComponentState component, final String[] args) { FormComponent orderForm = (FormComponent) viewDefinitionState.getComponentByReference("order"); Entity order = orderForm.getEntity(); Entity orderEntity = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get( order.getId()); orderEntity.setField(OrderFieldsCNFM.DIRECT_ADDITIONAL_COST, order.getDecimalField(OrderFieldsCNFM.DIRECT_ADDITIONAL_COST)); orderEntity.setField(OrderFieldsCNFM.DIRECT_ADDITIONAL_COST_DESCRIPTION, order.getStringField(OrderFieldsCNFM.DIRECT_ADDITIONAL_COST_DESCRIPTION)); orderEntity.getDataDefinition().save(orderEntity); }
private void addColumnForOrders(final Map<String, String> columnAttributes) { Entity column = columnExtensionService.addColumn(DeliveriesConstants.PLUGIN_IDENTIFIER, DeliveriesConstants.MODEL_COLUMN_FOR_ORDERS, columnAttributes); Entity parameter = parameterService.getParameter(); column.setField("parameter", parameter); column.getDataDefinition().save(column); addColumnForParameterOrders(column); }
@Override public Entity calculateTotalCost(final Entity entity) { entity.setField(CostCalculationFields.DATE, new Date()); // FIXME MAKU beware of side effects - order of computations matter! calculateOperationsAndProductsCosts(entity); final BigDecimal productionCosts = calculateProductionCost(entity); calculateMarginsAndOverheads(entity, productionCosts); final BigDecimal effectiveQuantity = getEffectiveQuantity(entity); calculateTotalCosts(entity, productionCosts, effectiveQuantity); return entity.getDataDefinition().save(entity); }
public void turnOffSoundNotifications(final ViewDefinitionState viewDefinitionState, final ComponentState triggerState, final String args[]) { GridComponent grid = (GridComponent) viewDefinitionState.getComponentByReference("grid"); List<Entity> selectedEntities = grid.getSelectedEntities(); selectedEntities.forEach(entity -> { entity = entity.getDataDefinition().getMasterModelEntity(entity.getId()); entity.setField(MaintenanceEventFields.SOUND_NOTIFICATIONS, false); entity.getDataDefinition().save(entity); }); viewDefinitionState.addMessage("cmmsMachineParts.plannedEventsList.turnedOffSoundNotifications", ComponentState.MessageType.SUCCESS); }
private void fillBasicProductionCounting(final Entity productionCountingQuantity) { if (productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.BASIC_PRODUCTION_COUNTING) == null) { Entity order = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.ORDER); Entity product = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.PRODUCT); String typeOfMaterial = productionCountingQuantity.getStringField(ProductionCountingQuantityFields.TYPE_OF_MATERIAL); String role = productionCountingQuantity.getStringField(ProductionCountingQuantityFields.ROLE); if (checkIfShouldFillBasicProductionCounting(order, product, typeOfMaterial, role)) { productionCountingQuantity.setField(ProductionCountingQuantityFields.BASIC_PRODUCTION_COUNTING, fillBasicProductionCounting(order, product)); } } }