use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class JFreeReportComponent method initReportConfigParameters.
private boolean initReportConfigParameters(final MasterReport report) {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
boolean result = true;
if (isDefinedInput(AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT)) {
Object reportConfigParams = jFreeReportAction.getReportConfig().getValue();
if (reportConfigParams != null) {
if (reportConfigParams instanceof IPentahoResultSet) {
setReportConfigParameters(report, (IPentahoResultSet) reportConfigParams);
} else if (reportConfigParams instanceof Map) {
setReportConfigParameters(report, (Map) reportConfigParams);
} else if (reportConfigParams instanceof JFreeReportAction.StaticReportConfig) {
setReportConfigParameters(report, (JFreeReportAction.StaticReportConfig) reportConfigParams);
} else {
error(Messages.getInstance().getErrorString(// $NON-NLS-1$
"JFreeReport.ERROR_0026_UNKNOWN_REPORT_CONFIGURATION_PARAMETERS"));
result = false;
}
}
}
return result;
}
use of org.pentaho.commons.connection.IPentahoResultSet 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.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class JFreeReportComponent method initReportInputs.
private boolean initReportInputs(final MasterReport report) throws CloneNotSupportedException {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
// Get input parameters, and set them as properties in the report
// object.
IActionInput[] actionInputs = jFreeReportAction.getInputs();
for (IActionInput element : actionInputs) {
String paramName = element.getName();
Object paramValue = element.getValue();
if ((paramValue == null) || "".equals(paramValue)) {
// $NON-NLS-1$
continue;
}
if (paramValue instanceof IPentahoResultSet) {
continue;
}
if (paramValue instanceof TableModel) {
continue;
}
if (AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT.equals(paramName)) {
continue;
}
if (AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_DATAINPUT.equals(paramName)) {
continue;
}
if (AbstractJFreeReportComponent.DATACOMPONENT_DATAINPUT.equals(paramName)) {
continue;
}
/*
* WG: Commenting out because this change (SVN: 44880) breaks bi-developers / reporting / subreport.xaction we'll
* need to revisit this when reving to the 4.0 reporting engine.
*
* final ParameterDefinitionEntry[] parameterDefinitions =
* report.getParameterDefinition().getParameterDefinitions(); boolean foundParameter = false; for (int j = 0; j <
* parameterDefinitions.length; j++) { final ParameterDefinitionEntry definition = parameterDefinitions[j]; if
* (paramName.equals(definition.getName())) { foundParameter = true; break; } } if (foundParameter == false) { if
* (report.getParameterDefinition() instanceof ModifiableReportParameterDefinition) { final
* ModifiableReportParameterDefinition parameterDefinition = (ModifiableReportParameterDefinition)
* report.getParameterDefinition(); parameterDefinition.addParameterDefinition(new PlainParameter(paramName)); } }
*/
if (paramValue instanceof Object[]) {
Object[] values = (Object[]) paramValue;
StringBuffer valuesBuffer = new StringBuffer();
// TODO support non-string items
for (int j = 0; j < values.length; j++) {
if (j == 0) {
valuesBuffer.append(values[j].toString());
} else {
valuesBuffer.append(',').append(values[j].toString());
}
}
report.getParameterValues().put(paramName, valuesBuffer.toString());
// report.setProperty(paramName, valuesBuffer.toString());
} else {
report.getParameterValues().put(paramName, paramValue);
// report.setProperty(paramName, paramValue);
}
}
return true;
}
use of org.pentaho.commons.connection.IPentahoResultSet 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.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class JFreeReportConfigParameterComponent method initReportConfigParameters.
private boolean initReportConfigParameters() {
boolean result = true;
if (isDefinedInput(AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT)) {
Object maybeReport = getInputValue(AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT);
if (maybeReport instanceof MasterReport) {
MasterReport report = (MasterReport) maybeReport;
// We should have our report object at this point.
if (isDefinedInput(JFreeReportConfigParameterComponent.REPORT_CONFIG_INPUT_PARAM)) {
// It's coming in as an input parameter
Object reportConfigParams = this.getInputValue(JFreeReportConfigParameterComponent.REPORT_CONFIG_INPUT_PARAM);
if (reportConfigParams instanceof IPentahoResultSet) {
setReportConfigParameters(report, (IPentahoResultSet) reportConfigParams);
} else if (reportConfigParams instanceof Map) {
setReportConfigParameters(report, (Map) reportConfigParams);
} else {
error(Messages.getInstance().getErrorString(// $NON-NLS-1$
"JFreeReport.ERROR_0026_UNKNOWN_REPORT_CONFIGURATION_PARAMETERS"));
result = false;
}
} else {
Node compDef = getComponentDefinition();
// $NON-NLS-1$
List configNodes = compDef.selectNodes(JFreeReportConfigParameterComponent.REPORT_CONFIG_COMPDEFN + "/*");
if ((configNodes != null) && (configNodes.size() > 0)) {
setReportConfigParameters(report, configNodes);
}
}
}
}
return result;
}
Aggregations