001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.module.ec.document.web.struts; 017 018 import java.util.List; 019 import java.util.Map; 020 import java.util.Set; 021 022 import org.kuali.kfs.module.ec.businessobject.EffortCertificationDetail; 023 import org.kuali.kfs.module.ec.businessobject.EffortCertificationDetailLineOverride; 024 import org.kuali.kfs.sys.businessobject.AccountingLineOverride; 025 import org.kuali.kfs.sys.context.SpringContext; 026 import org.kuali.kfs.sys.document.web.struts.FinancialSystemTransactionalDocumentActionBase; 027 import org.kuali.rice.kew.exception.WorkflowException; 028 import org.kuali.rice.kew.web.session.UserSession; 029 import org.kuali.rice.kim.bo.Person; 030 import org.kuali.rice.kns.rule.event.KualiDocumentEvent; 031 import org.kuali.rice.kns.service.KualiRuleService; 032 import org.kuali.rice.kns.service.PersistenceService; 033 import org.kuali.rice.kns.util.KNSConstants; 034 import org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase; 035 036 /** 037 * To define Actions for EffortCertification document. 038 */ 039 public class EffortCertificationAction extends FinancialSystemTransactionalDocumentActionBase { 040 041 /** 042 * execute the rules associated with the given event 043 * 044 * @param event the event that just occured 045 * @return true if the rules associated with the given event pass; otherwise, false 046 */ 047 protected boolean invokeRules(KualiDocumentEvent event) { 048 return SpringContext.getBean(KualiRuleService.class).applyRules(event); 049 } 050 051 /** 052 * Processes detail line overrides for output to JSP 053 */ 054 protected void processDetailLineOverrides(List<EffortCertificationDetail> detailLines) { 055 if (!detailLines.isEmpty()) { 056 SpringContext.getBean(PersistenceService.class).retrieveReferenceObjects(detailLines, EffortCertificationDetailLineOverride.REFRESH_FIELDS); 057 058 for (EffortCertificationDetail detailLine : detailLines) { 059 EffortCertificationDetailLineOverride.processForOutput(detailLine); 060 } 061 } 062 } 063 064 /** 065 * For the given detail line, set the corresponding override code 066 * 067 * @param line the given detail line 068 */ 069 protected void updateDetailLineOverrideCode(EffortCertificationDetail detailLine) { 070 AccountingLineOverride override = EffortCertificationDetailLineOverride.determineNeededOverrides(detailLine); 071 detailLine.setOverrideCode(override.getCode()); 072 } 073 }