01: /*
02: * Copyright 2006-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.kra.budget.web.struts.action;
17:
18: import java.util.ArrayList;
19:
20: import javax.servlet.http.HttpServletRequest;
21: import javax.servlet.http.HttpServletResponse;
22:
23: import org.apache.struts.action.ActionForm;
24: import org.apache.struts.action.ActionForward;
25: import org.apache.struts.action.ActionMapping;
26: import org.kuali.core.document.Copyable;
27: import org.kuali.kfs.context.SpringContext;
28: import org.kuali.module.kra.bo.AdhocOrg;
29: import org.kuali.module.kra.bo.AdhocPerson;
30: import org.kuali.module.kra.budget.document.BudgetDocument;
31: import org.kuali.module.kra.budget.service.BudgetIndirectCostService;
32: import org.kuali.module.kra.budget.web.struts.form.BudgetForm;
33:
34: /**
35: * This class handles Actions for the Budget Template page.
36: */
37: public class BudgetTemplateAction extends BudgetAction {
38: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
39: .getLogger(BudgetTemplateAction.class);
40:
41: /**
42: * Template the current document and forward to new document parameters page.
43: *
44: * @param mapping
45: * @param form
46: * @param request
47: * @param response
48: * @throws Exception
49: */
50: public ActionForward doTemplate(ActionMapping mapping,
51: ActionForm form, HttpServletRequest request,
52: HttpServletResponse response) throws Exception {
53:
54: // Make sure BudgetForm is fully populated
55: super .load(mapping, form, request, response);
56:
57: BudgetForm budgetForm = (BudgetForm) form;
58: BudgetDocument budgetDoc = budgetForm.getBudgetDocument();
59:
60: ((Copyable) budgetDoc).toCopy();
61:
62: // Check if ad-hoc permissions to be copied over
63: if (!budgetForm.isIncludeAdHocPermissions()) {
64: budgetDoc.setAdhocPersons(new ArrayList<AdhocPerson>());
65: budgetDoc.setAdhocOrgs(new ArrayList<AdhocOrg>());
66: }
67:
68: // Check if budget fringe rates to be copied over
69: if (!budgetForm.isIncludeBudgetIdcRates()) {
70: budgetDoc.getBudget().getIndirectCost()
71: .setBudgetManualRateIndicator("N");
72: SpringContext.getBean(BudgetIndirectCostService.class)
73: .setupIndirectCostRates(budgetDoc.getBudget());
74: }
75:
76: budgetForm.setBudgetDocument(budgetDoc);
77: budgetForm.setDocId(budgetDoc.getDocumentNumber());
78:
79: budgetForm.getBudgetDocument().setCleanseBudgetOnSave(false);
80: super .save(mapping, form, request, response);
81:
82: budgetForm.getBudgetDocument().setCleanseBudgetOnSave(true);
83: super.load(mapping, form, request, response);
84:
85: return super.parameters(mapping, budgetForm, request, response);
86: }
87: }
|