View Javadoc

1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
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.kpme.pm.position.web;
17  
18  
19  import java.util.Map;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  import org.apache.commons.lang.StringUtils;
25  import org.kuali.kpme.pm.position.Position;
26  import org.kuali.rice.kim.api.identity.Person;
27  import org.kuali.rice.krad.exception.AuthorizationException;
28  import org.kuali.rice.krad.maintenance.MaintenanceDocument;
29  import org.kuali.rice.krad.util.GlobalVariables;
30  import org.kuali.rice.krad.util.KRADConstants;
31  import org.kuali.rice.krad.web.controller.MaintenanceDocumentController;
32  import org.kuali.rice.krad.web.form.DocumentFormBase;
33  import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
34  import org.kuali.rice.krad.web.form.UifFormBase;
35  import org.springframework.stereotype.Controller;
36  import org.springframework.validation.BindingResult;
37  import org.springframework.web.bind.annotation.ModelAttribute;
38  import org.springframework.web.bind.annotation.RequestMapping;
39  import org.springframework.web.servlet.ModelAndView;
40  
41  @Controller
42  @RequestMapping(value = "/positionMaintenance")
43  public class PositionController extends MaintenanceDocumentController {
44  	
45  	    
46      @Override
47      @RequestMapping(params = "methodToCall=" + "setupMaintenance")
48      protected void setupMaintenance(MaintenanceDocumentForm form, HttpServletRequest request, String maintenanceAction) {
49      	super.setupMaintenance(form, request, maintenanceAction);
50      	
51      	if(KRADConstants.MAINTENANCE_EDIT_ACTION.equals(maintenanceAction)) {
52      		 MaintenanceDocument document = form.getDocument();
53  			 Position oldPosition = (Position) document.getOldMaintainableObject().getDataObject();
54  			 Position newPosition = (Position) document.getNewMaintainableObject().getDataObject();
55  			 
56      		 Map<String, String[]> aMap = request.getParameterMap();
57      		 String[] aStringCol = aMap.get("category");
58      		 if(aStringCol.length != 0) {
59      			 String aString = aStringCol[0];
60      			 if(StringUtils.isNotEmpty(aString)) {
61  	    			 oldPosition.setCategory(aString);
62  	    			 newPosition.setCategory(aString);
63      			 }
64      		 }
65      		 
66  //    		 aStringCol = aMap.get("reason");
67  //    		 if(aStringCol.length != 0) {
68  //    			 String aString = aStringCol[0];
69  //    			 if(StringUtils.isNotEmpty(aString)) {
70  //	    			 oldPosition.setReason(aString);
71  //	    			 newPosition.setReason(aString);
72  //    			 }
73  //    		 }
74      		 
75      		 document.getOldMaintainableObject().setDataObject(oldPosition);
76      		 document.getNewMaintainableObject().setDataObject(newPosition);
77      	}
78      }
79    
80  }