Source Code Cross Referenced for ResultSetCrosstabComponent.java in  » Report » pentaho-report » org » pentaho » plugin » core » 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.core 
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:        package org.pentaho.plugin.core;
014:
015:        import java.text.DecimalFormat;
016:        import java.text.Format;
017:        import java.text.SimpleDateFormat;
018:        import java.util.Set;
019:
020:        import org.apache.commons.logging.Log;
021:        import org.apache.commons.logging.LogFactory;
022:        import org.pentaho.commons.connection.IPentahoResultSet;
023:        import org.pentaho.commons.connection.PentahoDataTransmuter;
024:        import org.pentaho.messages.Messages;
025:        import org.pentaho.plugin.ComponentBase;
026:
027:        public class ResultSetCrosstabComponent extends ComponentBase {
028:
029:            private static final long serialVersionUID = -868492439427599791L;
030:
031:            private static final String RESULT_SET = "result_set"; //$NON-NLS-1$
032:
033:            private static final String PIVOT_COLUMN = "pivot_column"; //$NON-NLS-1$
034:
035:            private static final String MEASURES_COLUMN = "measures_column"; //$NON-NLS-1$
036:
037:            private static final String FORMAT_TYPE = "format_type"; //$NON-NLS-1$
038:
039:            private static final String FORMAT_STRING = "format_string"; //$NON-NLS-1$
040:
041:            private static final String ORDERED_MAPS = "ordered_maps"; //$NON-NLS-1$
042:
043:            private static final String TRANSFORM_SORTBYCOL = "sort_by_col"; //$NON-NLS-1$
044:
045:            private static final String SORT_FORMAT_TYPE = "sort_format_type"; //$NON-NLS-1$
046:
047:            private static final String SORT_FORMAT_STRING = "sort_format_string"; //$NON-NLS-1$
048:
049:            private static final String OLD_STYLE_CROSSTAB = "non_ordered"; //$NON-NLS-1$
050:
051:            private static final String UNIQUE_ROW_IDENTIFIER_COLUMN = "unique_row_identifier_column"; //$NON-NLS-1$ 
052:
053:            public void done() {
054:                // TODO Auto-generated method stub
055:
056:            }
057:
058:            protected boolean validateAction() {
059:                if (!isDefinedInput(PIVOT_COLUMN)) {
060:                    error(Messages
061:                            .getErrorString("ResultSetCrosstabComponent.ERROR_0001_PIVOT_COLUMN_IS_REQUIRED")); //$NON-NLS-1$
062:                    return false;
063:                }
064:                if (!isDefinedInput(MEASURES_COLUMN)) {
065:                    error(Messages
066:                            .getErrorString("ResultSetCrosstabComponent.ERROR_0002_MEASURES_COLUMN_IS_REQUIRED")); //$NON-NLS-1$
067:                    return false;
068:                }
069:                if (isDefinedInput(FORMAT_TYPE)) {
070:                    if (!isDefinedInput(FORMAT_STRING)) {
071:                        error(Messages
072:                                .getErrorString("ResultSetCrosstabComponent.ERROR_0003_FORMAT_PARAMETERS_BAD")); //$NON-NLS-1$
073:                        return false;
074:                    }
075:                }
076:                if (isDefinedInput(SORT_FORMAT_TYPE)) {
077:                    if (!isDefinedInput(SORT_FORMAT_STRING)) {
078:                        error(Messages
079:                                .getErrorString("ResultSetCrosstabComponent.ERROR_0004_SORT_FORMAT_PARAMETERS_BAD")); //$NON-NLS-1$
080:                        return false;
081:                    }
082:                }
083:                return true;
084:            }
085:
086:            protected boolean executeAction() throws Throwable {
087:                Object resultSetObject = getInputValue(RESULT_SET);
088:                String outputName = getResultOutputName();
089:                if (outputName == null) {
090:                    return false;
091:                }
092:                if (resultSetObject instanceof  IPentahoResultSet) {
093:                    int columnToPivot = Integer
094:                            .parseInt(getInputStringValue(PIVOT_COLUMN));
095:                    int measuresColumn = Integer
096:                            .parseInt(getInputStringValue(MEASURES_COLUMN));
097:                    String formatType = null;
098:                    String formatString = null;
099:                    if (isDefinedInput(FORMAT_TYPE)) {
100:                        formatType = getInputStringValue(FORMAT_TYPE);
101:                        formatString = getInputStringValue(FORMAT_STRING);
102:                    }
103:                    Format format = null;
104:
105:                    // this is that rSet is now the valid result Create the format if there is one
106:                    if (formatType != null && formatType.length() > 0) {
107:                        if (StandardSettings.DECIMAL_FORMAT_TYPE
108:                                .equalsIgnoreCase(formatType)) {
109:                            format = new DecimalFormat(formatString);
110:                        } else if (StandardSettings.DATE_FORMAT_TYPE
111:                                .equalsIgnoreCase(formatType)) {
112:                            format = new SimpleDateFormat(formatString);
113:                        }
114:                    }
115:                    // transform rSet here
116:                    String orderedMaps = getInputStringValue(ORDERED_MAPS);
117:                    boolean orderOutputColumns = "true".equalsIgnoreCase(orderedMaps); //$NON-NLS-1$
118:
119:                    // Sort-by column information
120:                    int transformSortByColumn = 0;
121:                    String sortColumn = getInputStringValue(TRANSFORM_SORTBYCOL);
122:                    if (sortColumn != null) {
123:                        transformSortByColumn = Integer.parseInt(sortColumn);
124:                    }
125:
126:                    //
127:                    // Column that uniquely identifies a row
128:                    // If supplied, will allow input rows to be un-ordered.
129:                    //
130:                    int uniqueRowIdentifierColumn = -1;
131:                    if (isDefinedInput(UNIQUE_ROW_IDENTIFIER_COLUMN)) {
132:                        String tmp = getInputStringValue(UNIQUE_ROW_IDENTIFIER_COLUMN);
133:                        uniqueRowIdentifierColumn = Integer.parseInt(tmp);
134:                    }
135:
136:                    String sortFormatType = null;
137:                    String sortFormatString = null;
138:                    if (isDefinedInput(SORT_FORMAT_TYPE)) {
139:                        sortFormatString = getInputStringValue(SORT_FORMAT_STRING);
140:                        sortFormatType = getInputStringValue(SORT_FORMAT_TYPE);
141:                    }
142:                    Format sortFormat = null;
143:                    if (sortFormatType != null && sortFormatType.length() > 0) {
144:                        if (StandardSettings.DECIMAL_FORMAT_TYPE
145:                                .equalsIgnoreCase(sortFormatString)) {
146:                            sortFormat = new DecimalFormat(sortFormatString);
147:                        } else if (StandardSettings.DATE_FORMAT_TYPE
148:                                .equalsIgnoreCase(sortFormatType)) {
149:                            sortFormat = new SimpleDateFormat(sortFormatString);
150:                        }
151:                    }
152:
153:                    IPentahoResultSet rSet = null;
154:
155:                    if (isDefinedInput(OLD_STYLE_CROSSTAB)) {
156:                        warn(Messages
157:                                .getString("ResultSetCrosstabComponent.WARN_DEPRECATED")); //$NON-NLS-1$
158:                        rSet = PentahoDataTransmuter.crossTab(
159:                                (IPentahoResultSet) resultSetObject,
160:                                columnToPivot - 1, measuresColumn - 1,
161:                                transformSortByColumn - 1, format, sortFormat,
162:                                orderOutputColumns);
163:                    } else {
164:                        rSet = PentahoDataTransmuter.crossTabOrdered(
165:                                (IPentahoResultSet) resultSetObject,
166:                                columnToPivot - 1, measuresColumn - 1,
167:                                transformSortByColumn - 1, format, sortFormat,
168:                                orderOutputColumns,
169:                                uniqueRowIdentifierColumn - 1);
170:                    }
171:                    // then set the outputResult
172:                    setOutputValue(outputName, rSet);
173:
174:                    return true;
175:
176:                }
177:                return false;
178:            }
179:
180:            public boolean init() {
181:                // TODO Auto-generated method stub
182:                return true;
183:            }
184:
185:            protected boolean validateSystemSettings() {
186:                return true; // nothing here...
187:            }
188:
189:            public Log getLogger() {
190:                return LogFactory.getLog(ResultSetCrosstabComponent.class);
191:            }
192:
193:            public String getResultOutputName() {
194:                Set outputs = getOutputNames();
195:                if ((outputs == null) || (outputs.size() != 1)) {
196:                    error(Messages
197:                            .getString("Template.ERROR_0002_OUTPUT_COUNT_WRONG")); //$NON-NLS-1$
198:                    return null;
199:                }
200:                String outputName = null;
201:                try {
202:                    outputName = getInputStringValue(StandardSettings.OUTPUT_NAME);
203:                } catch (Exception e) {
204:                }
205:                if (outputName == null) { // Drop back to the old behavior
206:                    outputName = (String) outputs.iterator().next();
207:                }
208:                return outputName;
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.