View Javadoc
1   package org.kuali.ole.deliver.notice.controller;
2   
3   import org.kuali.ole.deliver.bo.OleCirculationDesk;
4   import org.kuali.ole.deliver.notice.bo.OleNoticeContentConfigurationBo;
5   import org.kuali.ole.deliver.notice.bo.OleNoticeFieldLabelMapping;
6   import org.kuali.rice.krad.maintenance.MaintenanceDocument;
7   import org.kuali.rice.krad.util.GlobalVariables;
8   import org.kuali.rice.krad.web.controller.MaintenanceDocumentController;
9   import org.kuali.rice.krad.web.form.DocumentFormBase;
10  import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
11  import org.kuali.rice.krad.web.form.UifFormBase;
12  import org.springframework.stereotype.Controller;
13  import org.springframework.validation.BindingResult;
14  import org.springframework.web.bind.annotation.ModelAttribute;
15  import org.springframework.web.bind.annotation.RequestMapping;
16  import org.springframework.web.servlet.ModelAndView;
17  import org.apache.commons.collections.CollectionUtils;
18  import javax.servlet.http.HttpServletRequest;
19  import javax.servlet.http.HttpServletResponse;
20  
21  /**
22   * Created by maheswarang on 10/6/15.
23   */
24  
25  @Controller
26  @RequestMapping(value = "/oleNoticeContentConfigurationMaintenance")
27  public class OleNoticeContentConfigurationMaintenanceController extends MaintenanceDocumentController {
28  
29      @Override
30      @RequestMapping(params = "methodToCall=route")
31      public ModelAndView route(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
32                                HttpServletRequest request, HttpServletResponse response) {
33          MaintenanceDocumentForm maintenanceForm = (MaintenanceDocumentForm) form;
34          MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
35          OleNoticeContentConfigurationBo oleNoticeContentConfigurationBo = (OleNoticeContentConfigurationBo) document.getNewMaintainableObject().getDataObject();
36          oleNoticeContentConfigurationBo.getOleNoticeFieldLabelMappings().clear();
37          if(CollectionUtils.isNotEmpty(oleNoticeContentConfigurationBo.getOleNoticePatronFieldLabelMappings())){
38              for(OleNoticeFieldLabelMapping oleNoticeFieldLabelMapping :oleNoticeContentConfigurationBo.getOleNoticePatronFieldLabelMappings() ){
39                  oleNoticeFieldLabelMapping.setBelongsTo("PATRON");
40                  oleNoticeContentConfigurationBo.getOleNoticeFieldLabelMappings().add(oleNoticeFieldLabelMapping);
41              }
42          }
43          if(CollectionUtils.isNotEmpty(oleNoticeContentConfigurationBo.getOleNoticeItemFieldLabelMappings())){
44              for(OleNoticeFieldLabelMapping oleNoticeFieldLabelMapping :oleNoticeContentConfigurationBo.getOleNoticeItemFieldLabelMappings() ){
45                  oleNoticeFieldLabelMapping.setBelongsTo("ITEM");
46                  oleNoticeContentConfigurationBo.getOleNoticeFieldLabelMappings().add(oleNoticeFieldLabelMapping);
47              }
48  
49          }
50          return super.route(form, result, request, response);
51     }
52  
53  
54      @RequestMapping(params = "methodToCall=refresh")
55      public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
56                                  HttpServletRequest request, HttpServletResponse response) throws Exception {
57  
58          MaintenanceDocumentForm maintenanceForm = (MaintenanceDocumentForm) form;
59          MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
60          OleNoticeContentConfigurationBo oleNoticeContentConfigurationBo = (OleNoticeContentConfigurationBo) document.getNewMaintainableObject().getDataObject();
61          String noticeType = oleNoticeContentConfigurationBo.getNoticeType();
62          GlobalVariables.getUserSession().addObject("noticeType",noticeType);
63          return super.refresh(form,result,request,response);
64      }
65  
66  
67  
68  }