001/** 002 * Copyright 2004-2015 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.kpme.tklm.common; 017 018import javax.servlet.http.HttpServletRequest; 019import javax.servlet.http.HttpServletResponse; 020 021import org.apache.commons.lang.StringUtils; 022import org.apache.struts.action.ActionForm; 023import org.apache.struts.action.ActionForward; 024import org.apache.struts.action.ActionMapping; 025import org.kuali.kpme.core.web.KPMEAction; 026import org.kuali.kpme.tklm.leave.service.LmServiceLocator; 027import org.kuali.kpme.tklm.leave.workflow.LeaveCalendarDocumentHeader; 028import org.kuali.kpme.tklm.time.service.TkServiceLocator; 029import org.kuali.kpme.tklm.time.workflow.TimesheetDocumentHeader; 030import org.kuali.rice.kew.service.KEWServiceLocator; 031 032public class DeleteDocumentAction extends KPMEAction { 033 034 public ActionForward deleteDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 035 DeleteDocumentForm deleteDocumentForm = (DeleteDocumentForm) form; 036 String documentId = deleteDocumentForm.getDeleteDocumentId(); 037 038 if (StringUtils.isNotBlank(documentId)) { 039 TimesheetDocumentHeader tdh = TkServiceLocator.getTimesheetDocumentHeaderService().getDocumentHeader(documentId); 040 LeaveCalendarDocumentHeader ldh = LmServiceLocator.getLeaveCalendarDocumentHeaderService().getDocumentHeader(documentId); 041 042 if(tdh != null) { 043 TkServiceLocator.getClockLogService().deleteClockLogsForDocumentId(documentId); 044 TkServiceLocator.getTimeBlockService().deleteTimeBlocksAssociatedWithDocumentId(documentId); 045 TkServiceLocator.getTimesheetService().deleteTimesheet(documentId); 046 } else if (ldh != null) { 047 LmServiceLocator.getLeaveBlockService().deleteLeaveBlocksForDocumentId(documentId); 048 LmServiceLocator.getLeaveCalendarDocumentHeaderService().deleteLeaveCalendarHeader(documentId); 049 } 050 051 // KPME - 3294 : Delete ActionList items 052 KEWServiceLocator.getActionListService().deleteByDocumentId(documentId); 053 054 } 055 056 return mapping.findForward("basic"); 057 } 058 059}