[481] | 1 | package schedframe; |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | import java.util.ArrayList; |
---|
| 5 | import java.util.Collection; |
---|
| 6 | import java.util.Collections; |
---|
| 7 | import java.util.Iterator; |
---|
| 8 | import java.util.List; |
---|
| 9 | import java.util.ListIterator; |
---|
| 10 | |
---|
[490] | 11 | import dcworms.schedframe.scheduling.ExecTask; |
---|
| 12 | import dcworms.schedframe.scheduling.Executable; |
---|
| 13 | |
---|
[481] | 14 | public class ExecutablesList implements List<ExecTask> { |
---|
| 15 | |
---|
| 16 | private List<ExecTask> executables; |
---|
[490] | 17 | |
---|
[481] | 18 | public ExecutablesList (){ |
---|
| 19 | executables = Collections.synchronizedList(new ArrayList<ExecTask>()); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | public List<Executable> getJobExecutables(String jobId){ |
---|
| 23 | List<Executable> list = new ArrayList<Executable>(); |
---|
| 24 | synchronized (executables) { |
---|
| 25 | for(int i = 0; i < executables.size(); i++){ |
---|
| 26 | Executable exec = (Executable)executables.get(i); |
---|
| 27 | |
---|
| 28 | if(exec.getJobId().equals(jobId)) |
---|
| 29 | list.add(exec); |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | return list; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | public List<Executable> getTaskExecutables(String jobId, String taskId){ |
---|
| 36 | |
---|
| 37 | List<Executable> list = new ArrayList<Executable>(); |
---|
| 38 | synchronized (executables) { |
---|
| 39 | for(int i = 0; i < executables.size(); i++){ |
---|
| 40 | Executable exec = (Executable)executables.get(i); |
---|
| 41 | |
---|
| 42 | if(exec.getJobId().equals(jobId) && exec.getId().equals(taskId)) |
---|
| 43 | list.add(exec); |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | return list; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | public Executable getTaskExecutable(Integer executableId){ |
---|
| 50 | synchronized (executables) { |
---|
| 51 | for (ExecTask task : executables) { |
---|
| 52 | Executable exec = (Executable)task; |
---|
| 53 | if (exec.getUniqueId() == executableId) { |
---|
| 54 | return exec; |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | return null; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | public boolean add(ExecTask arg0) { |
---|
| 63 | return executables.add(arg0); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | public void add(int arg0, ExecTask arg1) { |
---|
| 67 | executables.add(arg0, arg1); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | public boolean addAll(Collection<? extends ExecTask> arg0) { |
---|
| 71 | return executables.addAll(arg0); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | public boolean addAll(int arg0, Collection<? extends ExecTask> arg1) { |
---|
| 75 | return executables.addAll(arg0, arg1); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | public void clear() { |
---|
| 79 | executables.clear(); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | public boolean contains(Object arg0) { |
---|
| 83 | return executables.contains(arg0); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | public boolean containsAll(Collection<?> arg0) { |
---|
| 87 | return executables.containsAll(arg0); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | public ExecTask get(int arg0) { |
---|
| 91 | return executables.get(arg0); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | public int indexOf(Object arg0) { |
---|
| 95 | return indexOf(arg0); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | public boolean isEmpty() { |
---|
| 99 | return executables.isEmpty(); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | public Iterator<ExecTask> iterator() { |
---|
| 103 | return executables.iterator(); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | public int lastIndexOf(Object arg0) { |
---|
| 107 | return executables.lastIndexOf(arg0); |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | public ListIterator<ExecTask> listIterator() { |
---|
| 111 | return executables.listIterator(); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | public ListIterator<ExecTask> listIterator(int arg0) { |
---|
| 115 | return executables.listIterator(arg0); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | public boolean remove(Object arg0) { |
---|
| 119 | return executables.remove(arg0); |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | public ExecTask remove(int arg0) { |
---|
| 123 | return executables.remove(arg0); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | public boolean removeAll(Collection<?> arg0) { |
---|
| 127 | return executables.removeAll(arg0); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | public boolean retainAll(Collection<?> arg0) { |
---|
| 131 | return executables.retainAll(arg0); |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | public ExecTask set(int arg0, ExecTask arg1) { |
---|
| 135 | return executables.set(arg0, arg1); |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | public int size() { |
---|
| 139 | return executables.size(); |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | public List<ExecTask> subList(int arg0, int arg1) { |
---|
| 143 | return executables.subList(arg0, arg1); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | public Object[] toArray() { |
---|
| 147 | return executables.toArray(); |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | public <T> T[] toArray(T[] arg0) { |
---|
| 151 | return executables.toArray(arg0); |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | } |
---|
| 155 | |
---|