1 /**
2 * Copyright 2005-2012 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
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.rice.krad.rules.rule.event;
17
18 import org.kuali.rice.krad.document.Document;
19 import org.kuali.rice.krad.rules.rule.BusinessRule;
20 import org.kuali.rice.krad.rules.rule.RouteDocumentRule;
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25 /**
26 * This class represents the route event that is part of an eDoc in Kuali. This could be triggered when a user presses the route
27 * button for a given document or it could happen when another piece of code calls the route method in the document service.
28 *
29 *
30 */
31 public final class RouteDocumentEvent extends KualiDocumentEventBase {
32 /**
33 * Constructs a RouteDocumentEvent with the specified errorPathPrefix and document
34 *
35 * @param errorPathPrefix
36 * @param document
37 */
38 public RouteDocumentEvent(String errorPathPrefix, Document document) {
39 super("creating route event for document " + getDocumentId(document), errorPathPrefix, document);
40 }
41
42 /**
43 * Constructs a RouteDocumentEvent with the given document
44 *
45 * @param document
46 */
47 public RouteDocumentEvent(Document document) {
48 this("", document);
49 }
50
51 /**
52 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
53 */
54 public Class<? extends BusinessRule> getRuleInterfaceClass() {
55 return RouteDocumentRule.class;
56 }
57
58 /**
59 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.rice.krad.rules.rule.BusinessRule)
60 */
61 public boolean invokeRuleMethod(BusinessRule rule) {
62 return ((RouteDocumentRule) rule).processRouteDocument(document);
63 }
64
65 /**
66 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#generateEvents()
67 */
68 @Override
69 public List<KualiDocumentEvent> generateEvents() {
70 List<KualiDocumentEvent> events = new ArrayList<KualiDocumentEvent>();
71 events.add(new SaveDocumentEvent(getDocument()));
72 return events;
73 }
74 }