01: /*
02: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.ubt.report.view.report;
06:
07: import com.sun.portal.ubt.report.data.file.raw.ChannelRenderMiner;
08: import com.sun.portal.ubt.report.data.file.derived.ChannelRenderDataSource;
09: import com.sun.portal.ubt.report.view.chart.ChannelRenderChart;
10: import com.sun.portal.ubt.report.view.chart.ChannelRenderUniqueUsersChart;
11: import com.sun.portal.ubt.report.view.toc.PortalChannelRenderToc;
12: import com.sun.portal.ubt.report.view.IllegalMinerException;
13: import com.sun.portal.ubt.report.view.IllegalDataSourceException;
14: import com.sun.portal.ubt.report.util.UBTReportResourceBundle;
15: import net.sf.jasperreports.engine.JasperReport;
16: import net.sf.jasperreports.engine.JRException;
17: import net.sf.jasperreports.engine.JasperFillManager;
18: import net.sf.jasperreports.engine.JasperPrint;
19: import net.sf.jasperreports.engine.JRParameter;
20: import net.sf.jasperreports.engine.data.JRTableModelDataSource;
21: import net.sf.jasperreports.engine.util.JRLoader;
22:
23: import java.util.ResourceBundle;
24:
25: /**
26: *
27: */
28: public class PortalChannelRenderReport extends UBTReportAdapter {
29: private static final String PORTAL_CHANNEL_RENDER_PIE = "ChannelRenderPie";
30: private static final String PORTAL_CHANNEL_RENDER_BAR = "ChannelRenderBar";
31: private static final String PORTAL_CHANNEL_RENDER_TOC = "PortalChannelRenderToc";
32: ChannelRenderDataSource dataSource;
33:
34: public PortalChannelRenderReport() {
35: this .reportName = UBTReportI.PORTAL_CHANNEL_RENDER;
36: this .miner[0] = new ChannelRenderMiner();
37: }
38:
39: private void prepareToFill() throws IllegalMinerException,
40: IllegalDataSourceException, JRException {
41: dataSource = new ChannelRenderDataSource(miner[0]);
42: this .reportParameters.put(
43: UBTReportI.REPORT_LOCAL_DATE_PROPERTY, this .getLDate());
44: this .reportParameters.put(UBTReportI.REPORT_PORTAL_ID_PROPERTY,
45: miner[0].getPortalID());
46: this .reportParameters.put(UBTReportI.REPORT_LOGO_PROPERTY,
47: getLogo());
48: this .reportParameters.put(UBTReportI.REPORT_HELP_LINK_PROPERTY,
49: UBTReportI.PORTAL_CHANNEL_RENDER_HELP);
50: try {
51: this .reportParameters.put(UBTReportI.REPORT_TOC_PROPERTY,
52: (JasperReport) JRLoader
53: .loadObject(getTocJasperFileName()));
54: } catch (JRException e) {
55: throw e;
56: }
57: try {
58: this .reportParameters.put(PORTAL_CHANNEL_RENDER_PIE,
59: new ChannelRenderChart(miner[0], this .clientLocale)
60: .getChart());
61: this .reportParameters.put(PORTAL_CHANNEL_RENDER_BAR,
62: new ChannelRenderUniqueUsersChart(miner[0],
63: this .clientLocale).getChart());
64: } catch (IllegalMinerException e) {
65: throw e;
66: }
67: try {
68: this .reportParameters
69: .put(PORTAL_CHANNEL_RENDER_TOC,
70: new PortalChannelRenderToc(dataSource,
71: clientLocale).getToc());
72: } catch (IllegalDataSourceException e) {
73: throw e;
74: }
75: this .reportParameters.put(JRParameter.REPORT_LOCALE,
76: this .clientLocale);
77: this .reportParameters.put(JRParameter.REPORT_RESOURCE_BUNDLE,
78: ResourceBundle.getBundle(
79: UBTReportResourceBundle.UBT_REPORT_RESOURCE,
80: clientLocale));
81: }
82:
83: public void fill() throws IllegalMinerException,
84: IllegalDataSourceException, JRException {
85: prepareToFill();
86: JasperFillManager.fillReportToFile(this .getJasperFileName(),
87: this .getJrprintFileName(), this .reportParameters,
88: new JRTableModelDataSource(dataSource));
89: }
90:
91: public JasperPrint getReport() throws IllegalMinerException,
92: JRException, IllegalDataSourceException {
93: prepareToFill();
94: return JasperFillManager.fillReport(this .getJasperFileName(),
95: this .reportParameters, new JRTableModelDataSource(
96: dataSource));
97: }
98: }
|