Search in sources :

Example 6 with TextFileField

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()));
    }
}
Also used : TextFileField(org.pentaho.di.trans.steps.textfileoutput.TextFileField) Test(org.junit.Test)

Example 7 with TextFileField

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();
}
Also used : TextFileField(org.pentaho.di.trans.steps.textfileoutput.TextFileField) TableItem(org.eclipse.swt.widgets.TableItem) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Point(org.eclipse.swt.graphics.Point)

Example 8 with TextFileField

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;
    }
}
Also used : TextFileField(org.pentaho.di.trans.steps.textfileoutput.TextFileField) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point)

Aggregations

TextFileField (org.pentaho.di.trans.steps.textfileoutput.TextFileField)8 Point (org.eclipse.swt.graphics.Point)4 TableItem (org.eclipse.swt.widgets.TableItem)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 KettleValueException (org.pentaho.di.core.exception.KettleValueException)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 StepInjectionMetaEntry (org.pentaho.di.trans.step.StepInjectionMetaEntry)1