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.instance;
009:
010: //base classes
011: import java.math.BigInteger;
012:
013: //project specific classes
014: import org.jfolder.common.UnexpectedSystemException;
015: import org.jfolder.security.audit.SecurityAudit;
016: import org.jfolder.workflow.model.WorkflowComponent;
017: import org.jfolder.workflow.model.WorkflowComponentApplyUpdatesContext;
018: import org.jfolder.workflow.model.WorkflowComponentIdentifyUpdatesContext;
019: import org.jfolder.workflow.model.WorkflowComponentUpdates;
020: import org.jfolder.workflow.model.dms.WorkflowDocumentSet;
021: import org.jfolder.workflow.model.dms.WorkflowDocumentSetUpdates;
022: import org.jfolder.workflow.model.trigger.WorkflowTrigger;
023: import org.jfolder.workflow.model.trigger.WorkflowTriggerUpdates;
024:
025: //other classes
026:
027: public class WorkflowInstance extends WorkflowComponent {
028:
029: //public boolean isParentWorkflowPresent();
030: //public String getParentWorkflowId();
031: //public int getParentWorkflowTraceId();
032: //public String getParentWorkflowWaitNode();
033: //public boolean isParentWorkflowReleaseRequired();
034: //
035: //public boolean isRetired();
036: public final static BigInteger INITIAL_STATE = new BigInteger("0");
037: public final static BigInteger INCREMENT = new BigInteger("1");
038:
039: private String id = null;
040: private BigInteger stateCode = null;
041: //
042: private WorkflowTrigger wfTrigger = null;
043: private WorkflowDocumentSet wfDocSet = null;
044:
045: //private boolean triggerDataUpdated = false;
046: //
047: //private WorkflowDocumentSet documentSet = null;
048:
049: private WorkflowInstance() {
050: resetMembers();
051: resetUpdates();
052: this .stateCode = INITIAL_STATE;
053: }
054:
055: private WorkflowInstance(String inInstanceId, BigInteger inStateCode) {
056: resetMembers();
057: resetUpdates();
058: this .id = inInstanceId;
059: this .stateCode = inStateCode;
060: }
061:
062: public final static WorkflowInstance newInstance() {
063: return new WorkflowInstance();
064: }
065:
066: public final static WorkflowInstance newInstance(
067: String inInstanceId, BigInteger inStateCode) {
068: return new WorkflowInstance(inInstanceId, inStateCode);
069: }
070:
071: private void resetMembers() {
072: this .id = null;
073: this .stateCode = null;
074: //
075: this .wfTrigger = null;
076: this .wfDocSet = null;
077: }
078:
079: private void resetUpdates() {
080: //this.triggerDataUpdated = false;
081: }
082:
083: //
084: //
085: public String getId() {
086: return this .id;
087: }
088:
089: public WorkflowTrigger getWorkflowTrigger() {
090: return this .wfTrigger;
091: }
092:
093: public void setWorkflowTrigger(WorkflowTrigger inTriggerData) {
094: //this.triggerDataUpdated = true;
095: this .wfTrigger = inTriggerData;
096: }
097:
098: public WorkflowDocumentSet getWorkflowDocumentSet() {
099: return this .wfDocSet;
100: }
101:
102: public void setWorkflowDocumentSet(WorkflowDocumentSet inDocumentSet) {
103: this .wfDocSet = inDocumentSet;
104: }
105:
106: public WorkflowComponentUpdates identifyUpdates(
107: WorkflowComponentIdentifyUpdatesContext inWciuc) {
108:
109: WorkflowInstanceUpdates outValue = new WorkflowInstanceUpdates();
110:
111: outValue.setId(this .id);
112: outValue.setSecurityAudit(inWciuc.getSecurityAudit());
113: //
114: WorkflowComponentUpdates wcuDocSet = this .wfDocSet
115: .identifyUpdates(inWciuc);
116: outValue
117: .setWorkflowDocumentSetUpdates((WorkflowDocumentSetUpdates) wcuDocSet);
118: //
119: WorkflowComponentUpdates wcuTrigger = this .wfTrigger
120: .identifyUpdates(inWciuc);
121: outValue
122: .setWorkflowTriggerUpdates((WorkflowTriggerUpdates) wcuTrigger);
123:
124: //
125: outValue.setCurrentStateCode(this .stateCode);
126: BigInteger nextStateCode = this .stateCode.add(INCREMENT);
127: outValue.setNextStateCode(nextStateCode);
128: this .stateCode = nextStateCode;
129:
130: return outValue;
131: }
132:
133: public void applyUpdates(
134: WorkflowComponentApplyUpdatesContext inWcauc) {
135: throw UnexpectedSystemException.notImplemented();
136: }
137: }
|