KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > war > action > ReportSchedulingListAction


1 /*
2  * Copyright (C) 2006 JasperSoft http://www.jaspersoft.com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed WITHOUT ANY WARRANTY; and without the
10  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15  * or write to:
16  *
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330,
19  * Boston, MA USA 02111-1307
20  */

21 package com.jaspersoft.jasperserver.war.action;
22
23 import java.util.List JavaDoc;
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 /**
34  * @author Lucian Chirita (lucianc@users.sourceforge.net)
35  * @version $Id: ReportSchedulingListAction.java 3607 2006-06-08 16:20:56Z lucian $
36  */

37 public class ReportSchedulingListAction extends MultiAction {
38     
39     private String JavaDoc reportUnitURIAttrName;
40     private String JavaDoc jobListAttrName;
41     private String JavaDoc 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 JavaDoc getJobListAttrName() {
57         return jobListAttrName;
58     }
59
60     public void setJobListAttrName(String JavaDoc jobListAttrName) {
61         this.jobListAttrName = jobListAttrName;
62     }
63
64     public String JavaDoc getReportUnitURIAttrName() {
65         return reportUnitURIAttrName;
66     }
67
68     public void setReportUnitURIAttrName(String JavaDoc reportUnitURIAttrName) {
69         this.reportUnitURIAttrName = reportUnitURIAttrName;
70     }
71
72     public String JavaDoc getSelectedJobsParamName() {
73         return selectedJobsParamName;
74     }
75
76     public void setSelectedJobsParamName(String JavaDoc selectedJobsParamName) {
77         this.selectedJobsParamName = selectedJobsParamName;
78     }
79
80     public Event listJobs(RequestContext context) {
81         String JavaDoc reportUnitURI = context.getFlowScope().getString(getReportUnitURIAttrName());
82         List JavaDoc 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 JavaDoc param = context.getRequestParameters().getMap().get(getSelectedJobsParamName());
89         String JavaDoc[] selectedJobs;
90         if (param instanceof String JavaDoc) {
91             selectedJobs = new String JavaDoc[]{(String JavaDoc) param};
92         } else {
93             selectedJobs = (String JavaDoc[]) 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