01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.chart.rules;
17:
18: import java.util.List;
19:
20: import org.kuali.core.document.MaintenanceDocument;
21: import org.kuali.core.service.MaintenanceDocumentDictionaryService;
22: import org.kuali.kfs.context.SpringContext;
23: import org.kuali.module.chart.bo.ObjectCodeGlobal;
24: import org.kuali.module.chart.bo.ObjectCodeGlobalDetail;
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: * Updates the university fiscal year when it is not already set.
33: *
34: * @see org.kuali.module.chart.rules.MaintenancePreRulesBase#doCustomPreRules(org.kuali.core.document.MaintenanceDocument)
35: */
36: protected boolean doCustomPreRules(
37: MaintenanceDocument maintenanceDocument) {
38: ObjectCodeGlobal bo = (ObjectCodeGlobal) maintenanceDocument
39: .getNewMaintainableObject().getBusinessObject();
40:
41: List<ObjectCodeGlobalDetail> details = bo
42: .getObjectCodeGlobalDetails();
43:
44: for (ObjectCodeGlobalDetail detail : details) {
45: if (detail.getUniversityFiscalYear() == null) {
46: if (LOG.isDebugEnabled()) {
47: LOG
48: .debug("setting fiscal year on ObjectCodeGlobalDetail: "
49: + detail);
50: }
51: detail
52: .setUniversityFiscalYear(new Integer(
53: SpringContext
54: .getBean(
55: MaintenanceDocumentDictionaryService.class)
56: .getCollectionFieldDefaultValue(
57: maintenanceDocument
58: .getDocumentHeader()
59: .getWorkflowDocument()
60: .getDocumentType(),
61: "objectCodeGlobalDetails",
62: "universityFiscalYear")));
63: }
64: }
65:
66: return true;
67: }
68: }
|