Search in sources :

Example 76 with KettleStepException

use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.

the class CsvInputDoubleLineEndTest method doTest.

private void doTest(final String fileEncoding, final String stepEncoding, final String testData) throws Exception {
    String testFilePath = createTestFile(fileEncoding, testData).getAbsolutePath();
    CsvInputMeta meta = createStepMeta(testFilePath, stepEncoding);
    CsvInputData data = new CsvInputData();
    CsvInput csvInput = new CsvInput(stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans);
    csvInput.init(meta, data);
    csvInput.addRowListener(new RowAdapter() {

        @Override
        public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
            for (int i = 0; i < rowMeta.size(); i++) {
                assertEquals("Value", row[i]);
            }
        }
    });
    boolean haveRowsToRead;
    do {
        haveRowsToRead = !csvInput.processRow(meta, data);
    } while (!haveRowsToRead);
    csvInput.dispose(meta, data);
    assertEquals(2, csvInput.getLinesWritten());
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) RowAdapter(org.pentaho.di.trans.step.RowAdapter) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 77 with KettleStepException

use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.

the class CsvInputUnicodeTest method doTest.

private void doTest(final String fileEncoding, final String stepEncoding, final String testData, final String delimiter) throws Exception {
    String testFilePath = createTestFile(fileEncoding, testData).getAbsolutePath();
    CsvInputMeta meta = createStepMeta(testFilePath, stepEncoding, delimiter);
    CsvInputData data = new CsvInputData();
    CsvInput csvInput = new CsvInput(stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans);
    csvInput.init(meta, data);
    csvInput.addRowListener(new RowAdapter() {

        @Override
        public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
            for (int i = 0; i < rowMeta.size(); i++) {
                Assert.assertEquals("Value", row[i]);
            }
        }
    });
    boolean haveRowsToRead;
    do {
        haveRowsToRead = !csvInput.processRow(meta, data);
    } while (!haveRowsToRead);
    csvInput.dispose(meta, data);
    Assert.assertEquals(2, csvInput.getLinesWritten());
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) RowAdapter(org.pentaho.di.trans.step.RowAdapter) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 78 with KettleStepException

use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.

the class CsvProcessRowInParallelTest method processRows.

/**
 * So as not to heap up list of taken parameters, we are passing combi, but we expect to see CsvInput class instances
 * in it's content.
 */
private int processRows(StepMetaDataCombi combi) throws Exception {
    CsvInput csvInput = (CsvInput) combi.step;
    CsvInputData stepData = (CsvInputData) combi.data;
    CsvInputMeta stepMeta = (CsvInputMeta) combi.meta;
    final int[] writtenRows = { 0 };
    csvInput.addRowListener(new RowAdapter() {

        @Override
        public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
            writtenRows[0]++;
        }
    });
    boolean haveRowsToRead;
    do {
        haveRowsToRead = !csvInput.processRow(stepMeta, stepData);
    } while (!haveRowsToRead);
    csvInput.dispose(stepMeta, stepData);
    return writtenRows[0];
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) RowAdapter(org.pentaho.di.trans.step.RowAdapter) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 79 with KettleStepException

use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.

the class GetPreviousRowFieldMeta method getFields.

@Override
public void getFields(RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    // Add new field?
    for (int i = 0; i < fieldOutStream.length; i++) {
        if (!Utils.isEmpty(fieldOutStream[i])) {
            int index = inputRowMeta.indexOfValue(fieldInStream[i]);
            if (index >= 0) {
                ValueMetaInterface in = inputRowMeta.getValueMeta(index);
                try {
                    ValueMetaInterface v = ValueMetaFactory.createValueMeta(space.environmentSubstitute(fieldOutStream[i]), in.getType());
                    v.setName(space.environmentSubstitute(fieldOutStream[i]));
                    v.setLength(in.getLength());
                    v.setPrecision(in.getPrecision());
                    v.setConversionMask(in.getConversionMask());
                    v.setOrigin(name);
                    inputRowMeta.addValueMeta(v);
                } catch (Exception e) {
                    throw new KettleStepException(e);
                }
            }
        }
    }
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 80 with KettleStepException

use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.

the class RulesAccumulator method runtimeInit.

public boolean runtimeInit() throws KettleStepException {
    try {
        data.setOutputRowMeta(getInputRowMeta().clone());
        meta.setKeepInputFields(false);
        meta.getFields(data.getOutputRowMeta(), getStepname(), null, null, this, repository, metaStore);
        data.setRuleFilePath(meta.getRuleFile());
        data.setRuleString(meta.getRuleDefinition());
        data.initializeRules();
        data.initializeInput(getInputRowMeta());
        return true;
    } catch (Exception e) {
        throw new KettleStepException(e);
    }
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Aggregations

KettleStepException (org.pentaho.di.core.exception.KettleStepException)235 KettleException (org.pentaho.di.core.exception.KettleException)139 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)103 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)97 RowMeta (org.pentaho.di.core.row.RowMeta)51 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)44 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)27 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)27 KettleValueException (org.pentaho.di.core.exception.KettleValueException)26 IOException (java.io.IOException)23 RowAdapter (org.pentaho.di.trans.step.RowAdapter)21 ArrayList (java.util.ArrayList)20 StepMeta (org.pentaho.di.trans.step.StepMeta)19 RowSet (org.pentaho.di.core.RowSet)18 Database (org.pentaho.di.core.database.Database)15 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)13 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)13 FormAttachment (org.eclipse.swt.layout.FormAttachment)12 FormData (org.eclipse.swt.layout.FormData)12 Button (org.eclipse.swt.widgets.Button)12