001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.workflow.model.history;
009:
010: //base classes
011: import java.util.ArrayList;
012:
013: //project specific classes
014: import org.jfolder.common.UnexpectedSystemException;
015:
016: //other classes
017:
018: public class HistoryAudit {
019:
020: private ArrayList traceList = null;
021:
022: private HistoryAudit() {
023: traceList = new ArrayList();
024: }
025:
026: public final static HistoryAudit newInstance() {
027: return new HistoryAudit();
028: }
029:
030: /*
031: public final static HistoryAudit createHistoryAudit(StartScriptTag inStart,
032: DetermineValueAndClassConceptTagContext inRvacfctc,
033: SecurityAudit inWa) {
034:
035: try {
036:
037: HistoryAudit outValue = new HistoryAuditBean();
038:
039: //determineValueAndClassContext rvacc =
040: // ScriptTagHelper.createdetermineValueAndClassContext(
041: // inAs, inTrigger, inName);
042:
043: String futureState = inStart.evaluateTransition(inRvacfctc);
044:
045: TraceAudit trace = outValue.createTraceAudit();
046:
047: trace.addRecord(inStart.getName(), futureState, inWa);
048:
049: for (int i = 0; i < inStart.getBranchCount(); i++) {
050: TraceAudit nextTrace = outValue.createTraceAudit();
051: nextTrace.addRecord(inStart.getName(),
052: inStart.evaluateBranch(i, inRvacfctc), inWa);
053: }
054:
055: return outValue;
056: }
057: catch (DetermineValueAndClassConceptTagException rcte) {
058: throw new UnexpectedSystemException(rcte);
059: }
060: }
061: */
062:
063: //TO DO: is this function necessary? maybe to limit trace size?
064: public int getTraceCount() {
065: return traceList.size();
066: }
067:
068: //TO DO: check this bounds limit elsewhere
069: public TraceAudit getTraceById(int inId) {
070: //TO DO: should I validate this and other ids before I parse?
071: //int number = Integer.parseInt(id);
072: if (inId < 0 || inId >= traceList.size()) {
073: throw new UnexpectedSystemException(inId
074: + " is not within the range of existing traces"
075: + " At this time there are " + traceList.size()
076: + ". Traces range from 0 to trace count - 1");
077: }
078: return (TraceAudit) traceList.get(inId);
079: }
080:
081: ////TO DO: should this include information about the first record?
082: public TraceAudit createTraceAudit() {
083:
084: //TO DO: check id and add accordingly
085: TraceAudit outValue = new TraceAudit(traceList.size());
086:
087: traceList.add(outValue);
088:
089: return outValue;
090: }
091:
092: public TraceAudit getOneTraceByStatus(String inStatus) {
093:
094: throw UnexpectedSystemException.notImplemented();
095: //TraceAudit outValue = null;
096: //
097: //for (int i = 0; i < traceList.size(); i++) {
098: // TraceAudit t = (TraceAudit)traceList.get(i);
099: // RecordAudit r = t.getCurrentRecord();
100: //
101: // if (r.getAuditStatus().equals(inStatus)) {
102: // outValue = t;
103: // break;
104: // }
105: //}
106: //
107: //return outValue;
108: }
109:
110: public int getTotalRecordCount() {
111:
112: int outValue = 0;
113:
114: for (int i = 0; i < traceList.size(); i++) {
115: TraceAudit nextTrace = (TraceAudit) traceList.get(i);
116: outValue += nextTrace.getRecordCount();
117: }
118:
119: return outValue;
120: }
121:
122: public TraceAudit[] getAllTraces() {
123:
124: TraceAudit outValue[] = new TraceAudit[traceList.size()];
125:
126: for (int i = 0; i < traceList.size(); i++) {
127: outValue[i] = (TraceAudit) traceList.get(i);
128: }
129:
130: return outValue;
131: }
132: }
|