View Javadoc
1   /*
2    * Copyright 2006 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.ole.coa.document.validation.impl;
17  
18  import org.kuali.ole.coa.businessobject.ProjectCode;
19  import org.kuali.rice.kns.document.MaintenanceDocument;
20  import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
21  /**
22   * This class implements the business rules specific to the {@link ProjectCode} Maintenance Document.
23   */
24  public class ProjectCodeRule extends MaintenanceDocumentRuleBase {
25  
26      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ProjectCodeRule.class);
27  
28      protected ProjectCode oldProjectCode;
29      protected ProjectCode newProjectCode;
30  
31      public ProjectCodeRule() {
32          super();
33      }
34  
35      /**
36       * This performs rules checks on document approve
37       * <ul>
38       * <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
39       * </ul>
40       * This rule fails on business rule failures
41       * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomApproveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
42       */
43      protected boolean processCustomApproveDocumentBusinessRules(MaintenanceDocument document) {
44  
45          LOG.debug("Entering processCustomApproveDocumentBusinessRules()");
46  
47          // check that all sub-objects whose keys are specified have matching objects in the db
48          checkExistenceAndActive();
49  
50          return true;
51      }
52  
53      /**
54       * This performs rules checks on document route
55       * <ul>
56       * <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
57       * </ul>
58       * This rule fails on business rule failures
59       * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
60       */
61      protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
62  
63          boolean success = true;
64  
65          LOG.debug("Entering processCustomRouteDocumentBusinessRules()");
66  
67          // check that all sub-objects whose keys are specified have matching objects in the db
68          success &= checkExistenceAndActive();
69  
70          return success;
71      }
72  
73      /**
74       * This performs rules checks on document save
75       * <ul>
76       * <li>{@link ProjectCodeRule#checkExistenceAndActive()}</li>
77       * </ul>
78       * This rule does not fail on business rule failures
79       * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomSaveDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
80       */
81      protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
82  
83          boolean success = true;
84  
85          LOG.debug("Entering processCustomSaveDocumentBusinessRules()");
86  
87          // check that all sub-objects whose keys are specified have matching objects in the db
88          success &= checkExistenceAndActive();
89  
90          return success;
91      }
92  
93      /**
94       * This method sets the convenience objects like newProjectCode and oldProjectCode, so you have short and easy handles to the new and
95       * old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load
96       * all sub-objects from the DB by their primary keys, if available.
97       * 
98       * @param document - the maintenanceDocument being evaluated
99       */
100     public void setupConvenienceObjects() {
101 
102         // setup oldAccount convenience objects, make sure all possible sub-objects are populated
103         oldProjectCode = (ProjectCode) super.getOldBo();
104 
105         // setup newAccount convenience objects, make sure all possible sub-objects are populated
106         newProjectCode = (ProjectCode) super.getNewBo();
107     }
108 
109     /**
110      * 
111      * This method currently doesn't do anything
112      * @return true
113      */
114     protected boolean checkExistenceAndActive() {
115 
116         LOG.debug("Entering checkExistenceAndActive()");
117         boolean success = true;
118 
119         return success;
120     }
121 
122 }