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.UserIdentityDataSource;
009: import com.sun.portal.ubt.report.view.IllegalDataSourceException;
010:
011: import java.util.ArrayList;
012: import java.util.Locale;
013:
014: /**
015: *
016: */
017: public class PortalUserIdentityToc extends ReportTocAdapter {
018: public static final String UserAccessServer = "UserAccessServer";
019: public static final String UserWithDiffRDN = "UserWithDiffRDN";
020: public static final String Domain = "Domain";
021: public static final String UserRDNs = "UserRDNs";
022:
023: public PortalUserIdentityToc(UBTDataSourceI dataSource,
024: Locale locale) throws IllegalDataSourceException {
025: super (dataSource, locale);
026: if (!(dataSource instanceof UserIdentityDataSource))
027: throw new IllegalDataSourceException();
028:
029: }
030:
031: protected void createToc() {
032: Object[][] dataArray = dataSource.getData();
033: Object prevServer = null;
034: Object prevDomain = null;
035: Object prevRDN = null;
036: int i = 0;
037: for (i = 0; i < dataArray.length; i++) {
038: if (prevServer == null && prevDomain == null
039: && prevRDN == null) {
040: this .tocCollection.addAll(serverBean(dataArray[i][0]));
041: this .tocCollection.addAll(domainBean(dataArray[i][0],
042: dataArray[i][1]));
043: this .tocCollection.add(rdnBean(dataArray[i][0],
044: dataArray[i][1], dataArray[i][2]));
045: prevServer = dataArray[i][0];
046: prevDomain = dataArray[i][1];
047: prevRDN = dataArray[i][2];
048: continue;
049: }
050: if (!prevServer.equals(dataArray[i][0])) {
051: this .tocCollection.addAll(domainCharts(
052: dataArray[i - 1][0], dataArray[i - 1][1]));
053: this .tocCollection.addAll(serverBean(dataArray[i][0]));
054: }
055: if (!prevDomain.equals(dataArray[i][1])) {
056: this .tocCollection.addAll(domainCharts(
057: dataArray[i - 1][0], dataArray[i - 1][1]));
058: }
059:
060: if (!prevDomain.equals(dataArray[i][1])
061: || !prevServer.equals(dataArray[i][0])) {
062: this .tocCollection.addAll(domainBean(dataArray[i][0],
063: dataArray[i][1]));
064: }
065: if (!prevRDN.equals(dataArray[i][2])
066: || !prevServer.equals(dataArray[i][0])
067: || !prevDomain.equals(dataArray[i][1])) {
068: this .tocCollection.add(rdnBean(dataArray[i][0],
069: dataArray[i][1], dataArray[i][2]));
070: }
071: prevServer = dataArray[i][0];
072: prevDomain = dataArray[i][1];
073: prevRDN = dataArray[i][2];
074: }
075: if (dataArray.length > 0)
076: this .tocCollection.addAll(domainCharts(dataArray[i - 1][0],
077: dataArray[i - 1][1]));
078: }
079:
080: private ArrayList serverBean(Object server) {
081: ArrayList toclist = new ArrayList();
082: toclist.add(new TOCBean(new Integer(0), reportsResource
083: .getReportProperty(UserAccessServer)
084: + " " + (String) server, "ServerHeadGroup_" + server,
085: null));
086: return toclist;
087: }
088:
089: private ArrayList domainCharts(Object server, Object domain) {
090: ArrayList toclist = new ArrayList();
091: toclist.add(new TOCBean(new Integer(2), reportsResource
092: .getReportProperty(PortalChannelRenderToc.CompCharts),
093: "DomainFootGroup_" + server + "_" + domain, null));
094: toclist.add(new TOCBean(new Integer(3), reportsResource
095: .getReportProperty(UserWithDiffRDN), "DomainFootGroup_"
096: + server + "_" + domain, null));
097: return toclist;
098: }
099:
100: private ArrayList domainBean(Object server, Object domain) {
101: ArrayList toclist = new ArrayList();
102: toclist.add(new TOCBean(new Integer(1), reportsResource
103: .getReportProperty(Domain)
104: + " " + (String) domain, "DomainHeadGroup_" + server
105: + "_" + domain, null));
106: toclist.add(new TOCBean(new Integer(2), reportsResource
107: .getReportProperty(UserRDNs), "DomainHeadGroup_"
108: + server + "_" + domain, null));
109: return toclist;
110: }
111:
112: private TOCBean rdnBean(Object server, Object domain, Object rdn) {
113: return new TOCBean(new Integer(3), (String) rdn,
114: "RDNHeadGroup_" + server + "_" + domain + "_" + rdn,
115: null);
116: }
117:
118: }
|