1 13 package org.pentaho.plugin.jfreereport.helper; 14 15 import java.lang.reflect.Method ; 16 import java.util.HashMap ; 17 import java.util.Map ; 18 19 import javax.swing.table.TableModel ; 20 21 import org.jfree.report.DataRow; 22 import org.jfree.report.ReportInitialisationException; 23 import org.jfree.report.modules.misc.datafactory.StaticDataFactory; 24 25 30 public class PentahoDataFactory extends StaticDataFactory 31 { 32 private ClassLoader classLoader; 33 34 public PentahoDataFactory(final ClassLoader classLoader) 35 { 36 this.classLoader = classLoader; 37 } 38 39 public ClassLoader getClassLoader() 40 { 41 return classLoader; 42 } 43 44 public TableModel queryData(String string, DataRow dataRow) 45 throws ReportInitialisationException 46 { 47 final TableModel tableModel = super.queryData(string, dataRow); 48 49 try 50 { 51 Class cls = tableModel.getClass(); 52 Map map = new HashMap (); 53 for (int i = 0; i < dataRow.getColumnCount(); i++) 54 { 55 map.put (dataRow.getColumnName(i), dataRow.get(i)); 56 } 57 Object [] args = {map}; 58 Class [] argt = {Map .class}; 59 Method theMethod = cls.getMethod("setParameters", argt); if (theMethod != null) 61 { 62 theMethod.invoke(tableModel, args); 63 } 64 } 65 catch (Exception ignored) 66 { 67 } 69 70 return tableModel; 71 } 72 } 73 | Popular Tags |