1
2
3
4
5
6
7
8 package org.astrogrid.workflow.beans.v1.execution;
9
10
11
12
13
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import java.util.ArrayList;
19 import java.util.Date;
20 import java.util.Enumeration;
21 import org.astrogrid.applications.beans.v1.cea.castor.MessageType;
22 import org.astrogrid.applications.beans.v1.cea.castor.types.ExecutionPhase;
23 import org.exolab.castor.xml.MarshalException;
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
26 import org.exolab.castor.xml.ValidationException;
27 import org.xml.sax.ContentHandler;
28
29 /***
30 * summary record for a single execution of a job
31 *
32 * @version $Revision: 1.6 $ $Date: 2007/01/04 16:26:08 $
33 */
34 public class WorkflowSummaryType extends org.astrogrid.common.bean.BaseBean
35 implements java.io.Serializable
36 {
37
38
39
40
41
42
43 /***
44 * time execution started
45 */
46 private java.util.Date _startTime;
47
48 /***
49 * time execution finished
50 */
51 private java.util.Date _finishTime;
52
53 /***
54 * current execution status
55 */
56 private org.astrogrid.applications.beans.v1.cea.castor.types.ExecutionPhase _status = org.astrogrid.applications.beans.v1.cea.castor.types.ExecutionPhase.valueOf("PENDING");
57
58 /***
59 * Field _jobId
60 */
61 private org.astrogrid.workflow.beans.v1.execution.JobURN _jobId;
62
63 /***
64 * A string 'buffer' for holding further information, keyed by
65 * attribute - so execution record becomes a map.
66 */
67 private java.util.ArrayList _extensionList;
68
69 /***
70 * Field _messageList
71 */
72 private java.util.ArrayList _messageList;
73
74 /***
75 * Field _workflowName
76 */
77 private java.lang.String _workflowName;
78
79 /***
80 * Field _description
81 */
82 private java.lang.String _description;
83
84
85
86
87
88
89 public WorkflowSummaryType() {
90 super();
91 setStatus(org.astrogrid.applications.beans.v1.cea.castor.types.ExecutionPhase.valueOf("PENDING"));
92 _extensionList = new ArrayList();
93 _messageList = new ArrayList();
94 }
95
96
97
98
99
100
101 /***
102 * Method addExtension
103 *
104 * @param vExtension
105 */
106 public void addExtension(org.astrogrid.workflow.beans.v1.execution.Extension vExtension)
107 throws java.lang.IndexOutOfBoundsException
108 {
109 _extensionList.add(vExtension);
110 }
111
112 /***
113 * Method addExtension
114 *
115 * @param index
116 * @param vExtension
117 */
118 public void addExtension(int index, org.astrogrid.workflow.beans.v1.execution.Extension vExtension)
119 throws java.lang.IndexOutOfBoundsException
120 {
121 _extensionList.add(index, vExtension);
122 }
123
124 /***
125 * Method addMessage
126 *
127 * @param vMessage
128 */
129 public void addMessage(org.astrogrid.applications.beans.v1.cea.castor.MessageType vMessage)
130 throws java.lang.IndexOutOfBoundsException
131 {
132 _messageList.add(vMessage);
133 }
134
135 /***
136 * Method addMessage
137 *
138 * @param index
139 * @param vMessage
140 */
141 public void addMessage(int index, org.astrogrid.applications.beans.v1.cea.castor.MessageType vMessage)
142 throws java.lang.IndexOutOfBoundsException
143 {
144 _messageList.add(index, vMessage);
145 }
146
147 /***
148 * Method clearExtension
149 */
150 public void clearExtension()
151 {
152 _extensionList.clear();
153 }
154
155 /***
156 * Method clearMessage
157 */
158 public void clearMessage()
159 {
160 _messageList.clear();
161 }
162
163 /***
164 * Method enumerateExtension
165 */
166 public java.util.Enumeration enumerateExtension()
167 {
168 return new org.exolab.castor.util.IteratorEnumeration(_extensionList.iterator());
169 }
170
171 /***
172 * Method enumerateMessage
173 */
174 public java.util.Enumeration enumerateMessage()
175 {
176 return new org.exolab.castor.util.IteratorEnumeration(_messageList.iterator());
177 }
178
179 /***
180 * Note: hashCode() has not been overriden
181 *
182 * @param obj
183 */
184 public boolean equals(java.lang.Object obj)
185 {
186 if ( this == obj )
187 return true;
188
189 if (super.equals(obj)==false)
190 return false;
191
192 if (obj instanceof WorkflowSummaryType) {
193
194 WorkflowSummaryType temp = (WorkflowSummaryType)obj;
195 if (this._startTime != null) {
196 if (temp._startTime == null) return false;
197 else if (!(this._startTime.equals(temp._startTime)))
198 return false;
199 }
200 else if (temp._startTime != null)
201 return false;
202 if (this._finishTime != null) {
203 if (temp._finishTime == null) return false;
204 else if (!(this._finishTime.equals(temp._finishTime)))
205 return false;
206 }
207 else if (temp._finishTime != null)
208 return false;
209 if (this._status != null) {
210 if (temp._status == null) return false;
211 else if (!(this._status.equals(temp._status)))
212 return false;
213 }
214 else if (temp._status != null)
215 return false;
216 if (this._jobId != null) {
217 if (temp._jobId == null) return false;
218 else if (!(this._jobId.equals(temp._jobId)))
219 return false;
220 }
221 else if (temp._jobId != null)
222 return false;
223 if (this._extensionList != null) {
224 if (temp._extensionList == null) return false;
225 else if (!(this._extensionList.equals(temp._extensionList)))
226 return false;
227 }
228 else if (temp._extensionList != null)
229 return false;
230 if (this._messageList != null) {
231 if (temp._messageList == null) return false;
232 else if (!(this._messageList.equals(temp._messageList)))
233 return false;
234 }
235 else if (temp._messageList != null)
236 return false;
237 if (this._workflowName != null) {
238 if (temp._workflowName == null) return false;
239 else if (!(this._workflowName.equals(temp._workflowName)))
240 return false;
241 }
242 else if (temp._workflowName != null)
243 return false;
244 if (this._description != null) {
245 if (temp._description == null) return false;
246 else if (!(this._description.equals(temp._description)))
247 return false;
248 }
249 else if (temp._description != null)
250 return false;
251 return true;
252 }
253 return false;
254 }
255
256 /***
257 * Returns the value of field 'description'.
258 *
259 * @return the value of field 'description'.
260 */
261 public java.lang.String getDescription()
262 {
263 return this._description;
264 }
265
266 /***
267 * Method getExtension
268 *
269 * @param index
270 */
271 public org.astrogrid.workflow.beans.v1.execution.Extension getExtension(int index)
272 throws java.lang.IndexOutOfBoundsException
273 {
274
275 if ((index < 0) || (index > _extensionList.size())) {
276 throw new IndexOutOfBoundsException();
277 }
278
279 return (org.astrogrid.workflow.beans.v1.execution.Extension) _extensionList.get(index);
280 }
281
282 /***
283 * Method getExtension
284 */
285 public org.astrogrid.workflow.beans.v1.execution.Extension[] getExtension()
286 {
287 int size = _extensionList.size();
288 org.astrogrid.workflow.beans.v1.execution.Extension[] mArray = new org.astrogrid.workflow.beans.v1.execution.Extension[size];
289 for (int index = 0; index < size; index++) {
290 mArray[index] = (org.astrogrid.workflow.beans.v1.execution.Extension) _extensionList.get(index);
291 }
292 return mArray;
293 }
294
295 /***
296 * Method getExtensionCount
297 */
298 public int getExtensionCount()
299 {
300 return _extensionList.size();
301 }
302
303 /***
304 * Returns the value of field 'finishTime'. The field
305 * 'finishTime' has the following description: time execution
306 * finished
307 *
308 * @return the value of field 'finishTime'.
309 */
310 public java.util.Date getFinishTime()
311 {
312 return this._finishTime;
313 }
314
315 /***
316 * Returns the value of field 'jobId'.
317 *
318 * @return the value of field 'jobId'.
319 */
320 public org.astrogrid.workflow.beans.v1.execution.JobURN getJobId()
321 {
322 return this._jobId;
323 }
324
325 /***
326 * Method getMessage
327 *
328 * @param index
329 */
330 public org.astrogrid.applications.beans.v1.cea.castor.MessageType getMessage(int index)
331 throws java.lang.IndexOutOfBoundsException
332 {
333
334 if ((index < 0) || (index > _messageList.size())) {
335 throw new IndexOutOfBoundsException();
336 }
337
338 return (org.astrogrid.applications.beans.v1.cea.castor.MessageType) _messageList.get(index);
339 }
340
341 /***
342 * Method getMessage
343 */
344 public org.astrogrid.applications.beans.v1.cea.castor.MessageType[] getMessage()
345 {
346 int size = _messageList.size();
347 org.astrogrid.applications.beans.v1.cea.castor.MessageType[] mArray = new org.astrogrid.applications.beans.v1.cea.castor.MessageType[size];
348 for (int index = 0; index < size; index++) {
349 mArray[index] = (org.astrogrid.applications.beans.v1.cea.castor.MessageType) _messageList.get(index);
350 }
351 return mArray;
352 }
353
354 /***
355 * Method getMessageCount
356 */
357 public int getMessageCount()
358 {
359 return _messageList.size();
360 }
361
362 /***
363 * Returns the value of field 'startTime'. The field
364 * 'startTime' has the following description: time execution
365 * started
366 *
367 * @return the value of field 'startTime'.
368 */
369 public java.util.Date getStartTime()
370 {
371 return this._startTime;
372 }
373
374 /***
375 * Returns the value of field 'status'. The field 'status' has
376 * the following description: current execution status
377 *
378 * @return the value of field 'status'.
379 */
380 public org.astrogrid.applications.beans.v1.cea.castor.types.ExecutionPhase getStatus()
381 {
382 return this._status;
383 }
384
385 /***
386 * Returns the value of field 'workflowName'.
387 *
388 * @return the value of field 'workflowName'.
389 */
390 public java.lang.String getWorkflowName()
391 {
392 return this._workflowName;
393 }
394
395 /***
396 * Method isValid
397 */
398 public boolean isValid()
399 {
400 try {
401 validate();
402 }
403 catch (org.exolab.castor.xml.ValidationException vex) {
404 return false;
405 }
406 return true;
407 }
408
409 /***
410 * Method marshal
411 *
412 * @param out
413 */
414 public void marshal(java.io.Writer out)
415 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
416 {
417
418 Marshaller.marshal(this, out);
419 }
420
421 /***
422 * Method marshal
423 *
424 * @param handler
425 */
426 public void marshal(org.xml.sax.ContentHandler handler)
427 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
428 {
429
430 Marshaller.marshal(this, handler);
431 }
432
433 /***
434 * Method removeExtension
435 *
436 * @param vExtension
437 */
438 public boolean removeExtension(org.astrogrid.workflow.beans.v1.execution.Extension vExtension)
439 {
440 boolean removed = _extensionList.remove(vExtension);
441 return removed;
442 }
443
444 /***
445 * Method removeMessage
446 *
447 * @param vMessage
448 */
449 public boolean removeMessage(org.astrogrid.applications.beans.v1.cea.castor.MessageType vMessage)
450 {
451 boolean removed = _messageList.remove(vMessage);
452 return removed;
453 }
454
455 /***
456 * Sets the value of field 'description'.
457 *
458 * @param description the value of field 'description'.
459 */
460 public void setDescription(java.lang.String description)
461 {
462 this._description = description;
463 }
464
465 /***
466 * Method setExtension
467 *
468 * @param index
469 * @param vExtension
470 */
471 public void setExtension(int index, org.astrogrid.workflow.beans.v1.execution.Extension vExtension)
472 throws java.lang.IndexOutOfBoundsException
473 {
474
475 if ((index < 0) || (index > _extensionList.size())) {
476 throw new IndexOutOfBoundsException();
477 }
478 _extensionList.set(index, vExtension);
479 }
480
481 /***
482 * Method setExtension
483 *
484 * @param extensionArray
485 */
486 public void setExtension(org.astrogrid.workflow.beans.v1.execution.Extension[] extensionArray)
487 {
488
489 _extensionList.clear();
490 for (int i = 0; i < extensionArray.length; i++) {
491 _extensionList.add(extensionArray[i]);
492 }
493 }
494
495 /***
496 * Sets the value of field 'finishTime'. The field 'finishTime'
497 * has the following description: time execution finished
498 *
499 * @param finishTime the value of field 'finishTime'.
500 */
501 public void setFinishTime(java.util.Date finishTime)
502 {
503 this._finishTime = finishTime;
504 }
505
506 /***
507 * Sets the value of field 'jobId'.
508 *
509 * @param jobId the value of field 'jobId'.
510 */
511 public void setJobId(org.astrogrid.workflow.beans.v1.execution.JobURN jobId)
512 {
513 this._jobId = jobId;
514 }
515
516 /***
517 * Method setMessage
518 *
519 * @param index
520 * @param vMessage
521 */
522 public void setMessage(int index, org.astrogrid.applications.beans.v1.cea.castor.MessageType vMessage)
523 throws java.lang.IndexOutOfBoundsException
524 {
525
526 if ((index < 0) || (index > _messageList.size())) {
527 throw new IndexOutOfBoundsException();
528 }
529 _messageList.set(index, vMessage);
530 }
531
532 /***
533 * Method setMessage
534 *
535 * @param messageArray
536 */
537 public void setMessage(org.astrogrid.applications.beans.v1.cea.castor.MessageType[] messageArray)
538 {
539
540 _messageList.clear();
541 for (int i = 0; i < messageArray.length; i++) {
542 _messageList.add(messageArray[i]);
543 }
544 }
545
546 /***
547 * Sets the value of field 'startTime'. The field 'startTime'
548 * has the following description: time execution started
549 *
550 * @param startTime the value of field 'startTime'.
551 */
552 public void setStartTime(java.util.Date startTime)
553 {
554 this._startTime = startTime;
555 }
556
557 /***
558 * Sets the value of field 'status'. The field 'status' has the
559 * following description: current execution status
560 *
561 * @param status the value of field 'status'.
562 */
563 public void setStatus(org.astrogrid.applications.beans.v1.cea.castor.types.ExecutionPhase status)
564 {
565 this._status = status;
566 }
567
568 /***
569 * Sets the value of field 'workflowName'.
570 *
571 * @param workflowName the value of field 'workflowName'.
572 */
573 public void setWorkflowName(java.lang.String workflowName)
574 {
575 this._workflowName = workflowName;
576 }
577
578 /***
579 * Method unmarshalWorkflowSummaryType
580 *
581 * @param reader
582 */
583 public static org.astrogrid.workflow.beans.v1.execution.WorkflowSummaryType unmarshalWorkflowSummaryType(java.io.Reader reader)
584 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
585 {
586 return (org.astrogrid.workflow.beans.v1.execution.WorkflowSummaryType) Unmarshaller.unmarshal(org.astrogrid.workflow.beans.v1.execution.WorkflowSummaryType.class, reader);
587 }
588
589 /***
590 * Method validate
591 */
592 public void validate()
593 throws org.exolab.castor.xml.ValidationException
594 {
595 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
596 validator.validate(this);
597 }
598
599 }