Source Code Cross Referenced for JFreeReportConfigParameterComponent.java in  » Report » pentaho-report » org » pentaho » plugin » jfreereport » components » 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 » pentaho report » org.pentaho.plugin.jfreereport.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005:         * this file except in compliance with the license. If you need a copy of the license,
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
008:         *
009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
011:         * the license for the specific language governing your rights and limitations.
012:         */
013:
014:        package org.pentaho.plugin.jfreereport.components;
015:
016:        import java.util.Iterator;
017:        import java.util.List;
018:        import java.util.Map;
019:
020:        import org.apache.commons.logging.Log;
021:        import org.apache.commons.logging.LogFactory;
022:        import org.dom4j.Node;
023:        import org.jfree.base.config.ModifiableConfiguration;
024:        import org.jfree.report.JFreeReport;
025:        import org.pentaho.commons.connection.IPentahoMetaData;
026:        import org.pentaho.commons.connection.IPentahoResultSet;
027:        import org.pentaho.core.util.XmlHelper;
028:        import org.pentaho.messages.Messages;
029:        import org.pentaho.plugin.jfreereport.AbstractJFreeReportComponent;
030:
031:        public class JFreeReportConfigParameterComponent extends
032:                AbstractJFreeReportComponent {
033:
034:            private static final long serialVersionUID = 6599442849458920502L;
035:
036:            private static final String REPORT_CONFIG_INPUT_PARAM = "config_parameters"; //$NON-NLS-1$
037:
038:            private static final String REPORT_CONFIG_COMPDEFN = "report_configuration_parameters"; //$NON-NLS-1$
039:
040:            public JFreeReportConfigParameterComponent() {
041:                // TODO Auto-generated constructor stub
042:                super ();
043:            }
044:
045:            public void done() {
046:                // Nothing to do here...
047:            }
048:
049:            private boolean initReportConfigParameters() {
050:                boolean result = true;
051:                if (isDefinedInput(DATACOMPONENT_REPORTTEMP_OBJINPUT)) {
052:                    Object maybeReport = getInputValue(DATACOMPONENT_REPORTTEMP_OBJINPUT);
053:                    if (maybeReport instanceof  JFreeReport) {
054:                        JFreeReport report = (JFreeReport) maybeReport;
055:                        // We should have our report object at this point.
056:                        if (isDefinedInput(REPORT_CONFIG_INPUT_PARAM)) {
057:                            // It's coming in as an input parameter
058:                            Object reportConfigParams = this 
059:                                    .getInputValue(REPORT_CONFIG_INPUT_PARAM);
060:                            if (reportConfigParams instanceof  IPentahoResultSet) {
061:                                setReportConfigParameters(report,
062:                                        (IPentahoResultSet) reportConfigParams);
063:                            } else if (reportConfigParams instanceof  Map) {
064:                                setReportConfigParameters(report,
065:                                        (Map) reportConfigParams);
066:                            } else {
067:                                error(Messages
068:                                        .getErrorString("JFreeReport.ERROR_0026_UNKNOWN_REPORT_CONFIGURATION_PARAMETERS")); //$NON-NLS-1$
069:                                result = false;
070:                                ;
071:                            }
072:
073:                        } else {
074:                            Node compDef = getComponentDefinition();
075:                            List configNodes = compDef
076:                                    .selectNodes(REPORT_CONFIG_COMPDEFN + "/*"); //$NON-NLS-1$
077:                            if ((configNodes != null)
078:                                    && (configNodes.size() > 0)) {
079:                                setReportConfigParameters(report, configNodes);
080:                            }
081:                        }
082:                    }
083:                }
084:                return result;
085:            }
086:
087:            protected boolean executeAction() throws Throwable {
088:                return initReportConfigParameters();
089:            }
090:
091:            public boolean init() {
092:                return true;
093:            }
094:
095:            private void setReportConfigParameters(JFreeReport report,
096:                    List configNodes) {
097:                // We have some configuration parameters in the component definition
098:                String parmName = null;
099:                String parmValue = null;
100:                for (int i = 0; i < configNodes.size(); i++) {
101:                    Node aNode = (Node) configNodes.get(i);
102:                    parmName = XmlHelper.getNodeText("@name", aNode, null); //$NON-NLS-1$
103:                    if ((parmName == null) || (parmName.length() == 0)) {
104:                        // Ignore configuration settings without name=
105:                        error(Messages
106:                                .getErrorString("JFreeReport.ERROR_0027_REPORT_CONFIGURATION_PARAMETER_IGNORED")); //$NON-NLS-1$
107:                        continue;
108:                    }
109:                    parmValue = aNode.getText();
110:                    if (parmValue != null) {
111:                        parmValue = parmValue.trim();
112:                        if (parmValue.length() > 0) {
113:                            report.getReportConfiguration().setConfigProperty(
114:                                    parmName, applyInputsToFormat(parmValue));
115:                        } else {
116:                            error(Messages
117:                                    .getErrorString("JFreeReport.ERROR_0027_REPORT_CONFIGURATION_PARAMETER_IGNORED")); //$NON-NLS-1$            
118:                        }
119:                    } else {
120:                        error(Messages
121:                                .getErrorString("JFreeReport.ERROR_0027_REPORT_CONFIGURATION_PARAMETER_IGNORED")); //$NON-NLS-1$          
122:                    }
123:                }
124:
125:            }
126:
127:            private void setReportConfigParameters(JFreeReport report,
128:                    Map values) {
129:                Map.Entry ent;
130:                ModifiableConfiguration config = report
131:                        .getReportConfiguration();
132:                Iterator it = values.entrySet().iterator();
133:                while (it.hasNext()) {
134:                    ent = (Map.Entry) it.next();
135:                    if ((ent.getKey() != null) && (ent.getValue() != null)) {
136:                        config.setConfigProperty(ent.getKey().toString(),
137:                                applyInputsToFormat(ent.getValue().toString()));
138:                    }
139:                }
140:            }
141:
142:            private void setReportConfigParameters(JFreeReport report,
143:                    IPentahoResultSet values) {
144:                int rowCount = values.getRowCount();
145:                int colCount = values.getColumnCount();
146:                ModifiableConfiguration config = report
147:                        .getReportConfiguration();
148:                if (colCount >= 2) {
149:                    IPentahoMetaData md = values.getMetaData();
150:                    int nameIdx = md.getColumnIndex("name");//$NON-NLS-1$
151:                    int valIdx = md.getColumnIndex("value");//$NON-NLS-1$
152:                    if (nameIdx < 0) {
153:                        nameIdx = 0;
154:                    }
155:                    if (valIdx < 0) {
156:                        valIdx = 1;
157:                    }
158:                    for (int i = 0; i < rowCount; i++) {
159:                        Object[] aRow = values.getDataRow(i);
160:                        if ((aRow[nameIdx] != null) && (aRow[valIdx] != null)) {
161:                            config
162:                                    .setConfigProperty(
163:                                            aRow[nameIdx].toString(),
164:                                            applyInputsToFormat(aRow[valIdx]
165:                                                    .toString()));
166:                        }
167:                    }
168:                } else {
169:                    error(Messages
170:                            .getErrorString("JFreeReport.ERROR_0025_INVALID_REPORT_CONFIGURATION_PARAMETERS")); //$NON-NLS-1$
171:                }
172:            }
173:
174:            protected boolean validateAction() {
175:                return true;
176:            }
177:
178:            protected boolean validateSystemSettings() {
179:                return true;
180:            }
181:
182:            public Log getLogger() {
183:                return LogFactory
184:                        .getLog(JFreeReportConfigParameterComponent.class);
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.