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