View Javadoc
1   /*
2    * Copyright 2007 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 java.util.Collection;
19  
20  import org.kuali.ole.coa.businessobject.ObjectCodeGlobal;
21  import org.kuali.ole.coa.businessobject.ObjectCodeGlobalDetail;
22  import org.kuali.ole.sys.context.SpringContext;
23  import org.kuali.rice.kns.document.MaintenanceDocument;
24  import org.kuali.rice.kns.service.MaintenanceDocumentDictionaryService;
25  
26  /**
27   * PreRules checks for the {@link ObjectCodeGlobal} that needs to occur while still in the Struts processing. This includes defaults
28   */
29  public class ObjectCodeGlobalPreRules extends MaintenancePreRulesBase {
30  
31  
32      /**
33       * Updates the university fiscal year when it is not already set.
34       * 
35       * @see org.kuali.ole.coa.document.validation.impl.MaintenancePreRulesBase#doCustomPreRules(org.kuali.rice.kns.document.MaintenanceDocument)
36       */
37      protected boolean doCustomPreRules(MaintenanceDocument maintenanceDocument) {
38          ObjectCodeGlobal bo = (ObjectCodeGlobal) maintenanceDocument.getNewMaintainableObject().getBusinessObject();
39  
40          Collection<ObjectCodeGlobalDetail> details = bo.getObjectCodeGlobalDetails();
41  
42          for (ObjectCodeGlobalDetail detail : details) {
43              if (detail.getUniversityFiscalYear() == null) {
44                  if (LOG.isDebugEnabled()) {
45                      LOG.debug("setting fiscal year on ObjectCodeGlobalDetail: " + detail);
46                  }
47                  detail.setUniversityFiscalYear(new Integer(SpringContext.getBean(MaintenanceDocumentDictionaryService.class).getCollectionFieldDefaultValue(maintenanceDocument.getDocumentHeader().getWorkflowDocument().getDocumentTypeName(), "objectCodeGlobalDetails", "universityFiscalYear")));
48              }
49          }
50  
51          return true;
52      }
53  }