1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.web.struts;
17
18 import org.apache.struts.action.ActionForm;
19 import org.apache.struts.action.ActionForward;
20 import org.apache.struts.action.ActionMapping;
21 import org.kuali.ole.select.businessobject.OleRequestor;
22 import org.kuali.ole.select.document.service.OleRequestorService;
23 import org.kuali.ole.select.document.service.impl.OleRequestorServiceImpl;
24 import org.kuali.ole.select.document.web.struts.PersonRequestorLookUpForm;
25 import org.kuali.ole.sys.context.SpringContext;
26 import org.kuali.rice.core.api.util.RiceConstants;
27 import org.kuali.rice.core.api.util.RiceKeyConstants;
28 import org.kuali.rice.kns.util.KNSGlobalVariables;
29 import org.kuali.rice.kns.web.struts.action.KualiLookupAction;
30 import org.kuali.rice.kns.web.struts.form.KualiForm;
31
32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse;
34
35
36
37
38
39
40 public class PersonRequestorLookUpAction extends KualiLookupAction {
41 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PersonRequestorLookUpAction.class);
42
43
44
45
46
47
48
49
50
51
52
53 public ActionForward createNew(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
54
55 LOG.debug("PersonRequestorLookUpAction : createNew() method -- Starts");
56 PersonRequestorLookUpForm personRequestorLookUpForm = (PersonRequestorLookUpForm) form;
57
58 String firstName = personRequestorLookUpForm.getFirstName();
59 String lastName = personRequestorLookUpForm.getLastName();
60
61 if (firstName != null && lastName != null) {
62 OleRequestor oleRequestor = new OleRequestor();
63 oleRequestor.setRequestorFirstName(firstName);
64 oleRequestor.setRequestorLastName(lastName);
65 oleRequestor.setRequestorEmail(personRequestorLookUpForm.getEmail());
66 oleRequestor.setRequestorPhoneNumber(personRequestorLookUpForm.getPhoneNumber());
67 oleRequestor.setRequestorTypeId(personRequestorLookUpForm.getRequestorTypeId());
68 oleRequestor.setRefKrimId(personRequestorLookUpForm.getRefKrimId());
69
70 OleRequestorService oleRequestorService = SpringContext.getBean(OleRequestorServiceImpl.class);
71 oleRequestorService.saveRequestor(oleRequestor);
72 KNSGlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_ROUTE_SUCCESSFUL);
73 } else {
74 if (firstName == null) {
75 KNSGlobalVariables.getMessageList().add(RiceKeyConstants.ERROR_CUSTOM, "First Name Field is a requried field");
76 }
77 if (lastName == null) {
78 KNSGlobalVariables.getMessageList().add(RiceKeyConstants.ERROR_CUSTOM, "Last Name Field is a requried field");
79 }
80
81 }
82 LOG.debug("PersonRequestorLookUpAction : createNew() method -- End");
83 ((KualiForm) form).setMethodToCall("search");
84 super.search(mapping, form, request, response);
85 return mapping.findForward(RiceConstants.MAPPING_BASIC);
86 }
87
88
89 }