1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.web.struts;
17
18 import java.util.Properties;
19
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse;
22
23 import org.apache.log4j.Logger;
24 import org.apache.struts.action.ActionForm;
25 import org.apache.struts.action.ActionForward;
26 import org.apache.struts.action.ActionMapping;
27 import org.apache.struts.action.ActionMessage;
28 import org.apache.struts.action.ActionMessages;
29 import org.kuali.ole.fp.document.CashManagementDocument;
30 import org.kuali.ole.sys.OLEConstants;
31 import org.kuali.ole.sys.OLEKeyConstants;
32 import org.kuali.ole.sys.context.SpringContext;
33 import org.kuali.rice.kns.service.DataDictionaryService;
34 import org.kuali.rice.kns.web.struts.action.KualiAction;
35 import org.kuali.rice.krad.util.UrlFactory;
36
37
38
39
40
41 public class CashManagementStatusAction extends KualiAction {
42 private static Logger LOG = Logger.getLogger(CashManagementStatusAction.class);
43
44
45
46
47 public CashManagementStatusAction() {
48 }
49
50
51
52
53
54
55 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
56
57 CashManagementStatusForm cform = (CashManagementStatusForm) form;
58
59 if (cform.getMethodToCall().equals("docHandler")) {
60 cform.setMethodToCall("displayPage");
61 }
62
63
64 String[] msgParams = { cform.getVerificationUnit(), cform.getControllingDocumentId(), cform.getCurrentDrawerStatus(), cform.getDesiredDrawerStatus() };
65
66 ActionMessage message = new ActionMessage(OLEKeyConstants.CashDrawer.MSG_CASH_DRAWER_ALREADY_OPEN, msgParams);
67
68 ActionMessages messages = new ActionMessages();
69 messages.add(ActionMessages.GLOBAL_MESSAGE, message);
70 saveMessages(request, messages);
71
72 return super.execute(mapping, form, request, response);
73 }
74
75
76
77
78
79
80
81
82
83
84
85 public ActionForward displayPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
86 return mapping.findForward(OLEConstants.MAPPING_BASIC);
87 }
88
89
90
91
92
93
94
95
96
97
98 public ActionForward returnToIndex(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
99 return mapping.findForward(OLEConstants.MAPPING_CLOSE);
100 }
101
102
103
104
105
106
107
108
109
110
111
112 public ActionForward openExisting(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
113 CashManagementStatusForm cform = (CashManagementStatusForm) form;
114
115 String cmDocTypeName = SpringContext.getBean(DataDictionaryService.class).getValidDocumentTypeNameByClass(CashManagementDocument.class);
116
117 Properties params = new Properties();
118 params.setProperty("methodToCall", "docHandler");
119 params.setProperty("command", "displayDocSearchView");
120 params.setProperty("docId", cform.getControllingDocumentId());
121
122
123 String cmActionUrl = UrlFactory.parameterizeUrl(OLEConstants.CASH_MANAGEMENT_DOCUMENT_ACTION, params);
124
125 return new ActionForward(cmActionUrl, true);
126 }
127 }