KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > analysis > AnalysisAdapter


1 /*********************************************************************************
2  * The contents of this file are subject to the OpenI Public License Version 1.0
3  * ("License"); You may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.openi.org/docs/LICENSE.txt
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is: OpenI Open Source
12  *
13  * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
14  * Portions created by Loyalty Matrix, Inc. are
15  * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
16  *
17  * Contributor(s): ______________________________________.
18  *
19  ********************************************************************************/

20 package org.openi.analysis;
21
22 import com.tonbeller.jpivot.chart.ChartComponent;
23 import com.tonbeller.jpivot.olap.model.OlapModel;
24 import com.tonbeller.jpivot.table.TableComponent;
25 import com.tonbeller.jpivot.table.navi.AxisStyleUI;
26 import com.tonbeller.jpivot.xmla.XMLA_Memento;
27 import com.tonbeller.wcf.component.ComponentSupport;
28 import org.openi.chart.EnhancedChartComponent;
29
30
31 /**
32  * @author plucas
33  *
34  * TODO To change the template for this generated type comment go to
35  * Window - Preferences - Java - Code Style - Code Templates
36  */

37 public class AnalysisAdapter {
38     /**
39      * Constructs an analysis out of jpivot components
40      *
41      * @param title
42      * @param chart
43      * @param olapModel
44      * @return
45      * @deprecated should no longer be using the tonbeller chart component - use the
46      * lmi EnhancedChartComponent
47      */

48     public static Analysis createAnalysis(String JavaDoc dataSourceName, String JavaDoc title,
49             ChartComponent chart, OlapModel olapModel) {
50         Analysis analysis = new Analysis();
51         analysis.setDataSourceName(dataSourceName);
52         analysis.setAnalysisTitle(title);
53         analysis.setChartTitle(chart.getChartTitle());
54         analysis.setFontName(chart.getFontName());
55         analysis.setFontStyle(chart.getFontStyle());
56         analysis.setFontSize(chart.getFontSize());
57         analysis.setSlicerFontName(chart.getSlicerFontName());
58         analysis.setSlicerFontStyle(chart.getSlicerFontStyle());
59         analysis.setSlicerFontSize(chart.getSlicerFontSize());
60         analysis.setAxisFontName(chart.getAxisFontName());
61         analysis.setAxisFontSize(chart.getAxisFontSize());
62         analysis.setAxisFontStyle(chart.getAxisFontStyle());
63         analysis.setLegendFontName(chart.getLegendFontName());
64         analysis.setLegendFontStyle(chart.getLegendFontStyle());
65         analysis.setLegendFontSize(chart.getLegendFontSize());
66         analysis.setLegendPosition(chart.getLegendPosition());
67         analysis.setSlicerPosition(chart.getSlicerPosition());
68         analysis.setSlicerAlignment(chart.getSlicerAlignment());
69         analysis.setChartType(chart.getChartType());
70         analysis.setChartHeight(chart.getChartHeight());
71         analysis.setChartWidth(chart.getChartWidth());
72         analysis.setHorizAxisLabel(chart.getHorizAxisLabel());
73         analysis.setVertAxisLabel(chart.getVertAxisLabel());
74         analysis.setAxisTickFontName(chart.getAxisTickFontName());
75         analysis.setAxisTickFontSize(chart.getAxisTickFontSize());
76         analysis.setAxisTickFontStyle(chart.getAxisTickFontStyle());
77         analysis.setShowLegend(chart.getShowLegend());
78         analysis.setShowSlicer(chart.isShowSlicer());
79         analysis.setDrillThroughEnabled(chart.isDrillThroughEnabled());
80         analysis.setTickLabelRotate(chart.getTickLabelRotate());
81         analysis.setBgColorB(chart.getBgColorB());
82         analysis.setBgColorG(chart.getBgColorG());
83         analysis.setBgColorR(chart.getBgColorR());
84         
85         // only if we have an xmla model
86
// logger.info(olapModel.getClass().getName());
87
if (olapModel.getBookmarkState(0) instanceof XMLA_Memento) {
88             XMLA_Memento olapMem = (XMLA_Memento) olapModel
89             .getBookmarkState(0);
90             analysis.setMdxQuery(olapMem.getMdxQuery());
91             
92             //analysis.setXmlaUri(olapMem.getUri());
93
//analysis.setCatalog(olapMem.getCatalog());
94
}
95         
96         return analysis;
97     }
98     
99     /**
100      * Constructs an analysis out of jpivot components
101      *
102      * @param title
103      * @param chart
104      * @param olapModel
105      * @return
106      */

107     public static Analysis createAnalysis(String JavaDoc dataSourceName,
108             String JavaDoc title, EnhancedChartComponent chart, TableComponent table,
109             OlapModel olapModel) {
110         Analysis analysis = new Analysis();
111         analysis.setDataSourceName(dataSourceName);
112         analysis.setAnalysisTitle(title);
113         analysis.setShowPareto(chart.getShowPareto());
114         analysis.setShowChart(((ComponentSupport) chart).isVisible());
115         analysis.setShowTable(((ComponentSupport) table).isVisible());
116         analysis.setChartTitle(chart.getChartTitle());
117         analysis.setFontName(chart.getFontName());
118         analysis.setFontStyle(chart.getFontStyle());
119         analysis.setFontSize(chart.getFontSize());
120         analysis.setSlicerFontName(chart.getSlicerFontName());
121         analysis.setSlicerFontStyle(chart.getSlicerFontStyle());
122         analysis.setSlicerFontSize(chart.getSlicerFontSize());
123         analysis.setAxisFontName(chart.getAxisFontName());
124         analysis.setAxisFontSize(chart.getAxisFontSize());
125         analysis.setAxisFontStyle(chart.getAxisFontStyle());
126         analysis.setLegendFontName(chart.getLegendFontName());
127         analysis.setLegendFontStyle(chart.getLegendFontStyle());
128         analysis.setLegendFontSize(chart.getLegendFontSize());
129         analysis.setLegendPosition(chart.getLegendPosition());
130         analysis.setSlicerPosition(chart.getSlicerPosition());
131         analysis.setSlicerAlignment(chart.getSlicerAlignment());
132         analysis.setChartType(chart.getChartType());
133         analysis.setChartHeight(chart.getChartHeight());
134         analysis.setChartWidth(chart.getChartWidth());
135         analysis.setHorizAxisLabel(chart.getHorizAxisLabel());
136         analysis.setVertAxisLabel(chart.getVertAxisLabel());
137         analysis.setAxisTickFontName(chart.getAxisTickFontName());
138         analysis.setAxisTickFontSize(chart.getAxisTickFontSize());
139         analysis.setAxisTickFontStyle(chart.getAxisTickFontStyle());
140         analysis.setShowLegend(chart.getShowLegend());
141         analysis.setShowSlicer(chart.isShowSlicer());
142         analysis.setDrillThroughEnabled(chart.isDrillThroughEnabled());
143         analysis.setTickLabelRotate(chart.getTickLabelRotate());
144         analysis.setForegroundAlpha(chart.getForegroundAlpha());
145         analysis.setUseChartSize(chart.isUseChartSize());
146         analysis.setBgColorB(chart.getBgColorB());
147         analysis.setBgColorG(chart.getBgColorG());
148         analysis.setBgColorR(chart.getBgColorR());
149         
150         AxisStyleUI asu = (AxisStyleUI) table.getExtensions()
151         .get(AxisStyleUI.ID);
152         analysis.setLevelStyle(asu.isLevelStyle());
153         analysis.setHideSpans(asu.isHideSpans());
154         
155         // only if we have an xmla model
156
// logger.info(olapModel.getClass().getName());
157
if (olapModel.getBookmarkState(0) instanceof XMLA_Memento) {
158             XMLA_Memento olapMem = (XMLA_Memento) olapModel.getBookmarkState(0);
159             analysis.setMdxQuery(olapMem.getMdxQuery());
160             
161             //analysis.setXmlaUri(olapMem.getUri());
162
//analysis.setCatalog(olapMem.getCatalog());
163
}
164         
165         return analysis;
166     }
167     
168     /**
169      * Constructs an analysis out of jpivot components and existing analysis
170      * @param analysis Analysis
171      * @param dataSourceName String
172      * @param title String
173      * @param chart EnhancedChartComponent
174      * @param table TableComponent
175      * @param olapModel OlapModel
176      * @return Analysis
177      */

178     public static Analysis createAnalysis(Analysis oldAnalysis,
179             EnhancedChartComponent chart, TableComponent table,
180             OlapModel olapModel) {
181         Analysis analysis = new Analysis();
182         
183         analysis.setDrillthroughSQL(oldAnalysis.getDrillthroughSQL());
184         analysis.setDataSourceName(oldAnalysis.getDataSourceName());
185         analysis.setAnalysisTitle(oldAnalysis.getAnalysisTitle());
186         analysis.setDescription(oldAnalysis.getDescription());
187         analysis.setDrillthroughDatasource(oldAnalysis.getDrillthroughDatasource());
188         
189         //analysis.setDataSourceName(dataSourceName);
190
//analysis.setAnalysisTitle(title);
191
analysis.setShowPareto(chart.getShowPareto());
192         analysis.setShowChart(((ComponentSupport) chart).isVisible());
193         analysis.setShowTable(((ComponentSupport) table).isVisible());
194         analysis.setChartTitle(chart.getChartTitle());
195         analysis.setFontName(chart.getFontName());
196         analysis.setFontStyle(chart.getFontStyle());
197         analysis.setFontSize(chart.getFontSize());
198         analysis.setSlicerFontName(chart.getSlicerFontName());
199         analysis.setSlicerFontStyle(chart.getSlicerFontStyle());
200         analysis.setSlicerFontSize(chart.getSlicerFontSize());
201         analysis.setAxisFontName(chart.getAxisFontName());
202         analysis.setAxisFontSize(chart.getAxisFontSize());
203         analysis.setAxisFontStyle(chart.getAxisFontStyle());
204         analysis.setLegendFontName(chart.getLegendFontName());
205         analysis.setLegendFontStyle(chart.getLegendFontStyle());
206         analysis.setLegendFontSize(chart.getLegendFontSize());
207         analysis.setLegendPosition(chart.getLegendPosition());
208         analysis.setSlicerPosition(chart.getSlicerPosition());
209         analysis.setSlicerAlignment(chart.getSlicerAlignment());
210         analysis.setChartType(chart.getChartType());
211         analysis.setChartHeight(chart.getChartHeight());
212         analysis.setChartWidth(chart.getChartWidth());
213         analysis.setHorizAxisLabel(chart.getHorizAxisLabel());
214         analysis.setVertAxisLabel(chart.getVertAxisLabel());
215         analysis.setAxisTickFontName(chart.getAxisTickFontName());
216         analysis.setAxisTickFontSize(chart.getAxisTickFontSize());
217         analysis.setAxisTickFontStyle(chart.getAxisTickFontStyle());
218         analysis.setShowLegend(chart.getShowLegend());
219         analysis.setShowSlicer(chart.isShowSlicer());
220         analysis.setDrillThroughEnabled(chart.isDrillThroughEnabled());
221         analysis.setTickLabelRotate(chart.getTickLabelRotate());
222         analysis.setForegroundAlpha(chart.getForegroundAlpha());
223         analysis.setUseChartSize(chart.isUseChartSize());
224         analysis.setBgColorB(chart.getBgColorB());
225         analysis.setBgColorG(chart.getBgColorG());
226         analysis.setBgColorR(chart.getBgColorR());
227         
228         AxisStyleUI asu = (AxisStyleUI) table.getExtensions()
229         .get(AxisStyleUI.ID);
230         analysis.setLevelStyle(asu.isLevelStyle());
231         analysis.setHideSpans(asu.isHideSpans());
232         
233         // only if we have an xmla model
234
// logger.info(olapModel.getClass().getName());
235
if (olapModel.getBookmarkState(0) instanceof XMLA_Memento) {
236             XMLA_Memento olapMem = (XMLA_Memento) olapModel.getBookmarkState(0);
237             analysis.setMdxQuery(olapMem.getMdxQuery());
238             
239             //analysis.setXmlaUri(olapMem.getUri());
240
//analysis.setCatalog(olapMem.getCatalog());
241
}
242         
243         return analysis;
244     }
245 }
246
Popular Tags