View Javadoc
1   /**
2    * Copyright 2005-2015 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;
17  
18  import org.kuali.rice.krad.document.Document;
19  import org.kuali.rice.krad.maintenance.MaintenanceDocument;
20  import org.kuali.rice.krad.rules.rule.event.AddCollectionLineEvent;
21  import org.kuali.rice.krad.rules.rule.event.ApproveDocumentEvent;
22  
23  /**
24   * Rule event interface for implementing business rules against a maintenance document.
25   *
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public interface MaintenanceDocumentRule {
29  
30      /**
31       * Runs all business rules needed prior to saving. This includes both common rules for all maintenance documents,
32       * plus class-specific business rules.
33       *
34       * Will only return false if it fails the isValidForSave() test. Otherwise, it will always return positive
35       * regardless of the outcome of the business rules. However, any error messages resulting from the business rules
36       * will still be populated, for display to the consumer of this service.
37       *
38       * @see org.kuali.rice.krad.rules.rule.SaveDocumentRule#processSaveDocument(org.kuali.rice.krad.document.Document)
39       */
40      public abstract boolean processSaveDocument(Document document);
41  
42      /**
43       * Runs all business rules needed prior to routing. This includes both common rules for all maintenance documents,
44       * plus class-specific business rules.
45       *
46       * Will return false if any business rule fails, or if the document is in an invalid state, and not routable (see
47       * isDocumentValidForRouting()).
48       *
49       * @see org.kuali.rice.krad.rules.rule.RouteDocumentRule#processRouteDocument(org.kuali.rice.krad.document.Document)
50       */
51      public abstract boolean processRouteDocument(Document document);
52  
53      /**
54       * Runs all business rules needed prior to approving. This includes both common rules for all maintenance documents,
55       * plus class-specific business rules.
56       *
57       * Will return false if any business rule fails, or if the document is in an invalid state, and not approvable (see
58       * isDocumentValidForApproving()).
59       *
60       * @see org.kuali.rice.krad.rules.rule.ApproveDocumentRule#processApproveDocument(org.kuali.rice.krad.rules.rule.event.ApproveDocumentEvent)
61       */
62      public abstract boolean processApproveDocument(ApproveDocumentEvent approveEvent);
63  
64      /**
65       * Runs all business rules needed prior to adding a collection to a line. This includes both common rules for all
66       * maintenance documents, plus class-specific business rules.
67       *
68       * Will return false if any business rule fails.
69       *
70       * @see org.kuali.rice.krad.rules.rule.AddCollectionLineRule#processAddCollectionLine(org.kuali.rice.krad.rules.rule.event.AddCollectionLineEvent)
71       */
72      public abstract boolean processAddCollectionLine(AddCollectionLineEvent addEvent);
73  
74      /**
75       * Sets the convenience objects like newAccount and oldAccount, so you have short and easy handles to the new and
76       * old objects contained in the maintenance document.
77       *
78       * It also calls the BusinessObjectBase.refresh(), which will attempt to load all sub-objects from the DB by their
79       * primary keys, if available.
80       *
81       * @param document - the maintenanceDocument being evaluated
82       */
83      public void setupBaseConvenienceObjects(MaintenanceDocument document);
84  
85      /**
86       * Should always be overriden if a subclass is created.
87       *
88       * The goal for this is to cast the oldBo and newBo into the correct types of the subclass.
89       */
90      public void setupConvenienceObjects();
91  }