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 ; 8 import java.util.HashMap ; 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 17 public abstract class SQLDataSourceResolver implements ISQLDataSourceResolver { 18 19 private static Map resolvers; 20 private String sqlText; 21 private ReportGeneratorConfiguration reportGeneratorConfiguration; 22 private DataSourceDefinitionConnectionString dataSourceDefinitionConnectionString; 23 private ReportSpec reportSpec; 24 protected ReportDataSource dataSource; 25 26 private static Map getResolvers() { 27 if (resolvers == null) { 28 resolvers = new HashMap (); 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 resolverClass = (Class ) 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 e) { 43 throw new InfoException(com.calipso.reportgenerator.common.LanguageTraslator.traslate("206"), e); 44 } 45 } 46 47 public IDataSource execute(String sqlText, Matrix matrix) throws InfoException { 48 setSqlText(sqlText); 49 return execute(matrix); 51 } 52 53 public String getSqlText() { 54 return sqlText; 55 } 56 57 public void setSqlText(String sqlText) { 58 this.sqlText = sqlText; 59 } 60 61 public void setReportDataSource(ReportDataSource dataSource) { 62 this.dataSource = dataSource; 63 } 64 65 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 |