View Javadoc
1   package org.kuali.ole.select.controller;
2   
3   import org.apache.commons.lang3.StringUtils;
4   import org.kuali.ole.OLEConstants;
5   import org.kuali.ole.alert.controller.OleTransactionalDocumentControllerBase;
6   import org.kuali.ole.select.bo.*;
7   import org.kuali.ole.select.document.OLEPlatformRecordDocument;
8   import org.kuali.ole.select.form.OLEPlatformRecordForm;
9   import org.kuali.ole.select.gokb.OleGokbOrganization;
10  import org.kuali.ole.select.gokb.OleGokbPlatform;
11  import org.kuali.ole.service.OLEEResourceSearchService;
12  import org.kuali.ole.service.OLEPlatformService;
13  import org.kuali.ole.vnd.businessobject.VendorDetail;
14  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
15  import org.kuali.rice.krad.service.BusinessObjectService;
16  import org.kuali.rice.krad.service.KRADServiceLocator;
17  import org.kuali.rice.krad.uif.UifParameters;
18  import org.kuali.rice.krad.uif.container.CollectionGroup;
19  import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
20  import org.kuali.rice.krad.util.GlobalVariables;
21  import org.kuali.rice.krad.util.ObjectUtils;
22  import org.kuali.rice.krad.web.form.DocumentFormBase;
23  import org.kuali.rice.krad.web.form.TransactionalDocumentFormBase;
24  import org.kuali.rice.krad.web.form.UifFormBase;
25  import org.springframework.stereotype.Controller;
26  import org.springframework.validation.BindingResult;
27  import org.springframework.web.bind.annotation.ModelAttribute;
28  import org.springframework.web.bind.annotation.RequestMapping;
29  import org.springframework.web.servlet.ModelAndView;
30  
31  import javax.servlet.http.HttpServletRequest;
32  import javax.servlet.http.HttpServletResponse;
33  import java.sql.Timestamp;
34  import java.util.*;
35  
36  /**
37   * Created by chenchulakshmig on 9/10/14.
38   * The OLEPlatformRecordController is the controller class for processing all the actions that corresponds to the Platform functionality in OLE.
39   * The request mapping tag takes care of mapping the individual action to the corresponding functions.
40   */
41  @Controller
42  @RequestMapping(value = "/platformRecordController")
43  public class OLEPlatformRecordController extends OleTransactionalDocumentControllerBase {
44  
45      private BusinessObjectService businessObjectService;
46      private OLEPlatformService olePlatformService;
47      private OLEEResourceSearchService oleEResourceSearchService = null;
48  
49      public BusinessObjectService getBusinessObjectService() {
50          if (businessObjectService == null) {
51              businessObjectService = KRADServiceLocator.getBusinessObjectService();
52          }
53          return businessObjectService;
54      }
55  
56      public OLEPlatformService getOlePlatformService() {
57          if (olePlatformService == null) {
58              olePlatformService = GlobalResourceLoader.getService(OLEConstants.PLATFORM_SERVICE);
59          }
60          return olePlatformService;
61      }
62  
63      public OLEEResourceSearchService getOleEResourceSearchService() {
64          if (oleEResourceSearchService == null) {
65              oleEResourceSearchService = GlobalResourceLoader.getService(OLEConstants.OLEEResourceRecord.ERESOURSE_SEARCH_SERVICE);
66          }
67          return oleEResourceSearchService;
68      }
69  
70      /**
71       * This method creates new olePlatformRecordForm
72       *
73       * @return olePlatformRecordForm
74       */
75      @Override
76      protected DocumentFormBase createInitialForm(HttpServletRequest request) {
77          OLEPlatformRecordForm olePlatformRecordForm = new OLEPlatformRecordForm();
78          return olePlatformRecordForm;
79      }
80  
81      /**
82       * This method is for saving the platform details
83       *
84       * @param form
85       * @return ModelAndView
86       */
87      @Override
88      @RequestMapping(params = "methodToCall=save")
89      public ModelAndView save(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
90                               HttpServletRequest request, HttpServletResponse response) throws Exception {
91          OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) form;
92          OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
93          olePlatformRecordDocument.setSaveValidationFlag(false);
94          olePlatformRecordForm.setTempId(null);
95          StringBuffer errorMessage = getOlePlatformService().validatePlatformRecordDocument(olePlatformRecordDocument);
96          if (StringUtils.isNotBlank(errorMessage)) {
97              olePlatformRecordForm.setMessage(errorMessage.toString());
98              olePlatformRecordDocument.setSaveValidationFlag(true);
99              return getUIFModelAndView(olePlatformRecordForm);
100         }
101 
102         if (StringUtils.isNotBlank(olePlatformRecordDocument.getName())) {
103             if (olePlatformRecordDocument.getName().length() < 40) {
104                 olePlatformRecordDocument.getDocumentHeader().setDocumentDescription(olePlatformRecordDocument.getName());
105             } else {
106                 String documentDescription = olePlatformRecordDocument.getName().substring(0, 39);
107                 olePlatformRecordDocument.getDocumentHeader().setDocumentDescription(documentDescription);
108             }
109         }
110 
111         getOlePlatformService().processEventAttachments(olePlatformRecordDocument.getEventLogs());
112 
113         if (StringUtils.isBlank(olePlatformRecordDocument.getStatusId())){
114             olePlatformRecordDocument.setStatusId("1");
115         }
116         OLEPlatformRecordDocument tempDocument = null;
117         if (StringUtils.isNotBlank(olePlatformRecordDocument.getOlePlatformId())) {
118             Map<String, String> tempId = new HashMap<>();
119             tempId.put(OLEConstants.OLE_PLATFORM_ID, olePlatformRecordDocument.getOlePlatformId());
120             tempDocument = KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(OLEPlatformRecordDocument.class, tempId);
121         }
122         if (olePlatformRecordDocument.getAdminUrls().size() > 0) {
123             olePlatformRecordDocument.setAdminUrls(getOlePlatformService().saveUrls(olePlatformRecordDocument.getAdminUrls(), tempDocument));
124         }
125         if (olePlatformRecordDocument.getEventLogs().size() > 0) {
126             olePlatformRecordDocument.setEventLogs(getOlePlatformService().saveEvents(olePlatformRecordDocument.getEventLogs(), tempDocument));
127         }
128         getOlePlatformService().getNewPlatformDoc(tempDocument);
129 
130         if (StringUtils.isNotBlank(olePlatformRecordDocument.getVendorId())) {
131             String[] vendorId = olePlatformRecordDocument.getVendorId().split("-");
132             if (vendorId != null && vendorId.length == 2) {
133                 olePlatformRecordDocument.setVendorHeaderGeneratedIdentifier(Integer.parseInt(vendorId[0]));
134                 olePlatformRecordDocument.setVendorDetailAssignedIdentifier(Integer.parseInt(vendorId[1]));
135             }
136         } else {
137             olePlatformRecordDocument.setVendorHeaderGeneratedIdentifier(null);
138             olePlatformRecordDocument.setVendorDetailAssignedIdentifier(null);
139         }
140         getOlePlatformService().addVendorEventLog(olePlatformRecordDocument);
141         return super.save(olePlatformRecordForm, result, request, response);
142     }
143 
144     /**
145      * This method is to add general note
146      *
147      * @param uifForm
148      * @param result
149      * @param request
150      * @param response
151      * @return ModelAndView
152      */
153     @RequestMapping(params = "methodToCall=addGeneralNote")
154     public ModelAndView addGeneralNote(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
155                                        HttpServletRequest request, HttpServletResponse response) {
156         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
157         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
158         olePlatformRecordDocument.setSaveValidationFlag(false);
159         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
160         index++;
161         List<OLEPlatformGeneralNote> olePlatformGeneralNotesList = olePlatformRecordDocument.getGeneralNotes();
162         olePlatformRecordDocument.getGeneralNotes().add(index, new OLEPlatformGeneralNote());
163         olePlatformRecordDocument.setGeneralNotes(olePlatformGeneralNotesList);
164         olePlatformRecordForm.setDocument(olePlatformRecordDocument);
165         return super.navigate(olePlatformRecordForm, result, request, response);
166     }
167 
168     /**
169      * This method is to delete general note
170      *
171      * @param uifForm
172      * @param result
173      * @param request
174      * @param response
175      * @return ModelAndView
176      */
177     @RequestMapping(params = "methodToCall=deleteGeneralNote")
178     public ModelAndView deleteGeneralNote(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
179                                           HttpServletRequest request, HttpServletResponse response) {
180         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
181         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
182         olePlatformRecordDocument.setSaveValidationFlag(false);
183         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
184         List<OLEPlatformGeneralNote> olePlatformGeneralNotesList = olePlatformRecordDocument.getGeneralNotes();
185         if (olePlatformGeneralNotesList.size() > 1) {
186             olePlatformGeneralNotesList.remove(index);
187         }
188         olePlatformRecordForm.setDocument(olePlatformRecordDocument);
189         return super.navigate(olePlatformRecordForm, result, request, response);
190     }
191 
192     /**
193      * This method is to add administrative url
194      *
195      * @param uifForm
196      * @param result
197      * @param request
198      * @param response
199      * @return ModelAndView
200      */
201     @RequestMapping(params = "methodToCall=addAdministrativeUrl")
202     public ModelAndView addAdministrativeUrl(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
203                                              HttpServletRequest request, HttpServletResponse response) {
204         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
205         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
206         olePlatformRecordDocument.setSaveValidationFlag(false);
207         olePlatformRecordDocument.getAdminUrls().add(new OLEPlatformAdminUrl());
208         return super.navigate(uifForm, result, request, response);
209     }
210 
211     /**
212      * This method is to save admin url
213      *
214      * @param uifForm
215      * @param result
216      * @param request
217      * @param response
218      * @return ModelAndView
219      */
220     @RequestMapping(params = "methodToCall=saveAdminUrl")
221     public ModelAndView saveAdminUrl(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
222                                      HttpServletRequest request, HttpServletResponse response) {
223         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
224         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
225         olePlatformRecordDocument.setSaveValidationFlag(false);
226         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
227         olePlatformRecordDocument.getAdminUrls().get(index).setSaveFlag(true);
228         return super.navigate(olePlatformRecordForm, result, request, response);
229     }
230 
231     /**
232      * This method is to edit admin url
233      *
234      * @param uifForm
235      * @param result
236      * @param request
237      * @param response
238      * @return ModelAndView
239      */
240     @RequestMapping(params = "methodToCall=editAdminUrl")
241     public ModelAndView editAdminUrl(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
242                                      HttpServletRequest request, HttpServletResponse response) {
243         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
244         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
245         olePlatformRecordDocument.setSaveValidationFlag(false);
246         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
247         olePlatformRecordDocument.getAdminUrls().get(index).setSaveFlag(false);
248         return super.navigate(uifForm, result, request, response);
249     }
250 
251     /**
252      * This method is to delete admin url
253      *
254      * @param uifForm
255      * @param result
256      * @param request
257      * @param response
258      * @return ModelAndView
259      */
260     @RequestMapping(params = "methodToCall=deleteAdminUrl")
261     public ModelAndView deleteAdminUrl(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
262                                        HttpServletRequest request, HttpServletResponse response) {
263         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
264         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
265         olePlatformRecordDocument.setSaveValidationFlag(false);
266         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
267         if (olePlatformRecordDocument.getAdminUrls().size() > index) {
268             olePlatformRecordDocument.getAdminUrls().remove(index);
269         }
270         return super.navigate(uifForm, result, request, response);
271     }
272 
273     /**
274      * This method is to add event
275      *
276      * @param uifForm
277      * @param result
278      * @param request
279      * @param response
280      * @return ModelAndView
281      */
282     @RequestMapping(params = "methodToCall=addEvent")
283     public ModelAndView addEvent(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
284                                  HttpServletRequest request, HttpServletResponse response) {
285         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
286         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
287         olePlatformRecordDocument.setSaveValidationFlag(false);
288         String selectedCollectionPath = olePlatformRecordForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
289         CollectionGroup collectionGroup = uifForm.getPostedView().getViewIndex().getCollectionGroupByPath(
290                 selectedCollectionPath);
291         String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
292         Object eventObject = ObjectPropertyUtils.getPropertyValue(uifForm, addLinePath);
293         OLEPlatformEventLog olePlatformEventLog = (OLEPlatformEventLog) eventObject;
294         boolean flag = true;
295         flag = getOlePlatformService().addAttachmentFile(olePlatformEventLog, "OLEPlatformEventLogTab-eventLogSection");
296 
297         if (StringUtils.isBlank(olePlatformEventLog.getEventNote())) {
298             GlobalVariables.getMessageMap().putErrorForSectionId("OLEPlatformEventLogTab-eventLogSection", OLEConstants.ERROR_NOTE_REQUIRED);
299             flag = false;
300         }
301         if (!flag){
302             return super.navigate(olePlatformRecordForm, result, request, response);
303         }
304         if (olePlatformRecordForm.getTempId() == null) {
305             olePlatformRecordForm.setTempId(0);
306         } else {
307             olePlatformRecordForm.setTempId(olePlatformRecordForm.getTempId() + 1);
308         }
309         olePlatformEventLog.setEventTempId(olePlatformRecordForm.getTempId());
310         if (StringUtils.isNotBlank(olePlatformEventLog.getLogTypeName()) && olePlatformEventLog.getLogTypeName().equalsIgnoreCase("Event")) {
311             olePlatformEventLog.setProblemTypeId(null);
312             olePlatformEventLog.setEventStatus(null);
313             olePlatformEventLog.setEventResolvedDate(null);
314             olePlatformEventLog.setEventResolution(null);
315         } else if (StringUtils.isNotBlank(olePlatformEventLog.getLogTypeName()) && olePlatformEventLog.getLogTypeName().equalsIgnoreCase("Problem")) {
316             olePlatformEventLog.setEventTypeId(null);
317         }
318         olePlatformEventLog.setSaveFlag(true);
319         return addLine(olePlatformRecordForm, result, request, response);
320     }
321 
322     /**
323      * This method is to add filter event
324      *
325      * @param uifForm
326      * @param result
327      * @param request
328      * @param response
329      * @return ModelAndView
330      */
331     @RequestMapping(params = "methodToCall=addFilterEvent")
332     public ModelAndView addFilterEvent(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
333                                        HttpServletRequest request, HttpServletResponse response) {
334         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
335         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
336         olePlatformRecordDocument.setSaveValidationFlag(false);
337         String selectedCollectionPath = olePlatformRecordForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
338         CollectionGroup collectionGroup = uifForm.getPostedView().getViewIndex().getCollectionGroupByPath(
339                 selectedCollectionPath);
340         String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
341         Object eventObject = ObjectPropertyUtils.getPropertyValue(uifForm, addLinePath);
342         OLEPlatformEventLog olePlatformEventLog = (OLEPlatformEventLog) eventObject;
343         boolean flag = true;
344         flag = getOlePlatformService().addAttachmentFile(olePlatformEventLog, "OLEPlatformEventLogTab-filterEventLogSection");
345 
346         if (StringUtils.isBlank(olePlatformEventLog.getEventNote())) {
347             GlobalVariables.getMessageMap().putErrorForSectionId("OLEPlatformEventLogTab-filterEventLogSection", OLEConstants.ERROR_NOTE_REQUIRED);
348             flag = false;
349         }
350         if (!flag){
351             return super.navigate(olePlatformRecordForm, result, request, response);
352         }
353         if (olePlatformRecordForm.getTempId() == null) {
354             olePlatformRecordForm.setTempId(0);
355         } else {
356             olePlatformRecordForm.setTempId(olePlatformRecordForm.getTempId() + 1);
357         }
358         olePlatformEventLog.setEventTempId(olePlatformRecordForm.getTempId());
359         if (StringUtils.isNotBlank(olePlatformEventLog.getLogTypeName()) && olePlatformEventLog.getLogTypeName().equalsIgnoreCase("Event")) {
360             olePlatformEventLog.setProblemTypeId(null);
361             olePlatformEventLog.setEventStatus(null);
362             olePlatformEventLog.setEventResolvedDate(null);
363             olePlatformEventLog.setEventResolution(null);
364         } else if (StringUtils.isNotBlank(olePlatformEventLog.getLogTypeName()) && olePlatformEventLog.getLogTypeName().equalsIgnoreCase("Problem")) {
365             olePlatformEventLog.setEventTypeId(null);
366         }
367         olePlatformEventLog.setSaveFlag(true);
368         OLEPlatformEventLog platformEventLog = (OLEPlatformEventLog) ObjectUtils.deepCopy(olePlatformEventLog);
369         olePlatformRecordDocument.getEventLogs().add(platformEventLog);
370         return addLine(olePlatformRecordForm, result, request, response);
371     }
372 
373 
374     /**
375      * This method is to edit event
376      *
377      * @param uifForm
378      * @param result
379      * @param request
380      * @param response
381      * @return ModelAndView
382      */
383     @RequestMapping(params = "methodToCall=editEvent")
384     public ModelAndView editEvent(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
385                                   HttpServletRequest request, HttpServletResponse response) {
386         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
387         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
388         olePlatformRecordDocument.setSaveValidationFlag(false);
389         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
390         OLEPlatformEventLog olePlatformEventLog = olePlatformRecordDocument.getEventLogs().get(index);
391         olePlatformEventLog.setSaveFlag(false);
392         return super.navigate(uifForm, result, request, response);
393     }
394 
395     /**
396      * This method is to edit filter event
397      *
398      * @param uifForm
399      * @param result
400      * @param request
401      * @param response
402      * @return ModelAndView
403      */
404     @RequestMapping(params = "methodToCall=editFilterEvent")
405     public ModelAndView editFilterEvent(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
406                                         HttpServletRequest request, HttpServletResponse response) {
407         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
408         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
409         olePlatformRecordDocument.setSaveValidationFlag(false);
410         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
411         OLEPlatformEventLog olePlatformEventLog = olePlatformRecordDocument.getFilterEventLogs().get(index);
412         olePlatformEventLog = getOlePlatformService().getFilterPlatformEventLog(olePlatformEventLog, olePlatformRecordDocument.getFilterEventLogs());
413         if (olePlatformEventLog != null) {
414             olePlatformEventLog.setSaveFlag(false);
415         }
416         return super.navigate(uifForm, result, request, response);
417     }
418 
419     /**
420      * This method is to save event
421      *
422      * @param uifForm
423      * @param result
424      * @param request
425      * @param response
426      * @return ModelAndView
427      */
428     @RequestMapping(params = "methodToCall=saveEvent")
429     public ModelAndView saveEvent(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
430                                   HttpServletRequest request, HttpServletResponse response) {
431         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
432         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
433         olePlatformRecordDocument.setSaveValidationFlag(false);
434         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
435         OLEPlatformEventLog olePlatformEventLog = olePlatformRecordDocument.getEventLogs().get(index);
436         if (StringUtils.isBlank(olePlatformEventLog.getEventNote())) {
437             GlobalVariables.getMessageMap().putErrorForSectionId("OLEPlatformEventLogTab-eventLogSection", OLEConstants.ERROR_NOTE_REQUIRED);
438             return super.navigate(olePlatformRecordForm, result, request, response);
439         }
440         if (StringUtils.isNotBlank(olePlatformEventLog.getLogTypeName()) && olePlatformEventLog.getLogTypeName().equalsIgnoreCase("Event")) {
441             olePlatformEventLog.setProblemTypeId(null);
442             olePlatformEventLog.setEventStatus(null);
443             olePlatformEventLog.setEventResolvedDate(null);
444             olePlatformEventLog.setEventResolution(null);
445         } else if (StringUtils.isNotBlank(olePlatformEventLog.getLogTypeName()) && olePlatformEventLog.getLogTypeName().equalsIgnoreCase("Problem")) {
446             olePlatformEventLog.setEventTypeId(null);
447         }
448         olePlatformEventLog.setSaveFlag(true);
449         return super.navigate(olePlatformRecordForm, result, request, response);
450     }
451 
452     /**
453      * This method is to save filter event
454      *
455      * @param uifForm
456      * @param result
457      * @param request
458      * @param response
459      * @return ModelAndView
460      */
461     @RequestMapping(params = "methodToCall=saveFilterEvent")
462     public ModelAndView saveFilterEvent(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
463                                         HttpServletRequest request, HttpServletResponse response) {
464         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
465         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
466         olePlatformRecordDocument.setSaveValidationFlag(false);
467         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
468         OLEPlatformEventLog olePlatformEventLog = olePlatformRecordDocument.getFilterEventLogs().get(index);
469         olePlatformEventLog = getOlePlatformService().getFilterPlatformEventLog(olePlatformEventLog, olePlatformRecordDocument.getFilterEventLogs());
470         if (StringUtils.isBlank(olePlatformEventLog.getEventNote())) {
471             GlobalVariables.getMessageMap().putErrorForSectionId("OLEPlatformEventLogTab-filterEventLogSection", OLEConstants.ERROR_NOTE_REQUIRED);
472             return super.navigate(olePlatformRecordForm, result, request, response);
473         }
474         if (olePlatformEventLog != null && StringUtils.isNotBlank(olePlatformEventLog.getLogTypeName()) && olePlatformEventLog.getLogTypeName().equalsIgnoreCase("Event")) {
475             olePlatformEventLog.setProblemTypeId(null);
476             olePlatformEventLog.setEventStatus(null);
477             olePlatformEventLog.setEventResolvedDate(null);
478             olePlatformEventLog.setEventResolution(null);
479             olePlatformEventLog.setSaveFlag(true);
480         } else if (olePlatformEventLog != null && StringUtils.isNotBlank(olePlatformEventLog.getLogTypeName()) && olePlatformEventLog.getLogTypeName().equalsIgnoreCase("Problem")) {
481             olePlatformEventLog.setEventTypeId(null);
482             olePlatformEventLog.setSaveFlag(true);
483         }
484         return super.navigate(olePlatformRecordForm, result, request, response);
485     }
486 
487 
488     /**
489      * This method is to delete event
490      *
491      * @param uifForm
492      * @param result
493      * @param request
494      * @param response
495      * @return ModelAndView
496      */
497     @RequestMapping(params = "methodToCall=deleteEvent")
498     public ModelAndView deleteEvent(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
499                                     HttpServletRequest request, HttpServletResponse response) {
500         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
501         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
502         olePlatformRecordDocument.setSaveValidationFlag(false);
503         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
504         if (olePlatformRecordDocument.getEventLogs().size() > index) {
505             olePlatformRecordDocument.getEventLogs().remove(index);
506         }
507         return super.navigate(uifForm, result, request, response);
508     }
509 
510     /**
511      * This method is to delete filter event
512      *
513      * @param uifForm
514      * @param result
515      * @param request
516      * @param response
517      * @return ModelAndView
518      */
519     @RequestMapping(params = "methodToCall=deleteFilterEvent")
520     public ModelAndView deleteFilterEvent(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
521                                           HttpServletRequest request, HttpServletResponse response) {
522         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
523         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
524         olePlatformRecordDocument.setSaveValidationFlag(false);
525         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
526         OLEPlatformEventLog olePlatformEventLog = olePlatformRecordDocument.getFilterEventLogs().get(index);
527         olePlatformEventLog = getOlePlatformService().getFilterPlatformEventLog(olePlatformEventLog, olePlatformRecordDocument.getFilterEventLogs());
528         if (olePlatformEventLog != null) {
529             olePlatformRecordDocument.getFilterEventLogs().remove(olePlatformEventLog);
530             olePlatformRecordDocument.getEventLogs().remove(olePlatformEventLog);
531         }
532         return super.navigate(uifForm, result, request, response);
533     }
534 
535     /**
536      * This method is to copy the platform
537      *
538      * @param form
539      * @return ModelAndView
540      */
541     @Override
542     @RequestMapping(params = "methodToCall=copy")
543     public ModelAndView copy(@ModelAttribute("KualiForm") TransactionalDocumentFormBase form, BindingResult result,
544                              HttpServletRequest request, HttpServletResponse response) throws Exception {
545         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) form;
546         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
547         olePlatformRecordDocument.setSaveValidationFlag(false);
548         super.copy(olePlatformRecordForm, result, request, response);
549         return getUIFModelAndView(form);
550     }
551 
552     /**
553      * This method is to clear gokb id, platform name, platform provider and software values
554      *
555      * @param uifForm
556      * @param result
557      * @param request
558      * @param response
559      * @return ModelAndView
560      */
561     @RequestMapping(params = "methodToCall=clearGOKbId")
562     public ModelAndView clearGOKbId(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
563                                     HttpServletRequest request, HttpServletResponse response) {
564         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
565         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
566         olePlatformRecordDocument.setSaveValidationFlag(false);
567         olePlatformRecordDocument.setGokbId(null);
568         olePlatformRecordDocument.setPlatformProviderFlag(false);
569         olePlatformRecordDocument.setVendorHeaderGeneratedIdentifier(null);
570         olePlatformRecordDocument.setVendorDetailAssignedIdentifier(null);
571         olePlatformRecordDocument.setVendorId(null);
572         olePlatformRecordDocument.setStatusId(null);
573         olePlatformRecordDocument.setPlatformProviderName(null);
574         olePlatformRecordDocument.setName(null);
575         olePlatformRecordDocument.setSoftware(null);
576         return super.navigate(olePlatformRecordForm, result, request, response);
577     }
578 
579     /**
580      * This method is to add variant title
581      *
582      * @param uifForm
583      * @param result
584      * @param request
585      * @param response
586      * @return ModelAndView
587      */
588     @RequestMapping(params = "methodToCall=addVariantTitle")
589     public ModelAndView addVariantTitle(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
590                                         HttpServletRequest request, HttpServletResponse response) {
591         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
592         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
593         olePlatformRecordDocument.setSaveValidationFlag(false);
594         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
595         index++;
596         List<OLEPlatformVariantTitle> olePlatformVariantTitleList = olePlatformRecordDocument.getVariantTitles();
597         olePlatformRecordDocument.getVariantTitles().add(index, new OLEPlatformVariantTitle());
598         olePlatformRecordDocument.setVariantTitles(olePlatformVariantTitleList);
599         olePlatformRecordForm.setDocument(olePlatformRecordDocument);
600         return super.navigate(olePlatformRecordForm, result, request, response);
601     }
602 
603     /**
604      * This method is to delete variant title
605      *
606      * @param uifForm
607      * @param result
608      * @param request
609      * @param response
610      * @return ModelAndView
611      */
612     @RequestMapping(params = "methodToCall=deleteVariantTitle")
613     public ModelAndView deleteVariantTitle(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
614                                            HttpServletRequest request, HttpServletResponse response) {
615         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
616         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
617         olePlatformRecordDocument.setSaveValidationFlag(false);
618         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
619         List<OLEPlatformVariantTitle> olePlatformVariantTitleList = olePlatformRecordDocument.getVariantTitles();
620         if (olePlatformVariantTitleList.size() > 1) {
621             olePlatformVariantTitleList.remove(index);
622         }
623         olePlatformRecordForm.setDocument(olePlatformRecordDocument);
624         return super.navigate(olePlatformRecordForm, result, request, response);
625     }
626 
627     @RequestMapping(params = "methodToCall=filter")
628     public ModelAndView filter(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
629                                HttpServletRequest request, HttpServletResponse response) {
630         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
631         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
632         olePlatformRecordDocument.setSaveValidationFlag(false);
633         List<OLEPlatformEventLog> olePlatformEventLogList = olePlatformRecordDocument.getEventLogs();
634         olePlatformEventLogList = getOlePlatformService().filterByReportedDate(olePlatformRecordForm.getFilterReportedBeginDate(), olePlatformRecordForm.getFilterReportedEndDate(), olePlatformEventLogList);
635         olePlatformEventLogList = getOlePlatformService().filterByResolvedDate(olePlatformRecordForm.getFilterResolvedBeginDate(), olePlatformRecordForm.getFilterResolvedEndDate(), olePlatformEventLogList);
636         if (StringUtils.isNotBlank(olePlatformRecordForm.getStatus()) && !olePlatformRecordForm.getStatus().equals("All")) {
637             olePlatformEventLogList = getOlePlatformService().filterByStatus(olePlatformEventLogList, olePlatformRecordForm.getStatus());
638         }
639         if (StringUtils.isNotBlank(olePlatformRecordForm.getLogType()) && !olePlatformRecordForm.getLogType().equals("All")) {
640             olePlatformEventLogList = getOlePlatformService().filterByLogType(olePlatformEventLogList, olePlatformRecordForm.getLogType());
641         }
642         if (StringUtils.isNotBlank(olePlatformRecordForm.getEventType()) && !olePlatformRecordForm.getEventType().equals("All")) {
643             olePlatformEventLogList = getOlePlatformService().filterByEventType(olePlatformEventLogList, olePlatformRecordForm.getEventType());
644         }
645         if (StringUtils.isNotBlank(olePlatformRecordForm.getProblemType()) && !olePlatformRecordForm.getProblemType().equals("All")) {
646             olePlatformEventLogList = getOlePlatformService().filterByProblemType(olePlatformEventLogList, olePlatformRecordForm.getProblemType());
647         }
648         olePlatformRecordDocument.setFilterEventLogs(olePlatformEventLogList);
649         olePlatformRecordForm.setFilterEventLog(true);
650         return super.navigate(olePlatformRecordForm, result, request, response);
651     }
652 
653     @RequestMapping(params = "methodToCall=clearFilter")
654     public ModelAndView clearFilter(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
655                                     HttpServletRequest request, HttpServletResponse response) {
656         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
657         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
658         olePlatformRecordDocument.setSaveValidationFlag(false);
659         olePlatformRecordForm.setEventType(null);
660         olePlatformRecordForm.setProblemType(null);
661         olePlatformRecordForm.setLogType(null);
662         olePlatformRecordForm.setStatus(null);
663         olePlatformRecordForm.setFilterReportedBeginDate(null);
664         olePlatformRecordForm.setFilterReportedEndDate(null);
665         olePlatformRecordForm.setFilterResolvedBeginDate(null);
666         olePlatformRecordForm.setFilterResolvedEndDate(null);
667         olePlatformRecordDocument.setFilterEventLogs(new ArrayList<OLEPlatformEventLog>());
668         olePlatformRecordForm.setFilterEventLog(false);
669         return super.navigate(olePlatformRecordForm, result, request, response);
670     }
671 
672     @RequestMapping(params = "methodToCall=downloadEventAttachment1")
673     public ModelAndView downloadEventAttachment1(@ModelAttribute("KualiForm") TransactionalDocumentFormBase form, BindingResult result,
674                                                  HttpServletRequest request, HttpServletResponse response) throws Exception {
675         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) form;
676         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
677         olePlatformRecordDocument.setSaveValidationFlag(false);
678         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
679         OLEPlatformEventLog olePlatformEventLog = olePlatformRecordDocument.getEventLogs().get(index);
680         getOlePlatformService().downloadAttachment(response, olePlatformEventLog.getPlatformEventLogId(), olePlatformEventLog.getAttachmentFileName1(), olePlatformEventLog.getAttachmentContent1(), olePlatformEventLog.getAttachmentMimeType1());
681         return super.navigate(olePlatformRecordForm, result, request, response);
682     }
683 
684     @RequestMapping(params = "methodToCall=downloadEventAttachment2")
685     public ModelAndView downloadEventAttachment2(@ModelAttribute("KualiForm") TransactionalDocumentFormBase form, BindingResult result,
686                                                  HttpServletRequest request, HttpServletResponse response) throws Exception {
687         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) form;
688         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
689         olePlatformRecordDocument.setSaveValidationFlag(false);
690         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
691         OLEPlatformEventLog olePlatformEventLog = olePlatformRecordDocument.getEventLogs().get(index);
692         getOlePlatformService().downloadAttachment(response, olePlatformEventLog.getPlatformEventLogId(), olePlatformEventLog.getAttachmentFileName2(), olePlatformEventLog.getAttachmentContent2(), olePlatformEventLog.getAttachmentMimeType2());
693         return super.navigate(olePlatformRecordForm, result, request, response);
694     }
695 
696     @RequestMapping(params = "methodToCall=downloadFilterEventAttachment1")
697     public ModelAndView downloadFilterEventAttachment1(@ModelAttribute("KualiForm") TransactionalDocumentFormBase form, BindingResult result,
698                                                  HttpServletRequest request, HttpServletResponse response) throws Exception {
699         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) form;
700         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
701         olePlatformRecordDocument.setSaveValidationFlag(false);
702         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
703         OLEPlatformEventLog olePlatformEventLog = olePlatformRecordDocument.getFilterEventLogs().get(index);
704         getOlePlatformService().downloadAttachment(response, olePlatformEventLog.getPlatformEventLogId(), olePlatformEventLog.getAttachmentFileName1(), olePlatformEventLog.getAttachmentContent1(), olePlatformEventLog.getAttachmentMimeType1());
705         return super.navigate(olePlatformRecordForm, result, request, response);
706     }
707 
708     @RequestMapping(params = "methodToCall=downloadFilterEventAttachment2")
709     public ModelAndView downloadFilterEventAttachment2(@ModelAttribute("KualiForm") TransactionalDocumentFormBase form, BindingResult result,
710                                                  HttpServletRequest request, HttpServletResponse response) throws Exception {
711         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) form;
712         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
713         olePlatformRecordDocument.setSaveValidationFlag(false);
714         int index = Integer.parseInt(olePlatformRecordForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX));
715         OLEPlatformEventLog olePlatformEventLog = olePlatformRecordDocument.getFilterEventLogs().get(index);
716         getOlePlatformService().downloadAttachment(response, olePlatformEventLog.getPlatformEventLogId(), olePlatformEventLog.getAttachmentFileName2(), olePlatformEventLog.getAttachmentContent2(), olePlatformEventLog.getAttachmentMimeType2());
717         return super.navigate(olePlatformRecordForm, result, request, response);
718     }
719 
720     @RequestMapping(params = "methodToCall=updateVendorDetails")
721     public ModelAndView updateVendorDetails(@ModelAttribute("KualiForm") TransactionalDocumentFormBase form, BindingResult result,
722                                                  HttpServletRequest request, HttpServletResponse response) throws Exception {
723         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) form;
724         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
725         OleGokbPlatform oleGokbPlatform = getBusinessObjectService().findBySinglePrimaryKey(OleGokbPlatform.class, olePlatformRecordDocument.getGokbId());
726         if (oleGokbPlatform!=null && oleGokbPlatform.getPlatformProviderId()!=null){
727             OleGokbOrganization oleGokbOrganization =  getBusinessObjectService().findBySinglePrimaryKey(OleGokbOrganization.class, oleGokbPlatform.getPlatformProviderId());
728             if (oleGokbOrganization != null && oleGokbOrganization.getGokbOrganizationId() != null) {
729                 Map<String, Integer> vendorMap = new HashMap();
730                 vendorMap.put(OLEConstants.GOKB_ID, oleGokbOrganization.getGokbOrganizationId());
731                 List<VendorDetail> vendorDetails = (List<VendorDetail>) KRADServiceLocator.getBusinessObjectService().findMatching(VendorDetail.class, vendorMap);
732                 if (vendorDetails != null && vendorDetails.size() > 0) {
733                     olePlatformRecordDocument.setVendorHeaderGeneratedIdentifier(vendorDetails.get(0).getVendorHeaderGeneratedIdentifier());
734                     olePlatformRecordDocument.setVendorDetailAssignedIdentifier(vendorDetails.get(0).getVendorDetailAssignedIdentifier());
735                     olePlatformRecordDocument.setPlatformProviderName(vendorDetails.get(0).getVendorName());
736                     olePlatformRecordDocument.setActiveVendor(vendorDetails.get(0).isActiveIndicator());
737                 }
738             }
739         }
740         olePlatformRecordDocument.setPlatformProviderFlag(false);
741         return super.navigate(olePlatformRecordForm, result, request, response);
742     }
743 
744 
745     @Override
746     public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request, HttpServletResponse response) throws Exception {
747         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) form;
748         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
749         olePlatformRecordDocument.setSaveValidationFlag(false);
750         if (olePlatformRecordDocument.getGokbPlatformId() != 0) {
751             olePlatformRecordDocument.setGokbPlatformFlag(true);
752             StringBuffer gokbMessge = new StringBuffer();
753             gokbMessge.append("Linking this Platform record to a GOKb identifier will overwrite the following fields with GOKb-provided metadata: ");
754             gokbMessge.append(OLEConstants.BREAK);
755             gokbMessge.append("GOKb Identifier, Platform Name, Platform Provider Name, and Software.");
756             gokbMessge.append(OLEConstants.BREAK);
757             gokbMessge.append("This data will no longer be editable. Select “OK” to proceed.");
758             olePlatformRecordDocument.setGokbMessage(gokbMessge.toString());
759             super.refresh(olePlatformRecordForm, result, request, response);
760             return getUIFModelAndView(olePlatformRecordForm);
761         }
762         return super.refresh(olePlatformRecordForm, result, request, response);
763     }
764 
765     @RequestMapping(params = "methodToCall=setGokbFields")
766     public ModelAndView setGokbFields(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
767                                       HttpServletRequest request, HttpServletResponse response) throws InterruptedException {
768         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
769         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
770         olePlatformRecordDocument.setPlatformProviderFlag(false);
771         olePlatformRecordDocument.setSaveValidationFlag(false);
772         if (olePlatformRecordDocument.getGokbPlatformId() != 0) {
773             OleGokbPlatform oleGokbPlatform = getBusinessObjectService().findBySinglePrimaryKey(OleGokbPlatform.class, olePlatformRecordDocument.getGokbPlatformId());
774             if (oleGokbPlatform != null) {
775                 olePlatformRecordDocument.setGokbId(oleGokbPlatform.getGokbPlatformId());
776                 olePlatformRecordDocument.setName(oleGokbPlatform.getPlatformName());
777                 olePlatformRecordDocument.setSoftware(oleGokbPlatform.getSoftwarePlatform());
778                 olePlatformRecordDocument.setStatusId(oleGokbPlatform.getStatusId());
779                 if (oleGokbPlatform.getPlatformProviderId() != null) {
780                     OleGokbOrganization oleGokbOrganization = getBusinessObjectService().findBySinglePrimaryKey(OleGokbOrganization.class, oleGokbPlatform.getPlatformProviderId());
781                     if (oleGokbOrganization != null && oleGokbOrganization.getGokbOrganizationId() != null) {
782                         Map vendorMap = new HashMap();
783                         vendorMap.put(OLEConstants.GOKB_ID, oleGokbOrganization.getGokbOrganizationId());
784                         List<VendorDetail> vendorDetails = (List<VendorDetail>) getBusinessObjectService().findMatching(VendorDetail.class, vendorMap);
785                         if (vendorDetails != null && vendorDetails.size() > 0) {
786                             getOleEResourceSearchService().updateVendor(vendorDetails.get(0), oleGokbOrganization.getOrganizationName());
787                             olePlatformRecordDocument.setVendorHeaderGeneratedIdentifier(vendorDetails.get(0).getVendorHeaderGeneratedIdentifier());
788                             olePlatformRecordDocument.setVendorDetailAssignedIdentifier(vendorDetails.get(0).getVendorDetailAssignedIdentifier());
789                             olePlatformRecordDocument.setPlatformProviderName(vendorDetails.get(0).getVendorName());
790                             olePlatformRecordDocument.setActiveVendor(vendorDetails.get(0).isActiveIndicator());
791                         } else {
792                             getOleEResourceSearchService().createVendor(oleGokbOrganization.getOrganizationName(), oleGokbOrganization.getGokbOrganizationId(), oleGokbOrganization.getVariantName());
793                             Thread.sleep(300);
794                             olePlatformRecordDocument.setPlatformProviderFlag(true);
795                         }
796                     }
797                 }
798             }
799         }
800         return super.navigate(olePlatformRecordForm, result, request, response);
801     }
802 
803     @RequestMapping(params = "methodToCall=validatePlatformProvider")
804     public ModelAndView validatePlatformProvider(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
805                                       HttpServletRequest request, HttpServletResponse response){
806         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
807         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
808         olePlatformRecordDocument.setPlatformProviderFlag(false);
809         olePlatformRecordDocument.setSaveValidationFlag(false);
810         olePlatformRecordDocument.setPlatformProviderMessage(null);
811         olePlatformRecordDocument.setVendorDetailAssignedIdentifier(null);
812         olePlatformRecordDocument.setVendorHeaderGeneratedIdentifier(null);
813         olePlatformRecordDocument.setVendorId(null);
814         if (StringUtils.isNotBlank(olePlatformRecordDocument.getPlatformProviderName())) {
815             Map vendorMap = new HashMap();
816             vendorMap.put(OLEConstants.VENDOR_NAME, olePlatformRecordDocument.getPlatformProviderName());
817             List<VendorDetail> vendorDetails = (List<VendorDetail>) KRADServiceLocator.getBusinessObjectService().findMatching(VendorDetail.class, vendorMap);
818             if (vendorDetails != null && vendorDetails.size() > 0) {
819                 olePlatformRecordDocument.setPlatformProviderFlag(true);
820                 olePlatformRecordDocument.setPlatformProviderMessage("You are about to link this platform to "+olePlatformRecordDocument.getPlatformProviderName()+"  Do you wish to proceed?");
821                 olePlatformRecordDocument.setVendorHeaderGeneratedIdentifier(vendorDetails.get(0).getVendorHeaderGeneratedIdentifier());
822                 olePlatformRecordDocument.setVendorDetailAssignedIdentifier(vendorDetails.get(0).getVendorDetailAssignedIdentifier());
823                 olePlatformRecordDocument.setActiveVendor(vendorDetails.get(0).isActiveIndicator());
824             }else {
825                 olePlatformRecordForm.setMessage("Invalid Platform Provider " + olePlatformRecordDocument.getPlatformProviderName());
826                 olePlatformRecordDocument.setSaveValidationFlag(true);
827             }
828         }
829         return getUIFModelAndView(olePlatformRecordForm);
830     }
831 
832     @RequestMapping(params = "methodToCall=setVendorFields")
833     public ModelAndView setVendorFields(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
834                                                  HttpServletRequest request, HttpServletResponse response){
835         OLEPlatformRecordForm olePlatformRecordForm = (OLEPlatformRecordForm) uifForm;
836         OLEPlatformRecordDocument olePlatformRecordDocument = (OLEPlatformRecordDocument) olePlatformRecordForm.getDocument();
837         olePlatformRecordDocument.setPlatformProviderName(null);
838         olePlatformRecordDocument.setVendorId(null);
839         olePlatformRecordDocument.setVendorHeaderGeneratedIdentifier(null);
840         olePlatformRecordDocument.setVendorDetailAssignedIdentifier(null);
841         return getUIFModelAndView(olePlatformRecordForm);
842     }
843 
844 }