use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.
the class SubActionComponent method executeAction.
@SuppressWarnings("deprecation")
@Override
protected boolean executeAction() throws Throwable {
SubActionAction subAction = (SubActionAction) getActionDefinition();
List<Object> ignoreParameters = new ArrayList<Object>();
String actionPath = buildActionPath(subAction.getSolution().getStringValue(), subAction.getPath().getStringValue(), subAction.getAction().getStringValue());
// see if we are supposed to proxy the session
IPentahoSession session = getSession();
if (subAction.getSessionProxy() != ActionInputConstant.NULL_INPUT) {
String sessionName = subAction.getSessionProxy().getStringValue();
// TODO support user-by-user locales
PentahoSessionParameterProvider params = new PentahoSessionParameterProvider(session);
session = new UserSession(sessionName, LocaleHelper.getLocale(), params);
}
// create a parameter provider
HashMap<String, Object> parameters = new HashMap<String, Object>();
Iterator<?> iterator = getInputNames().iterator();
while (iterator.hasNext()) {
String inputName = (String) iterator.next();
if (!StandardSettings.SOLUTION.equals(inputName) && !StandardSettings.PATH.equals(inputName) && !StandardSettings.ACTION.equals(inputName)) {
Object value = getInputValue(inputName);
ignoreParameters.add(value);
parameters.put(inputName, value);
}
}
parameters.put(StandardSettings.ACTION_URL_COMPONENT, getInputStringValue(StandardSettings.ACTION_URL_COMPONENT));
// get the ouptut stream
// TODO verify this with MB and JD
// getDefaultOutputStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ISolutionEngine solutionEngine = null;
try {
solutionEngine = SolutionHelper.execute(getProcessId(), session, actionPath, parameters, outputStream, null, true, false);
if (outputStream.size() > 0) {
getDefaultOutputStream(null).write(outputStream.toByteArray());
}
int status = solutionEngine.getStatus();
if (status == IRuntimeContext.RUNTIME_STATUS_SUCCESS) {
// now pass any outputs back
Iterator<?> it = this.getOutputNames().iterator();
while (it.hasNext()) {
String outputName = (String) it.next();
IActionParameter param = solutionEngine.getExecutionContext().getOutputParameter(outputName);
if (param != null) {
setOutputValue(outputName, param.getValue());
ignoreParameters.add(param.getValue());
}
}
return true;
} else {
return false;
}
} finally {
if (solutionEngine != null) {
solutionEngine.getExecutionContext().dispose(ignoreParameters);
}
}
}
use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.
the class JavaScriptResultSetIT method testRSCompareOK.
public void testRSCompareOK() {
startTest();
IRuntimeContext context = run("/samples/rules/ResultSetTest.xaction");
assertEquals(IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus());
IActionParameter rtn = context.getOutputParameter("COMPARERESULT");
assertNotNull(rtn);
String compareResult = rtn.getStringValue();
assertEquals(compareResult, "No Mismatches");
finishTest();
}
use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.
the class SubActionComponentIT method testSuccessPaths.
public void testSuccessPaths() {
startTest();
// $NON-NLS-1$
String testName = CO_TEST_NAME + "string_" + System.currentTimeMillis();
SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
parameterProvider.setParameter(SOLUTION_NAME_PARAM, SOLUTION_NAME);
parameterProvider.setParameter(SOLUTION_PATH_PARAM, "platform");
parameterProvider.setParameter(SUBACTION_PARAM, SUBACTION);
parameterProvider.setParameter(TEST_INPUT_PARAM, TEST_STRING);
IRuntimeContext context = run("/" + SOLUTION_NAME + "/platform/" + TEST_XACTION, parameterProvider, testName, CO_TEST_EXTN);
assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
context.getStatus());
IActionParameter rtn = context.getOutputParameter(TEST_OUTPUT_PARAM);
Object value = rtn.getValue();
assertEquals(TEST_STRING, value);
finishTest();
}
Aggregations