001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.kuali.core.bo;
018:
019: import java.sql.Timestamp;
020: import java.util.LinkedHashMap;
021:
022: import org.kuali.RiceConstants;
023: import org.kuali.core.bo.user.UniversalUser;
024: import org.kuali.rice.KNSServiceLocator;
025:
026: /**
027: * Represents a user note in the system.
028: */
029: public class Note extends PersistableBusinessObjectBase {
030: private static final long serialVersionUID = -7647166354016356770L;
031:
032: private Long noteIdentifier;
033: private String remoteObjectIdentifier;
034: private String authorUniversalIdentifier;
035: private Timestamp notePostedTimestamp;
036: private String noteTypeCode;
037: private String noteText;
038: private String noteTopicText;
039: private String notePurgeCode;
040: private String attachmentIdentifier;
041:
042: private NoteType noteType;
043: private UniversalUser authorUniversal;
044: private Attachment attachment;
045: private AdHocRouteRecipient adHocRouteRecipient;
046:
047: /**
048: * Default constructor.
049: */
050: public Note() {
051: super ();
052:
053: Timestamp now = KNSServiceLocator.getDateTimeService()
054: .getCurrentTimestamp();
055: this .setNotePostedTimestamp(now);
056: this .setNoteText(RiceConstants.EMPTY_STRING);
057: // for now just do this
058: this .setNoteTypeCode("DH");
059:
060: this .authorUniversal = new UniversalUser();
061: this .setAdHocRouteRecipient(new AdHocRoutePerson());
062: }
063:
064: /**
065: * Gets the noteIdentifier attribute.
066: *
067: * @return Returns the noteIdentifier.
068: */
069: public Long getNoteIdentifier() {
070: return noteIdentifier;
071: }
072:
073: /**
074: * Sets the noteIdentifier attribute value.
075: *
076: * @param noteIdentifier The noteIdentifier to set.
077: */
078: public void setNoteIdentifier(Long noteIdentifier) {
079: this .noteIdentifier = noteIdentifier;
080: }
081:
082: /**
083: * Gets the remoteObjectIdentifier attribute.
084: *
085: * @return Returns the remoteObjectIdentifier
086: */
087: public String getRemoteObjectIdentifier() {
088: return remoteObjectIdentifier;
089: }
090:
091: /**
092: * Sets the remoteObjectIdentifier attribute.
093: *
094: * @param remoteObjectIdentifier The remoteObjectIdentifier to set.
095: */
096: public void setRemoteObjectIdentifier(String remoteObjectIdentifier) {
097: this .remoteObjectIdentifier = remoteObjectIdentifier;
098: }
099:
100: /**
101: * Gets the authorUniversalIdentifier attribute.
102: *
103: * @return Returns the authorUniversalIdentifier
104: */
105: public String getAuthorUniversalIdentifier() {
106: return authorUniversalIdentifier;
107: }
108:
109: /**
110: * Sets the authorUniversalIdentifier attribute.
111: *
112: * @param authorUniversalIdentifier The authorUniversalIdentifier to set.
113: */
114: public void setAuthorUniversalIdentifier(String noteAuthorIdentifier) {
115: this .authorUniversalIdentifier = noteAuthorIdentifier;
116: }
117:
118: /**
119: * Gets the notePostedTimestamp attribute.
120: *
121: * @return Returns the notePostedTimestamp
122: */
123: public Timestamp getNotePostedTimestamp() {
124: return notePostedTimestamp;
125: }
126:
127: /**
128: * Sets the notePostedTimestamp attribute.
129: *
130: * @param notePostedTimestamp The notePostedTimestamp to set.
131: */
132: public void setNotePostedTimestamp(Timestamp notePostedTimestamp) {
133: this .notePostedTimestamp = notePostedTimestamp;
134: }
135:
136: /**
137: * Gets the noteTypeCode attribute.
138: *
139: * @return Returns the noteTypeCode
140: */
141: public String getNoteTypeCode() {
142: return noteTypeCode;
143: }
144:
145: /**
146: * Sets the noteTypeCode attribute.
147: *
148: * @param noteTypeCode The noteTypeCode to set.
149: */
150: public void setNoteTypeCode(String noteTypeCode) {
151: this .noteTypeCode = noteTypeCode;
152: }
153:
154: /**
155: * Gets the noteText attribute.
156: *
157: * @return Returns the noteText
158: */
159: public String getNoteText() {
160: return noteText;
161: }
162:
163: /**
164: * Sets the noteText attribute.
165: *
166: * @param noteText The noteText to set.
167: */
168: public void setNoteText(String noteText) {
169: this .noteText = noteText;
170: }
171:
172: /**
173: * Gets the noteTopicText attribute.
174: *
175: * @return Returns the noteTopicText.
176: */
177: public String getNoteTopicText() {
178: return noteTopicText;
179: }
180:
181: /**
182: * Sets the noteTopicText attribute value.
183: *
184: * @param noteTopicText The noteTopicText to set.
185: */
186: public void setNoteTopicText(String noteTopicText) {
187: this .noteTopicText = noteTopicText;
188: }
189:
190: /**
191: * Gets the notePurgeCode attribute.
192: *
193: * @return Returns the notePurgeCode
194: */
195: public String getNotePurgeCode() {
196: return notePurgeCode;
197: }
198:
199: /**
200: * Sets the notePurgeCode attribute.
201: *
202: * @param notePurgeCode The notePurgeCode to set.
203: */
204: public void setNotePurgeCode(String notePurgeCode) {
205: this .notePurgeCode = notePurgeCode;
206: }
207:
208: /**
209: * Gets the noteType attribute.
210: *
211: * @return Returns the noteType.
212: */
213: public NoteType getNoteType() {
214: return noteType;
215: }
216:
217: /**
218: * Sets the noteType attribute value.
219: *
220: * @param noteType The noteType to set.
221: * @deprecated
222: */
223: public void setNoteType(NoteType noteType) {
224: this .noteType = noteType;
225: }
226:
227: /**
228: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
229: */
230: protected LinkedHashMap toStringMapper() {
231: LinkedHashMap m = new LinkedHashMap();
232: if (this .noteIdentifier != null) {
233: m.put("noteIdentifier", this .noteIdentifier.toString());
234: }
235: return m;
236: }
237:
238: /**
239: * Gets the authorUniversal attribute.
240: *
241: * @return Returns the authorUniversal.
242: */
243: public UniversalUser getAuthorUniversal() {
244: authorUniversal = KNSServiceLocator.getUniversalUserService()
245: .updateUniversalUserIfNecessary(
246: authorUniversalIdentifier, authorUniversal);
247: return authorUniversal;
248: }
249:
250: /**
251: * Sets the authorUniversal attribute value.
252: *
253: * @param authorUniversal The authorUniversal to set.
254: * @deprecated
255: */
256: public void setAuthorUniversal(UniversalUser authorUniversal) {
257: this .authorUniversal = authorUniversal;
258: }
259:
260: /**
261: * Gets the attachment attribute.
262: *
263: * @return Returns the attachment.
264: */
265: public Attachment getAttachment() {
266: return attachment;
267: }
268:
269: /**
270: * Sets the attachment attribute value.
271: *
272: * @param attachment The attachment to set.
273: */
274: public void setAttachment(Attachment attachment) {
275: this .attachment = attachment;
276: }
277:
278: /**
279: * Gets the attachmentIdentifier attribute.
280: *
281: * @return Returns the attachmentIdentifier.
282: */
283: public String getAttachmentIdentifier() {
284: return attachmentIdentifier;
285: }
286:
287: /**
288: * Sets the attachmentIdentifier attribute value.
289: *
290: * @param attachmentIdentifier The attachmentIdentifier to set.
291: */
292: public void setAttachmentIdentifier(String attachmentIdentifier) {
293: this .attachmentIdentifier = attachmentIdentifier;
294: }
295:
296: /**
297: * Adds the given attachment to this note. More specifically, sets both the attachmentIdentifier and the attachment reference,
298: * since they both need to be done separately now that we aren't using anonymous keys.
299: *
300: * @param attachment
301: */
302: public void addAttachment(Attachment attachment) {
303: setAttachmentIdentifier(attachment.getAttachmentIdentifier());
304: setAttachment(attachment);
305:
306: // copy foreign key and redundant values into attachment
307: attachment.setNoteIdentifier(noteIdentifier);
308:
309: }
310:
311: /**
312: * Removes the current attachment, if any. More specifically, clears both the attachmentIdentifier and the attachment reference,
313: * since they both need to be done separately now that we aren't using anonymous keys.
314: */
315: public void removeAttachment() {
316: setAttachment(null);
317: setAttachmentIdentifier(null);
318: }
319:
320: /**
321: * @return the adHocRouteRecipient
322: */
323: public AdHocRouteRecipient getAdHocRouteRecipient() {
324: return adHocRouteRecipient;
325: }
326:
327: /**
328: * @param adHocRouteRecipient the adHocRouteRecipient to set
329: */
330: public void setAdHocRouteRecipient(
331: AdHocRouteRecipient adHocRouteRecipient) {
332: this.adHocRouteRecipient = adHocRouteRecipient;
333: }
334:
335: }
|