use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.
the class JFreeReportComponent method getDataFactory.
protected PentahoTableDataFactory getDataFactory() throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
PentahoTableDataFactory factory = null;
factory = getQueryComponentDataFactory();
if (factory == null) {
factory = getInputParamDataFactory();
}
if (factory == null) {
factory = getJarDataFactory();
}
if (factory == null) {
// $NON-NLS-1$
throw new Exception(Messages.getInstance().getString("JFreeReport.ERROR_0022_DATA_INPUT_INVALID_OBJECT"));
}
return factory;
}
use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.
the class JFreeReportComponent method getInputParamDataFactory.
private PentahoTableDataFactory getInputParamDataFactory() {
PentahoTableDataFactory factory = null;
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
ActionInput reportDataParam = (ActionInput) jFreeReportAction.getData();
Object dataObject = reportDataParam != null ? reportDataParam.getValue() : null;
if ((dataObject instanceof IPentahoResultSet) || (dataObject instanceof TableModel)) {
factory = new PentahoTableDataFactory();
if (dataObject instanceof IPentahoResultSet) {
IPentahoResultSet resultset = (IPentahoResultSet) dataObject;
if (resultset.isScrollable()) {
resultset.beforeFirst();
} else {
// $NON-NLS-1$
debug("ResultSet is not scrollable. Copying into memory");
IPentahoResultSet memSet = resultset.memoryCopy();
resultset.close();
resultset = memSet;
}
factory.addTable(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, new PentahoTableModel(resultset));
} else if (dataObject instanceof TableModel) {
factory.addTable(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, (TableModel) dataObject);
}
IActionInput[] subreportQueries = jFreeReportAction.getSubreportQueryParams();
for (IActionInput element : subreportQueries) {
dataObject = element.getValue();
if (dataObject instanceof IPreparedComponent) {
factory.addPreparedComponent(element.getName(), (IPreparedComponent) dataObject);
} else if (dataObject instanceof IPentahoResultSet) {
final IPentahoResultSet resultset = (IPentahoResultSet) dataObject;
resultset.beforeFirst();
factory.addTable(element.getName(), new PentahoTableModel(resultset));
} else if (dataObject instanceof TableModel) {
factory.addTable(element.getName(), (TableModel) dataObject);
}
}
}
return factory;
}
use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.
the class ReportWizardSpecComponent method getDataFactory.
@Override
protected PentahoTableDataFactory getDataFactory() throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
PentahoTableDataFactory factory = null;
if (reportSpec != null) {
if (!isDefinedInput(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTTEMP_PERFQRY) || "true".equals(getInputParameter(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTTEMP_PERFQRY))) {
// $NON-NLS-1$
IPentahoResultSet pentahoResultSet = getResultSet(getReportSpec());
factory = new PentahoTableDataFactory();
pentahoResultSet.beforeFirst();
factory.addTable(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, new PentahoTableModel(pentahoResultSet));
} else {
factory = super.getDataFactory();
}
} else {
factory = super.getDataFactory();
}
return factory;
}
use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.
the class JFreeReportDataComponent method getInputParamDataFactory.
@SuppressWarnings("unused")
private PentahoTableDataFactory getInputParamDataFactory() {
PentahoTableDataFactory factory = null;
if (isDefinedInput(AbstractJFreeReportComponent.DATACOMPONENT_DATAINPUT) || isDefinedInput(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT)) {
factory = new PentahoTableDataFactory();
final Iterator iter = getInputNames().iterator();
while (iter.hasNext()) {
String name = (String) iter.next();
final Object dataObject = getInputValue(name);
// if input name is "data", rename to "default" which is the name that jfreereport is expecting.
if (name.equals(AbstractJFreeReportComponent.DATACOMPONENT_DATAINPUT)) {
name = AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT;
}
if (dataObject instanceof IPreparedComponent) {
final IPreparedComponent comp = (IPreparedComponent) dataObject;
factory.addPreparedComponent(name, comp);
} else if (dataObject instanceof IPentahoResultSet) {
final IPentahoResultSet resultset = (IPentahoResultSet) dataObject;
resultset.beforeFirst();
factory.addTable(name, new PentahoTableModel(resultset));
} else if (dataObject instanceof TableModel) {
final TableModel model = (TableModel) dataObject;
factory.addTable(name, model);
}
}
}
return factory;
}
use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.
the class JFreeReportDataComponent method getQueryComponentDataFactory.
@SuppressWarnings("unused")
private PentahoTableDataFactory getQueryComponentDataFactory() throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
PentahoTableDataFactory factory = null;
dataComponent = null;
final Node sourceNode = getComponentDefinition().selectSingleNode(AbstractJFreeReportComponent.DATACOMPONENT_SOURCE);
if (sourceNode != null) {
String dataComponentClass = sourceNode.getText();
if (AbstractJFreeReportComponent.DATACOMPONENT_SQLSOURCE.equalsIgnoreCase(dataComponentClass)) {
dataComponentClass = AbstractJFreeReportComponent.DATACOMPONENT_SQLCLASS;
} else if (AbstractJFreeReportComponent.DATACOMPONENT_MDXSOURCE.equalsIgnoreCase(dataComponentClass)) {
dataComponentClass = AbstractJFreeReportComponent.DATACOMPONENT_MDXCLASS;
}
if (dataComponentClass != null) {
try {
final Class componentClass = Class.forName(dataComponentClass);
dataComponent = (IDataComponent) componentClass.newInstance();
dataComponent.setInstanceId(getInstanceId());
dataComponent.setActionName(getActionName());
dataComponent.setProcessId(getProcessId());
dataComponent.setComponentDefinition(getComponentDefinition());
dataComponent.setRuntimeContext(getRuntimeContext());
dataComponent.setSession(getSession());
dataComponent.setLoggingLevel(getLoggingLevel());
dataComponent.setMessages(getMessages());
// Abort, we cant continue anyway.
if ((dataComponent.validate() == IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_OK) && dataComponent.init() && (dataComponent.execute() == IRuntimeContext.RUNTIME_STATUS_SUCCESS)) {
final IPentahoResultSet resultset = dataComponent.getResultSet();
factory = new PentahoTableDataFactory(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, new PentahoTableModel(resultset));
} else {
throw new IllegalArgumentException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"JFreeReport.ERROR_0021_DATA_COMPONENT_FAILED"));
}
} catch (ClassNotFoundException e) {
// ignore
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return factory;
}
Aggregations