public boolean isDefined() { for (int i = 0; i < taskQueue.size(); i++) { IMonitorableTask task = (IMonitorableTask) taskQueue.get(i); if (!task.isDefined()) return false; } return true; }
public void run() throws Exception { System.out.println("lanzando procesos encolados..."); Iterator taskIterator = taskQueue.iterator(); while (taskIterator.hasNext() && (!canceled)) { currentTask = (IMonitorableTask) taskIterator.next(); System.out.println("proceso " + currentTask.toString()); currentTask.run(); } System.out.println("Se finalizo la cola de procesos"); }
public int getFinishStep() { int lastStep = 0; if (isDefined()) { for (int i = 0; i < taskQueue.size(); i++) { IMonitorableTask task = (IMonitorableTask) taskQueue.get(i); lastStep += task.getFinishStep(); } } else { lastStep += taskQueue.size(); } return lastStep; }
public String getNote() { if (currentTask != null) { return currentTask.getNote(); } else { return ""; } }
public String getStatusMessage() { if (currentTask != null) { return currentTask.getStatusMessage(); } else { return "Waiting for new tasks..."; } }
public int getCurrentStep() { int currentStep = 0; for (int i = 0; i < taskQueue.size(); i++) { IMonitorableTask task = (IMonitorableTask) taskQueue.get(i); if (task == currentTask) { if (isDefined()) { currentStep += currentTask.getCurrentStep(); } else { currentStep = i; } break; } else { if (isDefined()) currentStep += currentTask.getFinishStep(); } } return currentStep++; }
public boolean isFinished() { if (currentTask != null) { return currentTask.isFinished(); } return false; }
public void cancel() { if (currentTask != null) { currentTask.cancel(); } canceled = true; }