1 20 package org.openi.mondrian.datasource; 21 22 import org.openi.util.Util; 23 import org.openi.xml.*; 24 import java.io.FileInputStream ; 25 import java.io.FileWriter ; 26 import java.io.IOException ; 27 import java.util.ArrayList ; 28 import java.util.List ; 29 import javax.xml.transform.TransformerException ; 30 31 32 44 public class DataSourceConfig { 45 private String datasourceXmlFile; 46 private String mondrianXslFile; 47 private BeanStorage storage; 48 private XMLTransformer transformer; 49 50 57 public DataSourceConfig(String mondrianXslFile, String datasourceXmlFile) { 58 this.datasourceXmlFile = datasourceXmlFile; 59 this.mondrianXslFile = mondrianXslFile; 60 storage = new BeanStorage(); 61 transformer = new XMLTransformer(); 62 } 63 64 72 public List getDataSources() throws TransformerException , IOException { 73 List datasources = null; 74 75 String mondrianXml = transformer.transform(new FileInputStream ( 76 mondrianXslFile), new FileInputStream (datasourceXmlFile)); 77 78 return datasources; 81 } 82 83 91 public void setDataSources(List datasources) 92 throws TransformerException , IOException { 93 String mondrianXml = storage.toXmlString(datasources); 94 95 String datasourceXml = transformer.transform(Util.getFileContents( 96 mondrianXslFile), mondrianXml); 97 FileWriter writer = new FileWriter (datasourceXmlFile); 98 writer.write(datasourceXml); 99 writer.flush(); 100 writer.close(); 101 } 102 } 103 | Popular Tags |