solutionEngine.setLoggingLevel( PentahoSystem.loggingLevel ); solutionEngine.init( session ); try { context = solutionEngine.execute( globalStartupAction.getActionPath(), "Global startup actions", false, true, instanceId, false, parameterProviderMap, outputHandler, null, urlFactory, messages ); //$NON-NLS-1$
public String getOutput( final String name ) { if ( ( name == null ) || "default".equals( name ) || "".equals( name ) ) { //$NON-NLS-1$ //$NON-NLS-2$ return outputStream.toString(); } else { IActionParameter output = solutionEngine.getExecutionContext().getOutputParameter( name ); return output.getStringValue(); } }
private void initFromActionSequenceDefinition() { // TODO get audit setting from action sequence int actionLogLevel = actionSequence.getLoggingLevel(); int instanceLogLevel = runtimeData.getLoggingLevel(); int actionSequenceLoggingLevel = ( instanceLogLevel != ILogger.UNKNOWN ) ? instanceLogLevel : ( ( actionLogLevel != ILogger.UNKNOWN ) ? actionLogLevel : solutionEngine.getLoggingLevel() ); setLoggingLevel( actionSequenceLoggingLevel ); }
public IRuntimeContext handleActionRequest( final int timeout, final int timeoutType ) { // Get the solution engine ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session ); if ( solutionEngine == null ) { Logger.error( this, Messages.getInstance().getErrorString( "BaseRequestHandler.ERROR_0001_NO_SOLUTION_ENGINE" ) ); //$NON-NLS-1$ return null; } solutionEngine.setCreateFeedbackParameterCallback( createFeedbackParameterCallback ); 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; }
public static ISolutionEngine getSolutionEngine( IPentahoSession session ) { ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session ); solutionEngine.setLoggingLevel( ILogger.ERROR ); solutionEngine.init( session ); return solutionEngine; } }
public int execute() { PentahoSystem.systemEntryPoint(); try { // create a generic session object StandaloneSession session = new StandaloneSession( userId ); solutionEngine = PentahoSystem.get( SolutionEngine.class, session ); solutionEngine.init( session ); SimpleParameterProvider parameterProvider = new SimpleParameterProvider( parameters ); HashMap<String, IParameterProvider> parameterProviderMap = new HashMap<String, IParameterProvider>(); parameterProviderMap.put( IParameterProvider.SCOPE_REQUEST, parameterProvider ); IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext(); IPentahoUrlFactory urlFactory = new SimpleUrlFactory( requestContext.getContextPath() ); //$NON-NLS-1$ String processName = description; boolean persisted = false; List messages = new ArrayList(); outputStream = new ByteArrayOutputStream( 0 ); SimpleOutputHandler outputHandler = null; if ( outputStream != null ) { outputHandler = new SimpleOutputHandler( outputStream, false ); outputHandler.setOutputPreference( IOutputHandler.OUTPUT_TYPE_DEFAULT ); } solutionEngine.execute( actionSequence, processName, false, true, null, persisted, parameterProviderMap, outputHandler, null, urlFactory, messages ); } finally { PentahoSystem.systemExitPoint(); } return solutionEngine.getStatus(); }
String instanceId = null; ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session ); solutionEngine.setLoggingLevel( ILogger.ERROR ); solutionEngine.init( session ); HashMap parameterProviderMap = new HashMap(); IPentahoUrlFactory urlFactory = new SimpleUrlFactory( "" ); solutionEngine.setSession( session ); runtimeContext = solutionEngine.execute( xactionStr, actionSequence, "action sequence test", false, true, instanceId, false, //$NON-NLS-1$ parameterProviderMap, null, null, urlFactory, messages ); } catch ( Exception e ) {
public void testMultiOutput() { startTest(); ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine(); String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "services/MultiOutputTest.xaction" ); IRuntimeContext runtimeContext = solutionEngine.execute( xactionStr, "test1a.xaction", "empty action sequence test", false, true, null, false, //$NON-NLS-1$ //$NON-NLS-2$ new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); finishTest(); }
solutionEngine.init( session ); solutionEngine.setlistener( execListener ); outputHandler.setOutputPreference( IOutputHandler.OUTPUT_TYPE_DEFAULT ); solutionEngine.execute( actionSequence, processName, false, true, null, persisted, parameterProviderMap, outputHandler, null, urlFactory, messages );
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; }
IPentahoSession session = new StandaloneSession( "system" ); ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session ); solutionEngine.setLoggingLevel( ILogger.ERROR ); solutionEngine.init( session ); Map<Object, Object> parameterProviderMap = new HashMap<Object, Object>(); IPentahoUrlFactory urlFactory = new SimpleUrlFactory( "" ); solutionEngine.setSession( session ); IRuntimeContext runtimeContext = solutionEngine.execute( xactionStr, "test1.xaction", "empty action sequence test", false, true, instanceId, //$NON-NLS-1$ //$NON-NLS-2$ false, parameterProviderMap, null, null, urlFactory, messages ); assertNotNull( "RuntimeContext is null", runtimeContext );
solutionEngine.execute( xactionStr, xactionName, "simple output test", false, true, null, false, new HashMap(), //$NON-NLS-1$ null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ IParameterManager paramManager = runtimeContext.getParameterManager();
public IRuntimeContext run( String actionPath, String instanceId, boolean persisted, IParameterProvider parameterProvider, IOutputHandler outputHandler, IPentahoSession session ) { assertTrue( initOk ); ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session ); solutionEngine.setLoggingLevel( getLoggingLevel() ); solutionEngine.init( session ); return run( solutionEngine, actionPath, instanceId, persisted, parameterProvider, outputHandler ); }
solutionEngine.setLoggingLevel( ILogger.DEBUG ); solutionEngine.init( getSession() ); solutionEngine.execute( actionSeqPath, processId, false, true, instanceId, false, parameterProviders, outputHandler, null, urlFactory, messages );
public void testBadOutput() { startTest(); ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine(); try { String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo-bad5.xaction" ); PojoComponentTest.doneCalled = false; PojoComponentTest.executeCalled = false; PojoComponentTest.validateCalled = false; IRuntimeContext runtimeContext = solutionEngine.execute( xactionStr, "test", "invalid class setting test", false, true, null, false, //$NON-NLS-1$ //$NON-NLS-2$ new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); assertNotNull( "RuntimeContext is null", runtimeContext ); assertEquals( "Action sequence succeeded", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_STATUS_FAILURE ); } catch ( Exception e ) { // we should not get here e.printStackTrace(); assertTrue( e.getMessage(), false ); } finishTest(); }
@Override public String publish( final IPentahoSession localSession ) { try { HashMap<String, String> parameters = new HashMap<String, String>(); ISolutionEngine engine = SolutionHelper.execute( "publisher", localSession, "admin/clean_repository.xaction", //$NON-NLS-1$//$NON-NLS-2$ parameters, null ); IRuntimeContext context = engine.getExecutionContext(); int status = context.getStatus(); if ( status != IRuntimeContext.RUNTIME_STATUS_SUCCESS ) { return Messages.getInstance().getString( "CleanRepoPublisher.ERROR_0001_CLEAN_REPO_FAILED" ); //$NON-NLS-1$ } } catch ( Throwable t ) { error( Messages.getInstance().getErrorString( "CleanRepoPublisher.ERROR_0001_CLEAN_REPO_FAILED", t.getMessage() ), t ); //$NON-NLS-1$ return Messages.getInstance().getString( "CleanRepoPublisher.ERROR_0001_CLEAN_REPO_FAILED", t.getLocalizedMessage() ); //$NON-NLS-1$ } return Messages.getInstance().getString( "CleanRepoPublisher.CLEAN_REPO_DONE" ); //$NON-NLS-1$ } }
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, getMessages() ); //$NON-NLS-1$ } finally { if ( context != null ) { context.dispose(); } } return outputStream; }
/** * Test that unused parameters being passed in do not impact the running of the PojoComponent. A warning is written to * the log for user feedback on execution. */ public void testUnusedInput() { startTest(); ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine(); try { String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo-bad4.xaction" ); PojoComponentTest.doneCalled = false; PojoComponentTest.executeCalled = false; PojoComponentTest.validateCalled = false; IRuntimeContext runtimeContext = solutionEngine.execute( xactionStr, "test", "invalid class setting test", false, true, null, false, //$NON-NLS-1$ //$NON-NLS-2$ new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); assertNotNull( "RuntimeContext is null", runtimeContext ); assertEquals( "Action sequence succeeded", IRuntimeContext.RUNTIME_STATUS_SUCCESS, runtimeContext.getStatus() ); } catch ( Exception e ) { // we should not get here e.printStackTrace(); assertTrue( e.getMessage(), false ); } finishTest(); }
solutionEngine.setLoggingLevel( ILogger.DEBUG ); solutionEngine.init( getSession() ); context = solutionEngine.execute( actionPath, processId, false, true, instanceId, false, //$NON-NLS-1$ //$NON-NLS-2$ parameterProviders, outputHandler, null, urlFactory, messages );
public void testMissingClassSetting() { startTest(); ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine(); try { String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo-bad1.xaction" ); PojoComponentTest.doneCalled = false; PojoComponentTest.executeCalled = false; PojoComponentTest.validateCalled = false; IRuntimeContext runtimeContext = solutionEngine.execute( xactionStr, "test", "invalid class setting test", false, true, null, false, //$NON-NLS-1$ //$NON-NLS-2$ new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); assertNotNull( "RuntimeContext is null", runtimeContext ); assertEquals( "execute was called", false, PojoComponentTest.executeCalled ); assertEquals( "validate was called", false, PojoComponentTest.validateCalled ); assertEquals( "Action sequence validation succeeded", runtimeContext.getStatus(), IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_FAIL ); } catch ( Exception e ) { // we should not get here e.printStackTrace(); assertTrue( e.getMessage(), false ); } finishTest(); }