/** * Returns all bundle orders in this order for a given bundle * * @param bundle Bundle to search for * @return ArrayList containing all bundle orders for the given bundle */ public ArrayList<AbstractBundleOrder> getBundleOrders(Bundle bundle) { ArrayList<AbstractBundleOrder> result = new ArrayList<AbstractBundleOrder>(); for (Iterator<AbstractBundleOrder> bundleIterator = bundleOrders.values().iterator(); bundleIterator.hasNext(); ) { AbstractBundleOrder bundleOrder = (AbstractBundleOrder) bundleIterator.next(); if (bundleOrder.getBundle().equals(bundle)) { result.add(bundleOrder); } } return result; }
/** * Computes the maximal latest time range of all bundle orders in this order * * @return Maximal latest time slot */ public int getMaxLate() throws OrderException { int result = -1; for (Iterator<AbstractBundleOrder> bundleIterator = bundleOrders.values().iterator(); bundleIterator.hasNext(); ) { AbstractBundleOrder bundleOrder = (AbstractBundleOrder) bundleIterator.next(); if (bundleOrder.getLatest() > result) result = bundleOrder.getLatest(); } if (result == -1) { throw new OrderException( "No max late computed. No bundle found in this order with a size of " + this.getBundleOrders().size()); } return result; }
/** * Computes the minimal early time range of all bundle orders in this order * * @return Minimal early time slot */ public int getMinEarly() throws OrderException { int result = 10000; for (Iterator<AbstractBundleOrder> bundleIterator = bundleOrders.values().iterator(); bundleIterator.hasNext(); ) { AbstractBundleOrder bundleOrder = (AbstractBundleOrder) bundleIterator.next(); if (bundleOrder.getEarly() < result) { result = bundleOrder.getEarly(); } } if (result == 10000) { throw new OrderException("No min early computed. No bundle found in this order"); } return result; }
/** * Removes a bundle order from this order * * @param bundleOrder Bundle order to remove */ public void removeBundleOrder(AbstractBundleOrder bundleOrder) { bundleOrders.remove(bundleOrder.getId()); }
/** * Adds a bundle order to this order * * @param bundleOrder The bundle order to add */ public void addBundleOrder(AbstractBundleOrder bundleOrder) { bundleOrders.put(bundleOrder.getId(), bundleOrder); }