1 21 package com.jaspersoft.jasperserver.war.action; 22 23 import java.util.List ; 24 25 import org.springframework.webflow.Event; 26 import org.springframework.webflow.RequestContext; 27 import org.springframework.webflow.action.MultiAction; 28 29 import com.jaspersoft.jasperserver.api.common.domain.ExecutionContext; 30 import com.jaspersoft.jasperserver.api.engine.scheduling.service.ReportSchedulingService; 31 import com.jaspersoft.jasperserver.war.common.JasperServerUtil; 32 33 37 public class ReportSchedulingListAction extends MultiAction { 38 39 private String reportUnitURIAttrName; 40 private String jobListAttrName; 41 private String selectedJobsParamName; 42 43 private ReportSchedulingService schedulingService; 44 45 public ReportSchedulingListAction() { 46 } 47 48 public ReportSchedulingService getSchedulingService() { 49 return schedulingService; 50 } 51 52 public void setSchedulingService(ReportSchedulingService schedulingService) { 53 this.schedulingService = schedulingService; 54 } 55 56 public String getJobListAttrName() { 57 return jobListAttrName; 58 } 59 60 public void setJobListAttrName(String jobListAttrName) { 61 this.jobListAttrName = jobListAttrName; 62 } 63 64 public String getReportUnitURIAttrName() { 65 return reportUnitURIAttrName; 66 } 67 68 public void setReportUnitURIAttrName(String reportUnitURIAttrName) { 69 this.reportUnitURIAttrName = reportUnitURIAttrName; 70 } 71 72 public String getSelectedJobsParamName() { 73 return selectedJobsParamName; 74 } 75 76 public void setSelectedJobsParamName(String selectedJobsParamName) { 77 this.selectedJobsParamName = selectedJobsParamName; 78 } 79 80 public Event listJobs(RequestContext context) { 81 String reportUnitURI = context.getFlowScope().getString(getReportUnitURIAttrName()); 82 List jobs = schedulingService.getScheduledJobs(getExecutionContext(context), reportUnitURI); 83 context.getRequestScope().put(getJobListAttrName(), jobs); 84 return success(); 85 } 86 87 public Event deleteJobs(RequestContext context) { 88 Object param = context.getRequestParameters().getMap().get(getSelectedJobsParamName()); 89 String [] selectedJobs; 90 if (param instanceof String ) { 91 selectedJobs = new String []{(String ) param}; 92 } else { 93 selectedJobs = (String []) param; 94 } 95 if (selectedJobs != null && selectedJobs.length > 0) { 96 long[] jobIds = new long[selectedJobs.length]; 97 for (int i = 0; i < selectedJobs.length; i++) { 98 jobIds[i] = Long.parseLong(selectedJobs[i]); 99 } 100 schedulingService.removeScheduledJobs(getExecutionContext(context), jobIds); 101 } 102 103 return success(); 104 } 105 106 protected ExecutionContext getExecutionContext(RequestContext context) { 107 return JasperServerUtil.getExecutionContext(context); 108 } 109 110 } 111 | Popular Tags |