use of org.pentaho.di.trans.steps.textfileoutput.TextFileField in project pentaho-metaverse by pentaho.
the class TextFileOutputStepAnalyzerTest method testGetOutputResourceFields.
@Test
public void testGetOutputResourceFields() throws Exception {
TextFileField[] outputFields = new TextFileField[2];
TextFileField field1 = mock(TextFileField.class);
TextFileField field2 = mock(TextFileField.class);
outputFields[0] = field1;
outputFields[1] = field2;
when(field1.getName()).thenReturn("field1");
when(field2.getName()).thenReturn("field2");
when(meta.getOutputFields()).thenReturn(outputFields);
Set<String> outputResourceFields = analyzer.getOutputResourceFields(meta);
assertEquals(outputFields.length, outputResourceFields.size());
for (TextFileField outputField : outputFields) {
assertTrue(outputResourceFields.contains(outputField.getName()));
}
}
use of org.pentaho.di.trans.steps.textfileoutput.TextFileField in project pentaho-kettle by pentaho.
the class TextFileOutputDialog method getData.
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData() {
if (input.getFileName() != null) {
wFilename.setText(input.getFileName());
}
wFileIsCommand.setSelection(input.isFileAsCommand());
wServletOutput.setSelection(input.isServletOutput());
setFlagsServletOption();
wDoNotOpenNewFileInit.setSelection(input.isDoNotOpenNewFileInit());
wCreateParentFolder.setSelection(input.isCreateParentFolder());
wExtension.setText(Const.NVL(input.getExtension(), ""));
wSeparator.setText(Const.NVL(input.getSeparator(), ""));
wEnclosure.setText(Const.NVL(input.getEnclosure(), ""));
if (input.getFileFormat() != null) {
// default if not found: CR+LF
wFormat.select(0);
for (int i = 0; i < TextFileOutputMeta.formatMapperLineTerminator.length; i++) {
if (input.getFileFormat().equalsIgnoreCase(TextFileOutputMeta.formatMapperLineTerminator[i])) {
wFormat.select(i);
}
}
}
if (input.getFileCompression() != null) {
wCompression.setText(input.getFileCompression());
}
if (input.getEncoding() != null) {
wEncoding.setText(input.getEncoding());
}
if (input.getEndedLine() != null) {
wEndedLine.setText(input.getEndedLine());
}
wFileNameInField.setSelection(input.isFileNameInField());
if (input.getFileNameField() != null) {
wFileNameField.setText(input.getFileNameField());
}
wSplitEvery.setText("" + input.getSplitEvery());
wEnclForced.setSelection(input.isEnclosureForced());
wDisableEnclosureFix.setSelection(input.isEnclosureFixDisabled());
wHeader.setSelection(input.isHeaderEnabled());
wFooter.setSelection(input.isFooterEnabled());
wAddDate.setSelection(input.isDateInFilename());
wAddTime.setSelection(input.isTimeInFilename());
wDateTimeFormat.setText(Const.NVL(input.getDateTimeFormat(), ""));
wSpecifyFormat.setSelection(input.isSpecifyingFormat());
wAppend.setSelection(input.isFileAppended());
wAddStepnr.setSelection(input.isStepNrInFilename());
wAddPartnr.setSelection(input.isPartNrInFilename());
wPad.setSelection(input.isPadded());
wFastDump.setSelection(input.isFastDump());
wAddToResult.setSelection(input.isAddToResultFiles());
logDebug("getting fields info...");
for (int i = 0; i < input.getOutputFields().length; i++) {
TextFileField field = input.getOutputFields()[i];
TableItem item = wFields.table.getItem(i);
if (field.getName() != null) {
item.setText(1, field.getName());
}
item.setText(2, field.getTypeDesc());
if (field.getFormat() != null) {
item.setText(3, field.getFormat());
}
if (field.getLength() >= 0) {
item.setText(4, "" + field.getLength());
}
if (field.getPrecision() >= 0) {
item.setText(5, "" + field.getPrecision());
}
if (field.getCurrencySymbol() != null) {
item.setText(6, field.getCurrencySymbol());
}
if (field.getDecimalSymbol() != null) {
item.setText(7, field.getDecimalSymbol());
}
if (field.getGroupingSymbol() != null) {
item.setText(8, field.getGroupingSymbol());
}
String trim = field.getTrimTypeDesc();
if (trim != null) {
item.setText(9, trim);
}
if (field.getNullString() != null) {
item.setText(10, field.getNullString());
}
}
wFields.optWidth(true);
wStepname.selectAll();
wStepname.setFocus();
}
use of org.pentaho.di.trans.steps.textfileoutput.TextFileField in project pentaho-kettle by pentaho.
the class ConcatFieldsDialog method getInfo.
private void getInfo(ConcatFieldsMeta tfoi) {
// New concat fields
tfoi.setTargetFieldName(wTargetFieldName.getText());
tfoi.setTargetFieldLength(Const.toInt(wTargetFieldLength.getText(), 0));
tfoi.setRemoveSelectedFields(wRemoveSelectedFields.getSelection());
// previous fields derived from TextFileOutputDialog
tfoi.setEncoding(wEncoding.getText());
tfoi.setSeparator(wSeparator.getText());
tfoi.setEnclosure(wEnclosure.getText());
tfoi.setSplitEvery(Const.toInt(wSplitEvery.getText(), 0));
tfoi.setEndedLine(wEndedLine.getText());
tfoi.setEnclosureForced(wEnclForced.getSelection());
tfoi.setEnclosureFixDisabled(wDisableEnclosureFix.getSelection());
tfoi.setHeaderEnabled(wHeader.getSelection());
tfoi.setFooterEnabled(wFooter.getSelection());
tfoi.setPadded(wPad.getSelection());
tfoi.setFastDump(wFastDump.getSelection());
int i;
// Table table = wFields.table;
int nrfields = wFields.nrNonEmpty();
tfoi.allocate(nrfields);
for (i = 0; i < nrfields; i++) {
TextFileField field = new TextFileField();
TableItem item = wFields.getNonEmpty(i);
field.setName(item.getText(1));
field.setType(item.getText(2));
field.setFormat(item.getText(3));
field.setLength(Const.toInt(item.getText(4), -1));
field.setPrecision(Const.toInt(item.getText(5), -1));
field.setCurrencySymbol(item.getText(6));
field.setDecimalSymbol(item.getText(7));
field.setGroupingSymbol(item.getText(8));
field.setTrimType(ValueMetaString.getTrimTypeByDesc(item.getText(9)));
field.setNullString(item.getText(10));
// CHECKSTYLE:Indentation:OFF
tfoi.getOutputFields()[i] = field;
}
}
Aggregations