use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.
the class ServiceTestHelper method getSolutionEngine.
public static ISolutionEngine getSolutionEngine(IPentahoSession session) {
ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
solutionEngine.setLoggingLevel(ILogger.ERROR);
solutionEngine.init(session);
return solutionEngine;
}
use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.
the class ActionDelegateTest method execute.
@SuppressWarnings("unchecked")
private void execute(String actionSequenceFile, boolean exceptionOnError, IAction... actions) throws ActionSequenceException {
TestPluginManager pm = (TestPluginManager) PentahoSystem.get(IPluginManager.class);
for (IAction action : actions) {
pm.addAction(action);
}
// content outputs will write to this stream
out = new ByteArrayOutputStream();
// create SimpleOutputHandler (to handle outputs of type "response.content")
outputHandler = new SimpleOutputHandler(out, false);
outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_DEFAULT);
IPentahoSession session = new StandaloneSession("system");
ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
outputHandler.setSession(session);
String xactionStr = ServiceTestHelper.getXAction("src/test/resources/solution/test/ActionDelegateTest", actionSequenceFile);
// execute the action sequence, providing the outputHandler created above
IRuntimeContext rc = solutionEngine.execute(xactionStr, actionSequenceFile, "action sequence to test the TestAction", false, true, null, false, new HashMap(), outputHandler, null, new SimpleUrlFactory(""), new ArrayList());
int status = rc.getStatus();
if (status == IRuntimeContext.PARAMETERS_FAIL || status == IRuntimeContext.RUNTIME_CONTEXT_RESOLVE_FAIL || status == IRuntimeContext.RUNTIME_STATUS_FAILURE || status == IRuntimeContext.RUNTIME_STATUS_INITIALIZE_FAIL || status == IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL) {
throw new ActionSequenceException("Action sequence failed!");
}
}
use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.
the class WidgetGridComponent method getActionData.
protected IPentahoResultSet getActionData() {
// create an instance of the solution engine to execute the specified
// action
ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, getSession());
solutionEngine.setLoggingLevel(ILogger.DEBUG);
solutionEngine.init(getSession());
HashMap parameterProviders = getParameterProviders();
OutputStream outputStream = null;
SimpleOutputHandler outputHandler = null;
outputHandler = new SimpleOutputHandler(outputStream, false);
ArrayList messages = new ArrayList();
String processId = this.getClass().getName();
String actionSeqPath = ActionInfo.buildSolutionPath(solution, actionPath, actionName);
context = solutionEngine.execute(actionSeqPath, processId, false, true, instanceId, false, parameterProviders, outputHandler, null, urlFactory, messages);
if (actionOutput != null) {
if (context.getOutputNames().contains(actionOutput)) {
IActionParameter output = context.getOutputParameter(actionOutput);
IPentahoResultSet results = output.getValueAsResultSet();
if (results != null) {
results = results.memoryCopy();
}
return results;
} else {
// this is an error
return null;
}
} else {
// return the first list that we find...
Iterator it = context.getOutputNames().iterator();
while (it.hasNext()) {
IActionParameter output = (IActionParameter) it.next();
if (output.getType().equalsIgnoreCase(IActionParameter.TYPE_RESULT_SET)) {
IPentahoResultSet results = output.getValueAsResultSet();
if (results != null) {
results = results.memoryCopy();
}
return results;
}
}
}
return null;
}
use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.
the class CleanRepoPublisher method publish.
@Override
public String publish(final IPentahoSession localSession) {
try {
HashMap<String, String> parameters = new HashMap<String, String>();
ISolutionEngine engine = // $NON-NLS-1$//$NON-NLS-2$
SolutionHelper.execute(// $NON-NLS-1$//$NON-NLS-2$
"publisher", // $NON-NLS-1$//$NON-NLS-2$
localSession, // $NON-NLS-1$//$NON-NLS-2$
"admin/clean_repository.xaction", parameters, null);
IRuntimeContext context = engine.getExecutionContext();
int status = context.getStatus();
if (status != IRuntimeContext.RUNTIME_STATUS_SUCCESS) {
// $NON-NLS-1$
return Messages.getInstance().getString("CleanRepoPublisher.ERROR_0001_CLEAN_REPO_FAILED");
}
} catch (Throwable t) {
error(Messages.getInstance().getErrorString("CleanRepoPublisher.ERROR_0001_CLEAN_REPO_FAILED", t.getMessage()), // $NON-NLS-1$
t);
return Messages.getInstance().getString("CleanRepoPublisher.ERROR_0001_CLEAN_REPO_FAILED", // $NON-NLS-1$
t.getLocalizedMessage());
}
// $NON-NLS-1$
return Messages.getInstance().getString("CleanRepoPublisher.CLEAN_REPO_DONE");
}
use of org.pentaho.platform.api.engine.ISolutionEngine in project pentaho-platform by pentaho.
the class ActionComponent method getContentAsStream.
protected ByteArrayOutputStream getContentAsStream(final String mimeType) {
IPentahoSession userSession = getSession();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
outputHandler.setOutputPreference(outputPreference);
ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, getSession());
solutionEngine.setLoggingLevel(getLoggingLevel());
solutionEngine.init(userSession);
IRuntimeContext context = null;
try {
String actionSeqPath = ActionInfo.buildSolutionPath(solutionName, actionPath, actionName);
context = solutionEngine.execute(actionSeqPath, Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_TEST"), false, true, instanceId, false, getParameterProviders(), outputHandler, null, urlFactory, // $NON-NLS-1$
getMessages());
} finally {
if (context != null) {
context.dispose();
}
}
return outputStream;
}
Aggregations