Task task = getTaskFromAssignment(multi[j].getTask().getKey()); if (task != null) tasks.add (task);
org.cougaar.lib.vishnu.server.Task [] multiTasks = multi[j].getTasks();  for (int k = 0; k < multiTasks.length; k++) { Task task = getTaskFromAssignment(multiTasks[k].getKey()); if (task != null) tasks.add (task); }
  protected void runDirectly () {	//	Scheduler sched = new Scheduler ();	internalBuffer.append ("</root>");	if (myExtraExtraOutput)	  System.out.println(getName () + ".runDirectly - sending stuff " + internalBuffer.toString());	int unhandledTasks = myTaskUIDtoObject.size ();	// Call setupInternal before adding the data	sched.setupInternal (new String(internalBuffer), false);	// These are things created by the scheduler during setup that	// are needed for direct object writing.	TimeOps timeOps = sched.getTimeOps();	SchedulingData data = sched.getSchedulingData();	if (myExtraOutput || true) 	  System.out.println(getName () + ".runDirectly - adding " + 						 vishnuTasks.size() + " tasks, " +						 vishnuResources.size () + " resources to scheduler data.");	  	for (int i = 0; i < vishnuTasks.size (); i++) {	  Object vishnuObject = vishnuTasks.get(i);	  data.addTask ((org.cougaar.lib.vishnu.server.Task) vishnuObject);	}	for (int i = 0; i < vishnuResources.size (); i++) {	  Object vishnuObject = vishnuResources.get(i);	  data.addResource ((Resource) vishnuObject);	}	if (vishnuTasks.size () != data.getTasks().length)	  System.out.println(getName () + ".runDirectly - ERROR - data says only " + 						 data.getTasks().length + " tasks.");		if (vishnuResources.size () != data.getResources().length)	  System.out.println(getName () + ".runDirectly - ERROR - data says only " + 						 data.getResources().length + " resources.");		// Call scheduleInternal after adding all the data	sched.scheduleInternal();	// This shows how to extract the assignments after scheduling.	// When sched.assignmentsMultitask() is true, the assignments	// will actually be MultitaskAssignment objects instead.    if (! sched.assignmentsMultitask()) {      org.cougaar.lib.vishnu.server.Task[] tasks = data.getTasks();      for (int i = 0; i < tasks.length; i++) {        Assignment assign = tasks[i].getAssignment();		parseAssignment (assign.getTask().getKey(), assign.getResource().getKey(),						 timeOps.timeToDate (assign.getTaskStartTime()),						 timeOps.timeToDate (assign.getTaskEndTime()),						 timeOps.timeToDate (assign.getStartTime()), // setup						 timeOps.timeToDate (assign.getEndTime()));   // wrapup      }    } else {      Resource[] resources = data.getResources();      for (int i = 0; i < resources.length; i++) {        MultitaskAssignment[] multi = resources[i].getMultitaskAssignments();		if (multi.length > 0) {		  Vector tasks = new Vector ();		  MultitaskAssignment assign = multi[0];		  if (myExtraOutput) 			System.out.println (getName () + " for resource " + assign.getResource().getKey() +								" got " + multi.length + " tasks assigned.");		  		  for (int j = 0; j < multi.length; j++) {			Task task = getTaskFromAssignment(multi[j].getTask().getKey());			if (task != null)			  tasks.add (task);		  }		  handleMultiAssignment (tasks, 								 getAssignedAsset   (assign.getResource().getKey()),								 timeOps.timeToDate (assign.getTaskStartTime()),								 timeOps.timeToDate (assign.getTaskEndTime()),								 timeOps.timeToDate (assign.getStartTime()), // setup								 timeOps.timeToDate (assign.getEndTime()));   // wrapup		}	  }    }	clearInternalBuffer ();	if (myExtraOutput || true)	  System.out.println (getName () + ".runDirectly - created successful plan elements for " +						  (unhandledTasks-myTaskUIDtoObject.size ()) + " tasks.");	handleImpossibleTasks (myTaskUIDtoObject.values ());	myTaskUIDtoObject.clear ();  }