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.kfs.rule.event;
17:
18: import org.kuali.core.document.Document;
19: import org.kuali.core.rule.BusinessRule;
20: import org.kuali.core.util.ObjectUtils;
21: import org.kuali.kfs.bo.AccountingLine;
22: import org.kuali.kfs.document.AccountingDocument;
23: import org.kuali.kfs.rule.UpdateAccountingLineRule;
24:
25: /**
26: * This class represents the update accounting line event. This could be triggered when a user changes one or more values in an
27: * existing accounting line.
28: */
29: public final class UpdateAccountingLineEvent extends
30: AccountingLineEventBase {
31: private final AccountingLine updatedAccountingLine;
32:
33: /**
34: * Constructs an UpdateAccountingLineEvent with the given errorPathPrefix, document, and accountingLine.
35: *
36: * @param errorPathPrefix
37: * @param document
38: * @param accountingLine
39: * @param newAccountingLine
40: */
41: public UpdateAccountingLineEvent(String errorPathPrefix,
42: Document document, AccountingLine originalAccountingLine,
43: AccountingLine updatedAccountingLine) {
44: super ("updating accountingLine in document "
45: + getDocumentId(document), errorPathPrefix, document,
46: originalAccountingLine);
47:
48: this .updatedAccountingLine = (AccountingLine) ObjectUtils
49: .deepCopy(updatedAccountingLine);
50: }
51:
52: /**
53: * @return updated accountingLine associated with this event
54: */
55: public AccountingLine getUpdatedAccountingLine() {
56: return updatedAccountingLine;
57: }
58:
59: /**
60: * @see org.kuali.core.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
61: */
62: public Class getRuleInterfaceClass() {
63: return UpdateAccountingLineRule.class;
64: }
65:
66: /**
67: * @see org.kuali.core.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.core.rule.BusinessRule)
68: */
69: public boolean invokeRuleMethod(BusinessRule rule) {
70: return ((UpdateAccountingLineRule) rule)
71: .processUpdateAccountingLineBusinessRules(
72: (AccountingDocument) getDocument(),
73: getAccountingLine(), getUpdatedAccountingLine());
74: }
75:
76: /**
77: * @see org.kuali.core.rule.event.KualiDocumentEvent#validate()
78: */
79: public void validate() {
80: super .validate();
81: if (getUpdatedAccountingLine() == null) {
82: throw new IllegalArgumentException(
83: "invalid (null) updated accounting line");
84: }
85: }
86: }
|