use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.
the class S3CsvInputDialog method getData.
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData(S3CsvInputMeta inputMeta) {
wStepname.setText(stepname);
wAccessKey.setText(Const.NVL(inputMeta.getAwsAccessKey(), ""));
wSecretKey.setText(Const.NVL(inputMeta.getAwsSecretKey(), ""));
wBucket.setText(Const.NVL(inputMeta.getBucket(), ""));
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(), ""));
wMaxLineSize.setText(Const.NVL(inputMeta.getMaxLineSize(), ""));
wLazyConversion.setSelection(inputMeta.isLazyConversionActive());
wHeaderPresent.setSelection(inputMeta.isHeaderPresent());
wRunningInParallel.setSelection(inputMeta.isRunningInParallel());
wRowNumField.setText(Const.NVL(inputMeta.getRowNumField(), ""));
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++, ValueMeta.getTypeDesc(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();
}
use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.
the class S3CsvInputMeta method getXML.
@Override
public String getXML() {
StringBuffer retval = new StringBuffer(500);
retval.append(" ").append(XMLHandler.addTagValue("aws_access_key", Encr.encryptPasswordIfNotUsingVariables(awsAccessKey)));
retval.append(" ").append(XMLHandler.addTagValue("aws_secret_key", Encr.encryptPasswordIfNotUsingVariables(awsSecretKey)));
retval.append(" ").append(XMLHandler.addTagValue("bucket", bucket));
retval.append(" ").append(XMLHandler.addTagValue("filename", filename));
retval.append(" ").append(XMLHandler.addTagValue("filename_field", filenameField));
retval.append(" ").append(XMLHandler.addTagValue("rownum_field", rowNumField));
retval.append(" ").append(XMLHandler.addTagValue("include_filename", includingFilename));
retval.append(" ").append(XMLHandler.addTagValue("separator", delimiter));
retval.append(" ").append(XMLHandler.addTagValue("enclosure", enclosure));
retval.append(" ").append(XMLHandler.addTagValue("header", headerPresent));
retval.append(" ").append(XMLHandler.addTagValue("max_line_size", maxLineSize));
retval.append(" ").append(XMLHandler.addTagValue("lazy_conversion", lazyConversionActive));
retval.append(" ").append(XMLHandler.addTagValue("parallel", runningInParallel));
retval.append(" <fields>").append(Const.CR);
for (int i = 0; i < inputFields.length; i++) {
TextFileInputField field = inputFields[i];
retval.append(" <field>").append(Const.CR);
retval.append(" ").append(XMLHandler.addTagValue("name", field.getName()));
retval.append(" ").append(XMLHandler.addTagValue("type", ValueMetaFactory.getValueMetaName(field.getType())));
retval.append(" ").append(XMLHandler.addTagValue("format", field.getFormat()));
retval.append(" ").append(XMLHandler.addTagValue("currency", field.getCurrencySymbol()));
retval.append(" ").append(XMLHandler.addTagValue("decimal", field.getDecimalSymbol()));
retval.append(" ").append(XMLHandler.addTagValue("group", field.getGroupSymbol()));
retval.append(" ").append(XMLHandler.addTagValue("length", field.getLength()));
retval.append(" ").append(XMLHandler.addTagValue("precision", field.getPrecision()));
retval.append(" ").append(XMLHandler.addTagValue("trim_type", ValueMetaString.getTrimTypeCode(field.getTrimType())));
retval.append(" </field>").append(Const.CR);
}
retval.append(" </fields>").append(Const.CR);
return retval.toString();
}
use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.
the class S3CsvInputMeta method readRep.
@Override
public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException {
try {
awsAccessKey = Encr.decryptPasswordOptionallyEncrypted(rep.getStepAttributeString(id_step, "aws_access_key"));
awsSecretKey = Encr.decryptPasswordOptionallyEncrypted(rep.getStepAttributeString(id_step, "aws_secret_key"));
bucket = rep.getStepAttributeString(id_step, "bucket");
filename = rep.getStepAttributeString(id_step, "filename");
filenameField = rep.getStepAttributeString(id_step, "filename_field");
rowNumField = rep.getStepAttributeString(id_step, "rownum_field");
includingFilename = rep.getStepAttributeBoolean(id_step, "include_filename");
delimiter = rep.getStepAttributeString(id_step, "separator");
enclosure = rep.getStepAttributeString(id_step, "enclosure");
headerPresent = rep.getStepAttributeBoolean(id_step, "header");
maxLineSize = rep.getStepAttributeString(id_step, "max_line_size");
lazyConversionActive = rep.getStepAttributeBoolean(id_step, "lazy_conversion");
runningInParallel = rep.getStepAttributeBoolean(id_step, "parallel");
int nrfields = rep.countNrStepAttributes(id_step, "field_name");
allocate(nrfields);
for (int i = 0; i < nrfields; i++) {
inputFields[i] = new TextFileInputField();
inputFields[i].setName(rep.getStepAttributeString(id_step, i, "field_name"));
inputFields[i].setType(ValueMetaFactory.getIdForValueMeta(rep.getStepAttributeString(id_step, i, "field_type")));
inputFields[i].setFormat(rep.getStepAttributeString(id_step, i, "field_format"));
inputFields[i].setCurrencySymbol(rep.getStepAttributeString(id_step, i, "field_currency"));
inputFields[i].setDecimalSymbol(rep.getStepAttributeString(id_step, i, "field_decimal"));
inputFields[i].setGroupSymbol(rep.getStepAttributeString(id_step, i, "field_group"));
inputFields[i].setLength((int) rep.getStepAttributeInteger(id_step, i, "field_length"));
inputFields[i].setPrecision((int) rep.getStepAttributeInteger(id_step, i, "field_precision"));
inputFields[i].setTrimType(ValueMetaString.getTrimTypeByCode(rep.getStepAttributeString(id_step, i, "field_trim_type")));
}
} catch (Exception e) {
throw new KettleException("Unexpected error reading step information from the repository", e);
}
}
use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.
the class S3CsvInputMeta method saveRep.
@Override
public void saveRep(Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step) throws KettleException {
try {
rep.saveStepAttribute(id_transformation, id_step, "aws_secret_key", Encr.encryptPasswordIfNotUsingVariables(awsSecretKey));
rep.saveStepAttribute(id_transformation, id_step, "aws_access_key", Encr.encryptPasswordIfNotUsingVariables(awsAccessKey));
rep.saveStepAttribute(id_transformation, id_step, "bucket", bucket);
rep.saveStepAttribute(id_transformation, id_step, "filename", filename);
rep.saveStepAttribute(id_transformation, id_step, "filename_field", filenameField);
rep.saveStepAttribute(id_transformation, id_step, "rownum_field", rowNumField);
rep.saveStepAttribute(id_transformation, id_step, "include_filename", includingFilename);
rep.saveStepAttribute(id_transformation, id_step, "separator", delimiter);
rep.saveStepAttribute(id_transformation, id_step, "enclosure", enclosure);
rep.saveStepAttribute(id_transformation, id_step, "max_line_size", maxLineSize);
rep.saveStepAttribute(id_transformation, id_step, "header", headerPresent);
rep.saveStepAttribute(id_transformation, id_step, "lazy_conversion", lazyConversionActive);
rep.saveStepAttribute(id_transformation, id_step, "parallel", runningInParallel);
for (int i = 0; i < inputFields.length; i++) {
TextFileInputField field = inputFields[i];
rep.saveStepAttribute(id_transformation, id_step, i, "field_name", field.getName());
rep.saveStepAttribute(id_transformation, id_step, i, "field_type", ValueMetaFactory.getValueMetaName(field.getType()));
rep.saveStepAttribute(id_transformation, id_step, i, "field_format", field.getFormat());
rep.saveStepAttribute(id_transformation, id_step, i, "field_currency", field.getCurrencySymbol());
rep.saveStepAttribute(id_transformation, id_step, i, "field_decimal", field.getDecimalSymbol());
rep.saveStepAttribute(id_transformation, id_step, i, "field_group", field.getGroupSymbol());
rep.saveStepAttribute(id_transformation, id_step, i, "field_length", field.getLength());
rep.saveStepAttribute(id_transformation, id_step, i, "field_precision", field.getPrecision());
rep.saveStepAttribute(id_transformation, id_step, i, "field_trim_type", ValueMetaString.getTrimTypeCode(field.getTrimType()));
}
} catch (Exception e) {
throw new KettleException("Unable to save step information to the repository for id_step=" + id_step, e);
}
}
use of org.pentaho.di.trans.steps.textfileinput.TextFileInputField in project pentaho-kettle by pentaho.
the class CsvInputMeta method getXML.
@Override
public String getXML() {
StringBuilder retval = new StringBuilder(500);
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FILENAME"), filename));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FILENAME_FIELD"), filenameField));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("ROW_NUM_FIELD"), rowNumField));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("INCLUDE_FILENAME"), includingFilename));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("DELIMITER"), delimiter));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("ENCLOSURE"), enclosure));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("HEADER_PRESENT"), headerPresent));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("BUFFERSIZE"), bufferSize));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("LAZY_CONVERSION"), lazyConversionActive));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("ADD_FILENAME_RESULT"), isaddresult));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("PARALLEL"), runningInParallel));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("NEWLINE_POSSIBLE"), newlinePossibleInFields));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("ENCODING"), encoding));
retval.append(" ").append(XMLHandler.openTag(getXmlCode("FIELDS"))).append(Const.CR);
for (int i = 0; i < inputFields.length; i++) {
TextFileInputField field = inputFields[i];
retval.append(" ").append(XMLHandler.openTag(getXmlCode("FIELD"))).append(Const.CR);
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FIELD_NAME"), field.getName()));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FIELD_TYPE"), ValueMetaFactory.getValueMetaName(field.getType())));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FIELD_FORMAT"), field.getFormat()));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FIELD_CURRENCY"), field.getCurrencySymbol()));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FIELD_DECIMAL"), field.getDecimalSymbol()));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FIELD_GROUP"), field.getGroupSymbol()));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FIELD_LENGTH"), field.getLength()));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FIELD_PRECISION"), field.getPrecision()));
retval.append(" ").append(XMLHandler.addTagValue(getXmlCode("FIELD_TRIM_TYPE"), ValueMetaString.getTrimTypeCode(field.getTrimType())));
retval.append(" ").append(XMLHandler.closeTag(getXmlCode("FIELD"))).append(Const.CR);
}
retval.append(" ").append(XMLHandler.closeTag(getXmlCode("FIELDS"))).append(Const.CR);
return retval.toString();
}
Aggregations