01: /*
02: * Copyright 2006 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.AdHocRoutePerson;
19: import org.kuali.core.document.Document;
20: import org.kuali.core.rule.AddAdHocRoutePersonRule;
21: import org.kuali.core.rule.BusinessRule;
22: import org.kuali.core.util.ObjectUtils;
23:
24: /**
25: * This class represents the add AdHocRoutePerson event that is part of an eDoc in Kuali. This is triggered when a user presses the
26: * add button for a given adHocRoutePerson.
27: *
28: *
29: */
30: public final class AddAdHocRoutePersonEvent extends
31: KualiDocumentEventBase {
32: private AdHocRoutePerson adHocRoutePerson;
33:
34: /**
35: * Constructs an AddAdHocRoutePersonEvent with the specified errorPathPrefix, document, and adHocRoutePerson
36: *
37: * @param document
38: * @param adHocRoutePerson
39: * @param errorPathPrefix
40: */
41: public AddAdHocRoutePersonEvent(String errorPathPrefix,
42: Document document, AdHocRoutePerson adHocRoutePerson) {
43: super ("creating add ad hoc route person event for document "
44: + getDocumentId(document), errorPathPrefix, document);
45: this .adHocRoutePerson = (AdHocRoutePerson) ObjectUtils
46: .deepCopy(adHocRoutePerson);
47: }
48:
49: /**
50: * Constructs an AddAdHocRoutePersonEvent with the given document
51: *
52: * @param document
53: * @param adHocRoutePerson
54: */
55: public AddAdHocRoutePersonEvent(Document document,
56: AdHocRoutePerson adHocRoutePerson) {
57: this ("", document, adHocRoutePerson);
58: }
59:
60: /**
61: * This method retrieves the document adHocRoutePerson associated with this event.
62: *
63: * @return AdHocRoutePerson
64: */
65: public AdHocRoutePerson getAdHocRoutePerson() {
66: return adHocRoutePerson;
67: }
68:
69: /**
70: * @see org.kuali.core.rule.event.KualiDocumentEvent#validate()
71: */
72: public void validate() {
73: super .validate();
74: if (this .adHocRoutePerson == null) {
75: throw new IllegalArgumentException(
76: "invalid (null) document adHocRoutePerson");
77: }
78: }
79:
80: /**
81: * @see org.kuali.core.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
82: */
83: public Class getRuleInterfaceClass() {
84: return AddAdHocRoutePersonRule.class;
85: }
86:
87: /**
88: * @see org.kuali.core.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.core.rule.BusinessRule)
89: */
90: public boolean invokeRuleMethod(BusinessRule rule) {
91: return ((AddAdHocRoutePersonRule) rule)
92: .processAddAdHocRoutePerson(getDocument(),
93: this.adHocRoutePerson);
94: }
95: }
|