01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.core.rule.event;
17:
18: import org.kuali.core.bo.Note;
19: import org.kuali.core.document.Document;
20: import org.kuali.core.rule.AddNoteRule;
21: import org.kuali.core.rule.BusinessRule;
22: import org.kuali.core.util.ObjectUtils;
23:
24: /**
25: * This class represents the add note event that is part of an eDoc in Kuali. This is triggered when a user presses the add button
26: * for a given note or it could happen when another piece of code calls the create note method in the document service.
27: *
28: *
29: */
30: public final class AddNoteEvent extends KualiDocumentEventBase {
31: private Note note;
32:
33: /**
34: * Constructs an AddNoteEvent with the specified errorPathPrefix and document
35: *
36: * @param document
37: * @param errorPathPrefix
38: */
39: public AddNoteEvent(String errorPathPrefix, Document document,
40: Note note) {
41: super ("creating add note event for document "
42: + getDocumentId(document), errorPathPrefix, document);
43: this .note = (Note) ObjectUtils.deepCopy(note);
44: }
45:
46: /**
47: * Constructs an AddNoteEvent with the given document
48: *
49: * @param document
50: */
51: public AddNoteEvent(Document document, Note note) {
52: this ("", document, note);
53: }
54:
55: /**
56: * This method retrieves the note associated with this event.
57: *
58: * @return
59: */
60: public Note getNote() {
61: return note;
62: }
63:
64: public void validate() {
65: super .validate();
66: if (getNote() == null) {
67: throw new IllegalArgumentException("invalid (null) note");
68: }
69: }
70:
71: /**
72: * @see org.kuali.core.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
73: */
74: public Class getRuleInterfaceClass() {
75: return AddNoteRule.class;
76: }
77:
78: /**
79: * @see org.kuali.core.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.core.rule.BusinessRule)
80: */
81: public boolean invokeRuleMethod(BusinessRule rule) {
82: return ((AddNoteRule) rule).processAddNote(getDocument(),
83: getNote());
84: }
85: }
|