001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.kra.budget.web.struts.action;
017:
018: import javax.servlet.http.HttpServletRequest;
019: import javax.servlet.http.HttpServletResponse;
020:
021: import org.apache.struts.action.ActionForm;
022: import org.apache.struts.action.ActionForward;
023: import org.apache.struts.action.ActionMapping;
024: import org.kuali.core.service.KualiRuleService;
025: import org.kuali.kfs.KFSConstants;
026: import org.kuali.kfs.context.SpringContext;
027: import org.kuali.module.kra.budget.rules.event.RunAuditEvent;
028: import org.kuali.module.kra.budget.web.struts.form.BudgetForm;
029:
030: /**
031: * This class handles Actions for the Budget Audit Mode page.
032: */
033: public class BudgetAuditModeAction extends BudgetAction {
034:
035: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
036: .getLogger(BudgetAuditModeAction.class);
037:
038: /**
039: * Activate audit checks.
040: *
041: * @param mapping
042: * @param form
043: * @param request
044: * @param response
045: * @throws Exception
046: */
047: public ActionForward activate(ActionMapping mapping,
048: ActionForm form, HttpServletRequest request,
049: HttpServletResponse response) throws Exception {
050: super .load(mapping, form, request, response);
051:
052: BudgetForm budgetForm = (BudgetForm) form;
053: budgetForm.setAuditActivated(true);
054:
055: SpringContext.getBean(KualiRuleService.class).applyRules(
056: new RunAuditEvent(budgetForm.getBudgetDocument()));
057:
058: return mapping.findForward((KFSConstants.MAPPING_BASIC));
059: }
060:
061: /**
062: * De-activate audit checks.
063: *
064: * @param mapping
065: * @param form
066: * @param request
067: * @param response
068: * @throws Exception
069: */
070: public ActionForward deactivate(ActionMapping mapping,
071: ActionForm form, HttpServletRequest request,
072: HttpServletResponse response) throws Exception {
073: ((BudgetForm) form).setAuditActivated(false);
074: return mapping.findForward((KFSConstants.MAPPING_BASIC));
075: }
076:
077: /**
078: * Toggles all tabs to open. Overrides KualiAction.showAllTabs b/c we need to load the document to run audit.
079: *
080: * @param mapping
081: * @param form
082: * @param request
083: * @param response
084: * @return
085: * @throws Exception
086: */
087: public ActionForward showAllTabs(ActionMapping mapping,
088: ActionForm form, HttpServletRequest request,
089: HttpServletResponse response) throws Exception {
090: if (((BudgetForm) form).isAuditActivated()) {
091: super .load(mapping, form, request, response);
092: }
093:
094: return super .showAllTabs(mapping, form, request, response);
095: }
096:
097: /**
098: * Toggles all tabs to closed
099: *
100: * @param mapping
101: * @param form
102: * @param request
103: * @param response
104: * @return
105: * @throws Exception
106: */
107: public ActionForward hideAllTabs(ActionMapping mapping,
108: ActionForm form, HttpServletRequest request,
109: HttpServletResponse response) throws Exception {
110: if (((BudgetForm) form).isAuditActivated()) {
111: super.load(mapping, form, request, response);
112: }
113:
114: return super.hideAllTabs(mapping, form, request, response);
115: }
116: }
|