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.PortletRenderMiner;
08: import com.sun.portal.ubt.report.data.file.derived.PortletDataSource;
09: import com.sun.portal.ubt.report.view.chart.PortletChart;
10: import com.sun.portal.ubt.report.view.toc.PortletRenderToc;
11: import com.sun.portal.ubt.report.view.IllegalMinerException;
12: import com.sun.portal.ubt.report.view.IllegalDataSourceException;
13: import com.sun.portal.ubt.report.util.UBTReportResourceBundle;
14: import net.sf.jasperreports.engine.JasperReport;
15: import net.sf.jasperreports.engine.JRException;
16: import net.sf.jasperreports.engine.JasperFillManager;
17: import net.sf.jasperreports.engine.JasperPrint;
18: import net.sf.jasperreports.engine.JRParameter;
19: import net.sf.jasperreports.engine.data.JRTableModelDataSource;
20: import net.sf.jasperreports.engine.util.JRLoader;
21:
22: import java.util.ResourceBundle;
23:
24: /**
25: *
26: */
27: public class PortletRenderReport extends UBTReportAdapter {
28: public static final String PORTLET_BAR = "PortletBar";
29: public static final String PORTLET_RENDER_TOC = "PortletRenderToc";
30: PortletDataSource dataSource;
31:
32: public PortletRenderReport() {
33: this .reportName = UBTReportI.PORTLET_RENDER;
34: this .miner[0] = new PortletRenderMiner();
35: }
36:
37: private void prepareToFill() throws IllegalMinerException,
38: JRException, IllegalDataSourceException {
39: dataSource = new PortletDataSource(miner[0]);
40: this .reportParameters.put(
41: UBTReportI.REPORT_LOCAL_DATE_PROPERTY, this .getLDate());
42: this .reportParameters.put(UBTReportI.REPORT_PORTAL_ID_PROPERTY,
43: miner[0].getPortalID());
44: this .reportParameters.put(UBTReportI.REPORT_LOGO_PROPERTY,
45: getLogo());
46: this .reportParameters.put(UBTReportI.REPORT_HELP_LINK_PROPERTY,
47: UBTReportI.PORTLET_RENDER_HELP);
48: try {
49: this .reportParameters.put(UBTReportI.REPORT_TOC_PROPERTY,
50: (JasperReport) JRLoader
51: .loadObject(getTocJasperFileName()));
52: } catch (JRException e) {
53: throw e;
54: }
55: try {
56: this .reportParameters.put(PORTLET_BAR, new PortletChart(
57: miner[0], this .clientLocale).getChart());
58: } catch (IllegalMinerException e) {
59: throw e;
60: }
61: try {
62: this .reportParameters.put(PORTLET_RENDER_TOC,
63: new PortletRenderToc(dataSource, clientLocale)
64: .getToc());
65: } catch (IllegalDataSourceException e) {
66: throw e;
67: }
68: this .reportParameters.put(JRParameter.REPORT_LOCALE,
69: this .clientLocale);
70: this .reportParameters.put(JRParameter.REPORT_RESOURCE_BUNDLE,
71: ResourceBundle.getBundle(
72: UBTReportResourceBundle.UBT_REPORT_RESOURCE,
73: clientLocale));
74: }
75:
76: public void fill() throws IllegalMinerException, JRException,
77: IllegalDataSourceException {
78: prepareToFill();
79: JasperFillManager.fillReportToFile(this .getJasperFileName(),
80: this .getJrprintFileName(), this .reportParameters,
81: new JRTableModelDataSource(dataSource));
82: }
83:
84: public JasperPrint getReport() throws IllegalMinerException,
85: JRException, IllegalDataSourceException {
86: prepareToFill();
87: return JasperFillManager.fillReport(this .getJasperFileName(),
88: this .reportParameters, new JRTableModelDataSource(
89: dataSource));
90: }
91: }
|