Collection inventories, Integer startCTime, Integer endCTime, String timeAggregation) throws Exception
Collection inventories) throws Exception
    calculateDerivedSchedules(Vector derivedMetricFormula,                              Collection inventories, Integer startCTime,                              Integer endCTime, String timeAggregation)                              throws Exception  {    boolean filterTime = ((startCTime != null) && (endCTime != null));    // Convert metric strings in derived metric formula to InventoryMetric    // objects    Vector convertedDerivedMetricFormula = new Vector();    for (int i = 0; i < derivedMetricFormula.size(); i++)    {      String itemString = (String)derivedMetricFormula.elementAt(i);      InventoryMetric metric = InventoryMetric.fromString(itemString);      if (metric == null)      {        convertedDerivedMetricFormula.addElement(itemString);      }      else      {        convertedDerivedMetricFormula.addElement(metric);      }    }    Collection dataAtomCollection = new LinkedList();    for (Iterator i= inventories.iterator(); i.hasNext();)    {      InventoryWrapper inv = (InventoryWrapper)i.next();      inv.computeSimulatedProjectionSchedules();      Stack stack = new Stack();      for (int index = 0; index < convertedDerivedMetricFormula.size();index++)      {        Object item = convertedDerivedMetricFormula.elementAt(index);        if (item instanceof InventoryMetric)        {          stack.push(getInventorySchedule((InventoryMetric)item, inv));        }        else if (isUnaryOperator((String)item))        {          //if (item.equals(TRIM_TO_MOCK_INVENTORY))          //{          //  Object operand = (String)stack.pop();          //  stack.push(trimToMockInventory(operand));          //}        }        else if (isBinaryOperator((String)item))        {          Object operand2 = stack.pop();          Object operand1 = stack.pop();          stack.push(applyBinaryOperation(operand1, operand2, (String)item));        }        else        {          stack.push(item);        }      }      Schedule finalSchedule = (Schedule)stack.pop();      // simplify      finalSchedule = tryToCombineLikeQuantityElements(finalSchedule);      Collection dataAtoms =        createInventoryScheduleDataAtoms((Inventory)inv.getInventory(),                                         finalSchedule);      if (filterTime)      {        // filter based on time        dataAtoms = filterTimePeriod(dataAtoms, startCTime.intValue(),                                     endCTime.intValue());        if (timeAggregation != null)        {          dataAtoms =            aggregateScheduleOverTime(dataAtoms, startCTime.intValue(),                                      endCTime.intValue(), timeAggregation);        }      }      dataAtomCollection.addAll(dataAtoms);    }    return dataAtomCollection;  }