01 package com.bea.medrec.actions;
02
03 import com.bea.medrec.beans.RecordBean;
04 import com.bea.medrec.utils.ClientException;
05 import com.bea.medrec.utils.MedRecLog4jFactory;
06 import com.bea.medrec.value.Record;
07 import javax.servlet.http.HttpServletRequest;
08 import javax.servlet.http.HttpServletResponse;
09 import org.apache.log4j.Logger;
10 import org.apache.struts.action.ActionForm;
11 import org.apache.struts.action.ActionForward;
12 import org.apache.struts.action.ActionMapping;
13
14 /**
15 * <p>Controller to retrieve a particular medical record.</p>
16 *
17 * @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
18 */
19 public class ViewRecordAction extends PatientBaseAction {
20
21 private static Logger logger =
22 MedRecLog4jFactory.getLogger(ViewRecordAction.class.getName());
23
24 /**
25 * <p>Process the specified HTTP request, and create the corresponding HTTP
26 * response (or forward to another web component that will create it).
27 * Return an <code>ActionForward</code> instance describing where and how
28 * control should be forwarded.
29 * <br>
30 * Retrieves a particular record.
31 * </p>
32 *
33 * @param mapping The ActionMapping used to select this instance
34 * @param form The optional ActionForm bean for this request (if any)
35 * @param request The HTTP request we are processing
36 * @param response The HTTP response we are creating
37 */
38 public ActionForward executeAction(ActionMapping mapping,
39 ActionForm form,
40 HttpServletRequest request,
41 HttpServletResponse response)
42 throws ClientException, Exception {
43 Record record = null;
44 RecordBean recordBean = null;
45 String recordId = request.getParameter("id");
46 logger.debug("RecId: " + recordId);
47
48 try {
49 if (isEmpty(recordId)) {
50 throw new ClientException("Record not found.");
51 }
52
53 // Pass record id to be retrieved.
54 record = getRecordSession().getRecord(Integer.valueOf(recordId));
55
56 if (record == null) throw new ClientException("Record not found.");
57 } catch (Exception e) {
58 throwClientException(e, mapping, "view.records.summary");
59 }
60
61 // Convert record value object to presentation object.
62 recordBean = new RecordBean(record);
63
64 // Let's see the record.
65 logger.debug(recordBean.toString());
66
67 // Set on request to be display by view.
68 request.setAttribute(RECORD_BEAN, recordBean);
69
70 return mapping.findForward("view.record");
71 }
72 }
|