use of org.pentaho.di.trans.steps.jsoninput.JsonInputField in project pentaho-kettle by pentaho.
the class FastJsonReader method setInputFields.
public void setInputFields(JsonInputField[] inputFields) {
if (null != inputFields) {
this.inputFields = inputFields;
compiledJsonPaths = new JsonPath[inputFields.length];
int i = 0;
for (JsonInputField inputField : inputFields) {
compiledJsonPaths[i++] = JsonPath.compile(step.environmentSubstitute(inputField.getPath(), true));
}
} else {
this.inputFields = ZERO_INPUT_FIELDS;
}
}
use of org.pentaho.di.trans.steps.jsoninput.JsonInputField in project pentaho-kettle by pentaho.
the class FastJsonReader method compilePaths.
private static JsonPath[] compilePaths(JsonInputField[] fields) {
JsonPath[] paths = new JsonPath[fields.length];
int i = 0;
for (JsonInputField field : fields) {
paths[i++] = JsonPath.compile(field.getPath());
}
return paths;
}
use of org.pentaho.di.trans.steps.jsoninput.JsonInputField in project pentaho-kettle by pentaho.
the class JsonInputDialog method getData.
/**
* Read the data from the TextFileInputMeta object and show it in this dialog.
*
* @param in
* The TextFileInputMeta object to obtain the data from.
*/
public void getData(JsonInputMeta in) {
if (in.getFileName() != null) {
wFilenameList.removeAll();
for (int i = 0; i < in.getFileName().length; i++) {
String[] items = new String[] { in.getFileName()[i], in.getFileMask()[i], in.getExcludeFileMask()[i], in.getRequiredFilesDesc(in.getFileRequired()[i]), in.getRequiredFilesDesc(in.getIncludeSubFolders()[i]) };
wFilenameList.add(items);
}
wFilenameList.removeEmptyRows();
wFilenameList.setRowNums();
wFilenameList.optWidth(true);
}
wInclFilename.setSelection(in.includeFilename());
wInclRownum.setSelection(in.includeRowNumber());
wAddResult.setSelection(in.addResultFile());
wreadUrl.setSelection(in.isReadUrl());
wIgnoreEmptyFile.setSelection(in.isIgnoreEmptyFile());
wdoNotFailIfNoFile.setSelection(in.isDoNotFailIfNoFile());
wIgnoreMissingPath.setSelection(in.isIgnoreMissingPath());
wDefaultPathLeafToNull.setSelection(in.isDefaultPathLeafToNull());
wIncludeNulls.setSelection(in.isIncludeNulls() || JsonInputMeta.getIncludeNullsProperty());
wremoveSourceField.setSelection(in.isRemoveSourceField());
wSourceStreamField.setSelection(in.isInFields());
wSourceIsAFile.setSelection(in.getIsAFile());
if (in.getFieldValue() != null) {
wFieldValue.setText(in.getFieldValue());
}
if (in.getFilenameField() != null) {
wInclFilenameField.setText(in.getFilenameField());
}
if (in.getRowNumberField() != null) {
wInclRownumField.setText(in.getRowNumberField());
}
wLimit.setText("" + in.getRowLimit());
if (isDebug()) {
logDebug(BaseMessages.getString(PKG, "JsonInputDialog.Log.GettingFieldsInfo"));
}
for (int i = 0; i < in.getInputFields().length; i++) {
JsonInputField field = in.getInputFields()[i];
if (field != null) {
TableItem item = wFields.table.getItem(i);
String name = field.getName();
String xpath = field.getPath();
String type = field.getTypeDesc();
String format = field.getFormat();
String length = "" + field.getLength();
String prec = "" + field.getPrecision();
String curr = field.getCurrencySymbol();
String group = field.getGroupSymbol();
String decim = field.getDecimalSymbol();
String trim = field.getTrimTypeDesc();
String rep = field.isRepeated() ? YES : NO;
if (name != null) {
item.setText(1, name);
}
if (xpath != null) {
item.setText(2, xpath);
}
if (type != null) {
item.setText(3, type);
}
if (format != null) {
item.setText(4, format);
}
if (length != null && !"-1".equals(length)) {
item.setText(5, length);
}
if (prec != null && !"-1".equals(prec)) {
item.setText(6, prec);
}
if (curr != null) {
item.setText(7, curr);
}
if (decim != null) {
item.setText(8, decim);
}
if (group != null) {
item.setText(9, group);
}
if (trim != null) {
item.setText(10, trim);
}
if (rep != null) {
item.setText(11, rep);
}
}
}
setSourceStreamField();
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
if (in.getShortFileNameField() != null) {
wShortFileFieldName.setText(in.getShortFileNameField());
}
if (in.getPathField() != null) {
wPathFieldName.setText(in.getPathField());
}
if (in.isHiddenField() != null) {
wIsHiddenName.setText(in.isHiddenField());
}
if (in.getLastModificationDateField() != null) {
wLastModificationTimeName.setText(in.getLastModificationDateField());
}
if (in.getUriField() != null) {
wUriName.setText(in.getUriField());
}
if (in.getRootUriField() != null) {
wRootUriName.setText(in.getRootUriField());
}
if (in.getExtensionField() != null) {
wExtensionFieldName.setText(in.getExtensionField());
}
if (in.getSizeField() != null) {
wSizeFieldName.setText(in.getSizeField());
}
wStepname.selectAll();
wStepname.setFocus();
}
use of org.pentaho.di.trans.steps.jsoninput.JsonInputField in project pentaho-kettle by pentaho.
the class JsonInputDialog method getInfo.
/**
* dialog -> meta
*/
private void getInfo(JsonInputMeta in) throws KettleException {
// return value
stepname = wStepname.getText();
in.setRowLimit(Const.toLong(wLimit.getText(), 0L));
in.setFilenameField(wInclFilenameField.getText());
in.setRowNumberField(wInclRownumField.getText());
in.setAddResultFile(wAddResult.getSelection());
in.setIncludeFilename(wInclFilename.getSelection());
in.setIncludeRowNumber(wInclRownum.getSelection());
in.setReadUrl(wreadUrl.getSelection());
in.setIgnoreEmptyFile(wIgnoreEmptyFile.getSelection());
in.setDoNotFailIfNoFile(wdoNotFailIfNoFile.getSelection());
in.setIgnoreMissingPath(wIgnoreMissingPath.getSelection());
in.setDefaultPathLeafToNull(wDefaultPathLeafToNull.getSelection());
in.setIncludeNulls(wIncludeNulls.getSelection());
in.setRemoveSourceField(wremoveSourceField.getSelection());
in.setInFields(wSourceStreamField.getSelection());
in.setIsAFile(wSourceIsAFile.getSelection());
in.setFieldValue(wFieldValue.getText());
int nrFiles = wFilenameList.getItemCount();
int nrFields = wFields.nrNonEmpty();
in.allocate(nrFiles, nrFields);
in.setFileName(wFilenameList.getItems(0));
in.setFileMask(wFilenameList.getItems(1));
in.setExcludeFileMask(wFilenameList.getItems(2));
in.setFileRequired(wFilenameList.getItems(3));
in.setIncludeSubFolders(wFilenameList.getItems(4));
for (int i = 0; i < nrFields; i++) {
JsonInputField field = new JsonInputField();
TableItem item = wFields.getNonEmpty(i);
field.setName(item.getText(1));
field.setPath(item.getText(2));
field.setType(ValueMetaFactory.getIdForValueMeta(item.getText(3)));
field.setFormat(item.getText(4));
field.setLength(Const.toInt(item.getText(5), -1));
field.setPrecision(Const.toInt(item.getText(6), -1));
field.setCurrencySymbol(item.getText(7));
field.setDecimalSymbol(item.getText(8));
field.setGroupSymbol(item.getText(9));
field.setTrimType(ValueMetaBase.getTrimTypeByDesc(item.getText(10)));
field.setRepeated(YES.equalsIgnoreCase(item.getText(11)));
in.getInputFields()[i] = field;
}
in.setShortFileNameField(wShortFileFieldName.getText());
in.setPathField(wPathFieldName.getText());
in.setIsHiddenField(wIsHiddenName.getText());
in.setLastModificationDateField(wLastModificationTimeName.getText());
in.setUriField(wUriName.getText());
in.setRootUriField(wRootUriName.getText());
in.setExtensionField(wExtensionFieldName.getText());
in.setSizeField(wSizeFieldName.getText());
}
Aggregations