Search in sources :

Example 41 with TextFileInputField

use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.

the class CsvInputDialog method getData.

/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData(CsvInputMeta inputMeta, boolean copyStepname) {
    if (copyStepname) {
        wStepname.setText(stepname);
    }
    if (isReceivingInput) {
        wFilenameField.setText(Const.NVL(inputMeta.getFilenameField(), ""));
        wIncludeFilename.setSelection(inputMeta.isIncludingFilename());
    } else {
        wFilename.setText(Const.NVL(inputMeta.getFilename(), ""));
    }
    wDelimiter.setText(Const.NVL(inputMeta.getDelimiter(), ""));
    wEnclosure.setText(Const.NVL(inputMeta.getEnclosure(), ""));
    wBufferSize.setText(Const.NVL(inputMeta.getBufferSize(), ""));
    wLazyConversion.setSelection(inputMeta.isLazyConversionActive());
    wHeaderPresent.setSelection(inputMeta.isHeaderPresent());
    wRunningInParallel.setSelection(inputMeta.isRunningInParallel());
    wNewlinePossible.setSelection(inputMeta.isNewlinePossibleInFields());
    wRowNumField.setText(Const.NVL(inputMeta.getRowNumField(), ""));
    wAddResult.setSelection(inputMeta.isAddResultFile());
    wEncoding.setText(Const.NVL(inputMeta.getEncoding(), ""));
    for (int i = 0; i < inputMeta.getInputFields().length; i++) {
        TextFileInputField field = inputMeta.getInputFields()[i];
        TableItem item = new TableItem(wFields.table, SWT.NONE);
        int colnr = 1;
        item.setText(colnr++, Const.NVL(field.getName(), ""));
        item.setText(colnr++, ValueMetaFactory.getValueMetaName(field.getType()));
        item.setText(colnr++, Const.NVL(field.getFormat(), ""));
        item.setText(colnr++, field.getLength() >= 0 ? Integer.toString(field.getLength()) : "");
        item.setText(colnr++, field.getPrecision() >= 0 ? Integer.toString(field.getPrecision()) : "");
        item.setText(colnr++, Const.NVL(field.getCurrencySymbol(), ""));
        item.setText(colnr++, Const.NVL(field.getDecimalSymbol(), ""));
        item.setText(colnr++, Const.NVL(field.getGroupSymbol(), ""));
        item.setText(colnr++, Const.NVL(field.getTrimTypeDesc(), ""));
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);
    setFlags();
    wStepname.selectAll();
    wStepname.setFocus();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField)

Example 42 with TextFileInputField

use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.

the class CsvInputDialog method getInfo.

private void getInfo(CsvInputMeta inputMeta) {
    if (isReceivingInput) {
        inputMeta.setFilenameField(wFilenameField.getText());
        inputMeta.setIncludingFilename(wIncludeFilename.getSelection());
    } else {
        inputMeta.setFilename(wFilename.getText());
    }
    inputMeta.setDelimiter(wDelimiter.getText());
    inputMeta.setEnclosure(wEnclosure.getText());
    inputMeta.setBufferSize(wBufferSize.getText());
    inputMeta.setLazyConversionActive(wLazyConversion.getSelection());
    inputMeta.setHeaderPresent(wHeaderPresent.getSelection());
    inputMeta.setRowNumField(wRowNumField.getText());
    inputMeta.setAddResultFile(wAddResult.getSelection());
    inputMeta.setRunningInParallel(wRunningInParallel.getSelection());
    inputMeta.setNewlinePossibleInFields(wNewlinePossible.getSelection());
    inputMeta.setEncoding(wEncoding.getText());
    int nrNonEmptyFields = wFields.nrNonEmpty();
    inputMeta.allocate(nrNonEmptyFields);
    for (int i = 0; i < nrNonEmptyFields; i++) {
        TableItem item = wFields.getNonEmpty(i);
        // CHECKSTYLE:Indentation:OFF
        inputMeta.getInputFields()[i] = new TextFileInputField();
        int colnr = 1;
        inputMeta.getInputFields()[i].setName(item.getText(colnr++));
        inputMeta.getInputFields()[i].setType(ValueMetaFactory.getIdForValueMeta(item.getText(colnr++)));
        inputMeta.getInputFields()[i].setFormat(item.getText(colnr++));
        inputMeta.getInputFields()[i].setLength(Const.toInt(item.getText(colnr++), -1));
        inputMeta.getInputFields()[i].setPrecision(Const.toInt(item.getText(colnr++), -1));
        inputMeta.getInputFields()[i].setCurrencySymbol(item.getText(colnr++));
        inputMeta.getInputFields()[i].setDecimalSymbol(item.getText(colnr++));
        inputMeta.getInputFields()[i].setGroupSymbol(item.getText(colnr++));
        inputMeta.getInputFields()[i].setTrimType(ValueMetaString.getTrimTypeByDesc(item.getText(colnr++)));
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);
    inputMeta.setChanged();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField)

Example 43 with TextFileInputField

use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.

the class ParGzipCsvInputDialog method getData.

/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData(ParGzipCsvInputMeta inputMeta) {
    wStepname.setText(stepname);
    if (isReceivingInput) {
        wFilenameField.setText(Const.NVL(inputMeta.getFilenameField(), ""));
        wIncludeFilename.setSelection(inputMeta.isIncludingFilename());
    } else {
        wFilename.setText(Const.NVL(inputMeta.getFilename(), ""));
    }
    wDelimiter.setText(Const.NVL(inputMeta.getDelimiter(), ""));
    wEnclosure.setText(Const.NVL(inputMeta.getEnclosure(), ""));
    wBufferSize.setText(Const.NVL(inputMeta.getBufferSize(), ""));
    wLazyConversion.setSelection(inputMeta.isLazyConversionActive());
    wHeaderPresent.setSelection(inputMeta.isHeaderPresent());
    wRunningInParallel.setSelection(inputMeta.isRunningInParallel());
    wRowNumField.setText(Const.NVL(inputMeta.getRowNumField(), ""));
    wAddResult.setSelection(inputMeta.isAddResultFile());
    wEncoding.setText(Const.NVL(inputMeta.getEncoding(), ""));
    for (int i = 0; i < inputMeta.getInputFields().length; i++) {
        TextFileInputField field = inputMeta.getInputFields()[i];
        TableItem item = new TableItem(wFields.table, SWT.NONE);
        int colnr = 1;
        item.setText(colnr++, Const.NVL(field.getName(), ""));
        item.setText(colnr++, ValueMetaFactory.getValueMetaName(field.getType()));
        item.setText(colnr++, Const.NVL(field.getFormat(), ""));
        item.setText(colnr++, field.getLength() >= 0 ? Integer.toString(field.getLength()) : "");
        item.setText(colnr++, field.getPrecision() >= 0 ? Integer.toString(field.getPrecision()) : "");
        item.setText(colnr++, Const.NVL(field.getCurrencySymbol(), ""));
        item.setText(colnr++, Const.NVL(field.getDecimalSymbol(), ""));
        item.setText(colnr++, Const.NVL(field.getGroupSymbol(), ""));
        item.setText(colnr++, Const.NVL(field.getTrimTypeDesc(), ""));
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);
    wStepname.selectAll();
    wStepname.setFocus();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField)

Example 44 with TextFileInputField

use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.

the class CsvInputContentParsingTest method testSemicolonOptions.

@Test
public void testSemicolonOptions() throws Exception {
    meta.setDelimiter(";");
    init("semicolon.csv");
    setFields(new TextFileInputField("Field 1", -1, -1), new TextFileInputField("Field 2", -1, -1), new TextFileInputField("Field 3", -1, -1));
    process();
    check(new Object[][] { { "first", "1", "1.1" }, { "second", "2", "2.2" }, { "third", "3", "3.3" }, { "\u043d\u0435-\u043b\u0430\u0446\u0456\u043d\u043a\u0430(non-latin)", "4", "4" } });
}
Also used : TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField) Test(org.junit.Test)

Example 45 with TextFileInputField

use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.

the class CsvInputContentParsingTest method testColumnNameWithSpaces.

@Test
public void testColumnNameWithSpaces() throws Exception {
    init("column_name_with_spaces.csv");
    setFields(new TextFileInputField("Field 1", -1, -1), new TextFileInputField("Field 2", -1, -1), new TextFileInputField("Field 3", -1, -1));
    process();
    check(new Object[][] { { "first", "1", "1.1" }, { "second", "2", "2.2" }, { "third", "3", "3.3" } });
}
Also used : TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField) Test(org.junit.Test)

Aggregations

TextFileInputField (org.pentaho.di.trans.steps.textfileinput.TextFileInputField)47 KettleException (org.pentaho.di.core.exception.KettleException)13 KettleStepException (org.pentaho.di.core.exception.KettleStepException)11 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)11 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)11 TableItem (org.eclipse.swt.widgets.TableItem)9 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)4 S3ServiceException (org.jets3t.service.S3ServiceException)3 Node (org.w3c.dom.Node)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 TextFileInputFieldInterface (org.pentaho.di.core.gui.TextFileInputFieldInterface)2 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)2 StepInjectionMetaEntry (org.pentaho.di.trans.step.StepInjectionMetaEntry)2 StepMeta (org.pentaho.di.trans.step.StepMeta)2 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1