1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.common;
17
18 import javax.servlet.http.HttpServletRequest;
19 import javax.servlet.http.HttpServletResponse;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.apache.struts.action.ActionForm;
23 import org.apache.struts.action.ActionForward;
24 import org.apache.struts.action.ActionMapping;
25 import org.kuali.kpme.core.web.KPMEAction;
26 import org.kuali.kpme.tklm.leave.service.LmServiceLocator;
27 import org.kuali.kpme.tklm.leave.workflow.LeaveCalendarDocumentHeader;
28 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
29 import org.kuali.kpme.tklm.time.workflow.TimesheetDocumentHeader;
30
31 public class DeleteDocumentAction extends KPMEAction {
32
33 public ActionForward deleteDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
34 DeleteDocumentForm deleteDocumentForm = (DeleteDocumentForm) form;
35 String documentId = deleteDocumentForm.getDeleteDocumentId();
36
37 if (StringUtils.isNotBlank(documentId)) {
38 TimesheetDocumentHeader tdh = TkServiceLocator.getTimesheetDocumentHeaderService().getDocumentHeader(documentId);
39 LeaveCalendarDocumentHeader ldh = LmServiceLocator.getLeaveCalendarDocumentHeaderService().getDocumentHeader(documentId);
40
41 if(tdh != null) {
42 TkServiceLocator.getClockLogService().deleteClockLogsForDocumentId(documentId);
43 TkServiceLocator.getTimeBlockService().deleteTimeBlocksAssociatedWithDocumentId(documentId);
44 TkServiceLocator.getTimesheetService().deleteTimesheet(documentId);
45 } else if (ldh != null) {
46 LmServiceLocator.getLeaveBlockService().deleteLeaveBlocksForDocumentId(documentId);
47 LmServiceLocator.getLeaveCalendarDocumentHeaderService().deleteLeaveCalendarHeader(documentId);
48 }
49 }
50
51 return mapping.findForward("basic");
52 }
53
54 }