KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > services > SQLDataSourceResolver


1 package com.calipso.reportgenerator.services;
2
3 import com.calipso.reportgenerator.common.InfoException;
4 import com.calipso.reportgenerator.reportcalculator.IDataSource;
5 import com.calipso.reportgenerator.reportcalculator.Matrix;
6
7 import java.util.Map JavaDoc;
8 import java.util.HashMap JavaDoc;
9 import com.calipso.reportgenerator.common.ReportGeneratorConfiguration;
10 import com.calipso.reportgenerator.common.ReportSpec;
11 import com.calipso.reportgenerator.common.ReportDataSourceSpec;
12 import com.calipso.reportgenerator.reportmanager.ReportDataSource;
13
14 /**
15  * Clase para implementar los distintos resolvedores de SQL
16  */

17 public abstract class SQLDataSourceResolver implements ISQLDataSourceResolver {
18
19   private static Map JavaDoc resolvers;
20   private String JavaDoc sqlText;
21   private ReportGeneratorConfiguration reportGeneratorConfiguration;
22   private DataSourceDefinitionConnectionString dataSourceDefinitionConnectionString;
23   private ReportSpec reportSpec;
24   protected ReportDataSource dataSource;
25
26   private static Map JavaDoc getResolvers() {
27     if (resolvers == null) {
28       resolvers = new HashMap JavaDoc();
29       resolvers.put(FramewokPlatform.Calipso, DefaultSQLDataSourceResolver.class);
30       resolvers.put(FramewokPlatform.StandAlone, DefaultSQLDataSourceResolver.class);
31     }
32     return resolvers;
33   }
34
35   public static ISQLDataSourceResolver getResolver(ReportGeneratorConfiguration reportGeneratorConfiguration, DataSourceDefinitionConnectionString dataSourceDefinitionConnectionString,ReportSpec reportSpec) throws InfoException {
36     Class JavaDoc resolverClass = (Class JavaDoc) getResolvers().get(reportGeneratorConfiguration.getFrameworkPlatform());
37     try {
38       ISQLDataSourceResolver resolver = (ISQLDataSourceResolver) resolverClass.newInstance();
39       resolver.init(reportGeneratorConfiguration, dataSourceDefinitionConnectionString,reportSpec);
40       return resolver;
41     }
42     catch (Exception JavaDoc e) {
43       throw new InfoException(com.calipso.reportgenerator.common.LanguageTraslator.traslate("206"), e);
44     }
45   }
46
47   public IDataSource execute(String JavaDoc sqlText, Matrix matrix) throws InfoException {
48     setSqlText(sqlText);
49     //setReportDataSourceSpec(this.getReportDataSourceSpec());
50
return execute(matrix);
51   }
52
53   public String JavaDoc getSqlText() {
54     return sqlText;
55   }
56
57   public void setSqlText(String JavaDoc sqlText) {
58     this.sqlText = sqlText;
59   }
60
61   public void setReportDataSource(ReportDataSource dataSource) {
62     this.dataSource = dataSource;
63   }
64
65   /*public ReportDataSourceSpec getReportDataSourceSpec() {
66     return dataSourceSpec;
67   }*/

68
69   public void init(ReportGeneratorConfiguration reportGeneratorConfiguration, DataSourceDefinitionConnectionString dataSourceDefinitionConnectionString,ReportSpec reportSpec) {
70     this.reportGeneratorConfiguration = reportGeneratorConfiguration;
71     this.dataSourceDefinitionConnectionString = dataSourceDefinitionConnectionString;
72     this.reportSpec = reportSpec;
73   }
74
75   public ReportGeneratorConfiguration getReportGeneratorConfiguration() {
76     return reportGeneratorConfiguration;
77   }
78
79   public DataSourceDefinitionConnectionString getDataSourceDefinitionConnectionString() {
80     return dataSourceDefinitionConnectionString;
81   }
82
83   public ReportSpec getReportSpec() {
84     return reportSpec;
85   }
86 }
87
Popular Tags