View Javadoc

1   /**
2    * Copyright 2005-2013 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.bo.AdHocRouteWorkgroup;
19  import org.kuali.rice.krad.document.Document;
20  import org.kuali.rice.krad.rules.rule.AddAdHocRouteWorkgroupRule;
21  import org.kuali.rice.krad.rules.rule.BusinessRule;
22  
23  /**
24   * This class represents the add AdHocRouteWorkgroup event that is part of an eDoc in Kuali. This is triggered when a user presses
25   * the add button for a given adHocRouteWorkgroup.
26   *
27   *
28   */
29  public final class AddAdHocRouteWorkgroupEvent extends KualiDocumentEventBase {
30      private AdHocRouteWorkgroup adHocRouteWorkgroup;
31  
32      /**
33       * Constructs an AddAdHocRouteWorkgroupEvent with the specified errorPathPrefix, document, and adHocRouteWorkgroup
34       *
35       * @param document
36       * @param adHocRouteWorkgroup
37       * @param errorPathPrefix
38       */
39      public AddAdHocRouteWorkgroupEvent(String errorPathPrefix, Document document, AdHocRouteWorkgroup adHocRouteWorkgroup) {
40          super("creating add ad hoc route workgroup event for document " + KualiDocumentEventBase.getDocumentId(document), errorPathPrefix, document);
41          this.adHocRouteWorkgroup = adHocRouteWorkgroup;
42      }
43  
44      /**
45       * Constructs an AddAdHocRouteWorkgroupEvent with the given document
46       *
47       * @param document
48       * @param adHocRouteWorkgroup
49       */
50      public AddAdHocRouteWorkgroupEvent(Document document, AdHocRouteWorkgroup adHocRouteWorkgroup) {
51          this("", document, adHocRouteWorkgroup);
52      }
53  
54      /**
55       * This method retrieves the document adHocRouteWorkgroup associated with this event.
56       *
57       * @return AdHocRouteWorkgroup
58       */
59      public AdHocRouteWorkgroup getAdHocRouteWorkgroup() {
60          return adHocRouteWorkgroup;
61      }
62  
63      /**
64       * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#validate()
65       */
66      @Override
67      public void validate() {
68          super.validate();
69          if (this.adHocRouteWorkgroup == null) {
70              throw new IllegalArgumentException("invalid (null) document adHocRouteWorkgroup");
71          }
72      }
73  
74      /**
75       * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
76       */
77      public Class<? extends BusinessRule> getRuleInterfaceClass() {
78          return AddAdHocRouteWorkgroupRule.class;
79      }
80  
81      /**
82       * @see org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.rice.krad.rules.rule.BusinessRule)
83       */
84      public boolean invokeRuleMethod(BusinessRule rule) {
85          return ((AddAdHocRouteWorkgroupRule) rule).processAddAdHocRouteWorkgroup(getDocument(), this.adHocRouteWorkgroup);
86      }
87  }