01: /**********************************************************************************
02: * $URL:https://source.sakaiproject.org/svn/osp/trunk/reports/tool/src/java/org/theospi/portfolio/reports/tool/DecoratedReportDefinition.java $
03: * $Id:DecoratedReportDefinition.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.portfolio.reports.tool;
21:
22: import org.theospi.portfolio.reports.model.Report;
23: import org.theospi.portfolio.reports.model.ReportDefinition;
24: import org.theospi.portfolio.reports.model.ReportResult;
25:
26: /**
27: * This class allows the ReportDefinition to interact with
28: *
29: */
30: public class DecoratedReportDefinition {
31:
32: /** The link to the main tool */
33: private ReportsTool reportsTool = null;
34:
35: /** The report definition to decorate */
36: private ReportDefinition reportDefinition = null;
37:
38: public DecoratedReportDefinition(ReportDefinition reportDefinition,
39: ReportsTool reportsTool) {
40: this .reportDefinition = reportDefinition;
41: this .reportsTool = reportsTool;
42: }
43:
44: public ReportDefinition getReportDefinition() {
45: return reportDefinition;
46: }
47:
48: /**
49: * An action called from the JSP through the JSF framework.
50: * @return String the next page
51: */
52: public String selectReportDefinition() {
53: reportsTool.setWorkingReportDefinition(this );
54: Report report = reportsTool.getReportsManager().createReport(
55: reportDefinition);
56:
57: reportsTool.setWorkingReport(new DecoratedReport(reportsTool
58: .getReportsManager().createReport(reportDefinition),
59: reportsTool));
60:
61: if (!reportDefinition.isUsesWizard()) {
62:
63: //run the report and then send to results page
64: reportsTool.getWorkingReport();
65:
66: report.setTitle(reportDefinition.getTitle());
67: report.setDescription(reportDefinition.getDescription());
68: report.setIsLive(true);
69:
70: ReportResult result = reportsTool.getReportsManager()
71: .generateResults(report);
72: reportsTool.setWorkingResult(new DecoratedReportResult(
73: result, reportsTool));
74:
75: //result.setResultId();
76: //result = reportsTool.getReportsManager().loadResult(result);
77:
78: //result.setDescription(reportDefinition.getDescription());
79: //result.setTitle(reportDefinition.getTitle());
80: result.setIsSaved(false);
81:
82: // make it the working result
83:
84: return ReportsTool.reportResultsPage;
85: }
86: return ReportsTool.createReportPage;
87: }
88:
89: public String processDelete() {
90: return reportsTool.processDeleteReportDef(this
91: .getReportDefinition());
92: }
93: }
|