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 import org.kuali.rice.kew.service.KEWServiceLocator;
31
32 public class DeleteDocumentAction extends KPMEAction {
33
34 public ActionForward deleteDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
35 DeleteDocumentForm deleteDocumentForm = (DeleteDocumentForm) form;
36 String documentId = deleteDocumentForm.getDeleteDocumentId();
37
38 if (StringUtils.isNotBlank(documentId)) {
39 TimesheetDocumentHeader tdh = TkServiceLocator.getTimesheetDocumentHeaderService().getDocumentHeader(documentId);
40 LeaveCalendarDocumentHeader ldh = LmServiceLocator.getLeaveCalendarDocumentHeaderService().getDocumentHeader(documentId);
41
42 if(tdh != null) {
43 TkServiceLocator.getClockLogService().deleteClockLogsForDocumentId(documentId);
44 TkServiceLocator.getTimeBlockService().deleteTimeBlocksAssociatedWithDocumentId(documentId);
45 TkServiceLocator.getTimesheetService().deleteTimesheet(documentId);
46 deleteDocumentForm.setMessage("Timesheet deleted sucessfully.");
47 } else if (ldh != null) {
48 LmServiceLocator.getLeaveBlockService().deleteLeaveBlocksForDocumentId(documentId);
49 LmServiceLocator.getLeaveCalendarDocumentHeaderService().deleteLeaveCalendarHeader(documentId);
50 deleteDocumentForm.setMessage("Leave Calendar deleted sucessfully.");
51 }
52
53
54 KEWServiceLocator.getActionListService().deleteByDocumentId(documentId);
55
56 }
57
58 return mapping.findForward("basic");
59 }
60
61 }