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.AllocationInterface; |
---|
9 | import schedframe.scheduling.plan.ScheduledTaskInterface; |
---|
10 | import schedframe.scheduling.plan.ScheduledTimeInterface; |
---|
11 | import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; |
---|
12 | |
---|
13 | public class ScheduledTask implements ScheduledTaskInterface<org.qcg.broker.schemas.schedulingplan.Task> { |
---|
14 | |
---|
15 | private static final long serialVersionUID = -9006532413203045991L; |
---|
16 | protected org.qcg.broker.schemas.schedulingplan.Task t; |
---|
17 | |
---|
18 | public ScheduledTask(){ |
---|
19 | t = new org.qcg.broker.schemas.schedulingplan.Task(); |
---|
20 | } |
---|
21 | |
---|
22 | public ScheduledTask(org.qcg.broker.schemas.schedulingplan.Task value){ |
---|
23 | t = value; |
---|
24 | } |
---|
25 | |
---|
26 | public org.qcg.broker.schemas.schedulingplan.Task getDescription() { |
---|
27 | return t; |
---|
28 | } |
---|
29 | |
---|
30 | public String getDocument() { |
---|
31 | StringWriter writer = new StringWriter(); |
---|
32 | try { |
---|
33 | t.marshal(writer); |
---|
34 | } catch (MarshalException e) { |
---|
35 | e.printStackTrace(); |
---|
36 | } catch (ValidationException e) { |
---|
37 | e.printStackTrace(); |
---|
38 | } |
---|
39 | return writer.toString(); |
---|
40 | } |
---|
41 | |
---|
42 | public <Allocation_> void addAllocation( |
---|
43 | AllocationInterface<Allocation_> allocation) |
---|
44 | throws IndexOutOfBoundsException { |
---|
45 | t.addAllocation((org.qcg.broker.schemas.schedulingplan.Allocation) allocation.getDescription()); |
---|
46 | } |
---|
47 | |
---|
48 | public <Allocation_> void addAllocation(int index, AllocationInterface<Allocation_> allocation) |
---|
49 | throws IndexOutOfBoundsException { |
---|
50 | t.addAllocation(index, (org.qcg.broker.schemas.schedulingplan.Allocation) allocation.getDescription()); |
---|
51 | } |
---|
52 | |
---|
53 | public void deleteTopology() { |
---|
54 | t.deleteTopology(); |
---|
55 | } |
---|
56 | |
---|
57 | @SuppressWarnings("unchecked") |
---|
58 | public AllocationInterface<org.qcg.broker.schemas.schedulingplan.Allocation> getAllocation(int index) |
---|
59 | throws IndexOutOfBoundsException { |
---|
60 | return new schedframe.scheduling.plan.impl.Allocation(t.getAllocation(index)); |
---|
61 | } |
---|
62 | |
---|
63 | @SuppressWarnings("unchecked") |
---|
64 | public AllocationInterface<org.qcg.broker.schemas.schedulingplan.Allocation>[] getAllocation() { |
---|
65 | org.qcg.broker.schemas.schedulingplan.Allocation tab[] = t.getAllocation(); |
---|
66 | if(tab == null) return null; |
---|
67 | |
---|
68 | schedframe.scheduling.plan.impl.Allocation ret[] = new schedframe.scheduling.plan.impl.Allocation[tab.length]; |
---|
69 | for(int i = 0; i < tab.length; i++){ |
---|
70 | ret[i] = new schedframe.scheduling.plan.impl.Allocation(tab[i]); |
---|
71 | } |
---|
72 | return ret; |
---|
73 | } |
---|
74 | |
---|
75 | public int getAllocationCount() { |
---|
76 | return t.getAllocationCount(); |
---|
77 | } |
---|
78 | |
---|
79 | public String getJobId() { |
---|
80 | return t.getJobId(); |
---|
81 | } |
---|
82 | |
---|
83 | public AllocationStatus getStatus() { |
---|
84 | return t.getStatus(); |
---|
85 | } |
---|
86 | |
---|
87 | public String getStatusDescription(){ |
---|
88 | return t.getStatusDescription(); |
---|
89 | } |
---|
90 | |
---|
91 | public String getTaskId() { |
---|
92 | return t.getTaskId(); |
---|
93 | } |
---|
94 | |
---|
95 | public int getTopology() { |
---|
96 | return t.getTopology(); |
---|
97 | } |
---|
98 | |
---|
99 | public boolean hasTopology() { |
---|
100 | return t.hasTopology(); |
---|
101 | } |
---|
102 | |
---|
103 | public void removeAllAllocation() { |
---|
104 | t.removeAllAllocation(); |
---|
105 | } |
---|
106 | |
---|
107 | public <Allocation_> boolean removeAllocation( |
---|
108 | AllocationInterface<Allocation_> allocation) { |
---|
109 | return t.removeAllocation((org.qcg.broker.schemas.schedulingplan.Allocation) allocation.getDescription()); |
---|
110 | } |
---|
111 | |
---|
112 | @SuppressWarnings("unchecked") |
---|
113 | public AllocationInterface<org.qcg.broker.schemas.schedulingplan.Allocation> removeAllocationAt(int index) { |
---|
114 | return new schedframe.scheduling.plan.impl.Allocation(t.removeAllocationAt(index)); |
---|
115 | } |
---|
116 | |
---|
117 | public <Allocation_> void setAllocation(int index, |
---|
118 | AllocationInterface<Allocation_> allocation) |
---|
119 | throws IndexOutOfBoundsException { |
---|
120 | t.setAllocation(index, (org.qcg.broker.schemas.schedulingplan.Allocation)allocation.getDescription()); |
---|
121 | } |
---|
122 | |
---|
123 | public <Allocation_> void setAllocation( |
---|
124 | AllocationInterface<Allocation_>[] allocationArray) { |
---|
125 | if(allocationArray == null) return; |
---|
126 | |
---|
127 | org.qcg.broker.schemas.schedulingplan.Allocation tab[] = new org.qcg.broker.schemas.schedulingplan.Allocation[allocationArray.length]; |
---|
128 | for(int i = 0; i < allocationArray.length; i++){ |
---|
129 | tab[i] = (org.qcg.broker.schemas.schedulingplan.Allocation)allocationArray[i].getDescription(); |
---|
130 | } |
---|
131 | t.setAllocation(tab); |
---|
132 | } |
---|
133 | |
---|
134 | public void setJobId(String jobId) { |
---|
135 | t.setJobId(jobId); |
---|
136 | } |
---|
137 | |
---|
138 | public void setStatus(AllocationStatus status) { |
---|
139 | t.setStatus(status); |
---|
140 | } |
---|
141 | |
---|
142 | public void setStatusDescription(String statusDescription){ |
---|
143 | t.setStatusDescription(statusDescription); |
---|
144 | } |
---|
145 | |
---|
146 | public void setTaskId(String taskId) { |
---|
147 | t.setTaskId(taskId); |
---|
148 | } |
---|
149 | |
---|
150 | public void setTopology(int topology) { |
---|
151 | t.setTopology(topology); |
---|
152 | } |
---|
153 | |
---|
154 | @SuppressWarnings("unchecked") |
---|
155 | public ScheduledTimeInterface<org.qcg.broker.schemas.schedulingplan.ScheduledTime> getScheduledTime() { |
---|
156 | org.qcg.broker.schemas.schedulingplan.ScheduledTime time = t.getScheduledTime(); |
---|
157 | if(time == null) |
---|
158 | return null; |
---|
159 | |
---|
160 | ScheduledTime st = new ScheduledTime(time); |
---|
161 | return st; |
---|
162 | } |
---|
163 | |
---|
164 | public <ScheduledTime_> void setScheduledTime( |
---|
165 | ScheduledTimeInterface<ScheduledTime_> scheduledTime) { |
---|
166 | t.setScheduledTime((org.qcg.broker.schemas.schedulingplan.ScheduledTime) scheduledTime.getDescription()); |
---|
167 | } |
---|
168 | |
---|
169 | } |
---|