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.PortletDataSource;
09: import com.sun.portal.ubt.report.view.IllegalDataSourceException;
10: import com.sun.portal.ubt.report.view.chart.PortletChart;
11:
12: import java.util.ArrayList;
13: import java.util.Locale;
14:
15: /**
16: *
17: */
18: public class PortletRenderToc extends ReportTocAdapter {
19: public static final String Summary = "Summary";
20: public static final String PortletWiseRender = "PortletWiseRender";
21:
22: public PortletRenderToc(UBTDataSourceI dataSource, Locale locale)
23: throws IllegalDataSourceException {
24: super (dataSource, locale);
25: if (!(dataSource instanceof PortletDataSource))
26: throw new IllegalDataSourceException();
27: }
28:
29: protected void createToc() {
30: Object[][] dataArray = dataSource.getData();
31: Object prevPortlet = null;
32: int i = 0;
33: for (i = 0; i < dataArray.length; i++) {
34: if (prevPortlet == null) {
35: this .tocCollection.add(tocHeadBean(dataArray[i][0]));
36: this .tocCollection.add(portletBean(dataArray[i][0]));
37: prevPortlet = dataArray[i][0];
38: continue;
39: }
40: if (!prevPortlet.equals(dataArray[i][0])) {
41: this .tocCollection.add(portletBean(dataArray[i][0]));
42: }
43: prevPortlet = dataArray[i][0];
44: }
45: this .tocCollection.addAll(summaryBean());
46: }
47:
48: private ArrayList summaryBean() {
49: ArrayList toclist = new ArrayList();
50: toclist.add(new TOCBean(new Integer(0), reportsResource
51: .getReportProperty(Summary), "SummaryGroup", null));
52: toclist.add(new TOCBean(new Integer(1), reportsResource
53: .getReportProperty(PortletChart.PORTLET_POPULARITY),
54: "SummaryGroup_popular", null));
55: return toclist;
56: }
57:
58: private TOCBean tocHeadBean(Object o) {
59: return new TOCBean(new Integer(0), reportsResource
60: .getReportProperty(PortletWiseRender), null, null);
61: }
62:
63: private TOCBean portletBean(Object o) {
64: return new TOCBean(new Integer(1), (String) o, "EntityIDGroup_"
65: + o, null);
66: }
67: }
|