001/** 002 * Copyright 2004-2014 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.krad.kpme.controller; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.core.api.config.property.ConfigContext; 020import org.kuali.rice.kew.api.document.DocumentStatus; 021import org.kuali.rice.krad.bo.PersistableAttachment; 022import org.kuali.rice.krad.bo.PersistableBusinessObject; 023import org.kuali.rice.krad.document.Document; 024import org.kuali.rice.krad.maintenance.Maintainable; 025import org.kuali.rice.krad.maintenance.MaintenanceDocument; 026import org.kuali.rice.krad.uif.UifConstants; 027import org.kuali.rice.krad.uif.UifParameters; 028import org.kuali.rice.krad.util.KRADConstants; 029import org.kuali.rice.krad.web.controller.DocumentControllerBase; 030import org.kuali.rice.krad.web.controller.MaintenanceDocumentController; 031import org.kuali.rice.krad.web.form.DocumentFormBase; 032import org.kuali.rice.krad.web.form.MaintenanceDocumentForm; 033import org.kuali.rice.krad.web.form.UifFormBase; 034import org.springframework.stereotype.Controller; 035import org.springframework.validation.BindingResult; 036import org.springframework.web.bind.annotation.ModelAttribute; 037import org.springframework.web.bind.annotation.RequestMapping; 038import org.springframework.web.servlet.ModelAndView; 039import org.kuali.kpme.core.tkmdocument.KhrEmployeeDocument; 040import org.kuali.rice.krad.maintenance.MaintenanceDocument; 041 042import javax.servlet.http.HttpServletRequest; 043import javax.servlet.http.HttpServletResponse; 044import java.util.Properties; 045 046/** 047 * Created by mlemons on 9/9/14. 048*/ 049 050@Controller 051@RequestMapping(value = "/kpme/KhrEmployeeJobMaintenance") 052public class KhrEmployeeJobController extends MaintenanceDocumentController { 053/* 054 @Override 055 @RequestMapping(params = "methodToCall=cancel") 056 public ModelAndView cancel(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request, HttpServletResponse response) { 057 058 //return returnToPrevious(form); 059 DocumentFormBase documentForm = (DocumentFormBase) form; 060 DocumentStatus status = documentForm.getDocument().getDocumentHeader().getWorkflowDocument().getStatus(); 061 062 return super.cancel(form, result, request, response); 063 } 064*/ 065 066 @RequestMapping(params = "methodToCall=close") 067 public ModelAndView close(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, BindingResult result, 068 HttpServletRequest request, HttpServletResponse response) { 069 Properties props = new Properties(); 070 props.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.REFRESH); 071 072 String command = form.getCommand(); 073 String returnUrl = form.getReturnLocation(); 074 075 //if form is accessed from the action list or doc search return to application url 076 if (StringUtils.equals(command, "displayDocSearchView") 077 || StringUtils.equals(command, "displayActionListView") 078 || StringUtils.equals(command, "displaySuperUserView")) { 079 returnUrl = ConfigContext.getCurrentContextConfig().getProperty(KRADConstants.APPLICATION_URL_KEY); 080 } 081 return performRedirect(form, returnUrl, props); 082 } 083 084 085} 086