use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class FilterDefinitionIT method getSession.
private IPentahoSession getSession() {
IPentahoResultSet rs = getFakeResultSet();
// $NON-NLS-1$
IPentahoSession session = new StandaloneSession("REPOSTEST.JUNIT_TEST_SESSION");
// $NON-NLS-1$
session.setAttribute("customerNamesList", rs);
return session;
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class RuntimeContext method executeSequence.
@SuppressWarnings({ "unchecked" })
public void executeSequence(final IActionSequence sequence, final IActionCompleteListener doneListener, final IExecutionListener execListener, final boolean async) throws ActionSequenceException {
String loopParamName = sequence.getLoopParameter();
boolean peekOnly = sequence.getLoopUsingPeek();
Object loopList;
IActionParameter loopParm = null;
if (loopParamName == null) {
loopList = new ArrayList<Integer>();
((ArrayList) loopList).add(new Integer(0));
} else {
loopParm = getLoopParameter(loopParamName);
loopList = loopParm.getValue();
// If the loop list is an array, convert it to an array list for processing
if (loopList instanceof Object[]) {
loopList = Arrays.asList((Object[]) loopList);
}
}
if (loopList instanceof List) {
executeLoop(loopParm, (List) loopList, sequence, doneListener, execListener, async);
if (loopParm != null) {
// replace the loop param in case the last loop muggled it
addInputParameter(loopParm.getName(), loopParm);
}
} else if (loopList instanceof IPentahoResultSet) {
executeLoop(loopParm, (IPentahoResultSet) loopList, sequence, doneListener, execListener, async, peekOnly);
}
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class PojoComponent method callMethods.
protected void callMethods(List<Method> methods, Object value) throws Throwable {
if (value instanceof String) {
callMethodWithString(methods, value.toString());
return;
}
boolean done = false;
for (Method method : methods) {
Class<?>[] paramClasses = method.getParameterTypes();
if (paramClasses.length != 1) {
// we don't know how to handle this
throw new GenericSignatureFormatError();
}
Class<?> paramclass = paramClasses[0];
// do some type safety. this would be the point to do automatic type conversions
if (value instanceof IPentahoResultSet && paramclass.equals(IPentahoResultSet.class)) {
done = true;
method.invoke(pojo, new Object[] { (IPentahoResultSet) value });
break;
} else if (value instanceof java.lang.Boolean && (paramclass.equals(Boolean.class) || paramclass.equals(boolean.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof java.lang.Integer && (paramclass.equals(Integer.class) || paramclass.equals(int.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof java.lang.Long && (paramclass.equals(Long.class) || paramclass.equals(long.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof java.lang.Double && (paramclass.equals(Double.class) || paramclass.equals(double.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof java.lang.Float && (paramclass.equals(Float.class) || paramclass.equals(float.class))) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof IPentahoStreamSource && paramclass.equals(IPentahoStreamSource.class)) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof Date && paramclass.equals(Date.class)) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof BigDecimal && paramclass.equals(BigDecimal.class)) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof IContentItem && paramclass.equals(IContentItem.class)) {
done = true;
method.invoke(pojo, new Object[] { value });
break;
} else if (value instanceof IContentItem && paramclass.equals(String.class)) {
done = true;
method.invoke(pojo, new Object[] { value.toString() });
break;
} else if (paramclass.equals(IPentahoSession.class)) {
done = true;
method.invoke(pojo, new Object[] { (IPentahoSession) value });
break;
} else if (paramclass.equals(Log.class)) {
done = true;
method.invoke(pojo, new Object[] { (Log) value });
break;
}
}
if (!done) {
// Try invoking the first instance with what we have
try {
methods.get(0).invoke(pojo, new Object[] { value });
} catch (Exception ex) {
throw new IllegalArgumentException(// $NON-NLS-1$ //$NON-NLS-2$
"No implementation of method \"" + Method.class.getName() + "\" takes a " + value.getClass());
}
}
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class ConditionalExecutionTest method createParameterWithResult.
private static IActionParameter createParameterWithResult(int rowsCount) {
IActionParameter parameter = mock(IActionParameter.class);
IPentahoResultSet resultSet = mock(IPentahoResultSet.class);
when(resultSet.getRowCount()).thenReturn(rowsCount);
when(parameter.getValue()).thenReturn(resultSet);
return parameter;
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class ResultSetCompareComponentTest method validationSuccessful.
@Test
public void validationSuccessful() {
ResultSetCompareComponent rscc = createResultSetCompareComponent();
IPentahoResultSet rs = Mockito.mock(IPentahoResultSet.class);
ResultSetCompareAction resultSetCompareAction = createResultSetCompareAction(rs, rs, 0, false, true);
rscc.setActionDefinition(resultSetCompareAction);
int actualValidateResult = rscc.validate();
assertEquals(IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_OK, actualValidateResult);
}
Aggregations