Source Code Cross Referenced for StreamChartServlet.java in  » Report » openi » org » openi » chart » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » openi » org.openi.chart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.openi.chart;
002:
003:        import org.apache.log4j.Logger;
004:
005:        import org.jfree.data.category.DefaultCategoryDataset;
006:        import org.openi.analysis.Analysis;
007:        import org.openi.analysis.Datasource;
008:        import org.openi.project.ProjectContext;
009:        import org.openi.xmla.DatasetAdapter;
010:        import org.openi.xmla.XmlaConnector;
011:        import org.xml.sax.SAXException;
012:
013:        import com.tonbeller.jpivot.olap.model.OlapException;
014:        import com.tonbeller.jpivot.olap.model.OlapModel;
015:
016:        import java.io.FileNotFoundException;
017:        import java.io.IOException;
018:
019:        import javax.servlet.ServletException;
020:        import javax.servlet.http.HttpServlet;
021:        import javax.servlet.http.HttpServletRequest;
022:        import javax.servlet.http.HttpServletResponse;
023:
024:        /**
025:         * should this be a spring controller? 
026:         *
027:         */
028:        public class StreamChartServlet extends HttpServlet {
029:            private static Logger logger = Logger
030:                    .getLogger(StreamChartServlet.class);
031:
032:            public StreamChartServlet() {
033:                super ();
034:            }
035:
036:            private int parseInt(String value, int defaultValue) {
037:                int retVal = defaultValue;
038:
039:                try {
040:                    retVal = Integer.parseInt(value);
041:                    if (retVal == 0)
042:                        retVal = defaultValue;//if zero, also use default
043:                } catch (Exception e) {
044:                    logger.debug(e);
045:                }
046:
047:                return retVal;
048:            }
049:
050:            /**
051:             * requires:
052:             * config parameter in request
053:             * valid projectContext in session
054:             */
055:            public void service(HttpServletRequest request,
056:                    HttpServletResponse response) throws ServletException {
057:                long start = System.currentTimeMillis();
058:                ProjectContext projectContext = (ProjectContext) request
059:                        .getSession().getAttribute("projectContext");
060:
061:                // logger.debug("streaming chart for analysis: " + analysisName);
062:                logger.debug("projectContext: "
063:                        + projectContext.getProject().getProjectName());
064:
065:                String config = request.getParameter("config");
066:                String mdx = request.getParameter("mdx");
067:
068:                Analysis analysis = null;
069:                if (config != null && config.length() > 0) {
070:                    logger
071:                            .debug("found a config param, restoring analysis from file: "
072:                                    + config);
073:                    analysis = restoreAnalysis(projectContext, config);
074:                } else if (mdx != null && mdx.length() > 0) {
075:                    logger
076:                            .debug("found a mdx param, generating analysis on the fly using mdx: "
077:                                    + mdx);
078:                    String targetDatasource = request
079:                            .getParameter("targetDatasource");
080:                    String analysisName = request.getParameter("analysisName");
081:                    analysis = new Analysis();
082:                    analysis.setAnalysisTitle(analysisName);
083:                    analysis.setDataSourceName(targetDatasource);
084:                    analysis.setMdxQuery(mdx);
085:                }
086:
087:                if (analysis == null) {
088:                    try {
089:                        response.sendRedirect("images/spacer.gif");
090:                    } catch (IOException e) {
091:                        logger.error(e);
092:                    } finally {
093:                        return;
094:                    }
095:                }
096:                String datasourceName = analysis.getDataSourceName();
097:                logger.debug("using datasource name: " + datasourceName);
098:
099:                Datasource datasource = projectContext
100:                        .getDatasource(datasourceName);
101:                // logger.debug("using datasource: " + datasource.getServer());
102:
103:                // DefaultCategoryDataset dataset = getDataset(datasource.getServer(), datasource.getCatalog(), analysis);
104:
105:                OlapModel olapModel = getDataset(datasource.getServer(),
106:                        datasource.getCatalog(), analysis);
107:
108:                try {
109:                    int x = this .parseInt(request.getParameter("width"), 320);
110:                    int y = this .parseInt(request.getParameter("height"), 240);
111:                    EnhancedChartFactory.createChart(
112:                            response.getOutputStream(), analysis, olapModel, x,
113:                            y, request.getLocale());
114:                } catch (FileNotFoundException e) {
115:                    throw new ServletException(e);
116:                } catch (IOException e) {
117:                    throw new ServletException(e);
118:                } catch (OlapException e) {
119:                    throw new ServletException(e);
120:                } finally {
121:                    long elapsed = System.currentTimeMillis() - start;
122:                    logger.info("request completed in " + elapsed + "ms");
123:                }
124:            }
125:
126:            /**
127:             * trap all exception? 
128:             * @param projectContext
129:             * @param analysisName
130:             * @return
131:             * @throws ServletException
132:             */
133:            private Analysis restoreAnalysis(ProjectContext projectContext,
134:                    String analysisName) throws ServletException {
135:
136:                Analysis analysis = null;
137:
138:                try {
139:                    analysis = projectContext.restoreAnalysis(analysisName);
140:                } catch (IOException e) {
141:                    // throw new ServletException(e);
142:                }
143:                return analysis;
144:            }
145:
146:            /**
147:             * might want to trap all exceptions? 
148:             * @param xmlaUri
149:             * @param catalog
150:             * @param analysis
151:             * @return
152:             * @throws ServletException
153:             */
154:            private OlapModel getDataset(String xmlaUri, String catalog,
155:                    Analysis analysis) throws ServletException {
156:
157:                XmlaConnector connector = new XmlaConnector();
158:                String mdxQuery = analysis.getMdxQuery();
159:
160:                OlapModel model = null;
161:                ;
162:                try {
163:                    Datasource datasource = new Datasource(xmlaUri, catalog);
164:                    model = connector.query(datasource, mdxQuery);
165:                } catch (IOException e) {
166:                    throw new ServletException(e);
167:                } catch (OlapException e) {
168:                    throw new ServletException(e);
169:                } catch (SAXException e) {
170:                    throw new ServletException(e);
171:                }
172:                return model;
173:
174:            }
175:
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.