1 20 package org.openi.web.controller.analysis; 21 22 import com.tonbeller.wcf.controller.RequestContext; 23 import com.tonbeller.wcf.table.EditableTableComponent; 24 import org.apache.log4j.Logger; 25 import org.openi.analysis.Analysis; 26 import org.openi.analysis.Datasource; 27 import org.openi.application.Application; 28 import org.openi.chart.EnhancedChartComponent; 29 import org.openi.chart.EnhancedChartTag; 30 import org.openi.project.ProjectContext; 31 import org.openi.xmla.XMLAQueryTag; 32 import org.springframework.web.servlet.ModelAndView; 33 import org.springframework.web.servlet.mvc.AbstractController; 34 import java.util.*; 35 import javax.servlet.http.HttpServletRequest ; 36 import javax.servlet.http.HttpServletResponse ; 37 import javax.servlet.http.HttpSession ; 38 import org.openi.menu.ToolbarState; 39 import org.openi.security.Permission; 40 41 53 public class AnalysisController extends AbstractController { 54 private static Logger logger = Logger.getLogger(AnalysisController.class); 55 private HttpSession session = null; 56 private Analysis analysis = null; 57 private ProjectContext projectContext = null; 58 59 66 protected ModelAndView handleRequestInternal(HttpServletRequest request, 67 HttpServletResponse response) throws Exception { 68 Map model; 69 String analysisConfigName = null; 70 Datasource datasource = null; 71 72 session = request.getSession(); 73 projectContext = (ProjectContext) session.getAttribute("projectContext"); 75 76 ToolbarState newButtonState = new ToolbarState(); 78 newButtonState.setVisible( projectContext.hasPermission(Permission.CREATE_NEW)); 79 session.setAttribute("newButtonState", newButtonState); 80 try { 82 request.setAttribute("analysisPage", "true"); 85 86 analysisConfigName = request.getParameter("config"); 88 89 model = new HashMap(); 90 91 92 93 if (request.getParameter("config") != null) { 95 session.setAttribute("analysisConfigName", analysisConfigName); 97 98 removeSessionObjects(); 100 101 if (!"newanalysis".equalsIgnoreCase(analysisConfigName)) { 103 analysis = projectContext.restoreAnalysis(analysisConfigName); 104 session.setAttribute("analysis01", analysis); 105 } else { 106 analysis = (Analysis) session.getAttribute("analysis01"); 107 } 108 109 datasource = projectContext.getDatasource(analysis 111 .getDataSourceName()); 112 113 XMLAQueryTag query = new XMLAQueryTag(); 115 116 query.setCatalog(datasource.getCatalog()); 118 query.setMdxQuery(analysis.getMdxQuery()); 119 query.setUri(datasource.getServer()); 120 query.setId("query01"); 121 122 if (Application.getInstance().isBasicAuthentication()) { 124 query.setUser(request.getUserPrincipal().getName()); 125 query.setPassword((String ) session.getAttribute( 126 "user.credentials")); 127 } else { 128 query.setUser(""); 129 query.setPassword(""); 130 } 131 132 query.init(RequestContext.instance()); 134 135 EnhancedChartTag chartTag = new EnhancedChartTag(); 137 138 chartTag.setQuery("query01"); 140 141 EnhancedChartComponent chart = (EnhancedChartComponent) chartTag 143 .createComponent(RequestContext.instance()); 144 chart.initialize(RequestContext.instance()); 145 146 this.setChartSize(chart); 147 this.translateChart(chart); 149 session.setAttribute("chart01", chart); 150 151 } else { 153 } 156 157 if (request.getParameter("toolbar02.drillThrough01.x") != null) { 158 request.setAttribute("drillButtonClicked", "true"); 159 } 160 model.put("readOnly", projectContext.hasPermission(Permission.READ_ONLY)?Boolean.TRUE:Boolean.FALSE); 161 return new ModelAndView("analysisView", "model", model); 162 } catch (Exception e) { 163 logger.error("Exception:", e); 164 throw e; 165 } 166 } 167 168 private void setChartSize(EnhancedChartComponent chart){ 169 if (analysis.isUseChartSize()) { 170 chart.setChartHeight(analysis.getChartHeight()); 171 chart.setChartWidth(analysis.getChartWidth()); 172 173 } else { 175 if (session.getAttribute("clientWindowWidth") != null) { 177 chart.setChartWidth(Integer.parseInt( 178 session.getAttribute("clientWindowWidth").toString()) 179 - 250); 180 } 181 182 if (session.getAttribute("clientWindowHeight") != null) { 183 chart.setChartHeight((Integer.parseInt( 184 session.getAttribute("clientWindowHeight").toString()) / 2) 185 + 150); 186 } 187 } 188 } 189 190 private void translateChart(EnhancedChartComponent chart) { 191 193 194 List palette = (List) projectContext.getProject() 196 .getColorPalette(projectContext.getProject() 197 .getDefaultPaletteName()); 198 chart.setColorPalette(palette); 199 200 chart.setShowPareto(analysis.getShowPareto()); 201 chart.setForegroundAlpha(analysis.getForegroundAlpha()); 202 203 chart.setChartTitle(analysis.getChartTitle()); 204 chart.setChartType(analysis.getChartType()); 205 chart.setFontName(analysis.getFontName()); 206 chart.setFontStyle(analysis.getFontStyle()); 207 chart.setFontSize(analysis.getFontSize()); 208 209 chart.setShowLegend(analysis.isShowLegend()); 211 212 if (analysis.isShowLegend() == true) { 214 chart.setLegendFontName(analysis.getLegendFontName()); 215 chart.setLegendFontStyle(analysis.getLegendFontStyle()); 216 chart.setLegendFontSize(analysis.getLegendFontSize()); 217 chart.setLegendPosition(analysis.getLegendPosition()); 218 } 219 220 chart.setShowSlicer(analysis.isShowSlicer()); 222 223 if (analysis.isShowSlicer() == true) { 225 chart.setSlicerPosition(analysis.getSlicerPosition()); 226 chart.setSlicerAlignment(analysis.getSlicerAlignment()); 227 chart.setSlicerFontName(analysis.getSlicerFontName()); 228 chart.setSlicerFontStyle(analysis.getSlicerFontStyle()); 229 chart.setSlicerFontSize(analysis.getSlicerFontSize()); 230 } 231 232 chart.setAxisFontName(analysis.getAxisFontName()); 234 chart.setAxisFontStyle(analysis.getAxisFontStyle()); 235 chart.setAxisFontSize(analysis.getAxisFontSize()); 236 chart.setHorizAxisLabel(analysis.getHorizAxisLabel()); 237 chart.setVertAxisLabel(analysis.getVertAxisLabel()); 238 chart.setAxisTickFontName(analysis.getAxisTickFontName()); 239 chart.setAxisTickFontStyle(analysis.getAxisTickFontStyle()); 240 chart.setAxisTickFontSize(analysis.getAxisTickFontSize()); 241 242 chart.setDrillThroughEnabled(analysis.isDrillThroughEnabled()); 243 chart.setTickLabelRotate(analysis.getTickLabelRotate()); 244 245 chart.setUseChartSize(analysis.isUseChartSize()); 246 247 chart.setVisible(analysis.isShowChart()); 249 250 chart.setBgColorB(analysis.getBgColorB()); 252 chart.setBgColorG(analysis.getBgColorG()); 253 chart.setBgColorR(analysis.getBgColorR()); 254 255 chart.setWriteImageMap(projectContext.getProject().getWriteImageMap()); 256 } 257 258 262 private void removeSessionObjects() { 263 if (session.getAttribute("query01") != null) { 265 session.removeAttribute("query01"); 266 } 267 268 if (session.getAttribute("table01") != null) { 269 session.removeAttribute("table01"); 270 } 271 272 if (session.getAttribute("minichartform01") != null) { 273 session.removeAttribute("minichartform01"); 274 } 275 276 if (session.getAttribute("mdxedit01") != null) { 277 session.removeAttribute("mdxedit01"); 278 } 279 280 if (session.getAttribute("navi01") != null) { 281 session.removeAttribute("navi01"); 282 } 283 284 if (session.getAttribute("print01") != null) { 285 session.removeAttribute("print01"); 286 } 287 288 if (session.getAttribute("sortform01") != null) { 289 session.removeAttribute("sortform01"); 290 } 291 292 if (session.getAttribute("printform01") != null) { 293 session.removeAttribute("printform01"); 294 } 295 296 if (session.getAttribute("chartform01") != null) { 297 session.removeAttribute("chartform01"); 298 } 299 300 if (session.getAttribute("query01.drillthroughtable") != null) { 301 session.removeAttribute("query01.drillthroughtable"); 302 } 303 } 304 } 305 | Popular Tags |