001/**
002 * Copyright 2005-2016 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 */
016package org.kuali.rice.kim.web.struts.action;
017
018import org.apache.struts.action.ActionForm;
019import org.apache.struts.action.ActionForward;
020import org.apache.struts.action.ActionMapping;
021import org.kuali.rice.core.api.util.RiceConstants;
022import org.kuali.rice.kim.service.KIMServiceLocatorInternal;
023import org.kuali.rice.kim.service.UiDocumentService;
024import org.kuali.rice.kim.web.struts.form.IdentityManagementDocumentFormBase;
025import org.kuali.rice.kns.web.struts.action.KualiAction;
026import org.kuali.rice.kns.web.struts.form.KualiTableRenderFormMetadata;
027
028import javax.servlet.http.HttpServletRequest;
029import javax.servlet.http.HttpServletResponse;
030
031/**
032 * This is a description of what this class does - jonathan don't forget to fill this in. 
033 * 
034 * @author Kuali Rice Team (rice.collab@kuali.org)
035 *
036 */
037public abstract class IdentityManagementBaseInquiryAction extends KualiAction {
038
039        protected UiDocumentService uiDocumentService;
040
041    protected UiDocumentService getUiDocumentService() {
042                if ( uiDocumentService == null ) {
043                        uiDocumentService = KIMServiceLocatorInternal.getUiDocumentService();
044                }
045                return uiDocumentService;
046        }
047        
048        /**
049         * This overridden method ...
050         * 
051         * @see org.kuali.rice.krad.web.struts.action.KualiAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
052         */
053        @Override
054        public ActionForward execute(ActionMapping mapping, ActionForm form,
055                        HttpServletRequest request, HttpServletResponse response)
056                        throws Exception {
057                IdentityManagementDocumentFormBase idmForm = (IdentityManagementDocumentFormBase) form;
058                idmForm.setInquiry(true);
059
060        loadKimObject( request, idmForm );
061
062        KualiTableRenderFormMetadata memberTableMetadata = idmForm.getMemberTableMetadata();
063        memberTableMetadata.jumpToPage(memberTableMetadata.getSwitchToPageNumber(), idmForm.getMemberRows().size(), idmForm.getRecordsPerPage());
064        
065                return super.execute(mapping, form, request, response);
066        }
067        
068    protected abstract void loadKimObject( HttpServletRequest request, IdentityManagementDocumentFormBase form );
069            
070    public ActionForward inquiry(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
071        return mapping.findForward(RiceConstants.MAPPING_BASIC);
072    }
073 
074    /**
075     * @see org.kuali.rice.kns.web.struts.action.KualiTableRenderAction#switchToPage(org.apache.struts.action.ActionMapping,
076     *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
077     */
078    public ActionForward switchToPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
079        IdentityManagementDocumentFormBase idmForm = (IdentityManagementDocumentFormBase) form;
080        
081        KualiTableRenderFormMetadata memberTableMetadata = idmForm.getMemberTableMetadata();
082        memberTableMetadata.jumpToPage(memberTableMetadata.getSwitchToPageNumber(), idmForm.getMemberRows().size(), idmForm.getRecordsPerPage());
083        memberTableMetadata.setColumnToSortIndex(memberTableMetadata.getPreviouslySortedColumnIndex());
084        return mapping.findForward(RiceConstants.MAPPING_BASIC);
085    }
086    
087
088}