View Javadoc
1   /*
2    * Copyright 2012 The Kuali Foundation.
3    *
4    * Licensed under the Educational Community License, Version 1.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/ecl1.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.ole.vnd.web.struts;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  import org.apache.struts.action.ActionForm;
25  import org.apache.struts.action.ActionForward;
26  import org.apache.struts.action.ActionMapping;
27  import org.kuali.ole.sys.context.SpringContext;
28  import org.kuali.ole.vnd.batch.service.VendorExcludeService;
29  import org.kuali.rice.kns.web.struts.action.KualiAction;
30  import org.kuali.rice.krad.exception.AuthorizationException;
31  
32  public class VendorExclusionAction extends KualiAction {
33  
34      public ActionForward confirmDebarredVendor(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
35          VendorExclusionForm vendorExclusionForm = (VendorExclusionForm) form;
36  
37          Map<String, String> fields = new HashMap<String, String>();
38          fields.put("confirmStatusCode", vendorExclusionForm.getConfirmStatusCode());
39          fields.put("vendorExclusionStatus", vendorExclusionForm.getVendorExclusionStatus());
40          fields.put("vendorType", vendorExclusionForm.getVendorType());
41          vendorExclusionForm.setFields(fields);
42          SpringContext.getBean(VendorExcludeService.class).confirmDebarredVendor(Integer.parseInt(vendorExclusionForm.getDebarredVendorId()));
43          return new ActionForward(getBackUrl(vendorExclusionForm), true);
44      }
45  
46      public ActionForward denyDebarredVendor(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
47          VendorExclusionForm vendorExclusionForm = (VendorExclusionForm) form;
48  
49          Map<String, String> fields = new HashMap<String, String>();
50          fields.put("confirmStatusCode", vendorExclusionForm.getConfirmStatusCode());
51          fields.put("vendorExclusionStatus", vendorExclusionForm.getVendorExclusionStatus());
52          fields.put("vendorType", vendorExclusionForm.getVendorType());
53          vendorExclusionForm.setFields(fields);
54          SpringContext.getBean(VendorExcludeService.class).denyDebarredVendor(Integer.parseInt(vendorExclusionForm.getDebarredVendorId()));
55          return new ActionForward(getBackUrl(vendorExclusionForm), true);
56      }
57  
58      protected String getBackUrl(VendorExclusionForm form) {
59          return form.getBackLocation() + "?methodToCall=search&docFormKey=88888888&businessObjectClassName=" + form.getBusinessObjectClassName()+ "&confirmStatusCode=" +  form.getConfirmStatusCode()
60          + "&vendorExclusionStatus=" +  form.getVendorExclusionStatus() + "&vendorType=" +  form.getVendorType() + "&suppressActions=No&showMaintenanceLinks=Yes";
61      }
62  
63      @Override
64      protected void checkAuthorization(ActionForm form, String methodToCall) throws AuthorizationException {
65      }
66  
67  }