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.core.rule.event;
17:
18: import org.apache.commons.lang.StringUtils;
19: import org.apache.log4j.Logger;
20: import org.kuali.core.bo.PersistableBusinessObject;
21: import org.kuali.core.document.Document;
22: import org.kuali.core.document.MaintenanceDocument;
23: import org.kuali.core.rule.AddCollectionLineRule;
24: import org.kuali.core.rule.BusinessRule;
25:
26: public class KualiAddLineEvent extends KualiDocumentEventBase {
27: private static final Logger LOG = Logger
28: .getLogger(KualiAddLineEvent.class);
29:
30: private PersistableBusinessObject bo;
31: private String collectionName;
32:
33: public KualiAddLineEvent(Document document, String collectionName,
34: PersistableBusinessObject addLine) {
35: super ("adding bo to document collection "
36: + getDocumentId(document), "", document);
37:
38: this .bo = addLine;//(BusinessObject)ObjectUtils.deepCopy( addLine );
39: this .collectionName = collectionName;
40: }
41:
42: public boolean invokeRuleMethod(BusinessRule rule) {
43: return ((AddCollectionLineRule) rule)
44: .processAddCollectionLineBusinessRules(
45: (MaintenanceDocument) getDocument(),
46: collectionName, bo);
47: }
48:
49: /**
50: * Logs the event type and some information about the associated accountingLine
51: */
52: private void logEvent() {
53: if (LOG.isDebugEnabled()) {
54: StringBuffer logMessage = new StringBuffer(StringUtils
55: .substringAfterLast(this .getClass().getName(), "."));
56: logMessage.append(" with ");
57:
58: // vary logging detail as needed
59: if (bo == null) {
60: logMessage.append("null new bo");
61: } else {
62: logMessage.append(StringUtils.substringAfterLast(bo
63: .getObjectId(), "."));
64: }
65:
66: LOG.debug(logMessage);
67: }
68: }
69:
70: public Class getRuleInterfaceClass() {
71: return AddCollectionLineRule.class;
72: }
73: }
|