use of org.pentaho.commons.connection.IPentahoResultSet 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.commons.connection.IPentahoResultSet 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;
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class JFreeReportParametersComponent method initReportInputs.
private boolean initReportInputs() throws CloneNotSupportedException {
MasterReport report = getReport();
if (report == null) {
// $NON-NLS-1$
error(Messages.getInstance().getString("JFreeReportParametersComponent.ERROR_0034_NO_REPORT_DEFINITION"));
return false;
}
final boolean privateCopy = getInputBooleanValue(AbstractJFreeReportComponent.REPORTPARAMCOMPONENT_PRIVATEREPORT_OUTPUT, false);
if (privateCopy && isDefinedOutput(AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT)) {
report = (MasterReport) report.clone();
}
// Get input parameters, and set them as properties in the report
// object.
final Set paramNames = getInputNames();
final Iterator it = paramNames.iterator();
while (it.hasNext()) {
String paramName = (String) it.next();
Object paramValue = getInputValue(paramName);
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;
}
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);
}
}
if (privateCopy && isDefinedInput(AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT)) {
addTempParameterObject(AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT, report);
}
return true;
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class ResultSetCompareComponent method executeAction.
@Override
protected boolean executeAction() throws Throwable {
ResultSetCompareAction compareAction = (ResultSetCompareAction) getActionDefinition();
Object obj1 = compareAction.getResultSet1().getValue();
if (!(obj1 instanceof IPentahoResultSet)) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("ResultSetCompareComponent.ERROR_0004_INPUT_RS1_NOT_RS"));
return false;
}
Object obj2 = compareAction.getResultSet2().getValue();
if (!(obj2 instanceof IPentahoResultSet)) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("ResultSetCompareComponent.ERROR_0005_INPUT_RS2_NOT_RS"));
return false;
}
IPentahoResultSet rs1 = (IPentahoResultSet) compareAction.getResultSet1().getValue();
IPentahoResultSet rs2 = (IPentahoResultSet) compareAction.getResultSet2().getValue();
String tempOutputMismatches = compareAction.getOutputMismatches().getStringValue();
boolean outputMismatches = false;
if ((tempOutputMismatches != null) && tempOutputMismatches.trim().toLowerCase().equals("true")) {
// $NON-NLS-1$
outputMismatches = true;
}
boolean stopOnError = false;
String tempStopOnError = compareAction.getStopOnError().getStringValue();
if ((tempStopOnError != null) && tempStopOnError.trim().toLowerCase().equals("true")) {
// $NON-NLS-1$
stopOnError = true;
}
int compareCol = Integer.parseInt(compareAction.getCompareColumnNum().getStringValue());
return compareEquals(rs1, rs2, compareCol, outputMismatches, stopOnError);
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class IPreparedComponentIT method testIPreparedComponentXQueryShareConnection.
public void testIPreparedComponentXQueryShareConnection() {
startTest();
// $NON-NLS-1$
info("Expected: Successful execution with object available");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IRuntimeContext context = run("/test/ipreparedcomponents/ipreparedcomponent_xquery_shareconn.xaction");
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
context.getStatus());
// $NON-NLS-1$
IActionParameter rtn1 = context.getOutputParameter("prepared_component");
assertNotNull(rtn1);
IPreparedComponent preparedComponent1 = (IPreparedComponent) rtn1.getValue();
assertNotNull(preparedComponent1);
IPentahoResultSet resultset1 = preparedComponent1.executePrepared(null);
assertTrue(resultset1.getRowCount() >= 1);
Object val1 = resultset1.getValueAt(0, 0);
assertNotNull(val1);
finishTest();
}
Aggregations