Source Code Cross Referenced for DecoratedReportParam.java in  » ERP-CRM-Financial » sakai » org » theospi » portfolio » reports » tool » 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 » ERP CRM Financial » sakai » org.theospi.portfolio.reports.tool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL:https://source.sakaiproject.org/svn/osp/trunk/reports/tool/src/java/org/theospi/portfolio/reports/tool/DecoratedReportParam.java $
003:         * $Id:DecoratedReportParam.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2005, 2006 The Sakai Foundation.
007:         *
008:         * Licensed under the Educational Community License, Version 1.0 (the "License");
009:         * you may not use this file except in compliance with the License.
010:         * You may obtain a copy of the License at
011:         *
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         *
014:         * Unless required by applicable law or agreed to in writing, software
015:         * distributed under the License is distributed on an "AS IS" BASIS,
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:         * See the License for the specific language governing permissions and
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.theospi.portfolio.reports.tool;
021:
022:        import java.text.ParseException;
023:        import java.text.SimpleDateFormat;
024:        import java.util.ArrayList;
025:        import java.util.List;
026:
027:        import javax.faces.model.SelectItem;
028:
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:        import org.theospi.portfolio.reports.model.ReportDefinitionParam;
032:        import org.theospi.portfolio.reports.model.ReportParam;
033:
034:        /**
035:         * This class allows the ReportResult to interact with the view
036:         *
037:         */
038:        public class DecoratedReportParam {
039:
040:            protected final transient Log logger = LogFactory
041:                    .getLog(getClass());
042:
043:            /** The link to the main tool */
044:            private ReportsTool reportsTool = null;
045:
046:            /** the report to decorate */
047:            private ReportParam reportParam;
048:
049:            private boolean isValid = false;
050:
051:            /** the index in the list of params which contains this class */
052:            private int index;
053:
054:            private static SimpleDateFormat dateFormatter = new SimpleDateFormat(
055:                    "MM/dd/yyyy");
056:
057:            public DecoratedReportParam(ReportParam reportParam,
058:                    ReportsTool reportsTool) {
059:                setReportParam(reportParam);
060:                this .reportsTool = reportsTool;
061:            }
062:
063:            public ReportParam getReportParam() {
064:                return reportParam;
065:            }
066:
067:            public void setReportParam(ReportParam reportParam) {
068:                this .reportParam = reportParam;
069:            }
070:
071:            public ReportDefinitionParam getReportDefinitionParam() {
072:                return reportParam.getReportDefinitionParam();
073:            }
074:
075:            public int getIndex() {
076:                return index;
077:            }
078:
079:            public void setIndex(int index) {
080:                this .index = index;
081:            }
082:
083:            public String getStaticValue() {
084:                return reportParam.getValue();
085:            }
086:
087:            public String getTextValue() {
088:                return reportParam.getValue();
089:            }
090:
091:            public void setTextValue(String value) {
092:                isValid = false;
093:                if (getIsFillIn() && !getIsDate()) {
094:                    if (getIsInteger()) {
095:                        try {
096:                            value = Integer.toString(Integer.parseInt(value));
097:                            isValid = true;
098:                        } catch (NumberFormatException pe) {
099:                            //if it fails to parse then it won't set isValid to true
100:                        }
101:                    }
102:                    if (getIsFloat()) {
103:                        try {
104:                            value = Float.toString(Float.parseFloat(value));
105:                            isValid = true;
106:                        } catch (NumberFormatException pe) {
107:                            //if it fails to parse then it won't set isValid to true
108:                        }
109:                    }
110:                    if (getIsString()) {
111:                        isValid = value.length() > 0;
112:                    }
113:                    reportParam.setValue(value);
114:                }
115:            }
116:
117:            public String getDateValue() {
118:                return reportParam.getValue();
119:            }
120:
121:            public void setDateValue(String value) {
122:                isValid = false;
123:                if (getIsFillIn() && getIsDate()) {
124:
125:                    try {
126:                        reportParam.setValue(dateFormatter.format(dateFormatter
127:                                .parse(value)));
128:                        isValid = true;
129:                    } catch (ParseException pe) {
130:                        //if it fails to parse then it won't set isValid to true
131:                    }
132:                }
133:            }
134:
135:            public String getMenuValue() {
136:                return reportParam.getValue();
137:            }
138:
139:            public void setMenuValue(String value) {
140:                if (getIsSet() && !getIsMultiSelectable()) {
141:                    reportParam.setValue(value);
142:                    isValid = true;
143:                }
144:            }
145:
146:            /**
147:             * defunc - we don't do lists now, it will output the list of 
148:             * selected values
149:             * @return List
150:             */
151:            public List getListValue() {
152:                if (reportParam.getListValue() == null) {
153:                    return new ArrayList();
154:                } else {
155:                    return reportParam.getListValue();
156:                }
157:            }
158:
159:            /**
160:             * defunc - We don't do lists now, the list value should 
161:             * iterate through and build a string of values
162:             * @param List value
163:             */
164:            public void setListValue(List value) {
165:                if (getIsSet() && getIsMultiSelectable()) {
166:                    reportParam.setListValue(value);
167:                    if (value.size() < 1) {
168:                        isValid = false;
169:                    } else {
170:                        isValid = true;
171:                    }
172:                }
173:            }
174:
175:            /**
176:             * gets the list of possible titles and values
177:             * This will return a List of drop down SelectItem.
178:             * The list is generated from any of the following:<br>
179:             * 		[value1, value2, value3, ...]<br>
180:             * 		[(value1), (value2), (value3), ...]<br>
181:             * 		[(value1; item title1), (value2; item title2), (value3; item title3), ...]<br>
182:             * These values would be in the value field of the report definition parameter.
183:             * If the parameter is created from a sql query, then
184:             * it is run:
185:             * 		select value from table where ...<br>
186:             * 		select value, itemTitle from table where ...
187:             * 
188:             * @return List of SelectItem
189:             */
190:            public List getSelectableValues() {
191:                ArrayList array = new ArrayList();
192:                if (getIsSet()) {
193:                    String strSet = null;
194:                    if (getIsDynamic()) {
195:                        //	run the sql in the report definition parameter value
196:                        strSet = reportsTool.getReportsManager()
197:                                .generateSQLParameterValue(reportParam);
198:                    } else {
199:                        strSet = reportParam.getReportDefinitionParam()
200:                                .getValue();
201:                    }
202:
203:                    strSet = strSet.substring(strSet.indexOf("[") + 1, strSet
204:                            .indexOf("]"));
205:                    String[] set = strSet.split(",");
206:
207:                    for (int i = 0; i < set.length; i++) {
208:                        String element = set[i].trim();
209:
210:                        //	replace any system values for display in the interface
211:                        element = reportsTool.getReportsManager()
212:                                .replaceSystemValues(element);
213:
214:                        if (element.indexOf("(") != -1) {
215:                            element = element.substring(
216:                                    element.indexOf("(") + 1, element
217:                                            .indexOf(")"));
218:
219:                            String[] elementData = element.split(";");
220:                            if (elementData.length == 0)
221:                                array.add(new SelectItem());
222:                            if (elementData.length == 1)
223:                                array
224:                                        .add(new SelectItem(elementData[0]
225:                                                .trim()));
226:                            if (elementData.length > 1)
227:                                array.add(new SelectItem(elementData[0].trim(),
228:                                        elementData[1].trim()));
229:                        } else {
230:                            array.add(new SelectItem(element));
231:                        }
232:                    }
233:
234:                }
235:
236:                return array;
237:            }
238:
239:            /**
240:             * tells whether this parameter is a set
241:             * @return boolean
242:             */
243:            public boolean getIsSet() {
244:                String type = reportParam.getReportDefinitionParam()
245:                        .getValueType();
246:                return type.equals(ReportDefinitionParam.VALUE_TYPE_ONE_OF_SET)
247:                        || type
248:                                .equals(ReportDefinitionParam.VALUE_TYPE_ONE_OF_QUERY)
249:                        || type
250:                                .equals(ReportDefinitionParam.VALUE_TYPE_MULTI_OF_SET)
251:                        || type
252:                                .equals(ReportDefinitionParam.VALUE_TYPE_MULTI_OF_QUERY);
253:            }
254:
255:            /**
256:             * tells whether this parameter is the result of a sql query
257:             * @return boolean
258:             */
259:            public boolean getIsDynamic() {
260:                String type = reportParam.getReportDefinitionParam()
261:                        .getValueType();
262:                return type
263:                        .equals(ReportDefinitionParam.VALUE_TYPE_ONE_OF_QUERY)
264:                        || type
265:                                .equals(ReportDefinitionParam.VALUE_TYPE_MULTI_OF_QUERY);
266:            }
267:
268:            /**
269:             * tells whether this parameter can have multiple values selected
270:             * @return boolean
271:             */
272:            public boolean getIsMultiSelectable() {
273:                String type = reportParam.getReportDefinitionParam()
274:                        .getValueType();
275:                return type
276:                        .equals(ReportDefinitionParam.VALUE_TYPE_MULTI_OF_SET)
277:                        || type
278:                                .equals(ReportDefinitionParam.VALUE_TYPE_MULTI_OF_QUERY);
279:            }
280:
281:            /**
282:             * tells whether this parameter is a fill in value
283:             * @return boolean
284:             */
285:            public boolean getIsFillIn() {
286:                return reportParam.getReportDefinitionParam().getValueType()
287:                        .equals(ReportDefinitionParam.VALUE_TYPE_FILLIN);
288:            }
289:
290:            /**
291:             * tells whether this parameter is a static value
292:             * @return boolean
293:             */
294:            public boolean getIsStatic() {
295:                return reportParam.getReportDefinitionParam().getValueType()
296:                        .equals(ReportDefinitionParam.VALUE_TYPE_STATIC);
297:            }
298:
299:            public boolean getIsDate() {
300:                return reportParam.getReportDefinitionParam().getType().equals(
301:                        ReportDefinitionParam.TYPE_DATE);
302:            }
303:
304:            public boolean getIsFloat() {
305:                return reportParam.getReportDefinitionParam().getType().equals(
306:                        ReportDefinitionParam.TYPE_INT);
307:            }
308:
309:            public boolean getIsInteger() {
310:                return reportParam.getReportDefinitionParam().getType().equals(
311:                        ReportDefinitionParam.TYPE_FLOAT);
312:            }
313:
314:            public boolean getIsString() {
315:                return reportParam.getReportDefinitionParam().getType().equals(
316:                        ReportDefinitionParam.TYPE_STRING);
317:            }
318:
319:            public boolean getIsValid() {
320:                return isValid || getIsStatic();
321:            }
322:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.