KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > DataSourceBuilder


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 JavaDoc;
10 import java.lang.reflect.Constructor JavaDoc;
11 import java.lang.reflect.InvocationTargetException JavaDoc;
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(ReportGeneratorConfiguration reportGeneratorConfiguration, ReportSpec spec) throws InfoException {
23     if(reportGeneratorConfiguration.isDatawareHouseEnabled() && spec.getDatawarehouseSaved()){
24       try {
25         Class JavaDoc datawarehouseMatrix = Class.forName("com.calipso.reportgenerator.reportcalculator.DatawarehouseMatrix");
26         Constructor JavaDoc aConstructor = datawarehouseMatrix.getConstructor(new Class JavaDoc[]{reportGeneratorConfiguration.getClass(), spec.getClass()});
27         return (Matrix)aConstructor.newInstance(new Object JavaDoc[]{reportGeneratorConfiguration, spec});
28       } catch (Exception JavaDoc e) {
29         throw new InfoException(LanguageTraslator.traslate("590"), e);
30       }
31     }
32 /* if(reportGeneratorConfiguration.getBlockSize() > 0){
33       int blockSize = reportGeneratorConfiguration.getBlockSize();
34       String fileName = reportGeneratorConfiguration.getReportSourceRepositoryPath() + "/" + spec.getSourceId();
35       //return new DatawarehouseMatrix(reportGeneratorConfiguration, reportSourceDefinitionId);
36       return new BlockMatrix(blockSize, fileName);
37     }*/

38     return new CollectionMatrix();
39   }
40
41   public static IDataSource buildDataSource(Vector JavaDoc 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