[104] | 1 | package schedframe.scheduling.plan.impl; |
---|
| 2 | |
---|
| 3 | import java.io.StringWriter; |
---|
| 4 | |
---|
| 5 | import org.exolab.castor.xml.MarshalException; |
---|
| 6 | import org.exolab.castor.xml.ValidationException; |
---|
| 7 | |
---|
| 8 | import schedframe.scheduling.plan.ScheduledTaskInterface; |
---|
| 9 | import schedframe.scheduling.plan.SchedulingPlanInterface; |
---|
| 10 | |
---|
| 11 | public class SchedulingPlan implements SchedulingPlanInterface<org.qcg.broker.schemas.schedulingplan.SchedulingPlan> { |
---|
| 12 | |
---|
| 13 | private static final long serialVersionUID = 2557774150841711876L; |
---|
| 14 | protected org.qcg.broker.schemas.schedulingplan.SchedulingPlan sp; |
---|
| 15 | |
---|
| 16 | public SchedulingPlan(){ |
---|
| 17 | sp = new org.qcg.broker.schemas.schedulingplan.SchedulingPlan(); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | public SchedulingPlan(org.qcg.broker.schemas.schedulingplan.SchedulingPlan value){ |
---|
| 21 | sp = value; |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | public org.qcg.broker.schemas.schedulingplan.SchedulingPlan getDescription() { |
---|
| 25 | return sp; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | public String getDocument() { |
---|
| 29 | StringWriter writer = new StringWriter(); |
---|
| 30 | try { |
---|
| 31 | sp.marshal(writer); |
---|
| 32 | } catch (MarshalException e) { |
---|
| 33 | e.printStackTrace(); |
---|
| 34 | } catch (ValidationException e) { |
---|
| 35 | e.printStackTrace(); |
---|
| 36 | } |
---|
| 37 | return writer.toString(); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | public <Task_> void addTask(ScheduledTaskInterface<Task_> task) |
---|
| 41 | throws IndexOutOfBoundsException { |
---|
| 42 | sp.addTask((org.qcg.broker.schemas.schedulingplan.Task) task.getDescription()); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | public <Task_> void addTask(int index, ScheduledTaskInterface<Task_> task) |
---|
| 46 | throws IndexOutOfBoundsException { |
---|
| 47 | sp.addTask(index, (org.qcg.broker.schemas.schedulingplan.Task) task.getDescription()); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | @SuppressWarnings("unchecked") |
---|
| 51 | public ScheduledTaskInterface<org.qcg.broker.schemas.schedulingplan.Task> getTask(int index) |
---|
| 52 | throws IndexOutOfBoundsException { |
---|
| 53 | return new ScheduledTask(sp.getTask(index)); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | @SuppressWarnings("unchecked") |
---|
| 57 | public ScheduledTaskInterface<org.qcg.broker.schemas.schedulingplan.Task>[] getTask() { |
---|
| 58 | org.qcg.broker.schemas.schedulingplan.Task tab[] = sp.getTask(); |
---|
| 59 | if(tab == null) return null; |
---|
| 60 | |
---|
| 61 | ScheduledTask ret[] = new ScheduledTask[tab.length]; |
---|
| 62 | for(int i = 0; i < tab.length; i++){ |
---|
| 63 | ret[i] = new ScheduledTask(tab[i]); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | return ret; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | public int getTaskCount() { |
---|
| 70 | return sp.getTaskCount(); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | public void removeAllTask() { |
---|
| 74 | sp.removeAllTask(); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | public <Task_> boolean removeTask(ScheduledTaskInterface<Task_> task) { |
---|
| 78 | return sp.removeTask((org.qcg.broker.schemas.schedulingplan.Task) task.getDescription()); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | @SuppressWarnings("unchecked") |
---|
| 82 | public ScheduledTaskInterface<org.qcg.broker.schemas.schedulingplan.Task> removeTaskAt(int index) { |
---|
| 83 | return new ScheduledTask(sp.removeTaskAt(index)); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | public <Task_> void setTask(int index, ScheduledTaskInterface<Task_> task) |
---|
| 87 | throws IndexOutOfBoundsException { |
---|
| 88 | sp.setTask(index, (org.qcg.broker.schemas.schedulingplan.Task) task.getDescription()); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | public <Task_> void setTask(ScheduledTaskInterface<Task_>[] taskArray) { |
---|
| 92 | if(taskArray == null) return; |
---|
| 93 | |
---|
| 94 | org.qcg.broker.schemas.schedulingplan.Task tab[] = new org.qcg.broker.schemas.schedulingplan.Task[taskArray.length]; |
---|
| 95 | for(int i = 0; i < taskArray.length; i++){ |
---|
| 96 | tab[i] = (org.qcg.broker.schemas.schedulingplan.Task)taskArray[i].getDescription(); |
---|
| 97 | } |
---|
| 98 | sp.setTask(tab); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | } |
---|