Java Code Examples for org.pentaho.di.trans.Trans#cleanup()

The following examples show how to use org.pentaho.di.trans.Trans#cleanup() . 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: JPanelTransformation.java    From nordpos with GNU General Public License v3.0 5 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        this.app.waitCursorBegin();
        jPanelRows.setVisible(true);
        Trans t = runTransformationFromResource(getTransformation(), getTransVaribles());
        // retrieve logging appender        
        LoggingBuffer appender = KettleLogStore.getAppender();        
        // retrieve logging lines for job
        String logText = appender.getBuffer(t.getLogChannelId(), true).toString();

        if (t.nrActiveSteps() == 0) {
            t.cleanup();
        }

        if (t.isFinished()) {
            jMessage.setEnabled(true);
            int errors = t.getErrors();
            if (errors > 0) {
                jMessage.setText(AppLocal.getIntString("label.TransformationError"));
                jMessage.setBackground(Color.RED);
            } else {
                jMessage.setText(AppLocal.getIntString("label.TransformationComplete"));
                jMessage.setBackground(Color.GREEN);
            }

            jLogArea.setText(logText);
            appender.clear();
            appender.close();
        }

        this.app.waitCursorEnd();

    }
 
Example 2
Source File: AbstractKettleTransformationProducer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected TableModel performQueryOnTransformation( final DataRow parameters,
                                                 final int queryLimit,
                                                 final DataFactoryContext context,
                                                 final TransMeta transMeta )
  throws EvaluationException, ParseException, KettleException, ReportDataFactoryException {
  TableProducer tableProducer = null;
  Trans trans = null;

  try {
    trans = prepareTransformation( parameters, context, transMeta );

    final RowMetaInterface row = transMeta.getStepFields( getStepName() );
    tableProducer = new TableProducer( row, queryLimit, isStopOnError() );
    StepInterface targetStep = findTargetStep( trans );
    targetStep.addRowListener( tableProducer );

    currentlyRunningTransformation = trans;

    trans.startThreads();
    trans.waitUntilFinished();
  } finally {
    if ( null != trans ) {
      trans.cleanup();
    }
    currentlyRunningTransformation = null;
  }

  if ( trans.getErrors() != 0 && isStopOnError() ) {
    throw new ReportDataFactoryException( String
      .format( "Transformation reported %d records with errors and stop-on-error is true. Aborting.",
        trans.getErrors() ) );
  }

  return tableProducer.getTableModel();
}
 
Example 3
Source File: CheckSumTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Create, execute, and return the row listener attached to the output step with complete results from the execution.
 *
 * @param checkSumType
 *          Type of checksum to use (the array index of {@link CheckSumMeta#checksumtypeCodes})
 * @param compatibilityMode
 *          Use compatibility mode for CheckSum
 * @param fieldSeparatorString
 *          The string separate multiple fields with
 * @param inputs
 *          Array of objects representing row data
 * @param inputValueMetas
 *          metas to be processed
 * @return RowListener with results.
 */
private MockRowListener executeHexTest( int checkSumType, boolean compatibilityMode, boolean oldChecksumBehaviour,
    String fieldSeparatorString, Object[] inputs, ValueMetaInterface... inputValueMetas ) throws Exception {

  String[] fieldNames = new String[inputValueMetas.length];
  RowMeta inputRowMeta = new RowMeta();
  for ( int i = 0; i < inputValueMetas.length; i++ ) {
    inputRowMeta.addValueMeta( inputValueMetas[i] );
    fieldNames[i] = inputValueMetas[i].getName();
  }

  Trans trans =
      buildHexadecimalChecksumTrans( checkSumType, compatibilityMode, oldChecksumBehaviour, fieldSeparatorString,
          fieldNames );

  trans.prepareExecution( null );

  StepInterface output = trans.getRunThread( "Output", 0 );
  MockRowListener listener = new MockRowListener();
  output.addRowListener( listener );

  RowProducer rp = trans.addRowProducer( "CheckSum", 0 );

  ( (BaseStep) trans.getRunThread( "CheckSum", 0 ) ).setInputRowMeta( inputRowMeta );

  trans.startThreads();

  rp.putRow( inputRowMeta, inputs );
  rp.finished();

  trans.waitUntilFinished();
  trans.stopAll();
  trans.cleanup();
  return listener;
}