Search in sources :

Example 21 with IPentahoResultSet

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;
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession)

Example 22 with IPentahoResultSet

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);
    }
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 23 with IPentahoResultSet

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());
        }
    }
}
Also used : IPentahoStreamSource(org.pentaho.commons.connection.IPentahoStreamSource) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Method(java.lang.reflect.Method) Date(java.util.Date) BigDecimal(java.math.BigDecimal) PluginBeanException(org.pentaho.platform.api.engine.PluginBeanException) GenericSignatureFormatError(java.lang.reflect.GenericSignatureFormatError) IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) IContentItem(org.pentaho.platform.api.repository.IContentItem)

Example 24 with IPentahoResultSet

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;
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 25 with IPentahoResultSet

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);
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) ResultSetCompareAction(org.pentaho.actionsequence.dom.actions.ResultSetCompareAction) Test(org.junit.Test)

Aggregations

IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)113 Test (org.junit.Test)26 Node (org.dom4j.Node)18 ArrayList (java.util.ArrayList)17 IPentahoMetaData (org.pentaho.commons.connection.IPentahoMetaData)12 Iterator (java.util.Iterator)10 List (java.util.List)10 IPentahoConnection (org.pentaho.commons.connection.IPentahoConnection)10 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)10 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)10 OutputStream (java.io.OutputStream)9 ResultSetCompareAction (org.pentaho.actionsequence.dom.actions.ResultSetCompareAction)8 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)8 XQConnection (org.pentaho.platform.plugin.services.connections.xquery.XQConnection)8 SQLException (java.sql.SQLException)7 HashMap (java.util.HashMap)6 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)6 Map (java.util.Map)5 Set (java.util.Set)5 IPreparedComponent (org.pentaho.platform.api.data.IPreparedComponent)5