Search in sources :

Example 16 with TextFileInputField

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

the class CsvInputMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("BufferSize", "Delimiter", "Enclosure", "Encoding", "Filename", "FilenameField", "InputFields", "RowNumField", "AddResultFile", "HeaderPresent", "IncludingFilename", "LazyConversionActive", "NewlinePossibleInFields", "RunningInParallel");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("hasHeader", "hasHeader");
            put("includeFilename", "includeFilename");
            put("includeRowNumber", "includeRowNumber");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("includeFilename", "includeFilename");
            put("includeRowNumber", "includeRowNumber");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("InputFields", new ArrayLoadSaveValidator<TextFileInputField>(new TextFileInputFieldValidator(), 5));
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap, setterMap, attrValidatorMap, typeValidatorMap, this);
}
Also used : TextFileInputFieldValidator(org.pentaho.di.trans.steps.loadsave.validator.TextFileInputFieldValidator) ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField) ArrayList(java.util.ArrayList) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 17 with TextFileInputField

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

the class CsvInput1IT method createTextFileInputFields.

@Override
protected TextFileInputField[] createTextFileInputFields() {
    TextFileInputField[] fields = new TextFileInputField[5];
    for (int idx = 0; idx < fields.length; idx++) {
        fields[idx] = new TextFileInputField();
    }
    fields[0].setName("a");
    fields[0].setType(ValueMetaInterface.TYPE_INTEGER);
    fields[0].setFormat("");
    fields[0].setLength(-1);
    fields[0].setPrecision(-1);
    fields[0].setCurrencySymbol("");
    fields[0].setDecimalSymbol("");
    fields[0].setGroupSymbol("");
    fields[0].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    fields[1].setName("b");
    fields[1].setType(ValueMetaInterface.TYPE_STRING);
    fields[1].setFormat("");
    fields[1].setLength(-1);
    fields[1].setPrecision(-1);
    fields[1].setCurrencySymbol("");
    fields[1].setDecimalSymbol("");
    fields[1].setGroupSymbol("");
    fields[1].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    fields[2].setName("c");
    fields[2].setType(ValueMetaInterface.TYPE_STRING);
    fields[2].setFormat("");
    fields[2].setLength(-1);
    fields[2].setPrecision(-1);
    fields[2].setCurrencySymbol("");
    fields[2].setDecimalSymbol("");
    fields[2].setGroupSymbol("");
    fields[2].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    fields[3].setName("d");
    fields[3].setType(ValueMetaInterface.TYPE_STRING);
    fields[3].setFormat("");
    fields[3].setLength(-1);
    fields[3].setPrecision(-1);
    fields[3].setCurrencySymbol("");
    fields[3].setDecimalSymbol("");
    fields[3].setGroupSymbol("");
    fields[3].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    fields[4].setName("e");
    fields[4].setType(ValueMetaInterface.TYPE_STRING);
    fields[4].setFormat("");
    fields[4].setLength(-1);
    fields[4].setPrecision(-1);
    fields[4].setCurrencySymbol("");
    fields[4].setDecimalSymbol("");
    fields[4].setGroupSymbol("");
    fields[4].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    return fields;
}
Also used : TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField)

Example 18 with TextFileInputField

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

the class CsvInput2IT method createTextFileInputFields.

@Override
protected TextFileInputField[] createTextFileInputFields() {
    TextFileInputField[] fields = new TextFileInputField[3];
    for (int idx = 0; idx < fields.length; idx++) {
        fields[idx] = new TextFileInputField();
    }
    fields[0].setName("a");
    fields[0].setType(ValueMetaInterface.TYPE_INTEGER);
    fields[0].setFormat("");
    fields[0].setLength(-1);
    fields[0].setPrecision(-1);
    fields[0].setCurrencySymbol("");
    fields[0].setDecimalSymbol("");
    fields[0].setGroupSymbol("");
    fields[0].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    fields[1].setName("b");
    fields[1].setType(ValueMetaInterface.TYPE_STRING);
    fields[1].setFormat("");
    fields[1].setLength(-1);
    fields[1].setPrecision(-1);
    fields[1].setCurrencySymbol("");
    fields[1].setDecimalSymbol("");
    fields[1].setGroupSymbol("");
    fields[1].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    fields[2].setName("c");
    fields[2].setType(ValueMetaInterface.TYPE_STRING);
    fields[2].setFormat("");
    fields[2].setLength(-1);
    fields[2].setPrecision(-1);
    fields[2].setCurrencySymbol("");
    fields[2].setDecimalSymbol("");
    fields[2].setGroupSymbol("");
    fields[2].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    return fields;
}
Also used : TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField)

Example 19 with TextFileInputField

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

the class CsvInput3IT method createTextFileInputFields.

@Override
protected TextFileInputField[] createTextFileInputFields() {
    TextFileInputField[] fields = new TextFileInputField[3];
    for (int idx = 0; idx < fields.length; idx++) {
        fields[idx] = new TextFileInputField();
    }
    fields[0].setName("a");
    fields[0].setType(ValueMetaInterface.TYPE_INTEGER);
    fields[0].setFormat("");
    fields[0].setLength(-1);
    fields[0].setPrecision(-1);
    fields[0].setCurrencySymbol("");
    fields[0].setDecimalSymbol("");
    fields[0].setGroupSymbol("");
    fields[0].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    fields[1].setName("b");
    fields[1].setType(ValueMetaInterface.TYPE_STRING);
    fields[1].setFormat("");
    fields[1].setLength(-1);
    fields[1].setPrecision(-1);
    fields[1].setCurrencySymbol("");
    fields[1].setDecimalSymbol("");
    fields[1].setGroupSymbol("");
    fields[1].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    fields[2].setName("c");
    fields[2].setType(ValueMetaInterface.TYPE_STRING);
    fields[2].setFormat("");
    fields[2].setLength(-1);
    fields[2].setPrecision(-1);
    fields[2].setCurrencySymbol("");
    fields[2].setDecimalSymbol("");
    fields[2].setGroupSymbol("");
    fields[2].setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
    return fields;
}
Also used : TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField)

Example 20 with TextFileInputField

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

the class ParGzipCsvInputMeta method readData.

private void readData(Node stepnode) throws KettleXMLException {
    try {
        filename = XMLHandler.getTagValue(stepnode, "filename");
        filenameField = XMLHandler.getTagValue(stepnode, "filename_field");
        rowNumField = XMLHandler.getTagValue(stepnode, "rownum_field");
        includingFilename = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "include_filename"));
        delimiter = XMLHandler.getTagValue(stepnode, "separator");
        enclosure = XMLHandler.getTagValue(stepnode, "enclosure");
        bufferSize = XMLHandler.getTagValue(stepnode, "buffer_size");
        headerPresent = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "header"));
        lazyConversionActive = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "lazy_conversion"));
        isaddresult = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "add_filename_result"));
        runningInParallel = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "parallel"));
        encoding = XMLHandler.getTagValue(stepnode, "encoding");
        Node fields = XMLHandler.getSubNode(stepnode, "fields");
        int nrfields = XMLHandler.countNodes(fields, "field");
        allocate(nrfields);
        for (int i = 0; i < nrfields; i++) {
            inputFields[i] = new TextFileInputField();
            Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i);
            inputFields[i].setName(XMLHandler.getTagValue(fnode, "name"));
            inputFields[i].setType(ValueMetaFactory.getIdForValueMeta(XMLHandler.getTagValue(fnode, "type")));
            inputFields[i].setFormat(XMLHandler.getTagValue(fnode, "format"));
            inputFields[i].setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency"));
            inputFields[i].setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal"));
            inputFields[i].setGroupSymbol(XMLHandler.getTagValue(fnode, "group"));
            inputFields[i].setLength(Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1));
            inputFields[i].setPrecision(Const.toInt(XMLHandler.getTagValue(fnode, "precision"), -1));
            inputFields[i].setTrimType(ValueMetaString.getTrimTypeByCode(XMLHandler.getTagValue(fnode, "trim_type")));
        }
    } catch (Exception e) {
        throw new KettleXMLException("Unable to load step info from XML", e);
    }
}
Also used : Node(org.w3c.dom.Node) TextFileInputField(org.pentaho.di.trans.steps.textfileinput.TextFileInputField) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

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