01: package com.calipso.reportgenerator.reportcalculator;
02:
03: import com.calipso.reportgenerator.common.ReportGeneratorConfiguration;
04: import com.calipso.reportgenerator.common.ReportSpec;
05: import com.calipso.reportgenerator.common.InfoException;
06: import com.calipso.reportgenerator.common.LanguageTraslator;
07: import com.calipso.reportgenerator.reportdefinitions.ReportSourceDefinition;
08:
09: import java.util.Vector;
10: import java.lang.reflect.Constructor;
11: import java.lang.reflect.InvocationTargetException;
12:
13: /**
14: *
15: * User: jbassino
16: * Date: 16-sep-2005
17: * Time: 16:39:12
18: *
19: */
20: public class DataSourceBuilder {
21:
22: public static Matrix buildMatrix(
23: ReportGeneratorConfiguration reportGeneratorConfiguration,
24: ReportSpec spec) throws InfoException {
25: if (reportGeneratorConfiguration.isDatawareHouseEnabled()
26: && spec.getDatawarehouseSaved()) {
27: try {
28: Class datawarehouseMatrix = Class
29: .forName("com.calipso.reportgenerator.reportcalculator.DatawarehouseMatrix");
30: Constructor aConstructor = datawarehouseMatrix
31: .getConstructor(new Class[] {
32: reportGeneratorConfiguration.getClass(),
33: spec.getClass() });
34: return (Matrix) aConstructor.newInstance(new Object[] {
35: reportGeneratorConfiguration, spec });
36: } catch (Exception e) {
37: throw new InfoException(LanguageTraslator
38: .traslate("590"), e);
39: }
40: }
41: /* if(reportGeneratorConfiguration.getBlockSize() > 0){
42: int blockSize = reportGeneratorConfiguration.getBlockSize();
43: String fileName = reportGeneratorConfiguration.getReportSourceRepositoryPath() + "/" + spec.getSourceId();
44: //return new DatawarehouseMatrix(reportGeneratorConfiguration, reportSourceDefinitionId);
45: return new BlockMatrix(blockSize, fileName);
46: }*/
47: return new CollectionMatrix();
48: }
49:
50: public static IDataSource buildDataSource(Vector columnNames,
51: ReportGeneratorConfiguration configuration,
52: ReportSpec reportSpec) throws InfoException {
53: Matrix result = buildMatrix(configuration, reportSpec);
54: result.setColumNames(columnNames);
55: return result;
56: }
57:
58: public static Matrix buildMatrix(
59: ReportGeneratorConfiguration configuration,
60: ReportSourceDefinition definition) throws InfoException {
61: ReportSpec spec = new ReportSpec(configuration);
62: spec.fillFrom(definition);
63: return buildMatrix(configuration, spec);
64: }
65: }
|