001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.ubt.report.view.report;
006:
007: import com.sun.portal.ubt.report.data.file.raw.ChannelWiseActionsMiner;
008: import com.sun.portal.ubt.report.data.file.raw.ChannelWiseUserActionsMiner;
009: import com.sun.portal.ubt.report.data.file.derived.ChannelWiseActionsDataSource;
010: import com.sun.portal.ubt.report.data.file.derived.ChannelWiseUserActionsDataSource;
011: import com.sun.portal.ubt.report.data.DataMiner;
012: import com.sun.portal.ubt.report.view.chart.*;
013: import com.sun.portal.ubt.report.view.toc.PortalUserCustomizationToc;
014: import com.sun.portal.ubt.report.view.IllegalMinerException;
015: import com.sun.portal.ubt.report.view.IllegalDataSourceException;
016: import com.sun.portal.ubt.report.util.UBTReportResourceBundle;
017: import net.sf.jasperreports.engine.JasperReport;
018: import net.sf.jasperreports.engine.JRException;
019: import net.sf.jasperreports.engine.JasperFillManager;
020: import net.sf.jasperreports.engine.JasperPrint;
021: import net.sf.jasperreports.engine.JRParameter;
022: import net.sf.jasperreports.engine.data.JRTableModelDataSource;
023: import net.sf.jasperreports.engine.util.JRLoader;
024:
025: import java.util.ResourceBundle;
026:
027: /**
028: *
029: */
030: public class PortalUserCustomizationReport extends UBTReportAdapter {
031: public static final String BAR_CHARTS = "BarCharts";
032: public static final String PIE_CHARTS = "PieCharts";
033: public static final String SUMMARY_BAR_CHARTS = "SummaryBarChart";
034: public static final String SUMMARY_PIE_CHARTS = "SummaryPieChart";
035: public static final String PORTAL_USER_CUSTOMIZATION_TOC = "PortalUserCustomizationToc";
036: ChannelWiseActionsDataSource dataSource;
037: ChannelWiseUserActionsDataSource dataSource1;
038:
039: public PortalUserCustomizationReport() {
040: this .reportName = UBTReportI.PORTAL_USER_CUSTOMIZATION;
041: this .miner = new DataMiner[2];
042: this .miner[0] = new ChannelWiseActionsMiner();
043: this .miner[1] = new ChannelWiseUserActionsMiner();
044: }
045:
046: private void prepareToFill() throws IllegalMinerException,
047: JRException, IllegalDataSourceException {
048: dataSource = new ChannelWiseActionsDataSource(miner[0]);
049: this .reportParameters.put(
050: UBTReportI.REPORT_LOCAL_DATE_PROPERTY, this .getLDate());
051: this .reportParameters.put(UBTReportI.REPORT_PORTAL_ID_PROPERTY,
052: miner[0].getPortalID());
053: dataSource1 = new ChannelWiseUserActionsDataSource(miner[1]);
054: this .reportParameters.put(UBTReportI.REPORT_LOGO_PROPERTY,
055: getLogo());
056: this .reportParameters.put(UBTReportI.REPORT_HELP_LINK_PROPERTY,
057: UBTReportI.PORTAL_USER_CUSTOMIZATION_HELP);
058: try {
059: this .reportParameters.put(UBTReportI.REPORT_TOC_PROPERTY,
060: (JasperReport) JRLoader
061: .loadObject(getTocJasperFileName()));
062: } catch (JRException e) {
063: throw e;
064: }
065: try {
066: this .reportParameters.put(BAR_CHARTS,
067: new ChannelWiseActionsChart(miner[0],
068: this .clientLocale).getChart());
069: this .reportParameters.put(PIE_CHARTS,
070: new ChannelWiseUserActionsChart(miner[1],
071: this .clientLocale).getChart());
072: this .reportParameters.put(SUMMARY_BAR_CHARTS,
073: new ContainerWiseActionsChart(miner[0],
074: this .clientLocale).getChart());
075: this .reportParameters.put(SUMMARY_PIE_CHARTS,
076: new ContainerWiseUserActionsChart(miner[1],
077: this .clientLocale).getChart());
078: } catch (IllegalMinerException e) {
079: throw e;
080: }
081: try {
082: this .reportParameters.put(PORTAL_USER_CUSTOMIZATION_TOC,
083: new PortalUserCustomizationToc(dataSource,
084: clientLocale).getToc());
085: } catch (IllegalDataSourceException e) {
086: throw e;
087: }
088: this .reportParameters.put(JRParameter.REPORT_LOCALE,
089: this .clientLocale);
090: this .reportParameters.put(JRParameter.REPORT_RESOURCE_BUNDLE,
091: ResourceBundle.getBundle(
092: UBTReportResourceBundle.UBT_REPORT_RESOURCE,
093: clientLocale));
094: }
095:
096: public void fill() throws IllegalMinerException, JRException,
097: IllegalDataSourceException {
098: prepareToFill();
099: JasperFillManager.fillReportToFile(this .getJasperFileName(),
100: this .getJrprintFileName(), this .reportParameters,
101: new JRTableModelDataSource(dataSource1));
102: }
103:
104: public JasperPrint getReport() throws IllegalMinerException,
105: JRException, IllegalDataSourceException {
106: prepareToFill();
107: return JasperFillManager.fillReport(this .getJasperFileName(),
108: this .reportParameters, new JRTableModelDataSource(
109: dataSource1));
110: }
111: }
|