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.dms.model.v1;
009:
010: //base classes
011: import java.util.ArrayList;
012: import java.util.HashMap;
013: import java.util.HashSet;
014: import java.util.Iterator;
015:
016: //project specific classes
017: import org.jfolder.common.UnexpectedSystemException;
018: import org.jfolder.common.entity.InitializeSystemEntityTagContext;
019: import org.jfolder.common.entity.SystemEntity;
020: import org.jfolder.common.entity.SystemEntityUpdates;
021: import org.jfolder.common.entity.SystemEntityUpdatesContext;
022: import org.jfolder.common.tagging.AppraiseConceptTagContext;
023: import org.jfolder.common.tagging.ConceptTag;
024: import org.jfolder.common.tagging.ConceptTagCharacteristic;
025: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
026: import org.jfolder.common.tagging.ConceptTagConstraint;
027: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
028: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
029: import org.jfolder.common.tagging.InitializeConceptTagContext;
030: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
031: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
032: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
033: import org.jfolder.dms.model.DocumentFileSystemDirectory;
034: import org.jfolder.dms.model.DocumentFileSystemDirectoryUpdates;
035: import org.jfolder.dms.model.DocumentFileSystemFile;
036: import org.jfolder.dms.model.DocumentFileSystemFileUpdates;
037: import org.jfolder.security.audit.SecurityAudit;
038:
039: //other classes
040:
041: public class DocumentFileSystemDirectoryTag extends
042: DocumentFileSystemHolderTag implements
043: DocumentFileSystemDirectory {
044:
045: //
046: private ConceptTagCharacteristic nameCtchar = null;
047:
048: //
049: //name details
050: private final static String NAME_CTCON = "name";
051: private final static String NAME_TITLE = "Name";
052: private final static String NAME_SHORT_DESCRIPTION = "Name";
053:
054: //
055: public DocumentFileSystemDirectoryTag() {
056: }
057:
058: //
059: public ConceptTagConstraint[] initializeConstraints(
060: ConceptTagConstraintHolder inCtconh) {
061: //
062: ConceptTagConstraint outValue[] = new ConceptTagConstraint[1];
063:
064: //constrain "path"
065: ConceptTagConstraint nameCtcon = ConceptTagConstraint
066: .newInstance(NAME_CTCON, inCtconh);
067: nameCtcon.setTitle(NAME_TITLE);
068: nameCtcon.setShortDescription(NAME_SHORT_DESCRIPTION);
069: //
070: StaticConceptTagConstraintContext pathSctcc = StaticConceptTagConstraintContext
071: .newInstance(nameCtcon);
072:
073: //
074: outValue[0] = nameCtcon;
075:
076: return outValue;
077: }
078:
079: public void initializeCharacteristics(
080: ConceptTagConstraint inCtcon[]) {
081: this .nameCtchar = (inCtcon[0]).getCharacteristic();
082: }
083:
084: protected void setName(String inName) {
085: if (this .nameCtchar.getValueLength() > 0) {
086: this .nameCtchar.replaceValueAndRemoveLocalFiles(0, inName);
087: } else {
088: this .nameCtchar.addValue(0, inName);
089: }
090: }
091:
092: protected final static DocumentFileSystemDirectoryTag newInstance(
093: ConceptTagCharacteristic inCtchar, int inIndex,
094: String inName) {
095:
096: DocumentFileSystemDirectoryTag outValue = new DocumentFileSystemDirectoryTag();
097:
098: ConceptTagCharacteristicHolder ctcharh = inCtchar.addValue(
099: inIndex, outValue, true);
100:
101: InitializeSystemEntityTagContext isetc = new InitializeSystemEntityTagContext(
102: ctcharh);
103:
104: outValue.initialize(isetc);
105:
106: outValue.nameCtchar.addValue(0, inName);
107:
108: return outValue;
109: }
110:
111: //
112: public void appraise(AppraiseConceptTagContext inCtic) {
113: if (inCtic instanceof StudioConceptTagInstanceInfoContext) {
114: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inCtic;
115: sctiic.setInstanceTitle("Document Directory");
116: sctiic.setInstanceDescription("Document Directory");
117: } else if (inCtic instanceof StudioConceptTagTypeInfoContext) {
118: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inCtic;
119: scttic.setTypeTitle("Document Directory");
120: scttic.setTypeDescription("Document Directory");
121: }
122: }
123:
124: //
125: public SystemEntityUpdates getSystemEntityUpdates(
126: SystemEntityUpdatesContext inSeuc) {
127: //
128: throw UnexpectedSystemException.unknownState();
129: }
130:
131: //
132: //public SystemEntityUpdates getSystemEntityUpdates(
133: // SystemEntityUpdatesContext inSeuc) {
134: //
135: // DocumentGroupUpdatesTag outValue =
136: // new DocumentGroupUpdatesTag(this.path);
137: //
138: // //
139: // HashSet allInstanceKeys = new HashSet();
140: // allInstanceKeys.addAll(this.documentInstanceMap.keySet());
141: // allInstanceKeys.addAll(this.originalDocumentInstanceMap.keySet());
142: //
143: // //
144: // Iterator keyIter = allInstanceKeys.iterator();
145: // while (keyIter.hasNext()) {
146: // Object nextDiKey = keyIter.next();
147: // boolean nextOrigPresent =
148: // this.originalDocumentInstanceMap.containsKey(nextDiKey);
149: // boolean nextCurrPresent =
150: // this.documentInstanceMap.containsKey(nextDiKey);
151: // //DocumentGroup nextDg
152: //
153: // if (nextOrigPresent && nextCurrPresent) {
154: // //no high level changes document groups
155: // }
156: // else if (!nextOrigPresent && nextCurrPresent) {
157: // Object o = this.documentInstanceMap.get(nextDiKey);
158: // outValue.addCreateInstance((DocumentInstance)o);
159: // }
160: // else if (nextOrigPresent && !nextCurrPresent) {
161: // Object o = this.originalDocumentInstanceMap.get(nextDiKey);
162: // outValue.addDeleteInstance((DocumentInstance)o);
163: // }
164: // else {
165: // throw UnexpectedSystemException.unknownState();
166: // }
167: // }
168: //
169: // //
170: // HashSet allInstanceValues = new HashSet();
171: // allInstanceValues.addAll(this.documentInstanceMap.values());
172: // allInstanceValues.addAll(this.originalDocumentInstanceMap.values());
173: //
174: // //
175: // Iterator valueIter = allInstanceValues.iterator();
176: // while (valueIter.hasNext()) {
177: // DocumentInstance nextDiValue = (DocumentInstance)valueIter.next();
178: //
179: // SystemEntityUpdatesContext nextSeuc =
180: // SystemEntityUpdatesContext.newInstance(outValue, inSeuc);
181: //
182: // SystemEntityUpdates nextSeu =
183: // nextDiValue.getSystemEntityUpdates(nextSeuc);
184: // outValue.addInstanceUpdate((DocumentInstanceUpdates)nextSeu);
185: // }
186: //
187: // return outValue;
188: //}
189:
190: protected boolean isNameAvailable() {
191: return (this .nameCtchar.getValueLength() > 0);
192: }
193:
194: public String getName() {
195:
196: String outValue = null;
197:
198: if (this .nameCtchar.getValueLength() > 0) {
199: outValue = this .nameCtchar.getValueAsString(0, null);
200: } else {
201: throw UnexpectedSystemException.unknownState();
202: }
203:
204: return outValue;
205: }
206:
207: public String toString() {
208:
209: StringBuffer outValue = new StringBuffer();
210:
211: return outValue.toString();
212: }
213: }
|