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.toc;
06:
07: import com.sun.portal.ubt.report.data.file.derived.UBTDataSourceI;
08: import com.sun.portal.ubt.report.data.file.derived.ChannelRenderDataSource;
09: import com.sun.portal.ubt.report.view.IllegalDataSourceException;
10:
11: import java.util.ArrayList;
12: import java.util.Locale;
13:
14: /**
15: *
16: */
17: public class PortalChannelRenderToc extends ReportTocAdapter {
18: public static final String ChannelViewsOfContainer = "ChannelViewsOfContainer";
19: public static final String CompCharts = "CompCharts";
20: public static final String PopContainerChannelsUnique = "PopContainerChannelsUnique";
21: public static final String PopContainerChannelsView = "PopContainerChannelsView";
22: public static final String ChannelWiseUser = "ChannelWiseUser";
23:
24: public PortalChannelRenderToc(UBTDataSourceI dataSource,
25: Locale locale) throws IllegalDataSourceException {
26: super (dataSource, locale);
27: if (!(dataSource instanceof ChannelRenderDataSource))
28: throw new IllegalDataSourceException();
29: }
30:
31: protected void createToc() {
32: Object[][] dataArray = dataSource.getData();
33: Object prevContainer = null;
34: Object prevChannel = null;
35: int i = 0;
36: for (i = 0; i < dataArray.length; i++) {
37: if (prevContainer == null && prevChannel == null) {
38: this .tocCollection
39: .addAll(containerBean(dataArray[i][0]));
40: this .tocCollection.add(channelBean(dataArray[i][0],
41: dataArray[i][1]));
42: prevContainer = dataArray[i][0];
43: prevChannel = dataArray[i][1];
44: continue;
45: }
46: if (!prevContainer.equals(dataArray[i][0])) {
47: this .tocCollection
48: .addAll(containerBean(dataArray[i][0]));
49: }
50: if (!prevChannel.equals(dataArray[i][1]))
51: this .tocCollection.add(channelBean(dataArray[i][0],
52: dataArray[i][1]));
53: prevContainer = dataArray[i][0];
54: prevChannel = dataArray[i][1];
55: }
56: }
57:
58: private ArrayList containerBean(Object container) {
59: ArrayList toclist = new ArrayList();
60: toclist.add(new TOCBean(new Integer(0), reportsResource
61: .getReportProperty(ChannelViewsOfContainer)
62: + " " + (String) container, "ContainerHeadGroup_"
63: + container, null));
64: toclist.add(new TOCBean(new Integer(1), reportsResource
65: .getReportProperty(CompCharts), null, null));
66: toclist.add(new TOCBean(new Integer(2), reportsResource
67: .getReportProperty(PopContainerChannelsUnique),
68: "ContainerFootGroup_unique_" + container, null));
69: toclist.add(new TOCBean(new Integer(2), reportsResource
70: .getReportProperty(PopContainerChannelsView),
71: "ContainerFootGroup_number_" + container, null));
72: toclist.add(new TOCBean(new Integer(1), reportsResource
73: .getReportProperty(ChannelWiseUser),
74: "ContainerHeadGroup_" + container, null));
75: return toclist;
76: }
77:
78: private TOCBean channelBean(Object container, Object channel) {
79: return new TOCBean(new Integer(2), (String) channel,
80: "ChannelHeadGroup_" + container + "_" + channel, null);
81: }
82:
83: }
|