package edu.sc.seis.gee.task;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import edu.sc.seis.gee.CommonAccess;

/**
 * TaskInvoker.java
 *
 *
 * Created: Tue May 28 11:22:33 2002
 *
 * @author <a href="mailto:">Srinivasa Telukutla</a>
 * @version
 */

public class TaskInvoker implements Task{
    public TaskInvoker (){
    
    }

    public void invoke() throws Exception{
    
    if(!tasksInvoked) {
        
        Set connectionSet = configParams.keySet();
        Iterator iter = connectionSet.iterator();
        CommonAccess commonAccess = CommonAccess.getCommonAccess();
        int i = 0;
        while(iter.hasNext()) {
            
        String taskName = (String) iter.next();
        if(taskName.startsWith("loadtask")) {
            String taskId = (String)configParams.get(taskName);
            TaskAction taskAction = commonAccess.getTaskAction(taskId);
            //Task task = (Task)taskAction.getTask();
            //task.invoke();
            taskAction.actionPerformed(new java.awt.event.ActionEvent(this, i, taskAction.getName()));
            i++;
        }
        }
        
    }
    }

    public void destroy(){}

    public void configure(java.util.Map params) {

    this.configParams = params;
    }

    private Map configParams;
    private boolean tasksInvoked = false;
    
}// TaskInvoker
