01: /*
02: * JFolder, Copyright 2001-2006 Gary Steinmetz
03: *
04: * Distributable under LGPL license.
05: * See terms of license at gnu.org.
06: */
07:
08: package org.jfolder.workflow.model.history;
09:
10: //base classes
11: import java.sql.Timestamp;
12: import java.util.ArrayList;
13:
14: //project specific classes
15: import org.jfolder.common.UnexpectedSystemException;
16: import org.jfolder.security.audit.SecurityAudit;
17:
18: //other classes
19:
20: public class TraceAudit {
21:
22: public final static String STATUS_ACTIVE = "ACTIVE";
23: public final static String STATUS_WAIT = "WAIT";
24: public final static String STATUS_DONE = "DONE";
25: public final static String STATUS_EXCEPTION = "EXCEPTION";
26:
27: private ArrayList recordList = null;
28: private int id = 0;
29:
30: protected TraceAudit(int id) {
31:
32: this .id = id;
33: this .recordList = new ArrayList();
34: }
35:
36: //TO DO: consider removing this
37: //public TraceBean(int inId, String inCurrentNode, String inFutureNode,
38: // WorkflowAudit inWa) {
39: //
40: // this.id = inId;
41: // this.recordList = new ArrayList();
42: //
43: // addRecord(inCurrentNode, inFutureNode, inWa);
44: //}
45:
46: public int getId() {
47: return id;
48: }
49:
50: public int getRecordCount() {
51: return recordList.size();
52: }
53:
54: public RecordAudit getRecordById(int number) {
55: //TO DO: consider restructuring function signature
56: //TO DO: is this function really needed? yes, for XMLRep transform?
57: //TO DO: should I store records in a HashMap?
58: //TO DO: maybe have a function to remove done traces?
59: //int number = Integer.parseInt(id);
60: if (number < 0 || number >= recordList.size()) {
61: throw new UnexpectedSystemException(number
62: + " is not within the range of existing record"
63: + " At this time there are " + recordList.size()
64: + ". Records range from 0 to record count - 1");
65: }
66: return (RecordAudit) recordList.get(number);
67: }
68:
69: public void addRecord(String inCurrentNode, String inFutureNode,
70: SecurityAudit inWa) {
71:
72: RecordAudit curRec = new RecordAudit(inCurrentNode,
73: inFutureNode, inWa);
74: recordList.add(curRec);
75: }
76:
77: //TO DO: what should the status of a trace be without any records?
78: public RecordAudit getCurrentRecord() {
79: if (recordList.size() < 1) {
80: throw new UnexpectedSystemException(
81: "Cannot get current record from empty trace");
82: }
83: return (RecordAudit) recordList.get(recordList.size() - 1);
84: }
85:
86: public RecordAudit[] getAllRecords() {
87: RecordAudit recordSet[] = new RecordAudit[recordList.size()];
88: for (int i = 0; i < recordSet.length; i++) {
89: recordSet[i] = (RecordAudit) recordList.get(i);
90: }
91: return recordSet;
92: }
93: }
|