1 25 26 package net.killingar.forum.actions.task; 27 28 import it.unimi.dsi.fastutil.longs.LongArrayList; 29 import net.killingar.forum.internal.Task; 30 31 import java.sql.Timestamp ; 32 import java.util.ArrayList ; 33 import java.util.Iterator ; 34 import java.util.List ; 35 36 public class View extends ActionTaskSupport 37 { 38 40 long time = -1; 42 List myTasks = new ArrayList(); 43 List freeTasks = new ArrayList(); 44 List tasksInProgress = new ArrayList(); 45 46 public List getMyTasks() { return myTasks; } 47 public List getFreeTasks() { return freeTasks; } 48 public List getTasksInProgress() { return tasksInProgress; } 49 50 public void setTime(long inTime) { time = inTime; } 51 52 class TaskInfo extends Task 54 { 55 TaskInfo(Task inTask, boolean inUnread) 56 { 57 super(inTask); 58 unread = inUnread; 59 } 60 61 public boolean getUnread() { return unread; } 62 63 boolean unread; 64 } 65 66 class TaskInProgress extends TaskInfo 67 { 68 TaskInProgress(Task inTask, boolean inUnread, LongArrayList inVolunteers) 69 { 70 super(inTask, inUnread); 71 volunteers = inVolunteers; 72 } 73 74 LongArrayList volunteers; 75 76 public LongArrayList getVolunteers() { return volunteers; } 77 } 78 79 81 83 protected String doExecute() 85 { 86 try 87 { 88 Timestamp time = this.time != -1? new Timestamp (this.time): taskMgr.getTime(); 89 90 for (Iterator it = taskMgr.getTasks().iterator(); it.hasNext();) 91 { 92 Task i = (Task)it.next(); 93 94 LongArrayList volunteers = taskMgr.getVolunteers(i.getId()); 95 if (volunteers.size() == 0) 96 freeTasks.add(new TaskInfo(i, i.lastChanged.after(time))); 97 else if (volunteers.getLong(0) == manager.getUserID()) 98 myTasks.add(new TaskInfo(i, i.lastChanged.after(time))); 99 else 100 tasksInProgress.add(new TaskInProgress(i, i.lastChanged.after(time), volunteers)); 101 } 102 103 taskMgr.setRead(); 104 } 105 catch (Exception e) 106 { 107 e.printStackTrace(); 108 addErrorMessage("executing "+getClass().toString()+" action failed, exception thrown: "+e.toString()); 109 return ERROR; 110 } 111 112 return SUCCESS; 113 } 114 } 115 | Popular Tags |