public void delete() { for (int i = supplierOrderLineItems.size(); i > 0; i--) { SupplierOrderLineItem aSupplierOrderLineItem = supplierOrderLineItems.get(i - 1); aSupplierOrderLineItem.delete(); } Supplier placeholderSupplier = supplier; this.supplier = null; placeholderSupplier.removeOrderToSupplier(this); }
public boolean addSupplierOrderLineItem(SupplierOrderLineItem aSupplierOrderLineItem) { boolean wasAdded = false; if (supplierOrderLineItems.contains(aSupplierOrderLineItem)) { return false; } OrderToSupplier existingOrderToSupplier = aSupplierOrderLineItem.getOrderToSupplier(); boolean isNewOrderToSupplier = existingOrderToSupplier != null && !this.equals(existingOrderToSupplier); if (isNewOrderToSupplier) { aSupplierOrderLineItem.setOrderToSupplier(this); } else { supplierOrderLineItems.add(aSupplierOrderLineItem); } wasAdded = true; return wasAdded; }
public boolean removeSupplierOrderLineItem(SupplierOrderLineItem aSupplierOrderLineItem) { boolean wasRemoved = false; // Unable to remove aSupplierOrderLineItem, as it must always have a orderToSupplier if (!this.equals(aSupplierOrderLineItem.getOrderToSupplier())) { supplierOrderLineItems.remove(aSupplierOrderLineItem); wasRemoved = true; } return wasRemoved; }