HashMap supplyAssetMap = (HashMap) supplyHash.get(gpTask); Collection issuedSupplyTasks = null; if(supplyAssetMap != null) { issuedSupplyTasks = (Collection) supplyAssetMap.get(consumed); }   if((issuedSupplyTasks != null) && (!issuedSupplyTasks.isEmpty())) { if(logger.isWarnEnabled()) { logger.warn("Supply task already issued on this day for " + consumed + " not re-issuing."); } continue;  }
  public List generateDemandTasks(long start, long duration, Collection relevantProjectSupplys) {    ArrayList demandTasks = new ArrayList();    // Make sure the file reader is initialized    initReader();    if (reader == null) {      return demandTasks;    }    HashMap subtaskMap = new HashMap();    String line = null;    try {      // Mark current position in file      reader.mark(maxLineLength);      // Reader lines until we exit our defined period (ignore entries earlier)      for (line = reader.readLine(); line != null; line=reader.readLine()) {        line = line.trim();        // skip empty lines        if (line.length() == 0)          continue;        StringTokenizer tok = new StringTokenizer(line, ",");        long timeStamp = (new Long(tok.nextToken())).longValue();        if (timeStamp < start) {          // Ignore entries prior to start          continue;        }        if (timeStamp >= start + duration) {          // Done.  Reset file marker to beginning of this line          reader.reset();          break;        }        // Extract The Org Name        String org = tok.nextToken();        // Extract the Item Id of the item being maintained        String maintainedItemId = tok.nextToken();        if (maintainedItemId.equalsIgnoreCase("null")) {          maintainedItemId = null;        }        // Extract the Type Id of the item being maintained        String maintainedTypeId = tok.nextToken();        // Extract the Nomenclature of the item being maintained        String maintainedNomen = tok.nextToken();        if (maintainedNomen.equalsIgnoreCase("null")) {          maintainedNomen = null;        }        // Extract the Id of the consumed item        String consumedItem = tok.nextToken();        // Extract the qty demanded        double qty = Double.parseDouble(tok.nextToken());        // Extract the location (lat, lon, name) for delivery        double lat = Double.parseDouble(tok.nextToken());        double lon = Double.parseDouble(tok.nextToken());        String geoLocName = tok.nextToken();        // Create an instance of the consumed item to determine supply type        Asset consumed = getPlanningFactory().createInstance(consumedItem);        SupplyClassPG supplyPG = (SupplyClassPG)consumed.searchForPropertyGroup(            org.cougaar.glm.ldm.asset.SupplyClassPG.class);        if (supplyPG == null) {	  if(logger.isErrorEnabled()) {            logger.error("Unable to retrieve SupplyClassPG for " + consumedItem);	  }          continue;        }        String type = supplyPG.getSupplyType();        if (!type.equals(dgPlugin.getSupplyType())) {          // This plugin/module does not handle this particular supply type          continue;        }        // Create an instance of the Maintained Item and find the associated        // GenerateProjections task        MaintainedItem item = new MaintainedItem(type, maintainedTypeId,            maintainedItemId, maintainedNomen, this.dgPlugin);        Task gpTask = getGenerateProjectionsTask(item, type);        if (gpTask == null) {	  if(logger.isErrorEnabled()) {            logger.error("Unable to find GenerateProjections task for item type id = '" +                       item.getTypeIdentification() + "' and type = '" + type + "'");	  }          continue;        }        // Create the geoloc for delivery        GeolocLocationImpl geoLoc = new GeolocLocationImpl(Latitude.newLatitude(lat),            Longitude.newLongitude(lon), geoLocName);        // Create the new demand task for the entry and add to list of new subtasks        Task demandTask = createNewDemandTask(gpTask, consumed, timeStamp,            timeStamp+duration, qty, geoLoc, org, type, item);        demandTasks.add(demandTask);        ArrayList subtasks = (ArrayList)subtaskMap.get(gpTask);        if (subtasks == null) {          subtasks = new ArrayList();          subtaskMap.put(gpTask, subtasks);        }        subtasks.add(demandTask);        // Mark the beginning of the next line before reading        reader.mark(maxLineLength);      }    }    catch (IOException ioe) {      if(logger.isErrorEnabled()) {        logger.error("Unable to parse demand input file: '" + line + "'");      }      ioe.printStackTrace();      return demandTasks;    }    // Go through each of the new demand tasks and publish as subtasks    // of the appropriate GenerateProjections task    Iterator gpTasks = subtaskMap.keySet().iterator();    while (gpTasks.hasNext()) {      Task gpTask = (Task)gpTasks.next();      Collection subtasks = (Collection)subtaskMap.get(gpTask);      addToAndPublishExpansion(gpTask, subtasks);    }    // Return list of created demand tasks    return demandTasks;  }