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();
}
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();
}
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();
}
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" } });
}
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" } });
}
Aggregations