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.toc;
006:
007: import com.sun.portal.ubt.report.data.file.derived.UBTDataSourceI;
008: import com.sun.portal.ubt.report.data.file.derived.ChannelWiseActionsDataSource;
009: import com.sun.portal.ubt.report.view.IllegalDataSourceException;
010: import com.sun.portal.ubt.report.view.chart.ContainerWiseUserActionsChart;
011: import com.sun.portal.ubt.report.view.chart.ContainerWiseActionsChart;
012:
013: import java.util.ArrayList;
014: import java.util.Locale;
015:
016: /**
017: *
018: */
019: public class PortalUserCustomizationToc extends ReportTocAdapter {
020: public static final String Summary = "Summary";
021: public static final String ActOnChanOfCon = "ActOnChanOfCon";
022: public static final String PopConChanNumInt = "PopConChanNumInt";
023: public static final String PopConChanNumIntUnique = "PopConChanNumIntUnique";
024: public static final String ChannelWiseActions = "ChannelWiseActions";
025:
026: public PortalUserCustomizationToc(UBTDataSourceI dataSource,
027: Locale locale) throws IllegalDataSourceException {
028: super (dataSource, locale);
029: if (!(dataSource instanceof ChannelWiseActionsDataSource))
030: throw new IllegalDataSourceException();
031: }
032:
033: protected void createToc() {
034: Object[][] dataArray = dataSource.getData();
035: Object prevContainer = null;
036: Object prevChannel = null;
037: int i = 0;
038: for (i = 0; i < dataArray.length; i++) {
039: if (prevContainer == null && prevChannel == null) {
040: this .tocCollection
041: .addAll(containerBean(dataArray[i][0]));
042: this .tocCollection.add(channelBean(dataArray[i][0],
043: dataArray[i][1]));
044: prevContainer = dataArray[i][0];
045: prevChannel = dataArray[i][1];
046: continue;
047: }
048: if (!prevContainer.equals(dataArray[i][0])) {
049: this .tocCollection
050: .addAll(containerBean(dataArray[i][0]));
051: }
052: if (!prevChannel.equals(dataArray[i][1]))
053: this .tocCollection.add(channelBean(dataArray[i][0],
054: dataArray[i][1]));
055: prevContainer = dataArray[i][0];
056: prevChannel = dataArray[i][1];
057: }
058: this .tocCollection.addAll(summaryBean());
059: }
060:
061: private ArrayList containerBean(Object container) {
062: ArrayList toclist = new ArrayList();
063: toclist.add(new TOCBean(new Integer(0), reportsResource
064: .getReportProperty(ActOnChanOfCon)
065: + " " + (String) container, "ContainerHeadGroup_"
066: + container, null));
067: toclist.add(new TOCBean(new Integer(1), reportsResource
068: .getReportProperty(PortalChannelRenderToc.CompCharts),
069: null, null));
070: toclist.add(new TOCBean(new Integer(2), reportsResource
071: .getReportProperty(PopConChanNumInt),
072: "ContainerFootGroup_number_" + container, null));
073: toclist.add(new TOCBean(new Integer(2), reportsResource
074: .getReportProperty(PopConChanNumIntUnique),
075: "ContainerFootGroup_unique_" + container, null));
076: toclist.add(new TOCBean(new Integer(1), reportsResource
077: .getReportProperty(ChannelWiseActions),
078: "ContainerHeadGroup_" + container, null));
079: return toclist;
080: }
081:
082: private TOCBean channelBean(Object container, Object channel) {
083: return new TOCBean(new Integer(2), (String) channel,
084: "ChannelHeadGroup_" + container + "_" + channel, null);
085: }
086:
087: private ArrayList summaryBean() {
088: ArrayList toclist = new ArrayList();
089: toclist.add(new TOCBean(new Integer(0), reportsResource
090: .getReportProperty(Summary), "SummaryGroup", null));
091: toclist
092: .add(new TOCBean(
093: new Integer(1),
094: reportsResource
095: .getReportProperty(ContainerWiseActionsChart.ACTIONS_ON_CONTAINERS),
096: "SummaryActions", null));
097: toclist
098: .add(new TOCBean(
099: new Integer(1),
100: reportsResource
101: .getReportProperty(ContainerWiseUserActionsChart.POPULARITY_CONTAINER_PER_CUSTOM),
102: "SummaryPopularity", null));
103: return toclist;
104: }
105:
106: }
|