Source Code Cross Referenced for UBTReportAdapter.java in  » Portal » Open-Portal » com » sun » portal » ubt » report » view » report » 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 » Portal » Open Portal » com.sun.portal.ubt.report.view.report 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.report;
006:
007:        import com.sun.portal.ubt.report.data.DataMiner;
008:        import com.sun.portal.ubt.report.view.report.UBTReportI;
009:        import com.sun.portal.ubt.report.view.IllegalMinerException;
010:        import com.sun.portal.ubt.report.view.IllegalDataSourceException;
011:        import net.sf.jasperreports.engine.JasperCompileManager;
012:        import net.sf.jasperreports.engine.JRException;
013:        import net.sf.jasperreports.engine.JasperExportManager;
014:        import net.sf.jasperreports.engine.JasperPrint;
015:
016:        import java.util.Map;
017:        import java.util.HashMap;
018:        import java.util.Locale;
019:        import java.util.TimeZone;
020:        import java.util.Date;
021:        import java.io.*;
022:        import java.text.SimpleDateFormat;
023:        import java.text.DateFormat;
024:
025:        /**
026:         *
027:         */
028:        public abstract class UBTReportAdapter implements  UBTReportI {
029:            protected static String fileSeparator = System
030:                    .getProperty("file.separator");
031:            protected static String templateExtension = ".jrxml";
032:            protected static String fillExtension = ".jasper";
033:            protected static String printExtension = ".jrprint";
034:            protected static String htmlExtension = ".html";
035:            protected String templateFolder;
036:            protected String reportFolder;
037:            protected String reportName;
038:            protected DataMiner miner[] = new DataMiner[1];
039:            protected Map reportParameters = new HashMap();
040:            protected Locale clientLocale;
041:
042:            public String getReportName() {
043:                return reportName;
044:            }
045:
046:            public DataMiner[] getDataMiner() {
047:                return miner;
048:            }
049:
050:            public void setDataMiner(DataMiner[] dataMiner) {
051:                this .miner = dataMiner;
052:            }
053:
054:            public void setTemplateFolder(String templateFolder) {
055:                this .templateFolder = templateFolder;
056:            }
057:
058:            public void setReportFolder(String reportFolder) {
059:                this .reportFolder = reportFolder;
060:            }
061:
062:            public void compile() throws JRException {
063:                String templateFileName = getReportTemplateName();
064:                String jasperFileName = getJasperFileName();
065:                String tocFileName = getTocTemplateName();
066:                String jasperTocFileName = getTocJasperFileName();
067:                //If the template is already compiled ,do n't compile unless there is a change to the template
068:                if (!new File(jasperFileName).exists()
069:                        || (new File(jasperFileName).exists() && new File(
070:                                jasperFileName).lastModified() < new File(
071:                                templateFileName).lastModified()))
072:                    JasperCompileManager.compileReportToFile(templateFileName,
073:                            jasperFileName);
074:                if (!new File(jasperTocFileName).exists()
075:                        || (new File(jasperTocFileName).exists() && new File(
076:                                jasperTocFileName).lastModified() < new File(
077:                                tocFileName).lastModified()))
078:                    JasperCompileManager.compileReportToFile(tocFileName,
079:                            jasperTocFileName);
080:            }
081:
082:            public abstract void fill() throws IllegalMinerException,
083:                    IllegalDataSourceException, JRException;
084:
085:            public abstract JasperPrint getReport()
086:                    throws IllegalMinerException, JRException,
087:                    IllegalDataSourceException;
088:
089:            public void html() throws JRException {
090:                String jrprintFileName = this .getJrprintFileName();
091:                String htmlFileName = this .getHtmlFileName();
092:                JasperExportManager.exportReportToHtmlFile(jrprintFileName,
093:                        htmlFileName);
094:                copyHelpFile();
095:                cleanUpFiles();
096:            }
097:
098:            private void cleanUpFiles() {
099:                //new File(this.getJasperFileName()).deleteOnExit();
100:                //new File(this.getJrprintFileName()).deleteOnExit();
101:            }
102:
103:            private void copyHelpFile() {
104:                String helpLink = (String) this .reportParameters
105:                        .get(UBTReportI.REPORT_HELP_LINK_PROPERTY);
106:                String srcHelpFileName = templateFolder + fileSeparator
107:                        + helpLink.substring(2);
108:                String dstHelpFileName = reportFolder + fileSeparator
109:                        + helpLink.substring(2);
110:                try {
111:                    InputStream in = new FileInputStream(srcHelpFileName);
112:                    OutputStream out = new FileOutputStream(dstHelpFileName);
113:
114:                    // Transfer bytes from in to out
115:                    byte[] buf = new byte[1024];
116:                    int len;
117:                    while ((len = in.read(buf)) > 0) {
118:                        out.write(buf, 0, len);
119:                    }
120:                    in.close();
121:                    out.close();
122:                } catch (Exception e) {
123:                    //drop through
124:                }
125:            }
126:
127:            protected String getReportTemplateName() {
128:                return templateFolder + fileSeparator + reportName
129:                        + templateExtension;
130:            }
131:
132:            protected String getTocTemplateName() {
133:                return templateFolder + fileSeparator
134:                        + UBTReportI.TABLE_OF_CONTENT + templateExtension;
135:            }
136:
137:            protected String getTocJasperFileName() {
138:                return reportFolder + fileSeparator
139:                        + UBTReportI.TABLE_OF_CONTENT + fillExtension;
140:            }
141:
142:            protected String getJasperFileName() {
143:                return reportFolder + fileSeparator + reportName
144:                        + fillExtension;
145:            }
146:
147:            protected String getJrprintFileName() {
148:                return reportFolder + fileSeparator + reportName
149:                        + printExtension;
150:            }
151:
152:            protected String getHtmlFileName() {
153:                return reportFolder + fileSeparator + reportName
154:                        + htmlExtension;
155:            }
156:
157:            protected String getLogo() {
158:                return templateFolder + fileSeparator + UBTReportI.REPORT_LOGO;
159:            }
160:
161:            private synchronized void writeObject(java.io.ObjectOutputStream s)
162:                    throws IOException {
163:                // Write out the length, threshold, loadfactor
164:                s.defaultWriteObject();
165:            }
166:
167:            private void readObject(java.io.ObjectInputStream s)
168:                    throws IOException, ClassNotFoundException {
169:                // Read in the length, threshold, and loadfactor
170:                s.defaultReadObject();
171:            }
172:
173:            public void setLocale(Locale locale) {
174:                this .clientLocale = locale;
175:            }
176:
177:            protected String getLDate() {
178:                DateFormat formatter = new SimpleDateFormat(
179:                        "EEE MMM dd HH:mm:ss zzz yyyy", this .clientLocale);
180:                formatter.setTimeZone(TimeZone.getDefault());
181:                return formatter.format(new Date());
182:            }
183:
184:        }
w_w__w_.__j___av___a__2_s_.___com_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.