Source Code Cross Referenced for ReportGeneratorConfiguration.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » common » 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 » jmagallanes 1.0 » com.calipso.reportgenerator.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.common;
002:
003:        import org.apache.commons.configuration.Configuration;
004:        import org.apache.commons.configuration.PropertiesConfiguration;
005:
006:        import java.io.IOException;
007:        import java.io.File;
008:        import java.io.InputStream;
009:        import java.util.Iterator;
010:        import java.util.Map;
011:        import java.util.HashMap;
012:        import java.awt.*;
013:        import java.net.URL;
014:
015:        /**
016:         * Configuración del ReportGegnerator.
017:         */
018:        public class ReportGeneratorConfiguration implements 
019:                java.io.Serializable {
020:
021:            private Map values;
022:
023:            /**
024:             * Inicializa la configuración
025:             * @param reportGeneratorConfiguration
026:             * @throws com.calipso.reportgenerator.common.InfoException
027:             */
028:            public ReportGeneratorConfiguration(
029:                    Configuration reportGeneratorConfiguration)
030:                    throws InfoException {
031:                fillValues(reportGeneratorConfiguration);
032:                validate();
033:            }
034:
035:            public Map getValues() {
036:                if (values == null) {
037:                    values = new HashMap();
038:                }
039:                return values;
040:            }
041:
042:            private void fillValues(Configuration reportGeneratorConfiguration) {
043:                Iterator iter = reportGeneratorConfiguration.getKeys();
044:                while (iter.hasNext()) {
045:                    String key = (String) iter.next();
046:                    String value = reportGeneratorConfiguration.getString(key);
047:                    getValues().put(key, value);
048:                }
049:
050:            }
051:
052:            /**
053:             * Inicializa la configuración a partir de un file
054:             * @param file
055:             * @throws com.calipso.reportgenerator.common.InfoException
056:             */
057:            public ReportGeneratorConfiguration(String file)
058:                    throws InfoException {
059:                try {
060:                    fillValues(new PropertiesConfiguration(file));
061:                    validate();
062:                } catch (Exception e) {
063:                    throw new InfoException(LanguageTraslator.traslate("228"),
064:                            e);
065:                }
066:            }
067:
068:            /**
069:             * Valida que la configuración sea la correcta
070:             */
071:            public void validate() throws InfoException {
072:                if (getValues().isEmpty()) {
073:                    throw new InfoException(
074:                            com.calipso.reportgenerator.common.LanguageTraslator
075:                                    .traslate("81"));
076:                }
077:            }
078:
079:            public boolean getIsDistributed() {
080:                return (values.get("IsDistributed").equals("true"));
081:            }
082:
083:            public String getDistributedHost() {
084:                return (String) values.get("DistributedHost");
085:            }
086:
087:            public String getDistributedPort() {
088:                return (String) values.get("DistributedPort");
089:            }
090:
091:            public String getReportDefinitionRepositoryPath() {
092:                return (String) values.get("ReportDefinitionRepositoryPath");
093:            }
094:
095:            public String getReportSourceDefinitionRepositoryPath() {
096:                return (String) values
097:                        .get("ReportSourceDefinitionRepositoryPath");
098:            }
099:
100:            public String getReportSourceRepositoryPath() {
101:                return (String) values.get("ReportSourceRepositoryPath");
102:            }
103:
104:            public String getReportViewRepositoryPath() {
105:                return (String) values.get("ReportViewRepositoryPath");
106:            }
107:
108:            public String getINITIAL_CONTEXT_FACTORY() {
109:                return (String) values.get("INITIAL_CONTEXT_FACTORY");
110:            }
111:
112:            public String getJavaNamingFactoryUrlPkgs() {
113:                return (String) values.get("java.naming.factory.url.pkgs");
114:            }
115:
116:            public String getDatePattern() {
117:                return (String) values.get("DatePattern");
118:            }
119:
120:            public boolean queryCacheEnabled() {
121:                if (values.containsKey("queryCacheEnabled")) {
122:                    return (values.get("queryCacheEnabled").equals("true"));
123:                } else {
124:                    return true;
125:                }
126:
127:            }
128:
129:            public String getLocaleLanguage() {
130:                if (values.containsKey("Language")) {
131:                    if ((values.get("Language")).equals("")) {
132:                        return "ES";
133:                    } else {
134:                        return (String) values.get("Language");
135:                    }
136:                }
137:                return "ES";
138:            }
139:
140:            public String getCountry() {
141:                if (values.containsKey("Country")) {
142:                    return (String) values.get("Country");
143:                }
144:                return "";
145:            }
146:
147:            public String getSourceReportDefinitionsPath() {
148:                return (String) values.get("SourceReportDefinitionsPath");
149:            }
150:
151:            public String getSourceReportSourceDefinitionsPath() {
152:                return (String) values.get("SourceReportSourceDefinitionsPath");
153:            }
154:
155:            public String getSourceReportViewsPath() {
156:                return (String) values.get("SourceReportViewsPath");
157:            }
158:
159:            public String getSourceReportSchemasPath() {
160:                return (String) values.get("SourceReportSchemasPath");
161:            }
162:
163:            public String getFrameworkPlatform() {
164:                return (String) values.get("FrameworkPlatform");
165:            }
166:
167:            public String getCachePath() {
168:                return (String) values.get("CachePath");
169:            }
170:
171:            public String getCacheSizeLimit() {
172:                return (String) values.get("CacheSizeLimit");
173:            }
174:
175:            public String getUsersRepositoryPath() {
176:                return (String) values.get("UsersRepositoryPath");
177:            }
178:
179:            public String getBasePath() {
180:                if (values.containsKey("BasePath")) {
181:                    return (String) values.get("BasePath");
182:                } else {
183:                    return ".";
184:                }
185:            }
186:
187:            public String getLanguagesPath() {
188:                if (values.containsKey("LanguagesPath")) {
189:                    return (String) values.get("LanguagesPath");
190:                } else {
191:                    return ".";
192:                }
193:            }
194:
195:            public String getImagesPath() {
196:                if (values.containsKey("ImagesPath")) {
197:                    return (String) values.get("ImagesPath");
198:                } else {
199:                    return ".";
200:                }
201:            }
202:
203:            public String getJasperReportPath() {
204:                String returnStr = "";
205:                if (values.containsKey("JasperReportPath")) {
206:                    returnStr = (String) values.get("JasperReportPath");
207:                }
208:                return returnStr;
209:            }
210:
211:            public String getPolloPath() {
212:                String returnStr = "";
213:                if (values.containsKey("PolloPath")) {
214:                    returnStr = (String) values.get("PolloPath");
215:                }
216:                return returnStr;
217:            }
218:
219:            public String getJasperCompilerClass() {
220:                String returnStr = "";
221:                if (values.containsKey("JasperCompilerClass")) {
222:                    returnStr = (String) values.get("JasperCompilerClass");
223:                }
224:                return returnStr;
225:            }
226:
227:            public String getReportManagerEJB_SFName() {
228:                String returnStr = "ReportManagerSF";
229:                if (values.containsKey("ReportManagerEJB_SFName")) {
230:                    returnStr = (String) values.get("ReportManagerEJB_SFName");
231:                }
232:                return returnStr;
233:            }
234:
235:            public String getReportManagerEJB_SLName() {
236:                String returnStr = "ReportManagerSL";
237:                if (values.containsKey("ReportManagerEJB_SLName")) {
238:                    returnStr = (String) values.get("ReportManagerEJB_SLName");
239:                }
240:                return returnStr;
241:            }
242:
243:            public static PropertiesConfiguration getConfiguration(
244:                    String propertiesPath) throws InfoException {
245:                PropertiesConfiguration config = null;
246:                try {
247:                    config = new PropertiesConfiguration(
248:                            ReportGeneratorConfiguration
249:                                    .getConfigurationPath(propertiesPath));
250:                } catch (Exception e) {
251:                    ClassLoader loader = ReportGeneratorConfiguration.class
252:                            .getClassLoader();
253:                    InputStream inputStream = loader
254:                            .getResourceAsStream("ReportGeneratorConfiguration.properties");
255:                    config = new PropertiesConfiguration();
256:                    try {
257:                        config.load(inputStream);
258:                    } catch (Exception e1) {
259:                        throw new InfoException("372", e);
260:                    }
261:                }
262:                return config;
263:            }
264:
265:            public static String getConfigurationPath(String propertiesPath) {
266:                if (!propertiesPath.equals("")) {
267:                    return propertiesPath
268:                            + "/ReportGeneratorConfiguration.properties";
269:                } else {
270:                    String property = System
271:                            .getProperty("CalipsoConfigurationRoot");
272:                    if (property != null) {
273:                        return property
274:                                + "/ReportGeneratorConfiguration.properties";
275:                    } else {
276:                        return "./ReportGeneratorConfiguration.properties";
277:                    }
278:                }
279:            }
280:
281:            /**
282:             * Retorna el directorio de las imágenes
283:             * @return
284:             */
285:            public File getImageDir() {
286:                File file = new File(getImagesPath());
287:                String frameWork = getFrameworkPlatform();
288:                if (file.listFiles() != null) {
289:                    File[] files = file.listFiles();
290:                    for (int i = 0; i < files.length; i++) {
291:                        if (files[i].getName().toUpperCase().trim().equals(
292:                                frameWork)) {
293:                            return files[i];
294:                        }
295:                    }
296:                }
297:                return null;
298:            }
299:
300:            /**
301:             * Retorna el path de una imagen
302:             * @param imageName
303:             * @return
304:             */
305:            public String getImagePath(String imageName) {
306:                String imagePath = null;
307:                File file = getImageDir();
308:                if (file != null) {
309:                    File[] files = file.listFiles();
310:                    for (int i = 0; i < files.length; i++) {
311:                        if (files[i].getName().trim().equalsIgnoreCase(
312:                                imageName + ".jpg")
313:                                || files[i].getName().trim().equalsIgnoreCase(
314:                                        imageName + ".png")
315:                                || files[i].getName().trim().equalsIgnoreCase(
316:                                        imageName + ".bmp")
317:                                || files[i].getName().trim().equalsIgnoreCase(
318:                                        imageName + ".gif")) {
319:                            imagePath = files[i].toString();
320:                            break;
321:                        }
322:                    }
323:                }
324:                return imagePath;
325:            }
326:
327:            /**
328:             * Retorna una imagen
329:             * @param imageName
330:             * @return
331:             */
332:            public Image getImage(String imageName) {
333:                Image image = null;
334:                try {
335:                    String path = getImagePath(imageName);
336:                    if (path != null) {
337:                        image = java.awt.Toolkit.getDefaultToolkit().getImage(
338:                                path);
339:                    }
340:                    if (image == null) {
341:                        //Si viene de jar
342:                        try {
343:                            //URL url = this.getClass().getResource(path);
344:                            URL url = getResourceUrl(imageName);
345:                            if (url != null) {
346:                                image = Toolkit.getDefaultToolkit().getImage(
347:                                        url);
348:                            }
349:                        } catch (Exception e) {
350:                            e.printStackTrace();
351:                        }
352:                        /*if(image != null)
353:                        System.out.println("Levanto la imagen del jar");*/
354:                    }
355:                    /*if(image == null){
356:                      String path1 = path.substring(path.lastIndexOf("\\") + 1);
357:                      try{
358:                        URL url = this.getClass().getResource(path1);
359:                        image = Toolkit.getDefaultToolkit().getImage(url);
360:                      }catch(Exception e){
361:                        e.printStackTrace();
362:                      }
363:                      if(image != null)
364:                      System.out.println("funciono solo con el nombre");
365:                    }
366:                    if(image == null){
367:                      String path2 = path.substring(1);
368:                      try{
369:                        URL url = this.getClass().getResource(path2);
370:                        image = Toolkit.getDefaultToolkit().getImage(url);
371:                      }catch(Exception e){
372:                        e.printStackTrace();
373:                      }
374:                      if(image != null)
375:                      System.out.println("funciono sacandole el punto");
376:                    }
377:                    return image;
378:                    }else if(image == null){
379:                    try{
380:                      URL url = this.getClass().getResource("com/calipso/reportgenerator/userinterface/images/" + imageName + ".jpg");
381:                      image = Toolkit.getDefaultToolkit().getImage(url);
382:                    }catch(Exception e){
383:                      e.printStackTrace();
384:                    }
385:                    }     */
386:                } catch (Exception e) {
387:                    e.printStackTrace();
388:                }
389:                return image;
390:            }
391:
392:            private URL getResourceUrl(String imageName) {
393:                URL url = null;
394:                String[] ext = new String[] { "gif", "jpg" };
395:                String framework = getFrameworkPlatform();
396:                for (int i = 0; i < ext.length; i++) {
397:                    String s = ext[i];
398:                    url = this .getClass().getClassLoader().getResource(
399:                            "com/calipso/reportgenerator/userinterface/images/"
400:                                    + framework + "/" + imageName.toLowerCase()
401:                                    + "." + s);
402:                    if (url != null) {
403:                        return url;
404:                    }
405:                }
406:                return url;
407:            }
408:
409:            public String getSourceReportLayoutPath() {
410:                return (String) values.get("SourceReportLayoutsPath");
411:            }
412:
413:            public String getReportLayoutStyle() {
414:                return (String) values.get("ReportLayoutStyle");
415:            }
416:
417:            public String getRolsRepositoryPath() {
418:                return (String) values.get("RolsRepositoryPath");
419:            }
420:
421:            public String getUserDataRepositoryPath() {
422:                return (String) values.get("UserDataRepositoryPath");
423:            }
424:
425:            public String getTempPath() {
426:                return (String) values.get("TempPath");
427:            }
428:
429:            public String getRolDataRepositoryPath() {
430:                return (String) values.get("RolDataRepositoryPath");
431:            }
432:
433:            public String getMicroReportRepositoryPath() {
434:                return (String) values.get("MicroReportRepositoryPath");
435:            }
436:
437:            public boolean isCsvSerialized() {
438:                if (values.get("CsvSerialized") == null) {
439:                    return true;
440:                }
441:                return ((String) values.get("CsvSerialized"))
442:                        .equalsIgnoreCase("true");
443:            }
444:
445:            public int getBlockSize() {
446:                if (values.get("BlockSize") == null) {
447:                    return 0;
448:                }
449:                return Integer.parseInt((String) values.get("BlockSize"));
450:            }
451:
452:            public String getCachedDBlUrl() {
453:                return (String) values.get("CachedDBlUrl");
454:            }
455:
456:            public String getCachedDBUserName() {
457:                return (String) values.get("CachedDBUserName");
458:            }
459:
460:            public String getCachedDBPassword() {
461:                return (String) values.get("CachedDBPassword");
462:            }
463:
464:            public String getCachedDBJDBCClassName() {
465:                return (String) values.get("CachedDBJDBCClassName");
466:            }
467:
468:            public String getClientLogFile() {
469:                return (String) values.get("ClientLogFile");
470:            }
471:
472:            public boolean isDatawareHouseEnabled() {
473:                if (values.containsKey("DatawareHouseEnabled")) {
474:                    return (values.get("DatawareHouseEnabled").toString())
475:                            .equalsIgnoreCase("true");
476:                }
477:                return false;
478:            }
479:
480:            public int getFetchSize() {
481:                if (values.containsKey("FetchSize")) {
482:                    return Integer.parseInt(values.get("FetchSize").toString());
483:                }
484:                return 1000;
485:            }
486:
487:            public String getSQLBuilder() {
488:                return (String) values.get("SQLBuilder");
489:            }
490:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.