01: /*
02: * Copyright 2006-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.module.kra.budget.rules.event;
17:
18: import org.kuali.core.document.Document;
19: import org.kuali.core.rule.BusinessRule;
20: import org.kuali.core.rule.event.KualiDocumentEventBase;
21: import org.kuali.core.util.ObjectUtils;
22: import org.kuali.module.kra.budget.bo.BudgetPeriod;
23: import org.kuali.module.kra.budget.rules.budget.BudgetDocumentRule;
24:
25: /**
26: * Class capturing an insert period line event.
27: */
28: public final class InsertPeriodLineEventBase extends
29: KualiDocumentEventBase implements InsertPeriodLineEvent {
30:
31: private final BudgetPeriod budgetPeriod;
32:
33: /**
34: * Constructs an InsertPeriodLineEvent with the given errorPathPrefix, document, and accountingLine.
35: *
36: * @param errorPathPrefix
37: * @param document
38: * @param accountingLine
39: */
40: public InsertPeriodLineEventBase(String errorPathPrefix,
41: Document document, BudgetPeriod period) {
42: super ("adding periodLine to document "
43: + getDocumentId(document), errorPathPrefix, document);
44:
45: // by doing a deep copy, we are ensuring that the business rule class can't update
46: // the original object by reference
47: this .budgetPeriod = (BudgetPeriod) ObjectUtils.deepCopy(period);
48: }
49:
50: /**
51: * Constructs an AddAccountingLineEvent for the given document and accountingLine
52: *
53: * @param document
54: * @param accountingLine
55: */
56: public InsertPeriodLineEventBase(Document document,
57: BudgetPeriod period) {
58: this ("", document, period);
59: }
60:
61: public BudgetPeriod getBudgetPeriod() {
62: return budgetPeriod;
63: }
64:
65: /**
66: * @see org.kuali.core.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
67: */
68: public Class getRuleInterfaceClass() {
69: return BudgetDocumentRule.class;
70: }
71:
72: /**
73: * @see org.kuali.core.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.core.rule.BusinessRule)
74: */
75: public boolean invokeRuleMethod(BusinessRule rule) {
76: return ((BudgetDocumentRule) rule)
77: .processAddPeriodBusinessRules(getDocument(),
78: getBudgetPeriod());
79: }
80: }
|