1 package com.calipso.reportgenerator.reportcalculator; 2 3 import com.calipso.reportgenerator.common.ReportGeneratorConfiguration; 4 import com.calipso.reportgenerator.common.ReportSpec; 5 import com.calipso.reportgenerator.common.InfoException; 6 import com.calipso.reportgenerator.common.LanguageTraslator; 7 import com.calipso.reportgenerator.reportdefinitions.ReportSourceDefinition; 8 9 import java.util.Vector ; 10 import java.lang.reflect.Constructor ; 11 import java.lang.reflect.InvocationTargetException ; 12 13 20 public class DataSourceBuilder { 21 22 public static Matrix buildMatrix(ReportGeneratorConfiguration reportGeneratorConfiguration, ReportSpec spec) throws InfoException { 23 if(reportGeneratorConfiguration.isDatawareHouseEnabled() && spec.getDatawarehouseSaved()){ 24 try { 25 Class datawarehouseMatrix = Class.forName("com.calipso.reportgenerator.reportcalculator.DatawarehouseMatrix"); 26 Constructor aConstructor = datawarehouseMatrix.getConstructor(new Class []{reportGeneratorConfiguration.getClass(), spec.getClass()}); 27 return (Matrix)aConstructor.newInstance(new Object []{reportGeneratorConfiguration, spec}); 28 } catch (Exception e) { 29 throw new InfoException(LanguageTraslator.traslate("590"), e); 30 } 31 } 32 38 return new CollectionMatrix(); 39 } 40 41 public static IDataSource buildDataSource(Vector columnNames, ReportGeneratorConfiguration configuration, ReportSpec reportSpec) throws InfoException { 42 Matrix result = buildMatrix(configuration, reportSpec); 43 result.setColumNames(columnNames); 44 return result; 45 } 46 47 public static Matrix buildMatrix(ReportGeneratorConfiguration configuration, ReportSourceDefinition definition) throws InfoException { 48 ReportSpec spec = new ReportSpec(configuration); 49 spec.fillFrom(definition); 50 return buildMatrix(configuration, spec); 51 } 52 } 53 | Popular Tags |