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 java.util.ArrayList;
19: import java.util.List;
20:
21: import org.kuali.core.document.Document;
22: import org.kuali.core.rule.ApproveDocumentRule;
23: import org.kuali.core.rule.BusinessRule;
24:
25: /**
26: * This class represents the approve event that is part of an eDoc in Kuali. This could be triggered when a user presses the approve
27: * button for a given document enroute or it could happen when another piece of code calls the approve method in the document
28: * service.
29: *
30: *
31: */
32: public class ApproveDocumentEvent extends KualiDocumentEventBase {
33: /**
34: * Constructs an ApproveDocumentEvent with the specified errorPathPrefix and document
35: *
36: * @param errorPathPrefix
37: * @param document
38: */
39: public ApproveDocumentEvent(String errorPathPrefix,
40: Document document) {
41: this ("approve", errorPathPrefix, document);
42: }
43:
44: /**
45: * Constructs an ApproveDocumentEvent with the given document
46: *
47: * @param document
48: */
49: public ApproveDocumentEvent(Document document) {
50: this ("approve", "", document);
51: }
52:
53: /**
54: * Constructs a ApproveDocumentEvent, allowing the eventType to be passed in so that subclasses can specify a more accurate
55: * message.
56: *
57: * @param eventType
58: * @param errorPathPrefix
59: * @param document
60: */
61: protected ApproveDocumentEvent(String eventType,
62: String errorPathPrefix, Document document) {
63: super ("creating " + eventType + " event for document "
64: + getDocumentId(document), errorPathPrefix, document);
65: }
66:
67: /**
68: * @see org.kuali.core.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
69: */
70: public Class getRuleInterfaceClass() {
71: return ApproveDocumentRule.class;
72: }
73:
74: /**
75: * @see org.kuali.core.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.core.rule.BusinessRule)
76: */
77: public boolean invokeRuleMethod(BusinessRule rule) {
78: return ((ApproveDocumentRule) rule)
79: .processApproveDocument(this );
80: }
81:
82: /**
83: * @see org.kuali.core.rule.event.KualiDocumentEvent#generateEvents()
84: */
85: @Override
86: public List generateEvents() {
87: List events = new ArrayList();
88: events.add(new RouteDocumentEvent(getDocument()));
89: return events;
90: }
91: }
|