Java Code Examples for org.pentaho.di.trans.Trans#setPreviousResult()
The following examples show how to use
org.pentaho.di.trans.Trans#setPreviousResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformationResource.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@GET @Path( "/prepare/{id : .+}" ) @Produces( { MediaType.APPLICATION_JSON } ) public TransformationStatus prepareTransformation( @PathParam( "id" ) String id ) { Trans trans = CarteResource.getTransformation( id ); try { CarteObjectEntry entry = CarteResource.getCarteObjectEntry( id ); TransConfiguration transConfiguration = CarteSingleton.getInstance().getTransformationMap().getConfiguration( entry ); TransExecutionConfiguration executionConfiguration = transConfiguration.getTransExecutionConfiguration(); // Set the appropriate logging, variables, arguments, replay date, ... // etc. trans.setArguments( executionConfiguration.getArgumentStrings() ); trans.setReplayDate( executionConfiguration.getReplayDate() ); trans.setSafeModeEnabled( executionConfiguration.isSafeModeEnabled() ); trans.setGatheringMetrics( executionConfiguration.isGatheringMetrics() ); trans.injectVariables( executionConfiguration.getVariables() ); trans.setPreviousResult( executionConfiguration.getPreviousResult() ); trans.prepareExecution( null ); } catch ( KettleException e ) { e.printStackTrace(); } return getTransformationStatus( id ); }
Example 2
Source File: TransExecutor.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void executeTransformation( List<String> incomingFieldValues ) throws KettleException { TransExecutorData transExecutorData = getData(); // If we got 0 rows on input we don't really want to execute the transformation if ( transExecutorData.groupBuffer.isEmpty() ) { return; } transExecutorData.groupTimeStart = System.currentTimeMillis(); if ( first ) { discardLogLines( transExecutorData ); } Trans executorTrans = createInternalTrans(); transExecutorData.setExecutorTrans( executorTrans ); if ( incomingFieldValues != null ) { // Pass parameter values passParametersToTrans( incomingFieldValues ); } else { List<String> lastIncomingFieldValues = getLastIncomingFieldValues(); // incomingFieldValues == null- There are no more rows - Last Case - pass previous values if exists // If not still pass the null parameter values passParametersToTrans( lastIncomingFieldValues != null && !lastIncomingFieldValues.isEmpty() ? lastIncomingFieldValues : incomingFieldValues ); } // keep track for drill down in Spoon... getTrans().addActiveSubTransformation( getStepname(), executorTrans ); Result result = new Result(); result.setRows( transExecutorData.groupBuffer ); executorTrans.setPreviousResult( result ); try { executorTrans.prepareExecution( getTrans().getArguments() ); // run transformation executorTrans.startThreads(); // Inform the parent transformation we started something here... for ( DelegationListener delegationListener : getTrans().getDelegationListeners() ) { // TODO: copy some settings in the transformation execution configuration, not strictly needed // but the execution configuration information is useful in case of a transformation re-start on Carte delegationListener.transformationDelegationStarted( executorTrans, new TransExecutionConfiguration() ); } // Wait a while until we're done with the transformation executorTrans.waitUntilFinished(); result = executorTrans.getResult(); } catch ( KettleException e ) { log.logError( "An error occurred executing the transformation: ", e ); result.setResult( false ); result.setNrErrors( 1 ); } if ( result.isSafeStop() ) { getTrans().safeStop(); } collectTransResults( result ); collectExecutionResults( result ); collectExecutionResultFiles( result ); transExecutorData.groupBuffer.clear(); }