public void onUpdate(@Observes EntityUpdateEvent event) { if (!isValidEvent(event)) { return; } ShipmentInOutLine shipmentInOutLine = (ShipmentInOutLine) event.getTargetInstance(); if (shipmentInOutLine.getProduct() == null && (shipmentInOutLine.getMovementQuantity().doubleValue() != 0)) { throw new OBException(OBMessageUtils.messageBD("ProductNullAndMovementQtyGreaterZero")); } }
private void checkShipmentOrderRelation(ShipmentInOutLine shipmentInOutLine) { ConnectionProvider conn = new DalConnectionProvider(false); String language = OBContext.getOBContext().getLanguage().getLanguage(); OBCriteria<ShipmentInOutLine> criteria = OBDal.getInstance().createCriteria(ShipmentInOutLine.class); criteria.add( Restrictions.eq( ShipmentInOutLine.PROPERTY_SHIPMENTRECEIPT, shipmentInOutLine.getShipmentReceipt())); if (criteria.count() == 1) { ShipmentInOut shipmentInOut = OBDal.getInstance() .get(ShipmentInOut.class, shipmentInOutLine.getShipmentReceipt().getId()); if (shipmentInOut != null) { shipmentInOut.setSalesOrder(null); OBDal.getInstance().save(shipmentInOut); OBDal.getInstance().flush(); } } }