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); } }
private Optional<Entity> saveCoverage(Entity mcfo) { mcfo = mcfo.getDataDefinition().save(mcfo); if (!mcfo.isValid()) { mcfo = null; } return Optional.fromNullable(mcfo); }
private Entity saveAndValidate(final Entity entity) { if (entity == null) { return null; } Entity saved = entity.getDataDefinition().save(entity); if (!saved.isValid()) { throw new RuntimeException(String.format("Error on save state entity: %s", saved.getErrors())); } return saved; }
private void reduceReservationFor(Entity reservation, BigDecimal forQuantity) { BigDecimal newReservationQuantity = reservation.getDecimalField(ReservationFields.QUANTITY).subtract(forQuantity); if (newReservationQuantity.compareTo(BigDecimal.ZERO) > 0) { reservation.setField(ReservationFields.QUANTITY, newReservationQuantity); reservation.getDataDefinition().save(reservation); } else { reservation.setField(ReservationFields.QUANTITY, BigDecimal.ZERO); reservation.getDataDefinition().save(reservation); } }
public void tryToDispose(Entity palletNumber) { if (palletNumber != null) { DataDefinition palletNumberDataDefinition = palletNumber.getDataDefinition(); Assert.isTrue(palletNumberDataDefinition.getPluginIdentifier().equals(BasicConstants.PLUGIN_IDENTIFIER)); Assert.isTrue(palletNumberDataDefinition.getName().equals(BasicConstants.MODEL_PALLET_NUMBER)); if (canDisposePalletNumber(palletNumber)) { palletNumber.setField(PalletNumberFields.ISSUE_DATE_TIME, new Date()); palletNumberDataDefinition.save(palletNumber); } } }
@Transactional public void regenerateForOrder(Entity order) { registerService.removeEntriesForOrder(order, true); registerEvents.createRegistryEntriesForOrder(order, false); order.getDataDefinition().save(order); }
private void setAddressesCanBeDeleted(final Entity company) { List<Entity> addresses = company.getHasManyField(CompanyFields.ADDRESSES); addresses.forEach(address -> { address.setField(AddressFields.CAN_BE_DELETED, true); address = address.getDataDefinition().save(address); }); }
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); } }
private void generateNodeNumber(final Entity product, final Entity parent, final boolean doSave) { String entityType = product.getStringField(ENTITY_TYPE); if (PRODUCTS_FAMILY.getStringValue().equals(entityType)) { generateNodeNumberForProductsFamily(product, parent); } else if (PARTICULAR_PRODUCT.getStringValue().equals(entityType)) { generateNodeNumberForParticularProduct(product, parent); } if (doSave) { product.getDataDefinition().save(product); } }
@Transactional(propagation = Propagation.REQUIRES_NEW) private void tryGeneratePPS(final Entity order) { Date startDate = findStartDate(order); generateEmptyPpsForOrder(order); order.setField("generatePPS", true); order.setField(OrderFields.START_DATE, startDate); order.setField(OrderFields.FINISH_DATE, new DateTime(order.getDateField(OrderFields.START_DATE)).plusDays(1).toDate()); Entity storedOrder = order.getDataDefinition().save(order); if (!storedOrder.isValid()) { throw new EntityRuntimeException(storedOrder); } }
private void changeVisibility(ViewDefinitionState view, boolean visibility) { GridComponent grid = (GridComponent) view.getComponentByReference("grid"); for (Entity entity : grid.getEntities()) { entity.setField("checked", visibility); entity.getDataDefinition().save(entity); } }
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); } }
private void addColumnForRequests(final Map<String, String> columnAttributes) { Entity column = columnExtensionService.addColumn(SupplyNegotiationsConstants.PLUGIN_IDENTIFIER, SupplyNegotiationsConstants.MODEL_COLUMN_FOR_REQUESTS, columnAttributes); Entity parameter = parameterService.getParameter(); column.setField("parameter", parameter); column.getDataDefinition().save(column); addParameterColumnForRequests(column); }
public void onSelectedEventChange(ViewDefinitionState view) { GridComponent grid = (GridComponent) view.getComponentByReference(L_GRID); FormComponent form = (FormComponent) view.getComponentByReference(L_FORM); DataDefinition maintenanceEventDD = dataDefinitionService.get(CmmsMachinePartsConstants.PLUGIN_IDENTIFIER, CmmsMachinePartsConstants.MODEL_MAINTENANCE_EVENT); for (Entity eventEntity : grid.getSelectedEntities()) { eventEntity.setField(MaintenanceEventFields.MAINTENANCE_EVENT_CONTEXT, form.getEntityId()); maintenanceEventDD.save(eventEntity); } }
private Entity copyTechnology(final Entity technologyPrototype, final Entity order) { String number = technologyServiceO.generateNumberForTechnologyInOrder(order, technologyPrototype); Entity copyOfTechnology = technologyServiceO.getTechnologyDD().copy(technologyPrototype.getId()).get(0); copyOfTechnology.setField(TechnologyFields.NUMBER, number); copyOfTechnology.setField(TechnologyFields.TECHNOLOGY_PROTOTYPE, technologyPrototype); copyOfTechnology.setField(TechnologyFields.TECHNOLOGY_TYPE, getTechnologyType(order)); copyOfTechnology = copyOfTechnology.getDataDefinition().save(copyOfTechnology); return copyOfTechnology; }
public void completeWithoutIssue(final ViewDefinitionState view, final ComponentState state, final String[] args) { FormComponent form = (FormComponent) view.getComponentByReference(L_FORM); Entity anomaly = form.getEntity(); if (anomaly.getId() == null) { return; } anomaly.setField(AnomalyFields.STATE, AnomalyFields.State.COMPLETED); anomaly.setField(AnomalyFields.ISSUED, false); anomaly.getDataDefinition().save(anomaly); state.performEvent(view, "reset", new String[0]); } }
private boolean deleteBasicProductionCounting(final Entity productionCountingQuantity) { boolean isDeleted = true; Entity basicProductionCounting = productionCountingQuantity .getBelongsToField(ProductionCountingQuantityFields.BASIC_PRODUCTION_COUNTING); if ((basicProductionCounting != null) && checkIfItIsLastProductionCountingQuantity(basicProductionCounting)) { productionCountingQuantity.setField(ProductionCountingQuantityFields.BASIC_PRODUCTION_COUNTING, null); productionCountingQuantity.getDataDefinition().save(productionCountingQuantity); isDeleted = basicProductionCounting.getDataDefinition().delete(basicProductionCounting.getId()).isSuccessfull(); } return isDeleted; }
@Override public void updateProducedQuantity(final Entity order) { Entity basicProductionCounting = getBasicProductionCountingDD().find() .add(SearchRestrictions.belongsTo(BasicProductionCountingFields.ORDER, order)).add(SearchRestrictions .belongsTo(BasicProductionCountingFields.PRODUCT, order.getBelongsToField(OrderFields.PRODUCT))) .setMaxResults(1).uniqueResult(); if (Objects.nonNull(basicProductionCounting)) { basicProductionCounting.setField(BasicProductionCountingFields.PRODUCED_QUANTITY, order.getDecimalField(OrderFields.DONE_QUANTITY)); basicProductionCounting.getDataDefinition().save(basicProductionCounting); } }
@Override public Entity createBasicProductionCounting(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)); basicProductionCounting = basicProductionCounting.getDataDefinition().save(basicProductionCounting); return basicProductionCounting; }