View Javadoc

1   /**
2    * Copyright 2005-2014 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.SendAdHocRequestsRule;
21  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
22  import org.kuali.rice.krad.service.KualiRuleService;
23  
24  import java.util.ArrayList;
25  import java.util.List;
26  
27  /**
28   * This is a description of what this class does - wliang don't forget to fill this in. 
29   * 
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   *
32   */
33  public class SendAdHocRequestsEvent extends KualiDocumentEventBase {
34  
35      public SendAdHocRequestsEvent(String errorPathPrefix, Document document) {
36          this("creating send adhoc requests event for document " + getDocumentId(document), errorPathPrefix, document);
37      }
38  
39      /**
40       * Constructs a SaveDocumentEvent with the given document
41       * 
42       * @param document
43       */
44      public SendAdHocRequestsEvent(Document document) {
45          this("", document);
46      }
47      
48      public SendAdHocRequestsEvent(String description, String errorPathPrefix, Document document) {
49      	super(description, errorPathPrefix, document);
50      }
51      
52  	/**
53  	 * This overridden method ...
54  	 * 
55  	 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
56  	 */
57  	public Class<? extends BusinessRule> getRuleInterfaceClass() {
58  		return SendAdHocRequestsRule.class;
59  	}
60  
61  	/**
62  	 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.rice.krad.rules.rule.BusinessRule)
63  	 */
64  	public boolean invokeRuleMethod(BusinessRule rule) {
65  		return ((SendAdHocRequestsRule) rule).processSendAdHocRequests(document);
66  	}
67  
68  	/**
69  	 * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEventBase#generateEvents()
70  	 */
71  	@Override
72  	public List<KualiDocumentEvent> generateEvents() {
73  		KualiRuleService ruleService = KRADServiceLocatorWeb.getKualiRuleService();
74  		
75  		List<KualiDocumentEvent> events = new ArrayList<KualiDocumentEvent>();
76          events.addAll(ruleService.generateAdHocRoutePersonEvents(getDocument()));
77          events.addAll(ruleService.generateAdHocRouteWorkgroupEvents(getDocument()));
78          return events;
79  	}
80  }