public ISolutionEngine getSolutionEngine(String path) { StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(path, ""); // $NON-NLS-1$ if (!PentahoSystem.getInitializedOK()) { PentahoSystem.init(applicationContext); assertTrue( "PentahoSystem did not initialize", PentahoSystem.getInitializedOK()); // $NON-NLS-1$ } IPentahoSession session = new StandaloneSession("system"); // $NON-NLS-1$ ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session); assertNotNull("SolutionEngine is null", solutionEngine); // $NON-NLS-1$ solutionEngine.setLoggingLevel(ILogger.ERROR); solutionEngine.init(session); try { solutionEngine.setSession(session); return solutionEngine; } catch (Exception e) { // we should not get here e.printStackTrace(); assertTrue(e.getMessage(), false); } return null; }
public void testForcePrompt() { startTest(); SimpleParameterProvider parameterProvider = new SimpleParameterProvider(); OutputStream outputStream = getOutputStream("RuntimeTest.testForcePrompt", ".html"); // $NON-NLS-1$ //$NON-NLS-2$ SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_PARAMETERS); StandaloneSession session = new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); // $NON-NLS-1$ ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session); solutionEngine.setLoggingLevel(getLoggingLevel()); solutionEngine.init(session); solutionEngine.setForcePrompt(true); IRuntimeContext context = run( solutionEngine, "test", "reporting", "jfreereport-reports-test-param.xaction", null, false, parameterProvider, outputHandler); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals( Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus()); // $NON-NLS-1$ finishTest(); }
@SuppressWarnings("rawtypes") protected static IRuntimeContext executeInternal( RepositoryFile file, IParameterProvider requestParams, HttpServletRequest httpServletRequest, IOutputHandler outputHandler, Map<String, IParameterProvider> parameterProviders, IPentahoSession userSession, boolean forcePrompt, List messages) throws Exception { String processId = XactionUtil.class.getName(); String instanceId = httpServletRequest.getParameter("instance-id"); // $NON-NLS-1$ SimpleUrlFactory urlFactory = new SimpleUrlFactory(""); // $NON-NLS-1$ ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, userSession); ISystemSettings systemSettings = PentahoSystem.getSystemSettings(); if (solutionEngine == null) { throw new ObjectFactoryException("No Solution Engine"); } boolean instanceEnds = "true" .equalsIgnoreCase( requestParams.getStringParameter( "instanceends", "true")); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String parameterXsl = systemSettings.getSystemSetting( "default-parameter-xsl", "DefaultParameterForm.xsl"); // $NON-NLS-1$ //$NON-NLS-2$ solutionEngine.setLoggingLevel(2); solutionEngine.init(userSession); solutionEngine.setForcePrompt(forcePrompt); if (parameterXsl != null) { solutionEngine.setParameterXsl(parameterXsl); } return solutionEngine.execute( file.getPath(), processId, false, instanceEnds, instanceId, false, parameterProviders, outputHandler, null, urlFactory, messages); }
public IRuntimeContext handleActionRequest(final int timeout, final int timeoutType) { // Get the solution engine ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session); solutionEngine.setCreateFeedbackParameterCallback(createFeedbackParameterCallback); if (solutionEngine == null) { Logger.error( this, Messages.getInstance() .getErrorString("BaseRequestHandler.ERROR_0001_NO_SOLUTION_ENGINE")); // $NON-NLS-1$ return null; } solutionEngine.setLoggingLevel(ILogger.DEBUG); solutionEngine.init(session); solutionEngine.setForcePrompt(forcePrompt); if (parameterXsl != null) { solutionEngine.setParameterXsl(parameterXsl); } dispose(); runtime = solutionEngine.execute( actionPath, processId, false, instanceEnds, instanceId, true, parameterProviders, outputHandler, this, urlFactory, messages); // need to wait until this is complete // TODO // if this times out check the timeoutType before cancelling or // returning and leaving the component running return runtime; }
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; }
/** * Gets a IPentahoResultSet from the action output * * @return IPentahoResultSet */ public 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(); context = solutionEngine.execute( actionPath, processId, false, true, instanceId, false, //$NON-NLS-1$ //$NON-NLS-2$ parameterProviders, outputHandler, null, urlFactory, messages); if (context == null) { // this went badly wrong return null; } 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 { for (Object objAp : context.getOutputNames()) { IActionParameter output = (IActionParameter) objAp; if (output.getType().equalsIgnoreCase(IActionParameter.TYPE_RESULT_SET)) { IPentahoResultSet results = output.getValueAsResultSet(); if (results != null) { results = results.memoryCopy(); } return results; } } } return null; }