001: /*********************************************************************************
002: * The contents of this file are subject to the OpenI Public License Version 1.0
003: * ("License"); You may not use this file except in compliance with the
004: * License. You may obtain a copy of the License at
005: * http://www.openi.org/docs/LICENSE.txt
006: *
007: * Software distributed under the License is distributed on an "AS IS" basis,
008: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009: * the specific language governing rights and limitations under the License.
010: *
011: * The Original Code is: OpenI Open Source
012: *
013: * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
014: * Portions created by Loyalty Matrix, Inc. are
015: * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
016: *
017: * Contributor(s): ______________________________________.
018: *
019: ********************************************************************************/package org.openi.analysis;
020:
021: import com.tonbeller.jpivot.chart.ChartComponent;
022: import com.tonbeller.jpivot.olap.model.OlapModel;
023: import com.tonbeller.jpivot.table.TableComponent;
024: import com.tonbeller.jpivot.table.navi.AxisStyleUI;
025: import com.tonbeller.jpivot.xmla.XMLA_Memento;
026: import com.tonbeller.wcf.component.ComponentSupport;
027: import org.openi.chart.EnhancedChartComponent;
028:
029: /**
030: * @author plucas
031: *
032: * TODO To change the template for this generated type comment go to
033: * Window - Preferences - Java - Code Style - Code Templates
034: */
035: public class AnalysisAdapter {
036: /**
037: * Constructs an analysis out of jpivot components
038: *
039: * @param title
040: * @param chart
041: * @param olapModel
042: * @return
043: * @deprecated should no longer be using the tonbeller chart component - use the
044: * lmi EnhancedChartComponent
045: */
046: public static Analysis createAnalysis(String dataSourceName,
047: String title, ChartComponent chart, OlapModel olapModel) {
048: Analysis analysis = new Analysis();
049: analysis.setDataSourceName(dataSourceName);
050: analysis.setAnalysisTitle(title);
051: analysis.setChartTitle(chart.getChartTitle());
052: analysis.setFontName(chart.getFontName());
053: analysis.setFontStyle(chart.getFontStyle());
054: analysis.setFontSize(chart.getFontSize());
055: analysis.setSlicerFontName(chart.getSlicerFontName());
056: analysis.setSlicerFontStyle(chart.getSlicerFontStyle());
057: analysis.setSlicerFontSize(chart.getSlicerFontSize());
058: analysis.setAxisFontName(chart.getAxisFontName());
059: analysis.setAxisFontSize(chart.getAxisFontSize());
060: analysis.setAxisFontStyle(chart.getAxisFontStyle());
061: analysis.setLegendFontName(chart.getLegendFontName());
062: analysis.setLegendFontStyle(chart.getLegendFontStyle());
063: analysis.setLegendFontSize(chart.getLegendFontSize());
064: analysis.setLegendPosition(chart.getLegendPosition());
065: analysis.setSlicerPosition(chart.getSlicerPosition());
066: analysis.setSlicerAlignment(chart.getSlicerAlignment());
067: analysis.setChartType(chart.getChartType());
068: analysis.setChartHeight(chart.getChartHeight());
069: analysis.setChartWidth(chart.getChartWidth());
070: analysis.setHorizAxisLabel(chart.getHorizAxisLabel());
071: analysis.setVertAxisLabel(chart.getVertAxisLabel());
072: analysis.setAxisTickFontName(chart.getAxisTickFontName());
073: analysis.setAxisTickFontSize(chart.getAxisTickFontSize());
074: analysis.setAxisTickFontStyle(chart.getAxisTickFontStyle());
075: analysis.setShowLegend(chart.getShowLegend());
076: analysis.setShowSlicer(chart.isShowSlicer());
077: analysis.setDrillThroughEnabled(chart.isDrillThroughEnabled());
078: analysis.setTickLabelRotate(chart.getTickLabelRotate());
079: analysis.setBgColorB(chart.getBgColorB());
080: analysis.setBgColorG(chart.getBgColorG());
081: analysis.setBgColorR(chart.getBgColorR());
082:
083: // only if we have an xmla model
084: // logger.info(olapModel.getClass().getName());
085: if (olapModel.getBookmarkState(0) instanceof XMLA_Memento) {
086: XMLA_Memento olapMem = (XMLA_Memento) olapModel
087: .getBookmarkState(0);
088: analysis.setMdxQuery(olapMem.getMdxQuery());
089:
090: //analysis.setXmlaUri(olapMem.getUri());
091: //analysis.setCatalog(olapMem.getCatalog());
092: }
093:
094: return analysis;
095: }
096:
097: /**
098: * Constructs an analysis out of jpivot components
099: *
100: * @param title
101: * @param chart
102: * @param olapModel
103: * @return
104: */
105: public static Analysis createAnalysis(String dataSourceName,
106: String title, EnhancedChartComponent chart,
107: TableComponent table, OlapModel olapModel) {
108: Analysis analysis = new Analysis();
109: analysis.setDataSourceName(dataSourceName);
110: analysis.setAnalysisTitle(title);
111:
112: return createAnalysis(analysis, chart, table, olapModel);
113: }
114:
115: /**
116: * Constructs an analysis out of jpivot components and existing analysis
117: * @param analysis Analysis
118: * @param dataSourceName String
119: * @param title String
120: * @param chart EnhancedChartComponent
121: * @param table TableComponent
122: * @param olapModel OlapModel
123: * @return Analysis
124: */
125: public static Analysis createAnalysis(Analysis oldAnalysis,
126: EnhancedChartComponent chart, TableComponent table,
127: OlapModel olapModel) {
128: Analysis analysis = new Analysis();
129:
130: analysis.setDrillthroughSQL(oldAnalysis.getDrillthroughSQL());
131: analysis.setDataSourceName(oldAnalysis.getDataSourceName());
132: analysis.setAnalysisTitle(oldAnalysis.getAnalysisTitle());
133: analysis.setDescription(oldAnalysis.getDescription());
134: analysis.setDrillthroughDatasource(oldAnalysis
135: .getDrillthroughDatasource());
136:
137: analysis.setDrillReplaceEnabled(oldAnalysis
138: .isDrillReplaceEnabled());
139: analysis.setDrillPositionEnabled(oldAnalysis
140: .isDrillPositionEnabled());
141:
142: analysis.setShowPareto(chart.getShowPareto());
143: analysis.setShowChart(((ComponentSupport) chart).isVisible());
144: analysis.setShowTable(((ComponentSupport) table).isVisible());
145: analysis.setChartTitle(chart.getChartTitle());
146: analysis.setFontName(chart.getFontName());
147: analysis.setFontStyle(chart.getFontStyle());
148: analysis.setFontSize(chart.getFontSize());
149: analysis.setSlicerFontName(chart.getSlicerFontName());
150: analysis.setSlicerFontStyle(chart.getSlicerFontStyle());
151: analysis.setSlicerFontSize(chart.getSlicerFontSize());
152: analysis.setAxisFontName(chart.getAxisFontName());
153: analysis.setAxisFontSize(chart.getAxisFontSize());
154: analysis.setAxisFontStyle(chart.getAxisFontStyle());
155: analysis.setLegendFontName(chart.getLegendFontName());
156: analysis.setLegendFontStyle(chart.getLegendFontStyle());
157: analysis.setLegendFontSize(chart.getLegendFontSize());
158: analysis.setLegendPosition(chart.getLegendPosition());
159: analysis.setSlicerPosition(chart.getSlicerPosition());
160: analysis.setSlicerAlignment(chart.getSlicerAlignment());
161: analysis.setChartType(chart.getChartType());
162: analysis.setChartHeight(chart.getChartHeight());
163: analysis.setChartWidth(chart.getChartWidth());
164: analysis.setHorizAxisLabel(chart.getHorizAxisLabel());
165: analysis.setVertAxisLabel(chart.getVertAxisLabel());
166: analysis.setAxisTickFontName(chart.getAxisTickFontName());
167: analysis.setAxisTickFontSize(chart.getAxisTickFontSize());
168: analysis.setAxisTickFontStyle(chart.getAxisTickFontStyle());
169: analysis.setShowLegend(chart.getShowLegend());
170: analysis.setShowSlicer(chart.isShowSlicer());
171: analysis.setDrillThroughEnabled(chart.isDrillThroughEnabled());
172: analysis.setTickLabelRotate(chart.getTickLabelRotate());
173: analysis.setForegroundAlpha(chart.getForegroundAlpha());
174: analysis.setUseChartSize(chart.isUseChartSize());
175: analysis.setBgColorB(chart.getBgColorB());
176: analysis.setBgColorG(chart.getBgColorG());
177: analysis.setBgColorR(chart.getBgColorR());
178:
179: AxisStyleUI asu = (AxisStyleUI) table.getExtensions().get(
180: AxisStyleUI.ID);
181: analysis.setLevelStyle(asu.isLevelStyle());
182: analysis.setHideSpans(asu.isHideSpans());
183:
184: // only if we have an xmla model
185: // logger.info(olapModel.getClass().getName());
186: if (olapModel.getBookmarkState(0) instanceof XMLA_Memento) {
187: XMLA_Memento olapMem = (XMLA_Memento) olapModel
188: .getBookmarkState(0);
189: analysis.setMdxQuery(olapMem.getMdxQuery());
190:
191: //analysis.setXmlaUri(olapMem.getUri());
192: //analysis.setCatalog(olapMem.getCatalog());
193: }
194:
195: return analysis;
196: }
197: }
|