001: package org.contineo.core.document;
002:
003: import java.util.HashSet;
004: import java.util.Iterator;
005: import java.util.Set;
006:
007: import org.contineo.core.security.Menu;
008:
009: /**
010: * This class represents documents.
011: *
012: * @author Michael Scholz
013: * @author Marco Meschieri
014: * @version 1.0
015: */
016: public class Document {
017: public static final int DOC_CHECKED_IN = 0;
018:
019: public static final int DOC_CHECKED_OUT = 1;
020:
021: private int docId = 0;
022:
023: private String docName = "";
024:
025: private String docVersion = "";
026:
027: private String docDate = "";
028:
029: private String docPublisher = "";
030:
031: /**
032: * Whether document is checked in or out;
033: *
034: * @see Document#DOC_CHECKED_IN
035: * @see Document#DOC_CHECKED_OUT
036: * @uml.property name="docStatus"
037: */
038: private int docStatus = DOC_CHECKED_IN;
039:
040: private String docType = "";
041:
042: private String checkoutUser = "";
043:
044: private String source = "";
045:
046: private String sourceAuthor = "";
047:
048: private String sourceDate = "";
049:
050: private String sourceType = "";
051:
052: private String coverage = "";
053:
054: private String language = "";
055:
056: private Set<String> keywords = new HashSet<String>();
057:
058: private Set<Version> versions = new HashSet<Version>();
059:
060: private Menu menu;
061:
062: public Document() {
063: }
064:
065: public int getDocId() {
066: return docId;
067: }
068:
069: public String getDocName() {
070: return docName;
071: }
072:
073: public String getDocVersion() {
074: return docVersion;
075: }
076:
077: public String getDocDate() {
078: return docDate;
079: }
080:
081: public String getDocPublisher() {
082: return docPublisher;
083: }
084:
085: public int getDocStatus() {
086: return docStatus;
087: }
088:
089: public int getMenuId() {
090: return getMenu().getMenuId();
091: }
092:
093: public String getDocType() {
094: return docType;
095: }
096:
097: public String getCheckoutUser() {
098: return checkoutUser;
099: }
100:
101: public String getSource() {
102: return source;
103: }
104:
105: public String getSourceAuthor() {
106: return sourceAuthor;
107: }
108:
109: public String getSourceDate() {
110: return sourceDate;
111: }
112:
113: public String getSourceType() {
114: return sourceType;
115: }
116:
117: public String getCoverage() {
118: return coverage;
119: }
120:
121: public String getLanguage() {
122: return language;
123: }
124:
125: public Set<String> getKeywords() {
126: return keywords;
127: }
128:
129: public String getKeywordsString() {
130: StringBuffer sb = new StringBuffer();
131: Iterator iter = keywords.iterator();
132: boolean start = true;
133:
134: while (iter.hasNext()) {
135: String words = (String) iter.next();
136:
137: if (!start) {
138: sb.append(", ");
139: } else {
140: start = false;
141: }
142:
143: sb.append(words);
144: }
145:
146: return sb.toString();
147: }
148:
149: public Set<Version> getVersions() {
150: return versions;
151: }
152:
153: public Menu getMenu() {
154: return menu;
155: }
156:
157: public void setDocId(int id) {
158: docId = id;
159: }
160:
161: public void setDocName(String name) {
162: docName = name;
163: }
164:
165: public void setDocVersion(String version) {
166: docVersion = version;
167: }
168:
169: public void setDocDate(String date) {
170: docDate = date;
171: }
172:
173: public void setDocPublisher(String publisher) {
174: docPublisher = publisher;
175: }
176:
177: public void setDocStatus(int status) {
178: docStatus = status;
179: }
180:
181: public void setDocType(String type) {
182: docType = type;
183: }
184:
185: public void setCheckoutUser(String user) {
186: checkoutUser = user;
187: }
188:
189: public void setSource(String src) {
190: source = src;
191: }
192:
193: public void setSourceAuthor(String author) {
194: sourceAuthor = author;
195: }
196:
197: public void setSourceDate(String date) {
198: sourceDate = date;
199: }
200:
201: public void setSourceType(String type) {
202: sourceType = type;
203: }
204:
205: public void setCoverage(String cover) {
206: coverage = cover;
207: }
208:
209: public void setLanguage(String lang) {
210: language = lang;
211: }
212:
213: public void clearKeywords() {
214: keywords.clear();
215: }
216:
217: public void setKeywords(Set<String> words) {
218: keywords = words;
219: }
220:
221: public void setVersions(Set<Version> vers) {
222: versions = vers;
223: }
224:
225: public void setMenu(Menu m) {
226: menu = m;
227: }
228:
229: public void addKeyword(String word) {
230: keywords.add(word);
231: }
232:
233: public void addVersion(Version vers) {
234: versions.add(vers);
235: }
236:
237: /**
238: * Iterates over the versions searchinf for the specified id
239: *
240: * @param id The version id
241: * @return The found version
242: */
243: public Version getVersion(String id) {
244: for (Version version : versions) {
245: if (version.getVersion().equals(id))
246: return version;
247: }
248: return null;
249: }
250:
251: @Override
252: public boolean equals(Object obj) {
253: if (!(obj instanceof Document))
254: return false;
255:
256: Document other = (Document) obj;
257: return other.getDocId() == this .getDocId();
258: }
259:
260: @Override
261: public int hashCode() {
262: return new Integer(docId).hashCode();
263: }
264:
265: @Override
266: public String toString() {
267: return Integer.toString(docId);
268: }
269: }
|