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.dms;
009:
010: //base classes
011: import java.io.ByteArrayInputStream;
012: import java.io.InputStream;
013: import java.util.ArrayList;
014: import java.util.HashMap;
015: import java.util.Iterator;
016:
017: //project specific classes
018: import org.jfolder.common.UnexpectedSystemException;
019: import org.jfolder.workflow.model.WorkflowComponent;
020: import org.jfolder.workflow.model.WorkflowComponentApplyUpdatesContext;
021: import org.jfolder.workflow.model.WorkflowComponentIdentifyUpdatesContext;
022: import org.jfolder.workflow.model.WorkflowComponentUpdates;
023:
024: //other classes
025:
026: public class WorkflowDocumentSet extends WorkflowComponent {
027:
028: // Document Group -> Documents
029: // Document -> Audits, including comments
030: //
031: // each group add, delete, and update (rename?)
032: // (add group access?)
033:
034: //private boolean notNew = false;
035: //private String workflowInstanceId = null;
036: private HashMap documentGroupMap = null;
037: private ArrayList documentGroupArray = null;
038: private HashMap originalDocumentGroupMap = null;
039:
040: private WorkflowDocumentSet() {
041: //this.workflowInstanceId = inWorkflowInstanceId;
042: //this.notNew = true;
043: //
044: this .documentGroupMap = new HashMap();
045: this .documentGroupArray = new ArrayList();
046: this .originalDocumentGroupMap = new HashMap();
047: }
048:
049: public final static WorkflowDocumentSet newInstance() {
050: return new WorkflowDocumentSet();
051: }
052:
053: //public boolean isNotNew() {
054: // return this.notNew;
055: //}
056:
057: //public void setNotNew(boolean inNotNew) {
058: // this.notNew = inNotNew;
059: //}
060:
061: public void addDocumentGroup(WorkflowDocumentGroup inDg) {
062: String dgName = inDg.getName();
063: if (!this .documentGroupMap.containsKey(dgName)) {
064: this .documentGroupMap.put(dgName, inDg);
065: this .documentGroupArray.add(inDg);
066: } else {
067: throw new UnexpectedSystemException("DocumentGroup '"
068: + dgName + "' already exists");
069: }
070: }
071:
072: public void removeDocumentGroup(String inName) {
073: if (this .documentGroupMap.containsKey(inName)) {
074: this .documentGroupMap.remove(inName);
075: for (int i = 0; i < this .documentGroupArray.size(); i++) {
076: WorkflowDocumentGroup nextDg = (WorkflowDocumentGroup) this .documentGroupArray
077: .get(i);
078: if (nextDg.getName().equals(inName)) {
079: this .documentGroupArray.remove(i);
080: }
081: }
082: } else {
083: throw new UnexpectedSystemException("DocumentGroup '"
084: + inName + "' does not exists");
085: }
086: }
087:
088: public int getDocumentGroupCount() {
089: return this .documentGroupArray.size();
090: }
091:
092: public WorkflowDocumentGroup getDocumentGroup(String inName) {
093: return (WorkflowDocumentGroup) this .documentGroupMap
094: .get(inName);
095: }
096:
097: public WorkflowDocumentGroup getDocumentGroup(int inIndex) {
098: return (WorkflowDocumentGroup) this .documentGroupArray
099: .get(inIndex);
100: }
101:
102: //public String getWorkflowInstanceId() {
103: // return this.workflowInstanceId;
104: //}
105:
106: //public boolean isDocumentGroupPresent() {
107: //}
108:
109: //public int getDocumentGroupCount() {
110: //}
111:
112: //public String getDocumentGroupName(int inIndex) {
113: //}
114:
115: //public boolean isDeletedDocumentGroupPresent() {
116: //}
117:
118: //public int getDelectedDocumentGroupCount() {
119: //}
120:
121: //public String getDeletedDocumentGroupName(int inIndex) {
122: //}
123:
124: public WorkflowComponentUpdates identifyUpdates(
125: WorkflowComponentIdentifyUpdatesContext inWciuc) {
126:
127: WorkflowDocumentSetUpdates outValue = WorkflowDocumentSetUpdates
128: .newInstance();
129:
130: //
131: //DOCUMENT GROUPS
132: //
133: ArrayList removeDgArray = new ArrayList();
134: ArrayList addDgArray = new ArrayList();
135: HashMap removeDgMap = (HashMap) this .originalDocumentGroupMap
136: .clone();
137: Iterator sameDgIter = this .documentGroupMap.keySet().iterator();
138: while (sameDgIter.hasNext()) {
139: String nextSameDg = (String) sameDgIter.next();
140: if (removeDgMap.containsKey(nextSameDg)) {
141: removeDgMap.remove(nextSameDg);
142: } else {
143: addDgArray.add(removeDgMap.get(nextSameDg));
144: }
145: }
146: Iterator removeDgIter = removeDgMap.keySet().iterator();
147: while (removeDgIter.hasNext()) {
148: removeDgArray.add(removeDgIter.next());
149: }
150:
151: //
152: this .originalDocumentGroupMap = (HashMap) this .documentGroupMap
153: .clone();
154:
155: //throw UnexpectedSystemException.notImplemented();
156:
157: return outValue;
158: }
159:
160: public void applyUpdates(
161: WorkflowComponentApplyUpdatesContext inWcauc) {
162: throw UnexpectedSystemException.notImplemented();
163: }
164: }
|